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());
});
}
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());
}
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());
}
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);
}
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.");
}
Aggregations