@Generated(value="by gapic-generator") @BetaApi public class JobControllerClient extends Object implements com.google.api.gax.core.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) |
Job |
cancelJob(CancelJobRequest request)
Starts a job cancellation request.
|
Job |
cancelJob(String projectId,
String region,
String jobId)
Starts a job cancellation request.
|
com.google.api.gax.rpc.UnaryCallable<CancelJobRequest,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(DeleteJobRequest request)
Deletes the job from the project.
|
void |
deleteJob(String projectId,
String region,
String jobId)
Deletes the job from the project.
|
com.google.api.gax.rpc.UnaryCallable<DeleteJobRequest,Empty> |
deleteJobCallable()
Deletes the job from the project.
|
Job |
getJob(GetJobRequest request)
Gets the resource representation for a job in a project.
|
Job |
getJob(String projectId,
String region,
String jobId)
Gets the resource representation for a job in a project.
|
com.google.api.gax.rpc.UnaryCallable<GetJobRequest,Job> |
getJobCallable()
Gets the resource representation for a job in a project.
|
JobControllerSettings |
getSettings() |
JobControllerStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
JobControllerClient.ListJobsPagedResponse |
listJobs(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.
|
com.google.api.gax.rpc.UnaryCallable<ListJobsRequest,ListJobsResponse> |
listJobsCallable()
Lists regions/{region}/jobs in a project.
|
com.google.api.gax.rpc.UnaryCallable<ListJobsRequest,JobControllerClient.ListJobsPagedResponse> |
listJobsPagedCallable()
Lists regions/{region}/jobs in a project.
|
void |
shutdown() |
void |
shutdownNow() |
Job |
submitJob(String projectId,
String region,
Job job)
Submits a job to a cluster.
|
Job |
submitJob(SubmitJobRequest request)
Submits a job to a cluster.
|
com.google.api.gax.rpc.UnaryCallable<SubmitJobRequest,Job> |
submitJobCallable()
Submits a job to a cluster.
|
Job |
updateJob(UpdateJobRequest request)
Updates a job in a project.
|
com.google.api.gax.rpc.UnaryCallable<UpdateJobRequest,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 Job submitJob(String projectId, String region, 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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Job submitJob(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<SubmitJobRequest,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 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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Job getJob(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetJobRequest,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.com.google.api.gax.rpc.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 = *
com.google.api.gax.rpc.ApiException
- if the remote call failspublic final JobControllerClient.ListJobsPagedResponse listJobs(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<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 com.google.api.gax.rpc.UnaryCallable<ListJobsRequest,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 Job updateJob(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateJobRequest,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 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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Job cancelJob(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CancelJobRequest,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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final void deleteJob(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<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 com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.