com.google.cloud.dataproc.v1.stub.GrpcClusterControllerStub Maven / Gradle / Ivy
Show all versions of google-cloud-dataproc Show documentation
/*
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.dataproc.v1.stub;
import static com.google.cloud.dataproc.v1.ClusterControllerClient.ListClustersPagedResponse;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.grpc.GrpcCallSettings;
import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.dataproc.v1.Cluster;
import com.google.cloud.dataproc.v1.ClusterOperationMetadata;
import com.google.cloud.dataproc.v1.CreateClusterRequest;
import com.google.cloud.dataproc.v1.DeleteClusterRequest;
import com.google.cloud.dataproc.v1.DiagnoseClusterRequest;
import com.google.cloud.dataproc.v1.DiagnoseClusterResults;
import com.google.cloud.dataproc.v1.GetClusterRequest;
import com.google.cloud.dataproc.v1.ListClustersRequest;
import com.google.cloud.dataproc.v1.ListClustersResponse;
import com.google.cloud.dataproc.v1.UpdateClusterRequest;
import com.google.longrunning.Operation;
import com.google.longrunning.stub.GrpcOperationsStub;
import com.google.protobuf.Empty;
import io.grpc.MethodDescriptor;
import io.grpc.protobuf.ProtoUtils;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS
/**
* gRPC stub implementation for Google Cloud Dataproc API.
*
* This class is for advanced usage and reflects the underlying API directly.
*/
@Generated("by gapic-generator")
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public class GrpcClusterControllerStub extends ClusterControllerStub {
private static final MethodDescriptor
createClusterMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.dataproc.v1.ClusterController/CreateCluster")
.setRequestMarshaller(
ProtoUtils.marshaller(CreateClusterRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
updateClusterMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.dataproc.v1.ClusterController/UpdateCluster")
.setRequestMarshaller(
ProtoUtils.marshaller(UpdateClusterRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor
deleteClusterMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.dataproc.v1.ClusterController/DeleteCluster")
.setRequestMarshaller(
ProtoUtils.marshaller(DeleteClusterRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private static final MethodDescriptor getClusterMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.dataproc.v1.ClusterController/GetCluster")
.setRequestMarshaller(ProtoUtils.marshaller(GetClusterRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Cluster.getDefaultInstance()))
.build();
private static final MethodDescriptor
listClustersMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.dataproc.v1.ClusterController/ListClusters")
.setRequestMarshaller(ProtoUtils.marshaller(ListClustersRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(ListClustersResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor
diagnoseClusterMethodDescriptor =
MethodDescriptor.newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.cloud.dataproc.v1.ClusterController/DiagnoseCluster")
.setRequestMarshaller(
ProtoUtils.marshaller(DiagnoseClusterRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();
private final BackgroundResource backgroundResources;
private final GrpcOperationsStub operationsStub;
private final UnaryCallable createClusterCallable;
private final OperationCallable
createClusterOperationCallable;
private final UnaryCallable updateClusterCallable;
private final OperationCallable
updateClusterOperationCallable;
private final UnaryCallable deleteClusterCallable;
private final OperationCallable
deleteClusterOperationCallable;
private final UnaryCallable getClusterCallable;
private final UnaryCallable listClustersCallable;
private final UnaryCallable
listClustersPagedCallable;
private final UnaryCallable diagnoseClusterCallable;
private final OperationCallable
diagnoseClusterOperationCallable;
private final GrpcStubCallableFactory callableFactory;
public static final GrpcClusterControllerStub create(ClusterControllerStubSettings settings)
throws IOException {
return new GrpcClusterControllerStub(settings, ClientContext.create(settings));
}
public static final GrpcClusterControllerStub create(ClientContext clientContext)
throws IOException {
return new GrpcClusterControllerStub(
ClusterControllerStubSettings.newBuilder().build(), clientContext);
}
public static final GrpcClusterControllerStub create(
ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
return new GrpcClusterControllerStub(
ClusterControllerStubSettings.newBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of GrpcClusterControllerStub, using the given settings. This is
* protected so that it is easy to make a subclass, but otherwise, the static factory methods
* should be preferred.
*/
protected GrpcClusterControllerStub(
ClusterControllerStubSettings settings, ClientContext clientContext) throws IOException {
this(settings, clientContext, new GrpcClusterControllerCallableFactory());
}
/**
* Constructs an instance of GrpcClusterControllerStub, using the given settings. This is
* protected so that it is easy to make a subclass, but otherwise, the static factory methods
* should be preferred.
*/
protected GrpcClusterControllerStub(
ClusterControllerStubSettings settings,
ClientContext clientContext,
GrpcStubCallableFactory callableFactory)
throws IOException {
this.callableFactory = callableFactory;
this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
GrpcCallSettings createClusterTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(createClusterMethodDescriptor)
.build();
GrpcCallSettings updateClusterTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(updateClusterMethodDescriptor)
.build();
GrpcCallSettings deleteClusterTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(deleteClusterMethodDescriptor)
.build();
GrpcCallSettings getClusterTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(getClusterMethodDescriptor)
.build();
GrpcCallSettings listClustersTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(listClustersMethodDescriptor)
.build();
GrpcCallSettings diagnoseClusterTransportSettings =
GrpcCallSettings.newBuilder()
.setMethodDescriptor(diagnoseClusterMethodDescriptor)
.build();
this.createClusterCallable =
callableFactory.createUnaryCallable(
createClusterTransportSettings, settings.createClusterSettings(), clientContext);
this.createClusterOperationCallable =
callableFactory.createOperationCallable(
createClusterTransportSettings,
settings.createClusterOperationSettings(),
clientContext,
this.operationsStub);
this.updateClusterCallable =
callableFactory.createUnaryCallable(
updateClusterTransportSettings, settings.updateClusterSettings(), clientContext);
this.updateClusterOperationCallable =
callableFactory.createOperationCallable(
updateClusterTransportSettings,
settings.updateClusterOperationSettings(),
clientContext,
this.operationsStub);
this.deleteClusterCallable =
callableFactory.createUnaryCallable(
deleteClusterTransportSettings, settings.deleteClusterSettings(), clientContext);
this.deleteClusterOperationCallable =
callableFactory.createOperationCallable(
deleteClusterTransportSettings,
settings.deleteClusterOperationSettings(),
clientContext,
this.operationsStub);
this.getClusterCallable =
callableFactory.createUnaryCallable(
getClusterTransportSettings, settings.getClusterSettings(), clientContext);
this.listClustersCallable =
callableFactory.createUnaryCallable(
listClustersTransportSettings, settings.listClustersSettings(), clientContext);
this.listClustersPagedCallable =
callableFactory.createPagedCallable(
listClustersTransportSettings, settings.listClustersSettings(), clientContext);
this.diagnoseClusterCallable =
callableFactory.createUnaryCallable(
diagnoseClusterTransportSettings, settings.diagnoseClusterSettings(), clientContext);
this.diagnoseClusterOperationCallable =
callableFactory.createOperationCallable(
diagnoseClusterTransportSettings,
settings.diagnoseClusterOperationSettings(),
clientContext,
this.operationsStub);
backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources());
}
public GrpcOperationsStub getOperationsStub() {
return operationsStub;
}
public OperationCallable
createClusterOperationCallable() {
return createClusterOperationCallable;
}
public UnaryCallable createClusterCallable() {
return createClusterCallable;
}
public OperationCallable
updateClusterOperationCallable() {
return updateClusterOperationCallable;
}
public UnaryCallable updateClusterCallable() {
return updateClusterCallable;
}
public OperationCallable
deleteClusterOperationCallable() {
return deleteClusterOperationCallable;
}
public UnaryCallable deleteClusterCallable() {
return deleteClusterCallable;
}
public UnaryCallable getClusterCallable() {
return getClusterCallable;
}
public UnaryCallable listClustersPagedCallable() {
return listClustersPagedCallable;
}
public UnaryCallable listClustersCallable() {
return listClustersCallable;
}
public OperationCallable
diagnoseClusterOperationCallable() {
return diagnoseClusterOperationCallable;
}
public UnaryCallable diagnoseClusterCallable() {
return diagnoseClusterCallable;
}
@Override
public final void close() {
shutdown();
}
@Override
public void shutdown() {
backgroundResources.shutdown();
}
@Override
public boolean isShutdown() {
return backgroundResources.isShutdown();
}
@Override
public boolean isTerminated() {
return backgroundResources.isTerminated();
}
@Override
public void shutdownNow() {
backgroundResources.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return backgroundResources.awaitTermination(duration, unit);
}
}