@Generated(value="by gapic-generator") @BetaApi 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:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
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:
ClusterControllerSettings clusterControllerSettings =
ClusterControllerSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ClusterControllerClient clusterControllerClient =
ClusterControllerClient.create(clusterControllerSettings);
To customize the endpoint:
ClusterControllerSettings clusterControllerSettings =
ClusterControllerSettings.newBuilder().setEndpoint(myEndpoint).build();
ClusterControllerClient clusterControllerClient =
ClusterControllerClient.create(clusterControllerSettings);
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) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ClusterControllerClient |
create()
Constructs an instance of ClusterControllerClient with default settings.
|
static ClusterControllerClient |
create(ClusterControllerSettings settings)
Constructs an instance of ClusterControllerClient, using the given settings.
|
static ClusterControllerClient |
create(ClusterControllerStub stub)
Constructs an instance of ClusterControllerClient, using the given stub for making calls.
|
OperationFuture<com.google.cloud.dataproc.v1beta2.Cluster,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> |
createClusterAsync(com.google.cloud.dataproc.v1beta2.CreateClusterRequest request)
Creates a cluster in a project.
|
OperationFuture<com.google.cloud.dataproc.v1beta2.Cluster,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> |
createClusterAsync(String projectId,
String region,
com.google.cloud.dataproc.v1beta2.Cluster cluster)
Creates a cluster in a project.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.CreateClusterRequest,Operation> |
createClusterCallable()
Creates a cluster in a project.
|
OperationCallable<com.google.cloud.dataproc.v1beta2.CreateClusterRequest,com.google.cloud.dataproc.v1beta2.Cluster,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> |
createClusterOperationCallable()
Creates a cluster in a project.
|
OperationFuture<Empty,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> |
deleteClusterAsync(com.google.cloud.dataproc.v1beta2.DeleteClusterRequest request)
Deletes a cluster in a project.
|
OperationFuture<Empty,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> |
deleteClusterAsync(String projectId,
String region,
String clusterName)
Deletes a cluster in a project.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.DeleteClusterRequest,Operation> |
deleteClusterCallable()
Deletes a cluster in a project.
|
OperationCallable<com.google.cloud.dataproc.v1beta2.DeleteClusterRequest,Empty,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> |
deleteClusterOperationCallable()
Deletes a cluster in a project.
|
OperationFuture<Empty,com.google.cloud.dataproc.v1beta2.DiagnoseClusterResults> |
diagnoseClusterAsync(com.google.cloud.dataproc.v1beta2.DiagnoseClusterRequest request)
Gets cluster diagnostic information.
|
OperationFuture<Empty,com.google.cloud.dataproc.v1beta2.DiagnoseClusterResults> |
diagnoseClusterAsync(String projectId,
String region,
String clusterName)
Gets cluster diagnostic information.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.DiagnoseClusterRequest,Operation> |
diagnoseClusterCallable()
Gets cluster diagnostic information.
|
OperationCallable<com.google.cloud.dataproc.v1beta2.DiagnoseClusterRequest,Empty,com.google.cloud.dataproc.v1beta2.DiagnoseClusterResults> |
diagnoseClusterOperationCallable()
Gets cluster diagnostic information.
|
com.google.cloud.dataproc.v1beta2.Cluster |
getCluster(com.google.cloud.dataproc.v1beta2.GetClusterRequest request)
Gets the resource representation for a cluster in a project.
|
com.google.cloud.dataproc.v1beta2.Cluster |
getCluster(String projectId,
String region,
String clusterName)
Gets the resource representation for a cluster in a project.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.GetClusterRequest,com.google.cloud.dataproc.v1beta2.Cluster> |
getClusterCallable()
Gets the resource representation for a cluster in a project.
|
OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
ClusterControllerSettings |
getSettings() |
ClusterControllerStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
ClusterControllerClient.ListClustersPagedResponse |
listClusters(com.google.cloud.dataproc.v1beta2.ListClustersRequest request)
Lists all regions/{region}/clusters in a project.
|
ClusterControllerClient.ListClustersPagedResponse |
listClusters(String projectId,
String region)
Lists all regions/{region}/clusters in a project.
|
ClusterControllerClient.ListClustersPagedResponse |
listClusters(String projectId,
String region,
String filter)
Lists all regions/{region}/clusters in a project.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.ListClustersRequest,com.google.cloud.dataproc.v1beta2.ListClustersResponse> |
listClustersCallable()
Lists all regions/{region}/clusters in a project.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.ListClustersRequest,ClusterControllerClient.ListClustersPagedResponse> |
listClustersPagedCallable()
Lists all regions/{region}/clusters in a project.
|
void |
shutdown() |
void |
shutdownNow() |
OperationFuture<com.google.cloud.dataproc.v1beta2.Cluster,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> |
updateClusterAsync(String projectId,
String region,
String clusterName,
com.google.cloud.dataproc.v1beta2.Cluster cluster,
FieldMask updateMask)
Updates a cluster in a project.
|
OperationFuture<com.google.cloud.dataproc.v1beta2.Cluster,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> |
updateClusterAsync(com.google.cloud.dataproc.v1beta2.UpdateClusterRequest request)
Updates a cluster in a project.
|
UnaryCallable<com.google.cloud.dataproc.v1beta2.UpdateClusterRequest,Operation> |
updateClusterCallable()
Updates a cluster in a project.
|
OperationCallable<com.google.cloud.dataproc.v1beta2.UpdateClusterRequest,com.google.cloud.dataproc.v1beta2.Cluster,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> |
updateClusterOperationCallable()
Updates a cluster in a project.
|
protected ClusterControllerClient(ClusterControllerSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected ClusterControllerClient(ClusterControllerStub stub)
public static final ClusterControllerClient create() throws IOException
IOException
public static final ClusterControllerClient create(ClusterControllerSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final ClusterControllerClient create(ClusterControllerStub stub)
public final ClusterControllerSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public ClusterControllerStub getStub()
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationsClient getOperationsClient()
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.cloud.dataproc.v1beta2.Cluster,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> createClusterAsync(String projectId, String region, com.google.cloud.dataproc.v1beta2.Cluster cluster)
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
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 Cloud Dataproc region in which to handle the request.cluster
- Required. The cluster to create.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.cloud.dataproc.v1beta2.Cluster,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> createClusterAsync(com.google.cloud.dataproc.v1beta2.CreateClusterRequest request)
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
Cluster cluster = Cluster.newBuilder().build();
CreateClusterRequest request = CreateClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setCluster(cluster)
.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 fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<com.google.cloud.dataproc.v1beta2.CreateClusterRequest,com.google.cloud.dataproc.v1beta2.Cluster,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> createClusterOperationCallable()
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
Cluster cluster = Cluster.newBuilder().build();
CreateClusterRequest request = CreateClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setCluster(cluster)
.build();
OperationFuture<Cluster, ClusterOperationMetadata> future = clusterControllerClient.createClusterOperationCallable().futureCall(request);
// Do something
Cluster response = future.get();
}
public final UnaryCallable<com.google.cloud.dataproc.v1beta2.CreateClusterRequest,Operation> createClusterCallable()
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
Cluster cluster = Cluster.newBuilder().build();
CreateClusterRequest request = CreateClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setCluster(cluster)
.build();
ApiFuture<Operation> future = clusterControllerClient.createClusterCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.cloud.dataproc.v1beta2.Cluster,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> updateClusterAsync(String projectId, String region, String clusterName, com.google.cloud.dataproc.v1beta2.Cluster cluster, FieldMask updateMask)
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
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 Cloud 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> <tr> <td><strong>Mask</strong></td><td><strong>Purpose</strong></td> </tr> <tr> <td>labels</td><td>Updates labels</td> </tr> <tr> <td>config.worker_config.num_instances</td><td>Resize primary worker group</td> </tr> <tr> <td>config.secondary_worker_config.num_instances</td><td>Resize secondary worker group</td> </tr> <tr> <td>config.lifecycle_config.auto_delete_ttl</td><td>Reset MAX TTL duration</td> </tr> <tr> <td>config.lifecycle_config.auto_delete_time</td><td>Update MAX TTL deletion timestamp</td> </tr> <tr> <td>config.lifecycle_config.idle_delete_ttl</td><td>Update Idle TTL duration</td> </tr> </table>
ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.cloud.dataproc.v1beta2.Cluster,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> updateClusterAsync(com.google.cloud.dataproc.v1beta2.UpdateClusterRequest request)
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
Cluster cluster = Cluster.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateClusterRequest request = UpdateClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.setCluster(cluster)
.setUpdateMask(updateMask)
.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 fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<com.google.cloud.dataproc.v1beta2.UpdateClusterRequest,com.google.cloud.dataproc.v1beta2.Cluster,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> updateClusterOperationCallable()
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
Cluster cluster = Cluster.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateClusterRequest request = UpdateClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.setCluster(cluster)
.setUpdateMask(updateMask)
.build();
OperationFuture<Cluster, ClusterOperationMetadata> future = clusterControllerClient.updateClusterOperationCallable().futureCall(request);
// Do something
Cluster response = future.get();
}
public final UnaryCallable<com.google.cloud.dataproc.v1beta2.UpdateClusterRequest,Operation> updateClusterCallable()
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
Cluster cluster = Cluster.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateClusterRequest request = UpdateClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.setCluster(cluster)
.setUpdateMask(updateMask)
.build();
ApiFuture<Operation> future = clusterControllerClient.updateClusterCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Empty,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> deleteClusterAsync(String projectId, String region, String clusterName)
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
clusterControllerClient.deleteClusterAsync(projectId, region, clusterName).get();
}
projectId
- Required. The ID of the Google Cloud Platform project that the cluster belongs
to.region
- Required. The Cloud Dataproc region in which to handle the request.clusterName
- Required. The cluster name.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Empty,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> deleteClusterAsync(com.google.cloud.dataproc.v1beta2.DeleteClusterRequest request)
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
DeleteClusterRequest request = DeleteClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.build();
clusterControllerClient.deleteClusterAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<com.google.cloud.dataproc.v1beta2.DeleteClusterRequest,Empty,com.google.cloud.dataproc.v1beta2.ClusterOperationMetadata> deleteClusterOperationCallable()
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
DeleteClusterRequest request = DeleteClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.build();
OperationFuture<Empty, ClusterOperationMetadata> future = clusterControllerClient.deleteClusterOperationCallable().futureCall(request);
// Do something
future.get();
}
public final UnaryCallable<com.google.cloud.dataproc.v1beta2.DeleteClusterRequest,Operation> deleteClusterCallable()
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
DeleteClusterRequest request = DeleteClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.build();
ApiFuture<Operation> future = clusterControllerClient.deleteClusterCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.cloud.dataproc.v1beta2.Cluster getCluster(String projectId, String region, String clusterName)
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
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 Cloud Dataproc region in which to handle the request.clusterName
- Required. The cluster name.ApiException
- if the remote call failspublic final com.google.cloud.dataproc.v1beta2.Cluster getCluster(com.google.cloud.dataproc.v1beta2.GetClusterRequest request)
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
GetClusterRequest request = GetClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.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<com.google.cloud.dataproc.v1beta2.GetClusterRequest,com.google.cloud.dataproc.v1beta2.Cluster> getClusterCallable()
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
GetClusterRequest request = GetClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.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:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
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 Cloud 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:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String filter = "";
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 Cloud 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(com.google.cloud.dataproc.v1beta2.ListClustersRequest request)
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
ListClustersRequest request = ListClustersRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.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<com.google.cloud.dataproc.v1beta2.ListClustersRequest,ClusterControllerClient.ListClustersPagedResponse> listClustersPagedCallable()
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
ListClustersRequest request = ListClustersRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.build();
ApiFuture<ListClustersPagedResponse> future = clusterControllerClient.listClustersPagedCallable().futureCall(request);
// Do something
for (Cluster element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.cloud.dataproc.v1beta2.ListClustersRequest,com.google.cloud.dataproc.v1beta2.ListClustersResponse> listClustersCallable()
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
ListClustersRequest request = ListClustersRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.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;
}
}
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Empty,com.google.cloud.dataproc.v1beta2.DiagnoseClusterResults> diagnoseClusterAsync(String projectId, String region, String clusterName)
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
clusterControllerClient.diagnoseClusterAsync(projectId, region, clusterName).get();
}
projectId
- Required. The ID of the Google Cloud Platform project that the cluster belongs
to.region
- Required. The Cloud Dataproc region in which to handle the request.clusterName
- Required. The cluster name.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Empty,com.google.cloud.dataproc.v1beta2.DiagnoseClusterResults> diagnoseClusterAsync(com.google.cloud.dataproc.v1beta2.DiagnoseClusterRequest request)
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
DiagnoseClusterRequest request = DiagnoseClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.build();
clusterControllerClient.diagnoseClusterAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<com.google.cloud.dataproc.v1beta2.DiagnoseClusterRequest,Empty,com.google.cloud.dataproc.v1beta2.DiagnoseClusterResults> diagnoseClusterOperationCallable()
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
DiagnoseClusterRequest request = DiagnoseClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.build();
OperationFuture<Empty, DiagnoseClusterResults> future = clusterControllerClient.diagnoseClusterOperationCallable().futureCall(request);
// Do something
future.get();
}
public final UnaryCallable<com.google.cloud.dataproc.v1beta2.DiagnoseClusterRequest,Operation> diagnoseClusterCallable()
Sample code:
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
String clusterName = "";
DiagnoseClusterRequest request = DiagnoseClusterRequest.newBuilder()
.setProjectId(projectId)
.setRegion(region)
.setClusterName(clusterName)
.build();
ApiFuture<Operation> future = clusterControllerClient.diagnoseClusterCallable().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.