Search in sources :

Example 1 with ClusterConnectivityManagementV2BlockingStub

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();
    }
}
Also used : RegisterAgentResponse(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.RegisterAgentResponse) RegisterAgentRequest(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.RegisterAgentRequest) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) ClusterConnectivityManagementV2BlockingStub(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub)

Example 2 with ClusterConnectivityManagementV2BlockingStub

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);
    }
}
Also used : UnregisterAgentRequest(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.UnregisterAgentRequest) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) ClusterConnectivityManagementV2BlockingStub(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub)

Example 3 with ClusterConnectivityManagementV2BlockingStub

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;
}
Also used : InvertingProxyAgent(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent) ManagedChannelBuilder(io.grpc.ManagedChannelBuilder) Builder(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsRequest.Builder) ArrayList(java.util.ArrayList) ListAgentsRequest(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsRequest) PageToken(com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) ClusterConnectivityManagementV2BlockingStub(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub) ListAgentsResponse(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsResponse)

Example 4 with ClusterConnectivityManagementV2BlockingStub

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();
    }
}
Also used : CreateOrGetInvertingProxyResponse(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.CreateOrGetInvertingProxyResponse) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) ClusterConnectivityManagementV2BlockingStub(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub) CreateOrGetInvertingProxyRequest(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.CreateOrGetInvertingProxyRequest)

Aggregations

ClusterConnectivityManagementV2BlockingStub (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub)4 ManagedChannelWrapper (com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper)4 CreateOrGetInvertingProxyRequest (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.CreateOrGetInvertingProxyRequest)1 CreateOrGetInvertingProxyResponse (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.CreateOrGetInvertingProxyResponse)1 InvertingProxyAgent (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent)1 ListAgentsRequest (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsRequest)1 Builder (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsRequest.Builder)1 ListAgentsResponse (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsResponse)1 RegisterAgentRequest (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.RegisterAgentRequest)1 RegisterAgentResponse (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.RegisterAgentResponse)1 UnregisterAgentRequest (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.UnregisterAgentRequest)1 PageToken (com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken)1 ManagedChannelBuilder (io.grpc.ManagedChannelBuilder)1 ArrayList (java.util.ArrayList)1