- 0.53.0 (latest)
- 0.52.0
- 0.51.0
- 0.49.0
- 0.48.0
- 0.47.0
- 0.46.0
- 0.45.0
- 0.44.0
- 0.43.0
- 0.42.0
- 0.41.0
- 0.40.0
- 0.39.0
- 0.37.0
- 0.36.0
- 0.35.0
- 0.34.0
- 0.33.0
- 0.32.0
- 0.31.0
- 0.30.0
- 0.29.0
- 0.28.0
- 0.27.0
- 0.24.0
- 0.23.0
- 0.22.0
- 0.21.0
- 0.20.0
- 0.19.0
- 0.18.0
- 0.17.0
- 0.16.0
- 0.15.0
- 0.14.0
- 0.13.0
- 0.12.0
- 0.11.0
- 0.10.0
- 0.9.0
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.0
- 0.3.2
- 0.2.2
- 0.1.1
public class BatchServiceClient implements BackgroundResource
Service Description: Google Batch Service. The service manages user submitted batch jobs and allocates Google Compute Engine VM instances to run the jobs.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Job job = Job.newBuilder().build();
String jobId = "jobId101296568";
Job response = batchServiceClient.createJob(parent, job, jobId);
}
Note: close() needs to be called on the BatchServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of BatchServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
BatchServiceSettings batchServiceSettings =
BatchServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
BatchServiceSettings batchServiceSettings =
BatchServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final BatchServiceClient create()
Constructs an instance of BatchServiceClient with default settings.
Type | Description |
BatchServiceClient |
Type | Description |
IOException |
create(BatchServiceSettings settings)
public static final BatchServiceClient create(BatchServiceSettings settings)
Constructs an instance of BatchServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Name | Description |
settings | BatchServiceSettings |
Type | Description |
BatchServiceClient |
Type | Description |
IOException |
create(BatchServiceStub stub)
public static final BatchServiceClient create(BatchServiceStub stub)
Constructs an instance of BatchServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(BatchServiceSettings).
Name | Description |
stub | BatchServiceStub |
Type | Description |
BatchServiceClient |
Constructors
BatchServiceClient(BatchServiceSettings settings)
protected BatchServiceClient(BatchServiceSettings settings)
Constructs an instance of BatchServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
Name | Description |
settings | BatchServiceSettings |
BatchServiceClient(BatchServiceStub stub)
protected BatchServiceClient(BatchServiceStub stub)
Name | Description |
stub | BatchServiceStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
createJob(CreateJobRequest request)
public final Job createJob(CreateJobRequest request)
Create a Job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
CreateJobRequest request =
CreateJobRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setJobId("jobId101296568")
.setJob(Job.newBuilder().build())
.setRequestId("requestId693933066")
.build();
Job response = batchServiceClient.createJob(request);
}
Name | Description |
request | CreateJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
Job |
createJob(LocationName parent, Job job, String jobId)
public final Job createJob(LocationName parent, Job job, String jobId)
Create a Job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Job job = Job.newBuilder().build();
String jobId = "jobId101296568";
Job response = batchServiceClient.createJob(parent, job, jobId);
}
Name | Description |
parent | LocationName Required. The parent resource name where the Job will be created. Pattern: "projects/{project}/locations/{location}" |
job | Job Required. The Job to create. |
jobId | String ID used to uniquely identify the Job within its parent scope. This field should contain at most 63 characters. Only alphanumeric characters or '-' are accepted. The '-' character cannot be the first or the last one. A system generated ID will be used if the field is not set. The job.name field in the request will be ignored and the created resource name of the Job will be "{parent}/jobs/{job_id}". |
Type | Description |
Job |
createJob(String parent, Job job, String jobId)
public final Job createJob(String parent, Job job, String jobId)
Create a Job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
Job job = Job.newBuilder().build();
String jobId = "jobId101296568";
Job response = batchServiceClient.createJob(parent, job, jobId);
}
Name | Description |
parent | String Required. The parent resource name where the Job will be created. Pattern: "projects/{project}/locations/{location}" |
job | Job Required. The Job to create. |
jobId | String ID used to uniquely identify the Job within its parent scope. This field should contain at most 63 characters. Only alphanumeric characters or '-' are accepted. The '-' character cannot be the first or the last one. A system generated ID will be used if the field is not set. The job.name field in the request will be ignored and the created resource name of the Job will be "{parent}/jobs/{job_id}". |
Type | Description |
Job |
createJobCallable()
public final UnaryCallable<CreateJobRequest,Job> createJobCallable()
Create a Job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
CreateJobRequest request =
CreateJobRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setJobId("jobId101296568")
.setJob(Job.newBuilder().build())
.setRequestId("requestId693933066")
.build();
ApiFuture<Job> future = batchServiceClient.createJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
Type | Description |
UnaryCallable<CreateJobRequest,Job> |
deleteJobAsync(DeleteJobRequest request)
public final OperationFuture<Empty,OperationMetadata> deleteJobAsync(DeleteJobRequest request)
Delete a Job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setName("name3373707")
.setReason("reason-934964668")
.setRequestId("requestId693933066")
.build();
batchServiceClient.deleteJobAsync(request).get();
}
Name | Description |
request | DeleteJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Empty,OperationMetadata> |
deleteJobAsync(String name)
public final OperationFuture<Empty,OperationMetadata> deleteJobAsync(String name)
Delete a Job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
String name = "name3373707";
batchServiceClient.deleteJobAsync(name).get();
}
Name | Description |
name | String Job name. |
Type | Description |
OperationFuture<Empty,OperationMetadata> |
deleteJobCallable()
public final UnaryCallable<DeleteJobRequest,Operation> deleteJobCallable()
Delete a Job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setName("name3373707")
.setReason("reason-934964668")
.setRequestId("requestId693933066")
.build();
ApiFuture<Operation> future = batchServiceClient.deleteJobCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<DeleteJobRequest,Operation> |
deleteJobOperationCallable()
public final OperationCallable<DeleteJobRequest,Empty,OperationMetadata> deleteJobOperationCallable()
Delete a Job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setName("name3373707")
.setReason("reason-934964668")
.setRequestId("requestId693933066")
.build();
OperationFuture<Empty, OperationMetadata> future =
batchServiceClient.deleteJobOperationCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
OperationCallable<DeleteJobRequest,Empty,OperationMetadata> |
getJob(GetJobRequest request)
public final Job getJob(GetJobRequest request)
Get a Job specified by its resource name.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
GetJobRequest request =
GetJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
Job response = batchServiceClient.getJob(request);
}
Name | Description |
request | GetJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
Job |
getJob(JobName name)
public final Job getJob(JobName name)
Get a Job specified by its resource name.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]");
Job response = batchServiceClient.getJob(name);
}
Name | Description |
name | JobName Required. Job name. |
Type | Description |
Job |
getJob(String name)
public final Job getJob(String name)
Get a Job specified by its resource name.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString();
Job response = batchServiceClient.getJob(name);
}
Name | Description |
name | String Required. Job name. |
Type | Description |
Job |
getJobCallable()
public final UnaryCallable<GetJobRequest,Job> getJobCallable()
Get a Job specified by its resource name.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
GetJobRequest request =
GetJobRequest.newBuilder()
.setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
.build();
ApiFuture<Job> future = batchServiceClient.getJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
Type | Description |
UnaryCallable<GetJobRequest,Job> |
getOperationsClient()
public final OperationsClient getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
Type | Description |
OperationsClient |
getSettings()
public final BatchServiceSettings getSettings()
Type | Description |
BatchServiceSettings |
getStub()
public BatchServiceStub getStub()
Type | Description |
BatchServiceStub |
getTask(GetTaskRequest request)
public final Task getTask(GetTaskRequest request)
Return a single Task.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
GetTaskRequest request =
GetTaskRequest.newBuilder()
.setName(
TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]")
.toString())
.build();
Task response = batchServiceClient.getTask(request);
}
Name | Description |
request | GetTaskRequest The request object containing all of the parameters for the API call. |
Type | Description |
Task |
getTask(TaskName name)
public final Task getTask(TaskName name)
Return a single Task.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]");
Task response = batchServiceClient.getTask(name);
}
Name | Description |
name | TaskName Required. Task name. |
Type | Description |
Task |
getTask(String name)
public final Task getTask(String name)
Return a single Task.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
String name =
TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]").toString();
Task response = batchServiceClient.getTask(name);
}
Name | Description |
name | String Required. Task name. |
Type | Description |
Task |
getTaskCallable()
public final UnaryCallable<GetTaskRequest,Task> getTaskCallable()
Return a single Task.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
GetTaskRequest request =
GetTaskRequest.newBuilder()
.setName(
TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]")
.toString())
.build();
ApiFuture<Task> future = batchServiceClient.getTaskCallable().futureCall(request);
// Do something.
Task response = future.get();
}
Type | Description |
UnaryCallable<GetTaskRequest,Task> |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listJobs(ListJobsRequest request)
public final BatchServiceClient.ListJobsPagedResponse listJobs(ListJobsRequest request)
List all Jobs for a project within a region.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent("parent-995424086")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Job element : batchServiceClient.listJobs(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListJobsRequest The request object containing all of the parameters for the API call. |
Type | Description |
BatchServiceClient.ListJobsPagedResponse |
listJobs(String parent)
public final BatchServiceClient.ListJobsPagedResponse listJobs(String parent)
List all Jobs for a project within a region.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
String parent = "parent-995424086";
for (Job element : batchServiceClient.listJobs(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Parent path. |
Type | Description |
BatchServiceClient.ListJobsPagedResponse |
listJobsCallable()
public final UnaryCallable<ListJobsRequest,ListJobsResponse> listJobsCallable()
List all Jobs for a project within a region.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent("parent-995424086")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListJobsResponse response = batchServiceClient.listJobsCallable().call(request);
for (Job element : response.getJobsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListJobsRequest,ListJobsResponse> |
listJobsPagedCallable()
public final UnaryCallable<ListJobsRequest,BatchServiceClient.ListJobsPagedResponse> listJobsPagedCallable()
List all Jobs for a project within a region.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setParent("parent-995424086")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Job> future = batchServiceClient.listJobsPagedCallable().futureCall(request);
// Do something.
for (Job element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListJobsRequest,ListJobsPagedResponse> |
listTasks(ListTasksRequest request)
public final BatchServiceClient.ListTasksPagedResponse listTasks(ListTasksRequest request)
List Tasks associated with a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListTasksRequest request =
ListTasksRequest.newBuilder()
.setParent(
TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Task element : batchServiceClient.listTasks(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListTasksRequest The request object containing all of the parameters for the API call. |
Type | Description |
BatchServiceClient.ListTasksPagedResponse |
listTasks(TaskGroupName parent)
public final BatchServiceClient.ListTasksPagedResponse listTasks(TaskGroupName parent)
List Tasks associated with a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
TaskGroupName parent = TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]");
for (Task element : batchServiceClient.listTasks(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | TaskGroupName Required. Name of a TaskGroup from which Tasks are being requested. Pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" |
Type | Description |
BatchServiceClient.ListTasksPagedResponse |
listTasks(String parent)
public final BatchServiceClient.ListTasksPagedResponse listTasks(String parent)
List Tasks associated with a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
String parent =
TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString();
for (Task element : batchServiceClient.listTasks(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. Name of a TaskGroup from which Tasks are being requested. Pattern: "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" |
Type | Description |
BatchServiceClient.ListTasksPagedResponse |
listTasksCallable()
public final UnaryCallable<ListTasksRequest,ListTasksResponse> listTasksCallable()
List Tasks associated with a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListTasksRequest request =
ListTasksRequest.newBuilder()
.setParent(
TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListTasksResponse response = batchServiceClient.listTasksCallable().call(request);
for (Task element : response.getTasksList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListTasksRequest,ListTasksResponse> |
listTasksPagedCallable()
public final UnaryCallable<ListTasksRequest,BatchServiceClient.ListTasksPagedResponse> listTasksPagedCallable()
List Tasks associated with a job.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
ListTasksRequest request =
ListTasksRequest.newBuilder()
.setParent(
TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Task> future = batchServiceClient.listTasksPagedCallable().futureCall(request);
// Do something.
for (Task element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListTasksRequest,ListTasksPagedResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()