- 4.51.0 (latest)
- 4.50.0
- 4.49.0
- 4.48.0
- 4.46.0
- 4.45.0
- 4.44.0
- 4.43.0
- 4.42.0
- 4.41.0
- 4.40.0
- 4.39.0
- 4.38.0
- 4.37.0
- 4.36.0
- 4.34.0
- 4.33.0
- 4.32.0
- 4.31.0
- 4.30.0
- 4.29.0
- 4.28.0
- 4.27.0
- 4.26.0
- 4.25.0
- 4.24.0
- 4.21.0
- 4.20.0
- 4.19.0
- 4.18.0
- 4.17.0
- 4.16.0
- 4.15.0
- 4.14.0
- 4.13.0
- 4.12.0
- 4.11.0
- 4.10.0
- 4.9.0
- 4.8.0
- 4.6.0
- 4.5.0
- 4.4.0
- 4.3.0
- 4.2.0
- 4.1.0
- 4.0.8
- 3.1.2
- 3.0.3
- 2.3.1
public class JobControllerClient implements BackgroundResource
Service Description: The JobController provides methods to manage 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:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
Job job = Job.newBuilder().build();
Job response = jobControllerClient.submitJob(projectId, region, job);
}
Note: close() needs to be called on the JobControllerClient 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 JobControllerSettings to create(). For example:
To customize credentials:
JobControllerSettings jobControllerSettings =
JobControllerSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
JobControllerClient jobControllerClient = JobControllerClient.create(jobControllerSettings);
To customize the endpoint:
JobControllerSettings jobControllerSettings =
JobControllerSettings.newBuilder().setEndpoint(myEndpoint).build();
JobControllerClient jobControllerClient = JobControllerClient.create(jobControllerSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final JobControllerClient create()
Constructs an instance of JobControllerClient with default settings.
Type | Description |
JobControllerClient |
Type | Description |
IOException |
create(JobControllerSettings settings)
public static final JobControllerClient create(JobControllerSettings settings)
Constructs an instance of JobControllerClient, 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 | JobControllerSettings |
Type | Description |
JobControllerClient |
Type | Description |
IOException |
create(JobControllerStub stub)
public static final JobControllerClient create(JobControllerStub stub)
Constructs an instance of JobControllerClient, using the given stub for making calls. This is for advanced usage - prefer using create(JobControllerSettings).
Name | Description |
stub | JobControllerStub |
Type | Description |
JobControllerClient |
Constructors
JobControllerClient(JobControllerSettings settings)
protected JobControllerClient(JobControllerSettings settings)
Constructs an instance of JobControllerClient, 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 | JobControllerSettings |
JobControllerClient(JobControllerStub stub)
protected JobControllerClient(JobControllerStub stub)
Name | Description |
stub | JobControllerStub |
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 |
cancelJob(CancelJobRequest request)
public final Job cancelJob(CancelJobRequest request)
Starts a job cancellation request. To access the job resource after cancellation, call regions/{region}/jobs.list or regions/{region}/jobs.get.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
CancelJobRequest request =
CancelJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJobId("jobId101296568")
.build();
Job response = jobControllerClient.cancelJob(request);
}
Name | Description |
request | CancelJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
Job |
cancelJob(String projectId, String region, String jobId)
public final Job cancelJob(String projectId, String region, String jobId)
Starts a job cancellation request. To access the job resource after cancellation, call regions/{region}/jobs.list or regions/{region}/jobs.get.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
String jobId = "jobId101296568";
Job response = jobControllerClient.cancelJob(projectId, region, jobId);
}
Name | Description |
projectId | String Required. The ID of the Google Cloud Platform project that the job belongs to. |
region | String Required. The Dataproc region in which to handle the request. |
jobId | String Required. The job ID. |
Type | Description |
Job |
cancelJobCallable()
public final UnaryCallable<CancelJobRequest,Job> cancelJobCallable()
Starts a job cancellation request. To access the job resource after cancellation, call regions/{region}/jobs.list or regions/{region}/jobs.get.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
CancelJobRequest request =
CancelJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJobId("jobId101296568")
.build();
ApiFuture<Job> future = jobControllerClient.cancelJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
Type | Description |
UnaryCallable<CancelJobRequest,Job> |
close()
public final void close()
deleteJob(DeleteJobRequest request)
public final void deleteJob(DeleteJobRequest request)
Deletes the job from the project. If the job is active, the delete fails, and the response
returns FAILED_PRECONDITION
.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJobId("jobId101296568")
.build();
jobControllerClient.deleteJob(request);
}
Name | Description |
request | DeleteJobRequest The request object containing all of the parameters for the API call. |
deleteJob(String projectId, String region, String jobId)
public final void deleteJob(String projectId, String region, String jobId)
Deletes the job from the project. If the job is active, the delete fails, and the response
returns FAILED_PRECONDITION
.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
String jobId = "jobId101296568";
jobControllerClient.deleteJob(projectId, region, jobId);
}
Name | Description |
projectId | String Required. The ID of the Google Cloud Platform project that the job belongs to. |
region | String Required. The Dataproc region in which to handle the request. |
jobId | String Required. The job ID. |
deleteJobCallable()
public final UnaryCallable<DeleteJobRequest,Empty> deleteJobCallable()
Deletes the job from the project. If the job is active, the delete fails, and the response
returns FAILED_PRECONDITION
.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
DeleteJobRequest request =
DeleteJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJobId("jobId101296568")
.build();
ApiFuture<Empty> future = jobControllerClient.deleteJobCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<DeleteJobRequest,Empty> |
getJob(GetJobRequest request)
public final Job getJob(GetJobRequest request)
Gets the resource representation for a job in a project.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
GetJobRequest request =
GetJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJobId("jobId101296568")
.build();
Job response = jobControllerClient.getJob(request);
}
Name | Description |
request | GetJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
Job |
getJob(String projectId, String region, String jobId)
public final Job getJob(String projectId, String region, String jobId)
Gets the resource representation for a job in a project.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
String jobId = "jobId101296568";
Job response = jobControllerClient.getJob(projectId, region, jobId);
}
Name | Description |
projectId | String Required. The ID of the Google Cloud Platform project that the job belongs to. |
region | String Required. The Dataproc region in which to handle the request. |
jobId | String Required. The job ID. |
Type | Description |
Job |
getJobCallable()
public final UnaryCallable<GetJobRequest,Job> getJobCallable()
Gets the resource representation for a job in a project.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
GetJobRequest request =
GetJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJobId("jobId101296568")
.build();
ApiFuture<Job> future = jobControllerClient.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 JobControllerSettings getSettings()
Type | Description |
JobControllerSettings |
getStub()
public JobControllerStub getStub()
Type | Description |
JobControllerStub |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listJobs(ListJobsRequest request)
public final JobControllerClient.ListJobsPagedResponse listJobs(ListJobsRequest request)
Lists regions/{region}/jobs in a project.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setClusterName("clusterName-1141738587")
.setFilter("filter-1274492040")
.build();
for (Job element : jobControllerClient.listJobs(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListJobsRequest The request object containing all of the parameters for the API call. |
Type | Description |
JobControllerClient.ListJobsPagedResponse |
listJobs(String projectId, String region)
public final JobControllerClient.ListJobsPagedResponse listJobs(String projectId, String region)
Lists regions/{region}/jobs in a project.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
for (Job element : jobControllerClient.listJobs(projectId, region).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
projectId | String Required. The ID of the Google Cloud Platform project that the job belongs to. |
region | String Required. The Dataproc region in which to handle the request. |
Type | Description |
JobControllerClient.ListJobsPagedResponse |
listJobs(String projectId, String region, String filter)
public final JobControllerClient.ListJobsPagedResponse listJobs(String projectId, String region, String filter)
Lists regions/{region}/jobs in a project.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
String filter = "filter-1274492040";
for (Job element : jobControllerClient.listJobs(projectId, region, filter).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
projectId | String Required. The ID of the Google Cloud Platform project that the job belongs to. |
region | String Required. The Dataproc region in which to handle the request. |
filter | String Optional. A filter constraining the jobs to list. Filters are case-sensitive and have the following syntax: [field = value] AND [field [= value]] ... where **field** is Example filter: status.state = ACTIVE AND labels.env = staging AND labels.starred = * |
Type | Description |
JobControllerClient.ListJobsPagedResponse |
listJobsCallable()
public final UnaryCallable<ListJobsRequest,ListJobsResponse> listJobsCallable()
Lists regions/{region}/jobs in a project.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setClusterName("clusterName-1141738587")
.setFilter("filter-1274492040")
.build();
while (true) {
ListJobsResponse response = jobControllerClient.listJobsCallable().call(request);
for (Job element : response.getResponsesList()) {
// 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,JobControllerClient.ListJobsPagedResponse> listJobsPagedCallable()
Lists regions/{region}/jobs in a project.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
ListJobsRequest request =
ListJobsRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setClusterName("clusterName-1141738587")
.setFilter("filter-1274492040")
.build();
ApiFuture<Job> future = jobControllerClient.listJobsPagedCallable().futureCall(request);
// Do something.
for (Job element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListJobsRequest,ListJobsPagedResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
submitJob(SubmitJobRequest request)
public final Job submitJob(SubmitJobRequest request)
Submits a job to a cluster.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
SubmitJobRequest request =
SubmitJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJob(Job.newBuilder().build())
.setRequestId("requestId693933066")
.build();
Job response = jobControllerClient.submitJob(request);
}
Name | Description |
request | SubmitJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
Job |
submitJob(String projectId, String region, Job job)
public final Job submitJob(String projectId, String region, Job job)
Submits a job to a cluster.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
Job job = Job.newBuilder().build();
Job response = jobControllerClient.submitJob(projectId, region, job);
}
Name | Description |
projectId | String Required. The ID of the Google Cloud Platform project that the job belongs to. |
region | String Required. The Dataproc region in which to handle the request. |
job | Job Required. The job resource. |
Type | Description |
Job |
submitJobAsOperationAsync(SubmitJobRequest request)
public final OperationFuture<Job,JobMetadata> submitJobAsOperationAsync(SubmitJobRequest request)
Submits job to a cluster.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
SubmitJobRequest request =
SubmitJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJob(Job.newBuilder().build())
.setRequestId("requestId693933066")
.build();
Job response = jobControllerClient.submitJobAsOperationAsync(request).get();
}
Name | Description |
request | SubmitJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Job,JobMetadata> |
submitJobAsOperationAsync(String projectId, String region, Job job)
public final OperationFuture<Job,JobMetadata> submitJobAsOperationAsync(String projectId, String region, Job job)
Submits job to a cluster.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
Job job = Job.newBuilder().build();
Job response = jobControllerClient.submitJobAsOperationAsync(projectId, region, job).get();
}
Name | Description |
projectId | String Required. The ID of the Google Cloud Platform project that the job belongs to. |
region | String Required. The Dataproc region in which to handle the request. |
job | Job Required. The job resource. |
Type | Description |
OperationFuture<Job,JobMetadata> |
submitJobAsOperationCallable()
public final UnaryCallable<SubmitJobRequest,Operation> submitJobAsOperationCallable()
Submits job to a cluster.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
SubmitJobRequest request =
SubmitJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJob(Job.newBuilder().build())
.setRequestId("requestId693933066")
.build();
ApiFuture<Operation> future =
jobControllerClient.submitJobAsOperationCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
Type | Description |
UnaryCallable<SubmitJobRequest,Operation> |
submitJobAsOperationOperationCallable()
public final OperationCallable<SubmitJobRequest,Job,JobMetadata> submitJobAsOperationOperationCallable()
Submits job to a cluster.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
SubmitJobRequest request =
SubmitJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJob(Job.newBuilder().build())
.setRequestId("requestId693933066")
.build();
OperationFuture<Job, JobMetadata> future =
jobControllerClient.submitJobAsOperationOperationCallable().futureCall(request);
// Do something.
Job response = future.get();
}
Type | Description |
OperationCallable<SubmitJobRequest,Job,JobMetadata> |
submitJobCallable()
public final UnaryCallable<SubmitJobRequest,Job> submitJobCallable()
Submits a job to a cluster.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
SubmitJobRequest request =
SubmitJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJob(Job.newBuilder().build())
.setRequestId("requestId693933066")
.build();
ApiFuture<Job> future = jobControllerClient.submitJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
Type | Description |
UnaryCallable<SubmitJobRequest,Job> |
updateJob(UpdateJobRequest request)
public final Job updateJob(UpdateJobRequest request)
Updates a job in a project.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
UpdateJobRequest request =
UpdateJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJobId("jobId101296568")
.setJob(Job.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Job response = jobControllerClient.updateJob(request);
}
Name | Description |
request | UpdateJobRequest The request object containing all of the parameters for the API call. |
Type | Description |
Job |
updateJobCallable()
public final UnaryCallable<UpdateJobRequest,Job> updateJobCallable()
Updates a job in a project.
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
UpdateJobRequest request =
UpdateJobRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setJobId("jobId101296568")
.setJob(Job.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Job> future = jobControllerClient.updateJobCallable().futureCall(request);
// Do something.
Job response = future.get();
}
Type | Description |
UnaryCallable<UpdateJobRequest,Job> |