@Generated(value="by gapic-generator-java") public class ClusterControllerClient 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:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
String clusterName = "clusterName-1141738587";
Cluster response = clusterControllerClient.getCluster(projectId, region, clusterName);
}
Note: close() needs to be called on the ClusterControllerClient 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 ClusterControllerSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ClusterControllerSettings clusterControllerSettings =
ClusterControllerSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ClusterControllerClient clusterControllerClient =
ClusterControllerClient.create(clusterControllerSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ClusterControllerSettings clusterControllerSettings =
ClusterControllerSettings.newBuilder().setEndpoint(myEndpoint).build();
ClusterControllerClient clusterControllerClient =
ClusterControllerClient.create(clusterControllerSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ClusterControllerSettings clusterControllerSettings =
ClusterControllerSettings.newBuilder()
.setTransportChannelProvider(
ClusterControllerSettings.defaultHttpJsonTransportProviderBuilder().build())
.build();
ClusterControllerClient clusterControllerClient =
ClusterControllerClient.create(clusterControllerSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Modifier and Type | Class and Description |
---|---|
static class |
ClusterControllerClient.ListClustersFixedSizeCollection |
static class |
ClusterControllerClient.ListClustersPage |
static class |
ClusterControllerClient.ListClustersPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
ClusterControllerClient(ClusterControllerSettings settings)
Constructs an instance of ClusterControllerClient, using the given settings.
|
protected |
ClusterControllerClient(ClusterControllerStub stub) |
protected ClusterControllerClient(ClusterControllerSettings settings) throws IOException
IOException
protected ClusterControllerClient(ClusterControllerStub stub)
public static final ClusterControllerClient create() throws IOException
IOException
public static final ClusterControllerClient create(ClusterControllerSettings settings) throws IOException
IOException
public static final ClusterControllerClient create(ClusterControllerStub stub)
public final ClusterControllerSettings getSettings()
public ClusterControllerStub getStub()
public final OperationsClient getOperationsClient()
@BetaApi public final OperationsClient getHttpJsonOperationsClient()
public final OperationFuture<Cluster,ClusterOperationMetadata> createClusterAsync(String projectId, String region, Cluster cluster)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
Cluster cluster = Cluster.newBuilder().build();
Cluster response =
clusterControllerClient.createClusterAsync(projectId, region, cluster).get();
}
projectId
- Required. The ID of the Google Cloud Platform project that the cluster belongs
to.region
- Required. The Dataproc region in which to handle the request.cluster
- Required. The cluster to create.ApiException
- if the remote call failspublic final OperationFuture<Cluster,ClusterOperationMetadata> createClusterAsync(CreateClusterRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
CreateClusterRequest request =
CreateClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setCluster(Cluster.newBuilder().build())
.setRequestId("requestId693933066")
.setActionOnFailedPrimaryWorkers(FailureAction.forNumber(0))
.build();
Cluster response = clusterControllerClient.createClusterAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final OperationCallable<CreateClusterRequest,Cluster,ClusterOperationMetadata> createClusterOperationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
CreateClusterRequest request =
CreateClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setCluster(Cluster.newBuilder().build())
.setRequestId("requestId693933066")
.setActionOnFailedPrimaryWorkers(FailureAction.forNumber(0))
.build();
OperationFuture<Cluster, ClusterOperationMetadata> future =
clusterControllerClient.createClusterOperationCallable().futureCall(request);
// Do something.
Cluster response = future.get();
}
public final UnaryCallable<CreateClusterRequest,Operation> createClusterCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
CreateClusterRequest request =
CreateClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setCluster(Cluster.newBuilder().build())
.setRequestId("requestId693933066")
.setActionOnFailedPrimaryWorkers(FailureAction.forNumber(0))
.build();
ApiFuture<Operation> future =
clusterControllerClient.createClusterCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final OperationFuture<Cluster,ClusterOperationMetadata> updateClusterAsync(String projectId, String region, String clusterName, Cluster cluster, FieldMask updateMask)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
String clusterName = "clusterName-1141738587";
Cluster cluster = Cluster.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Cluster response =
clusterControllerClient
.updateClusterAsync(projectId, region, clusterName, cluster, updateMask)
.get();
}
projectId
- Required. The ID of the Google Cloud Platform project the cluster belongs to.region
- Required. The Dataproc region in which to handle the request.clusterName
- Required. The cluster name.cluster
- Required. The changes to the cluster.updateMask
- Required. Specifies the path, relative to `Cluster`, of the field to update.
For example, to change the number of workers in a cluster to 5, the `update_mask` parameter
would be specified as `config.worker_config.num_instances`, and the `PATCH` request body
would specify the new value, as follows:
{ "config":{ "workerConfig":{ "numInstances":"5" } } } Similarly, to change the number of preemptible workers in a cluster to 5, the `update_mask` parameter would be `config.secondary_worker_config.num_instances`, and the `PATCH` request body would be set as follows:
{ "config":{ "secondaryWorkerConfig":{ "numInstances":"5" } } } <strong>Note:</strong> Currently, only the following fields can be updated:
<table> <tbody> <tr> <td><strong>Mask</strong></td> <td><strong>Purpose</strong></td> </tr> <tr> <td><strong><em>labels</em></strong></td> <td>Update labels</td> </tr> <tr> <td><strong><em>config.worker_config.num_instances</em></strong></td> <td>Resize primary worker group</td> </tr> <tr> <td><strong><em>config.secondary_worker_config.num_instances</em></strong></td> <td>Resize secondary worker group</td> </tr> <tr> <td>config.autoscaling_config.policy_uri</td><td>Use, stop using, or change autoscaling policies</td> </tr> </tbody> </table>
ApiException
- if the remote call failspublic final OperationFuture<Cluster,ClusterOperationMetadata> updateClusterAsync(UpdateClusterRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
UpdateClusterRequest request =
UpdateClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.setCluster(Cluster.newBuilder().build())
.setGracefulDecommissionTimeout(Duration.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.setRequestId("requestId693933066")
.build();
Cluster response = clusterControllerClient.updateClusterAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final OperationCallable<UpdateClusterRequest,Cluster,ClusterOperationMetadata> updateClusterOperationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
UpdateClusterRequest request =
UpdateClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.setCluster(Cluster.newBuilder().build())
.setGracefulDecommissionTimeout(Duration.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.setRequestId("requestId693933066")
.build();
OperationFuture<Cluster, ClusterOperationMetadata> future =
clusterControllerClient.updateClusterOperationCallable().futureCall(request);
// Do something.
Cluster response = future.get();
}
public final UnaryCallable<UpdateClusterRequest,Operation> updateClusterCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
UpdateClusterRequest request =
UpdateClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.setCluster(Cluster.newBuilder().build())
.setGracefulDecommissionTimeout(Duration.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.setRequestId("requestId693933066")
.build();
ApiFuture<Operation> future =
clusterControllerClient.updateClusterCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final OperationFuture<Cluster,ClusterOperationMetadata> stopClusterAsync(StopClusterRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
StopClusterRequest request =
StopClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.setClusterUuid("clusterUuid-1141510955")
.setRequestId("requestId693933066")
.build();
Cluster response = clusterControllerClient.stopClusterAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final OperationCallable<StopClusterRequest,Cluster,ClusterOperationMetadata> stopClusterOperationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
StopClusterRequest request =
StopClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.setClusterUuid("clusterUuid-1141510955")
.setRequestId("requestId693933066")
.build();
OperationFuture<Cluster, ClusterOperationMetadata> future =
clusterControllerClient.stopClusterOperationCallable().futureCall(request);
// Do something.
Cluster response = future.get();
}
public final UnaryCallable<StopClusterRequest,Operation> stopClusterCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
StopClusterRequest request =
StopClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.setClusterUuid("clusterUuid-1141510955")
.setRequestId("requestId693933066")
.build();
ApiFuture<Operation> future =
clusterControllerClient.stopClusterCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final OperationFuture<Cluster,ClusterOperationMetadata> startClusterAsync(StartClusterRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
StartClusterRequest request =
StartClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.setClusterUuid("clusterUuid-1141510955")
.setRequestId("requestId693933066")
.build();
Cluster response = clusterControllerClient.startClusterAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final OperationCallable<StartClusterRequest,Cluster,ClusterOperationMetadata> startClusterOperationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
StartClusterRequest request =
StartClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.setClusterUuid("clusterUuid-1141510955")
.setRequestId("requestId693933066")
.build();
OperationFuture<Cluster, ClusterOperationMetadata> future =
clusterControllerClient.startClusterOperationCallable().futureCall(request);
// Do something.
Cluster response = future.get();
}
public final UnaryCallable<StartClusterRequest,Operation> startClusterCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
StartClusterRequest request =
StartClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.setClusterUuid("clusterUuid-1141510955")
.setRequestId("requestId693933066")
.build();
ApiFuture<Operation> future =
clusterControllerClient.startClusterCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final OperationFuture<Empty,ClusterOperationMetadata> deleteClusterAsync(String projectId, String region, String clusterName)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
String clusterName = "clusterName-1141738587";
clusterControllerClient.deleteClusterAsync(projectId, region, clusterName).get();
}
projectId
- Required. The ID of the Google Cloud Platform project that the cluster belongs
to.region
- Required. The Dataproc region in which to handle the request.clusterName
- Required. The cluster name.ApiException
- if the remote call failspublic final OperationFuture<Empty,ClusterOperationMetadata> deleteClusterAsync(DeleteClusterRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
DeleteClusterRequest request =
DeleteClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.setClusterUuid("clusterUuid-1141510955")
.setRequestId("requestId693933066")
.build();
clusterControllerClient.deleteClusterAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final OperationCallable<DeleteClusterRequest,Empty,ClusterOperationMetadata> deleteClusterOperationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
DeleteClusterRequest request =
DeleteClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.setClusterUuid("clusterUuid-1141510955")
.setRequestId("requestId693933066")
.build();
OperationFuture<Empty, ClusterOperationMetadata> future =
clusterControllerClient.deleteClusterOperationCallable().futureCall(request);
// Do something.
future.get();
}
public final UnaryCallable<DeleteClusterRequest,Operation> deleteClusterCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
DeleteClusterRequest request =
DeleteClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.setClusterUuid("clusterUuid-1141510955")
.setRequestId("requestId693933066")
.build();
ApiFuture<Operation> future =
clusterControllerClient.deleteClusterCallable().futureCall(request);
// Do something.
future.get();
}
public final Cluster getCluster(String projectId, String region, String clusterName)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
String clusterName = "clusterName-1141738587";
Cluster response = clusterControllerClient.getCluster(projectId, region, clusterName);
}
projectId
- Required. The ID of the Google Cloud Platform project that the cluster belongs
to.region
- Required. The Dataproc region in which to handle the request.clusterName
- Required. The cluster name.ApiException
- if the remote call failspublic final Cluster getCluster(GetClusterRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
GetClusterRequest request =
GetClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.build();
Cluster response = clusterControllerClient.getCluster(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetClusterRequest,Cluster> getClusterCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
GetClusterRequest request =
GetClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.build();
ApiFuture<Cluster> future = clusterControllerClient.getClusterCallable().futureCall(request);
// Do something.
Cluster response = future.get();
}
public final ClusterControllerClient.ListClustersPagedResponse listClusters(String projectId, String region)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
for (Cluster element : clusterControllerClient.listClusters(projectId, region).iterateAll()) {
// doThingsWith(element);
}
}
projectId
- Required. The ID of the Google Cloud Platform project that the cluster belongs
to.region
- Required. The Dataproc region in which to handle the request.ApiException
- if the remote call failspublic final ClusterControllerClient.ListClustersPagedResponse listClusters(String projectId, String region, String filter)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
String filter = "filter-1274492040";
for (Cluster element :
clusterControllerClient.listClusters(projectId, region, filter).iterateAll()) {
// doThingsWith(element);
}
}
projectId
- Required. The ID of the Google Cloud Platform project that the cluster belongs
to.region
- Required. The Dataproc region in which to handle the request.filter
- Optional. A filter constraining the clusters to list. Filters are case-sensitive
and have the following syntax:
field = value [AND [field = value]] ...
where **field** is one of `status.state`, `clusterName`, or `labels.[KEY]`, and `[KEY]` is a label key. **value** can be `*` to match all values. `status.state` can be one of the following: `ACTIVE`, `INACTIVE`, `CREATING`, `RUNNING`, `ERROR`, `DELETING`, or `UPDATING`. `ACTIVE` contains the `CREATING`, `UPDATING`, and `RUNNING` states. `INACTIVE` contains the `DELETING` and `ERROR` states. `clusterName` is the name of the cluster provided at creation time. Only the logical `AND` operator is supported; space-separated items are treated as having an implicit `AND` operator.
Example filter:
status.state = ACTIVE AND clusterName = mycluster AND labels.env = staging AND labels.starred = *
ApiException
- if the remote call failspublic final ClusterControllerClient.ListClustersPagedResponse listClusters(ListClustersRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
ListClustersRequest request =
ListClustersRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Cluster element : clusterControllerClient.listClusters(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<ListClustersRequest,ClusterControllerClient.ListClustersPagedResponse> listClustersPagedCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
ListClustersRequest request =
ListClustersRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Cluster> future =
clusterControllerClient.listClustersPagedCallable().futureCall(request);
// Do something.
for (Cluster element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListClustersRequest,ListClustersResponse> listClustersCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
ListClustersRequest request =
ListClustersRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListClustersResponse response =
clusterControllerClient.listClustersCallable().call(request);
for (Cluster element : response.getClustersList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final OperationFuture<DiagnoseClusterResults,ClusterOperationMetadata> diagnoseClusterAsync(String projectId, String region, String clusterName)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "projectId-894832108";
String region = "region-934795532";
String clusterName = "clusterName-1141738587";
DiagnoseClusterResults response =
clusterControllerClient.diagnoseClusterAsync(projectId, region, clusterName).get();
}
projectId
- Required. The ID of the Google Cloud Platform project that the cluster belongs
to.region
- Required. The Dataproc region in which to handle the request.clusterName
- Required. The cluster name.ApiException
- if the remote call failspublic final OperationFuture<DiagnoseClusterResults,ClusterOperationMetadata> diagnoseClusterAsync(DiagnoseClusterRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
DiagnoseClusterRequest request =
DiagnoseClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.build();
DiagnoseClusterResults response = clusterControllerClient.diagnoseClusterAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final OperationCallable<DiagnoseClusterRequest,DiagnoseClusterResults,ClusterOperationMetadata> diagnoseClusterOperationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
DiagnoseClusterRequest request =
DiagnoseClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.build();
OperationFuture<DiagnoseClusterResults, ClusterOperationMetadata> future =
clusterControllerClient.diagnoseClusterOperationCallable().futureCall(request);
// Do something.
DiagnoseClusterResults response = future.get();
}
public final UnaryCallable<DiagnoseClusterRequest,Operation> diagnoseClusterCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
DiagnoseClusterRequest request =
DiagnoseClusterRequest.newBuilder()
.setProjectId("projectId-894832108")
.setRegion("region-934795532")
.setClusterName("clusterName-1141738587")
.build();
ApiFuture<Operation> future =
clusterControllerClient.diagnoseClusterCallable().futureCall(request);
// Do something.
Operation response = 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 © 2022 Google LLC. All rights reserved.