use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent in project cloudbreak by hortonworks.
the class UpgradeCcmActions method finishedAction.
@Bean(name = "UPGRADE_CCM_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractUpgradeCcmSdxAction<>(UpgradeCcmSuccessEvent.class) {
@Override
protected void doExecute(SdxContext context, UpgradeCcmSuccessEvent payload, Map<Object, Object> variables) {
LOGGER.info("CCM upgrade finalized for SDX: {}", payload.getResourceId());
SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.RUNNING, "Cluster Connectivity Manager upgrade completed successfully", payload.getResourceId());
metricService.incrementMetricCounter(MetricType.UPGRADE_CCM_FINISHED, sdxCluster);
sendEvent(context, UPGRADE_CCM_FINALIZED_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent in project cloudbreak by hortonworks.
the class UpgradeCcmActionsTest method finishedFailPath.
@Test
void finishedFailPath() {
actionPayload = new UpgradeCcmSuccessEvent(SDX_ID, USER_ID);
setupContextWithPayload();
testErrorInSdxStatusService(underTest::finishedAction);
verify(sdxStatusService).setStatusForDatalakeAndNotify(DatalakeStatusEnum.RUNNING, "Cluster Connectivity Manager upgrade completed successfully", SDX_ID);
UpgradeCcmSuccessEvent payload = (UpgradeCcmSuccessEvent) payloadArgumentCaptor.getValue();
assertThat(payload.getResourceId()).isEqualTo(SDX_ID);
assertThat(payload.getUserId()).isEqualTo(USER_ID);
}
use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent in project cloudbreak by hortonworks.
the class UpgradeCcmActionsTest method finishedHappyPath.
@Test
void finishedHappyPath() {
actionPayload = new UpgradeCcmSuccessEvent(SDX_ID, USER_ID);
setupContextWithPayload();
SdxCluster sdxCluster = mock(SdxCluster.class);
when(sdxStatusService.setStatusForDatalakeAndNotify(any(), any(), anyLong())).thenReturn(sdxCluster);
testUpgradeActionHappyPath(underTest::finishedAction);
verify(metricService).incrementMetricCounter(MetricType.UPGRADE_CCM_FINISHED, sdxCluster);
verify(sdxStatusService).setStatusForDatalakeAndNotify(DatalakeStatusEnum.RUNNING, "Cluster Connectivity Manager upgrade completed successfully", SDX_ID);
UpgradeCcmSuccessEvent payload = (UpgradeCcmSuccessEvent) payloadArgumentCaptor.getValue();
assertThat(selectorArgumentCaptor.getValue()).isEqualTo(UPGRADE_CCM_FINALIZED_EVENT.event());
assertThat(payload.getResourceId()).isEqualTo(SDX_ID);
assertThat(payload.getUserId()).isEqualTo(USER_ID);
}
use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent in project cloudbreak by hortonworks.
the class UpgradeCcmStackHandlerTest method acceptSuccess.
@Test
void acceptSuccess() throws Exception {
SdxCluster sdxCluster = getSdxCluster();
when(sdxService.getById(any())).thenReturn(sdxCluster);
UpgradeCcmStackRequest request = new UpgradeCcmStackRequest(1L, "user");
PollingConfig expectedPollingConfig = new PollingConfig(1, TimeUnit.SECONDS, 2, TimeUnit.MINUTES);
Event.Headers headers = new Event.Headers();
Event<UpgradeCcmStackRequest> event = new Event<>(headers, request);
Selectable selectable = new ExceptionCatcherEventHandlerTestSupport<>(underTest).doAccept(event);
UpgradeCcmSuccessEvent successEvent = new UpgradeCcmSuccessEvent(1L, "user");
assertThat(selectable).usingRecursiveComparison().isEqualTo(successEvent);
verify(ccmUpgradeService).initAndWaitForStackUpgrade(eq(sdxCluster), refEq(expectedPollingConfig));
}
use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmSuccessEvent in project cloudbreak by hortonworks.
the class UpgradeCcmStackHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<UpgradeCcmStackRequest> event) {
UpgradeCcmStackRequest request = event.getData();
SdxCluster sdxCluster = sdxService.getById(request.getResourceId());
Long sdxId = request.getResourceId();
String userId = request.getUserId();
Selectable response;
try {
LOGGER.debug("Initiating CCM upgrade and start polling for SDX: {}", sdxCluster.getName());
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
ccmUpgradeService.initAndWaitForStackUpgrade(sdxCluster, pollingConfig);
response = new UpgradeCcmSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Upgrade CCM poller exited before timeout. Cause: ", userBreakException);
response = new UpgradeCcmFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Upgrade CCM poller stopped for stack: {}", sdxId);
response = new UpgradeCcmFailedEvent(sdxId, userId, new PollerStoppedException("Upgrade CCM timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Upgrade CCM polling failed for stack: {}", sdxId);
response = new UpgradeCcmFailedEvent(sdxId, userId, exception);
}
return response;
}
Aggregations