use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub in project cloudbreak by hortonworks.
the class GrpcCcmV2Client method registerAgent.
public InvertingProxyAgent registerAgent(String requestId, String accountId, Optional<String> environmentCrnOpt, String domainName, String keyId, String actorCrn) {
try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
ClusterConnectivityManagementV2BlockingStub client = makeClient(channelWrapper.getChannel(), requestId, actorCrn);
RegisterAgentRequest.Builder registerAgentRequestBuilder = RegisterAgentRequest.newBuilder().setAccountId(accountId).setDomainName(domainName).setKeyId(keyId);
environmentCrnOpt.ifPresent(registerAgentRequestBuilder::setEnvironmentCrn);
RegisterAgentRequest registerAgentRequest = registerAgentRequestBuilder.build();
LOGGER.debug("Calling registerAgent with params accountId: '{}', environmentCrnOpt: '{}', domainName: '{}', keyId:'{}' ", accountId, environmentCrnOpt, domainName, keyId);
RegisterAgentResponse registerAgentResponse = client.registerAgent(registerAgentRequest);
return registerAgentResponse.getInvertingProxyAgent();
}
}
use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub in project cloudbreak by hortonworks.
the class GrpcCcmV2Client method unRegisterAgent.
public UnregisterAgentResponse unRegisterAgent(String requestId, String agentCrn, String actorCrn) {
try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
ClusterConnectivityManagementV2BlockingStub client = makeClient(channelWrapper.getChannel(), requestId, actorCrn);
UnregisterAgentRequest unregisterAgentRequest = UnregisterAgentRequest.newBuilder().setAgentCrn(agentCrn).build();
LOGGER.debug("Calling unRegisterAgent with params agentCrn: '{}'", agentCrn);
return client.unregisterAgent(unregisterAgentRequest);
}
}
use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub in project cloudbreak by hortonworks.
the class GrpcCcmV2Client method listAgents.
public List<InvertingProxyAgent> listAgents(String requestId, String actorCrn, String accountId, Optional<String> environmentCrnOpt) {
List<InvertingProxyAgent> result = new ArrayList<>();
try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
ClusterConnectivityManagementV2BlockingStub client = makeClient(channelWrapper.getChannel(), requestId, actorCrn);
Builder listAgentsRequestBuilder = ListAgentsRequest.newBuilder();
environmentCrnOpt.ifPresentOrElse(listAgentsRequestBuilder::setEnvironmentCrn, () -> listAgentsRequestBuilder.setAccountId(accountId));
ListAgentsRequest listAgentsRequest = listAgentsRequestBuilder.build();
PageToken nextPageToken = null;
int page = 0;
while (page == 0 || nextPageToken.getExclusiveStartKeyStringAttrsCount() > 0 || nextPageToken.getExclusiveStartKeyNumAttrsCount() > 0) {
++page;
LOGGER.debug("Calling listAgents with params accountId: '{}', environment CRN: '{}', page: '{}'", accountId, environmentCrnOpt, page);
ListAgentsResponse listAgentsResponse = client.listAgents(listAgentsRequest);
result.addAll(listAgentsResponse.getAgentsList());
nextPageToken = listAgentsResponse.getNextPageToken();
listAgentsRequestBuilder.setPageToken(nextPageToken);
listAgentsRequest = listAgentsRequestBuilder.build();
}
}
return result;
}
use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub in project cloudbreak by hortonworks.
the class GrpcCcmV2Client method getOrCreateInvertingProxy.
public InvertingProxy getOrCreateInvertingProxy(String requestId, String accountId, String actorCrn) {
try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
ClusterConnectivityManagementV2BlockingStub client = makeClient(channelWrapper.getChannel(), requestId, actorCrn);
CreateOrGetInvertingProxyRequest invertingProxyRequest = CreateOrGetInvertingProxyRequest.newBuilder().setAccountId(accountId).build();
LOGGER.debug("Calling getOrCreateInvertingProxy with params accountId: '{}'", accountId);
CreateOrGetInvertingProxyResponse invertingProxyRequestResponse = client.createOrGetInvertingProxy(invertingProxyRequest);
return invertingProxyRequestResponse.getInvertingProxy();
}
}
Aggregations