use of com.sequenceiq.cloudbreak.ccm.exception.CcmV2Exception 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.sequenceiq.cloudbreak.ccm.exception.CcmV2Exception in project cloudbreak by hortonworks.
the class CcmV2ManagementClient method deregisterInvertingProxyAgent.
public UnregisterAgentResponse deregisterInvertingProxyAgent(String requestId, String agentCrn) {
return getRetryTemplate().execute(retryContext -> {
LOGGER.debug("Deregistering Agent for agentCrn '{}'", agentCrn);
UnregisterAgentResponse unregisterAgentResponse = grpcCcmV2Client.unRegisterAgent(requestId, agentCrn, ThreadBasedUserCrnProvider.getUserCrn());
LOGGER.debug("Deregistered Agent for agentCrn '{}', unregisterAgentResponse '{}'", agentCrn, unregisterAgentResponse);
return unregisterAgentResponse;
}, retryExhausted -> {
LOGGER.error("Error Deregistering Agent for agentCrn '{}', retryCount '{}'", agentCrn, retryExhausted.getRetryCount());
throw new CcmV2Exception("Error Deregistering CCM Agent", retryExhausted.getLastThrowable());
});
}
use of com.sequenceiq.cloudbreak.ccm.exception.CcmV2Exception in project cloudbreak by hortonworks.
the class DefaultCcmV2ParameterSupplier method unregisterExistingAgent.
private void unregisterExistingAgent(String requestId, String accountId, Optional<String> environmentCrnOpt, String agentKeyId) {
try {
List<InvertingProxyAgent> invertingProxyAgents = ccmV2Client.listInvertingProxyAgents(requestId, accountId, environmentCrnOpt);
Optional<InvertingProxyAgent> registeredAgentWithSameKey = invertingProxyAgents.stream().filter(agent -> agentKeyId.equals(CcmResourceUtil.getKeyId(agent.getAgentCrn()))).findFirst();
registeredAgentWithSameKey.ifPresent(agent -> ccmV2Client.deregisterInvertingProxyAgent(requestId, agent.getAgentCrn()));
} catch (CcmV2Exception e) {
throw new CcmV2Exception("Error in trying to deregister possibly existing CCM Agent", e);
}
}
use of com.sequenceiq.cloudbreak.ccm.exception.CcmV2Exception in project cloudbreak by hortonworks.
the class DefaultCcmV2ParameterSupplierTest method unregisterAgentRethrows.
@Test
void unregisterAgentRethrows() {
setupRegisterInvertingProxyDetails();
when(ccmV2Client.listInvertingProxyAgents(any(), any(), any())).thenThrow(new CcmV2Exception("internal error"));
assertThatThrownBy(() -> underTest.getCcmV2Parameters(TEST_ACCOUNT_ID, Optional.of(TEST_ENVIRONMENT_CRN), TEST_GATEWAY_DOMAIN, Crn.fromString(TEST_CLUSTER_CRN).getResource())).hasMessageNotContaining("internal error").isInstanceOf(CcmV2Exception.class);
verify(ccmV2Client).listInvertingProxyAgents(anyString(), eq(TEST_ACCOUNT_ID), eq(Optional.of(TEST_ENVIRONMENT_CRN)));
verify(ccmV2Client, never()).registerInvertingProxyAgent(anyString(), eq(TEST_ACCOUNT_ID), eq(Optional.of(TEST_ENVIRONMENT_CRN)), eq(TEST_GATEWAY_DOMAIN), eq(TEST_RESOURCE_ID));
verify(ccmV2Client, never()).deregisterInvertingProxyAgent(any(), eq(TEST_AGENT_CRN));
}
use of com.sequenceiq.cloudbreak.ccm.exception.CcmV2Exception in project cloudbreak by hortonworks.
the class CcmV2ManagementClient method registerInvertingProxyAgent.
public InvertingProxyAgent registerInvertingProxyAgent(String requestId, String accountId, Optional<String> environmentCrnOpt, String domainName, String keyId) {
return getRetryTemplate().execute(retryContext -> {
LOGGER.debug("Registering Agent for accountId '{}', environmentCrnOpt: '{}', domainName '{}'", accountId, environmentCrnOpt, domainName);
InvertingProxyAgent invertingProxyAgent = grpcCcmV2Client.registerAgent(requestId, accountId, environmentCrnOpt, domainName, keyId, ThreadBasedUserCrnProvider.getUserCrn());
LOGGER.debug("Registered Agent for accountId '{}', environmentCrnOpt: '{}', domainName '{}', invertingProxyAgent '{}'", accountId, environmentCrnOpt, domainName, invertingProxyAgent);
return invertingProxyAgent;
}, retryExhausted -> {
LOGGER.error("Error Registering Agent for accountId '{}', domainName '{}', retryCount '{}'", accountId, domainName, retryExhausted.getRetryCount());
throw new CcmV2Exception("Error Registering CCM Agent", retryExhausted.getLastThrowable());
});
}
Aggregations