@Generated(value="by gapic-generator") @BetaApi public class JobControllerClient extends Object implements BackgroundResource
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 = "";
String region = "";
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:
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);
Modifier and Type | Class and Description |
---|---|
static class |
JobControllerClient.ListJobsFixedSizeCollection |
static class |
JobControllerClient.ListJobsPage |
static class |
JobControllerClient.ListJobsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
JobControllerClient(JobControllerSettings settings)
Constructs an instance of JobControllerClient, using the given settings.
|
protected |
JobControllerClient(JobControllerStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
com.google.cloud.dataproc.v1beta2.Job |
cancelJob(com.google.cloud.dataproc.v1beta2.CancelJobRequest request)
Starts a job cancellation request.
|
com.google.cloud.dataproc.v1beta2.Job |
cancelJob(String projectId,
String region,
String jobId)
Starts a job cancellation request.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.CancelJobRequest,com.google.cloud.dataproc.v1beta2.Job> |
cancelJobCallable()
Starts a job cancellation request.
|
void |
close() |
static JobControllerClient |
create()
Constructs an instance of JobControllerClient with default settings.
|
static JobControllerClient |
create(JobControllerSettings settings)
Constructs an instance of JobControllerClient, using the given settings.
|
static JobControllerClient |
create(JobControllerStub stub)
Constructs an instance of JobControllerClient, using the given stub for making calls.
|
void |
deleteJob(com.google.cloud.dataproc.v1beta2.DeleteJobRequest request)
Deletes the job from the project.
|
void |
deleteJob(String projectId,
String region,
String jobId)
Deletes the job from the project.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.DeleteJobRequest,Empty> |
deleteJobCallable()
Deletes the job from the project.
|
com.google.cloud.dataproc.v1beta2.Job |
getJob(com.google.cloud.dataproc.v1beta2.GetJobRequest request)
Gets the resource representation for a job in a project.
|
com.google.cloud.dataproc.v1beta2.Job |
getJob(String projectId,
String region,
String jobId)
Gets the resource representation for a job in a project.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.GetJobRequest,com.google.cloud.dataproc.v1beta2.Job> |
getJobCallable()
Gets the resource representation for a job in a project.
|
JobControllerSettings |
getSettings() |
JobControllerStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
JobControllerClient.ListJobsPagedResponse |
listJobs(com.google.cloud.dataproc.v1beta2.ListJobsRequest request)
Lists regions/{region}/jobs in a project.
|
JobControllerClient.ListJobsPagedResponse |
listJobs(String projectId,
String region)
Lists regions/{region}/jobs in a project.
|
JobControllerClient.ListJobsPagedResponse |
listJobs(String projectId,
String region,
String filter)
Lists regions/{region}/jobs in a project.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.ListJobsRequest,com.google.cloud.dataproc.v1beta2.ListJobsResponse> |
listJobsCallable()
Lists regions/{region}/jobs in a project.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.ListJobsRequest,JobControllerClient.ListJobsPagedResponse> |
listJobsPagedCallable()
Lists regions/{region}/jobs in a project.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.cloud.dataproc.v1beta2.Job |
submitJob(String projectId,
String region,
com.google.cloud.dataproc.v1beta2.Job job)
Submits a job to a cluster.
|
com.google.cloud.dataproc.v1beta2.Job |
submitJob(com.google.cloud.dataproc.v1beta2.SubmitJobRequest request)
Submits a job to a cluster.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.SubmitJobRequest,com.google.cloud.dataproc.v1beta2.Job> |
submitJobCallable()
Submits a job to a cluster.
|
com.google.cloud.dataproc.v1beta2.Job |
updateJob(com.google.cloud.dataproc.v1beta2.UpdateJobRequest request)
Updates a job in a project.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.UpdateJobRequest,com.google.cloud.dataproc.v1beta2.Job> |
updateJobCallable()
Updates a job in a project.
|
protected JobControllerClient(JobControllerSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected JobControllerClient(JobControllerStub stub)
public static final JobControllerClient create() throws IOException
IOException
public static final JobControllerClient create(JobControllerSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final JobControllerClient create(JobControllerStub stub)
public final JobControllerSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public JobControllerStub getStub()
public final com.google.cloud.dataproc.v1beta2.Job submitJob(String projectId, String region, com.google.cloud.dataproc.v1beta2.Job job)
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
Job job = Job.newBuilder().build();
Job response = jobControllerClient.submitJob(projectId, region, job);
}
projectId
- Required. The ID of the Google Cloud Platform project that the job belongs to.region
- Required. The Cloud Dataproc region in which to handle the request.job
- Required. The job resource.ApiException
- if the remote call failspublic final com.google.cloud.dataproc.v1beta2.Job submitJob(com.google.cloud.dataproc.v1beta2.SubmitJobRequest request)
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
Job job = Job.newBuilder().build();
SubmitJobRequest request = SubmitJobRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setJob(job)
.build();
Job response = jobControllerClient.submitJob(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.dataproc.v1beta2.SubmitJobRequest,com.google.cloud.dataproc.v1beta2.Job> submitJobCallable()
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
Job job = Job.newBuilder().build();
SubmitJobRequest request = SubmitJobRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setJob(job)
.build();
ApiFuture<Job> future = jobControllerClient.submitJobCallable().futureCall(request);
// Do something
Job response = future.get();
}
public final com.google.cloud.dataproc.v1beta2.Job getJob(String projectId, String region, String jobId)
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
String jobId = "";
Job response = jobControllerClient.getJob(projectId, region, jobId);
}
projectId
- Required. The ID of the Google Cloud Platform project that the job belongs to.region
- Required. The Cloud Dataproc region in which to handle the request.jobId
- Required. The job ID.ApiException
- if the remote call failspublic final com.google.cloud.dataproc.v1beta2.Job getJob(com.google.cloud.dataproc.v1beta2.GetJobRequest request)
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
String jobId = "";
GetJobRequest request = GetJobRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setJobId(jobId)
.build();
Job response = jobControllerClient.getJob(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.dataproc.v1beta2.GetJobRequest,com.google.cloud.dataproc.v1beta2.Job> getJobCallable()
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
String jobId = "";
GetJobRequest request = GetJobRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setJobId(jobId)
.build();
ApiFuture<Job> future = jobControllerClient.getJobCallable().futureCall(request);
// Do something
Job response = future.get();
}
public final JobControllerClient.ListJobsPagedResponse listJobs(String projectId, String region)
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
for (Job element : jobControllerClient.listJobs(projectId, region).iterateAll()) {
// doThingsWith(element);
}
}
projectId
- Required. The ID of the Google Cloud Platform project that the job belongs to.region
- Required. The Cloud Dataproc region in which to handle the request.ApiException
- if the remote call failspublic final JobControllerClient.ListJobsPagedResponse listJobs(String projectId, String region, String filter)
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
String filter = "";
for (Job element : jobControllerClient.listJobs(projectId, region, filter).iterateAll()) {
// doThingsWith(element);
}
}
projectId
- Required. The ID of the Google Cloud Platform project that the job belongs to.region
- Required. The Cloud Dataproc region in which to handle the request.filter
- 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 `status.state` or `labels.[KEY]`, and `[KEY]` is a label key. **value** can be `*` to match all values. `status.state` can be either `ACTIVE` or `NON_ACTIVE`. Only the logical `AND` operator is supported; space-separated items are treated as having an implicit `AND` operator.
Example filter:
status.state = ACTIVE AND labels.env = staging AND labels.starred = *
ApiException
- if the remote call failspublic final JobControllerClient.ListJobsPagedResponse listJobs(com.google.cloud.dataproc.v1beta2.ListJobsRequest request)
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
ListJobsRequest request = ListJobsRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.build();
for (Job element : jobControllerClient.listJobs(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.dataproc.v1beta2.ListJobsRequest,JobControllerClient.ListJobsPagedResponse> listJobsPagedCallable()
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
ListJobsRequest request = ListJobsRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.build();
ApiFuture<ListJobsPagedResponse> future = jobControllerClient.listJobsPagedCallable().futureCall(request);
// Do something
for (Job element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.cloud.dataproc.v1beta2.ListJobsRequest,com.google.cloud.dataproc.v1beta2.ListJobsResponse> listJobsCallable()
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
ListJobsRequest request = ListJobsRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.build();
while (true) {
ListJobsResponse response = jobControllerClient.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;
}
}
}
public final com.google.cloud.dataproc.v1beta2.Job updateJob(com.google.cloud.dataproc.v1beta2.UpdateJobRequest request)
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
String jobId = "";
Job job = Job.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateJobRequest request = UpdateJobRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setJobId(jobId)
.setJob(job)
.setUpdateMask(updateMask)
.build();
Job response = jobControllerClient.updateJob(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.dataproc.v1beta2.UpdateJobRequest,com.google.cloud.dataproc.v1beta2.Job> updateJobCallable()
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
String jobId = "";
Job job = Job.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateJobRequest request = UpdateJobRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setJobId(jobId)
.setJob(job)
.setUpdateMask(updateMask)
.build();
ApiFuture<Job> future = jobControllerClient.updateJobCallable().futureCall(request);
// Do something
Job response = future.get();
}
public final com.google.cloud.dataproc.v1beta2.Job cancelJob(String projectId, String region, String jobId)
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
String jobId = "";
Job response = jobControllerClient.cancelJob(projectId, region, jobId);
}
projectId
- Required. The ID of the Google Cloud Platform project that the job belongs to.region
- Required. The Cloud Dataproc region in which to handle the request.jobId
- Required. The job ID.ApiException
- if the remote call failspublic final com.google.cloud.dataproc.v1beta2.Job cancelJob(com.google.cloud.dataproc.v1beta2.CancelJobRequest request)
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
String jobId = "";
CancelJobRequest request = CancelJobRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setJobId(jobId)
.build();
Job response = jobControllerClient.cancelJob(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.dataproc.v1beta2.CancelJobRequest,com.google.cloud.dataproc.v1beta2.Job> cancelJobCallable()
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
String jobId = "";
CancelJobRequest request = CancelJobRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setJobId(jobId)
.build();
ApiFuture<Job> future = jobControllerClient.cancelJobCallable().futureCall(request);
// Do something
Job response = future.get();
}
public final void deleteJob(String projectId, String region, String jobId)
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
String jobId = "";
jobControllerClient.deleteJob(projectId, region, jobId);
}
projectId
- Required. The ID of the Google Cloud Platform project that the job belongs to.region
- Required. The Cloud Dataproc region in which to handle the request.jobId
- Required. The job ID.ApiException
- if the remote call failspublic final void deleteJob(com.google.cloud.dataproc.v1beta2.DeleteJobRequest request)
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
String jobId = "";
DeleteJobRequest request = DeleteJobRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setJobId(jobId)
.build();
jobControllerClient.deleteJob(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.dataproc.v1beta2.DeleteJobRequest,Empty> deleteJobCallable()
Sample code:
try (JobControllerClient jobControllerClient = JobControllerClient.create()) {
String projectId = "";
String region = "";
String jobId = "";
DeleteJobRequest request = DeleteJobRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setJobId(jobId)
.build();
ApiFuture<Void> future = jobControllerClient.deleteJobCallable().futureCall(request);
// Do something
future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.