use of com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse in project cloudbreak by hortonworks.
the class UpgradeCcmOnDatalakeHandler method accept.
@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
LOGGER.debug("In UpgradeCcmOnDatalakeHandler.accept");
EnvironmentDto environmentDto = environmentDtoEvent.getData();
try {
LOGGER.debug("Calling Upgrade CCM endpoint on data lake service");
SdxCcmUpgradeResponse ccmUpgradeResponse = sdxService.upgradeCcm(environmentDto.getResourceCrn());
switch(ccmUpgradeResponse.getResponseType()) {
case ERROR:
String message = String.format("Upgrade CCM returned with reason: %s", ccmUpgradeResponse.getReason());
LOGGER.warn(message);
sendFailedEvent(environmentDtoEvent, environmentDto, new OperationException(message));
return;
case TRIGGERED:
LOGGER.debug("Waiting for data lake Upgrade CCM flow to finish.");
pollerService.waitForUpgradeCcm(environmentDto.getId(), ccmUpgradeResponse.getResourceCrn());
break;
case SKIP:
LOGGER.debug("Upgrade CCM is skipped due to {}", ccmUpgradeResponse.getReason());
break;
default:
message = String.format("Unknown response type: %s", ccmUpgradeResponse.getResponseType());
LOGGER.warn(message);
sendFailedEvent(environmentDtoEvent, environmentDto, new OperationException(message));
return;
}
UpgradeCcmEvent upgradeCcmEvent = UpgradeCcmEvent.builder().withSelector(UpgradeCcmStateSelectors.UPGRADE_CCM_DATAHUB_EVENT.selector()).withResourceCrn(environmentDto.getResourceCrn()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(upgradeCcmEvent, environmentDtoEvent.getHeaders());
LOGGER.debug("UPGRADE_CCM_DATAHUB_EVENT event sent");
} catch (Exception e) {
sendFailedEvent(environmentDtoEvent, environmentDto, e);
}
}
use of com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse in project cloudbreak by hortonworks.
the class SdxUpgradeControllerTest method testUpgradeCcm.
@Test
void testUpgradeCcm() {
SdxCcmUpgradeResponse response = new SdxCcmUpgradeResponse(CcmUpgradeResponseType.TRIGGERED, new FlowIdentifier(FlowType.FLOW, "FlowId"), "OK", "crn");
when(sdxCcmUpgradeService.upgradeCcm(ENV_CRN)).thenReturn(response);
SdxCcmUpgradeResponse sdxCcmUpgradeResponse = underTest.upgradeCcm(ENV_CRN, USER_CRN);
assertThat(sdxCcmUpgradeResponse).isEqualTo(response);
}
use of com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse in project cloudbreak by hortonworks.
the class SdxCcmUpgradeService method triggerCcmUpgradeFlow.
private SdxCcmUpgradeResponse triggerCcmUpgradeFlow(SdxCluster cluster) {
MDCBuilder.buildMdcContext(cluster);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerCcmUpgradeFlow(cluster);
return new SdxCcmUpgradeResponse(CcmUpgradeResponseType.TRIGGERED, flowIdentifier, getMessage(DATALAKE_UPGRADE_CCM, null), cluster.getResourceCrn());
}
use of com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse in project cloudbreak by hortonworks.
the class SdxCcmUpgradeServiceTest method testTriggerUpgrade.
@Test
void testTriggerUpgrade() {
SdxCluster sdxCluster = getSdxCluster();
when(sdxService.listSdxByEnvCrn(anyString())).thenReturn(List.of(sdxCluster));
when(sdxService.getAccountIdFromCrn(any())).thenReturn(ACCOUNT_ID);
when(sdxService.getDetail(CLUSTER_NAME, null, ACCOUNT_ID)).thenReturn(getStack(Tunnel.CCM, Status.AVAILABLE));
when(messagesService.getMessage(any(), any())).thenReturn("success");
FlowIdentifier flowId = new FlowIdentifier(FlowType.FLOW, "flowId");
when(sdxReactorFlowManager.triggerCcmUpgradeFlow(sdxCluster)).thenReturn(flowId);
SdxCcmUpgradeResponse response = underTest.upgradeCcm(ENV_CRN);
assertThat(response.getReason()).isEqualTo("success");
assertThat(response.getFlowIdentifier()).isEqualTo(flowId);
}
use of com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse in project cloudbreak by hortonworks.
the class SdxCcmUpgradeServiceTest method testNotUpgradable.
@ParameterizedTest
@EnumSource(value = Tunnel.class, names = { "DIRECT", "CLUSTER_PROXY" }, mode = Mode.INCLUDE)
void testNotUpgradable(Tunnel tunnel) {
SdxCluster sdxCluster = getSdxCluster();
when(sdxService.listSdxByEnvCrn(anyString())).thenReturn(List.of(sdxCluster));
when(sdxService.getAccountIdFromCrn(any())).thenReturn(ACCOUNT_ID);
when(sdxService.getDetail(CLUSTER_NAME, null, ACCOUNT_ID)).thenReturn(getStack(tunnel, Status.AVAILABLE));
when(messagesService.getMessage(any())).thenReturn("not upgradeable");
SdxCcmUpgradeResponse response = underTest.upgradeCcm(ENV_CRN);
assertThat(response.getReason()).isEqualTo("not upgradeable");
assertThat(response.getFlowIdentifier()).isEqualTo(FlowIdentifier.notTriggered());
}
Aggregations