Search in sources :

Example 1 with InvertingProxy

use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy in project cloudbreak by hortonworks.

the class CcmV2ManagementClient method awaitReadyInvertingProxyForAccount.

public InvertingProxy awaitReadyInvertingProxyForAccount(String requestId, String accountId) {
    return getRetryTemplate().execute(retryContext -> {
        LOGGER.debug("Retrieving InvertingProxy for accountId '{}'", accountId);
        InvertingProxy invertingProxy = grpcCcmV2Client.getOrCreateInvertingProxy(requestId, accountId, ThreadBasedUserCrnProvider.getUserCrn());
        LOGGER.debug("Retrieved InvertingProxy with status '{}' for accountId '{}'", invertingProxy.getStatus(), accountId);
        if (!InvertingProxy.Status.READY.equals(invertingProxy.getStatus())) {
            throw new CcmV2Exception(String.format("InvertingProxy is not available in 'READY' state for accountId '%s'", accountId));
        }
        return invertingProxy;
    }, retryExhausted -> {
        LOGGER.error("Error Retrieving InvertingProxy for accountId '{}', retryCount '{}'", accountId, retryExhausted.getRetryCount());
        throw new CcmV2Exception("Error Retrieving CCM InvertingProxy", retryExhausted.getLastThrowable());
    });
}
Also used : InvertingProxy(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy) CcmV2Exception(com.sequenceiq.cloudbreak.ccm.exception.CcmV2Exception)

Example 2 with InvertingProxy

use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy in project cloudbreak by hortonworks.

the class DefaultCcmV2JumpgateParameterSupplier method getCcmV2JumpgateParameters.

@Override
public CcmV2JumpgateParameters getCcmV2JumpgateParameters(@Nonnull String accountId, @Nonnull Optional<String> environmentCrnOpt, @Nonnull String clusterGatewayDomain, @Nonnull String agentKeyId) {
    InvertingProxyAndAgent invertingProxyAndAgent = getInvertingProxyAndAgent(accountId, environmentCrnOpt, clusterGatewayDomain, agentKeyId);
    InvertingProxy invertingProxy = invertingProxyAndAgent.getInvertingProxy();
    InvertingProxyAgent invertingProxyAgent = invertingProxyAndAgent.getInvertingProxyAgent();
    LOGGER.debug("CcmV2JumpgateConfig successfully retrieved InvertingProxyHost: '{}', InvertingProxyStatus: '{}', InvertingProxyAgentCrn: '{}', " + "EnvironmentCrnOpt: '{}'", invertingProxy.getHostname(), invertingProxy.getStatus(), invertingProxyAgent.getAgentCrn(), invertingProxyAgent.getEnvironmentCrn());
    return new DefaultCcmV2JumpgateParameters(invertingProxy.getHostname(), invertingProxy.getCertificate(), invertingProxyAgent.getAgentCrn(), agentKeyId, invertingProxyAgent.getEncipheredPrivateKey(), invertingProxyAgent.getCertificate(), invertingProxyAgent.getEnvironmentCrn(), invertingProxyAgent.getAccessKeyId(), invertingProxyAgent.getEncipheredAccessKey());
}
Also used : InvertingProxyAgent(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) InvertingProxy(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy)

Example 3 with InvertingProxy

use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy in project cloudbreak by hortonworks.

the class DefaultCcmV2ParameterSupplier method getCcmV2Parameters.

public CcmV2Parameters getCcmV2Parameters(@Nonnull String accountId, @Nonnull Optional<String> environmentCrnOpt, @Nonnull String clusterGatewayDomain, @Nonnull String agentKeyId) {
    InvertingProxyAndAgent invertingProxyAndAgent = getInvertingProxyAndAgent(accountId, environmentCrnOpt, clusterGatewayDomain, agentKeyId);
    InvertingProxy invertingProxy = invertingProxyAndAgent.getInvertingProxy();
    InvertingProxyAgent invertingProxyAgent = invertingProxyAndAgent.getInvertingProxyAgent();
    LOGGER.debug("CcmV2Config successfully retrieved InvertingProxyHost: '{}', InvertingProxyStatus: '{}', InvertingProxyAgentCrn: '{}', " + "EnvironmentCrnOpt: '{}'", invertingProxy.getHostname(), invertingProxy.getStatus(), invertingProxyAgent.getAgentCrn(), Optional.of(invertingProxyAgent.getEnvironmentCrn()));
    return new DefaultCcmV2Parameters(invertingProxy.getHostname(), invertingProxy.getCertificate(), invertingProxyAgent.getAgentCrn(), agentKeyId, invertingProxyAgent.getEncipheredPrivateKey(), invertingProxyAgent.getCertificate());
}
Also used : InvertingProxyAgent(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent) InvertingProxy(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters)

Example 4 with InvertingProxy

use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy in project cloudbreak by hortonworks.

the class DefaultCcmV2ParameterSupplier method getInvertingProxyAndAgent.

protected InvertingProxyAndAgent getInvertingProxyAndAgent(@Nonnull String accountId, @Nonnull Optional<String> environmentCrnOpt, @Nonnull String clusterGatewayDomain, @Nonnull String agentKeyId) {
    String requestId = MDCBuilder.getOrGenerateRequestId();
    InvertingProxy invertingProxy = ccmV2Client.awaitReadyInvertingProxyForAccount(requestId, accountId);
    unregisterExistingAgent(requestId, accountId, environmentCrnOpt, agentKeyId);
    InvertingProxyAgent invertingProxyAgent = ccmV2Client.registerInvertingProxyAgent(requestId, accountId, environmentCrnOpt, clusterGatewayDomain, agentKeyId);
    validateCcmV2ConfigResponse(invertingProxy, invertingProxyAgent);
    return new InvertingProxyAndAgent(invertingProxy, invertingProxyAgent);
}
Also used : InvertingProxyAgent(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent) InvertingProxy(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy)

Example 5 with InvertingProxy

use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy in project cloudbreak by hortonworks.

the class CcmV2ManagementClientTest method testAwaitReadyInvertingProxyForAccountWhenInvertingProxyIsReady.

@Test
void testAwaitReadyInvertingProxyForAccountWhenInvertingProxyIsReady() {
    InvertingProxy invertingProxy = InvertingProxy.newBuilder().setStatus(InvertingProxy.Status.READY).build();
    when(grpcCcmV2Client.getOrCreateInvertingProxy(TEST_REQUEST_ID, TEST_ACCOUNT_ID, TEST_USER_CRN)).thenReturn(invertingProxy);
    InvertingProxy retrievedProxy = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.awaitReadyInvertingProxyForAccount(TEST_REQUEST_ID, TEST_ACCOUNT_ID));
    assertEquals(InvertingProxy.Status.READY, retrievedProxy.getStatus(), "Inverting Proxy Status should be ready.");
}
Also used : InvertingProxy(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy) Test(org.junit.jupiter.api.Test)

Aggregations

InvertingProxy (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy)10 InvertingProxyAgent (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent)6 Test (org.junit.jupiter.api.Test)4 Optional (java.util.Optional)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ClusterConnectivityManagementV2BlockingStub (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub)1 CreateOrGetInvertingProxyRequest (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.CreateOrGetInvertingProxyRequest)1 CreateOrGetInvertingProxyResponse (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.CreateOrGetInvertingProxyResponse)1 CcmV2JumpgateParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters)1 DefaultCcmV2JumpgateParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters)1 DefaultCcmV2Parameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters)1 CcmV2Exception (com.sequenceiq.cloudbreak.ccm.exception.CcmV2Exception)1 ManagedChannelWrapper (com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1