use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.
the class UpgradeCcmActionsTest method failureAction.
@Test
void failureAction() {
IllegalStateException failureException = new IllegalStateException(MESSAGE);
actionPayload = new UpgradeCcmFailedEvent(SDX_ID, USER_ID, failureException);
setupContextWithPayload();
testUpgradeActionHappyPath(underTest::failedAction);
UpgradeCcmFailedEvent payload = (UpgradeCcmFailedEvent) payloadArgumentCaptor.getValue();
assertThat(selectorArgumentCaptor.getValue()).isEqualTo(UPGRADE_CCM_FAILED_HANDLED_EVENT.event());
assertThat(payload.getResourceId()).isEqualTo(SDX_ID);
assertThat(payload.getUserId()).isEqualTo(USER_ID);
verify(sdxStatusService).setStatusForDatalakeAndNotify(DatalakeStatusEnum.DATALAKE_UPGRADE_CCM_FAILED, MESSAGE, SDX_ID);
verify(metricService).incrementMetricCounter(eq(MetricType.UPGRADE_CCM_FAILED), (SdxCluster) any());
}
use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.
the class UpgradeCcmStackHandlerTest method acceptWithExceptions.
@ParameterizedTest
@ValueSource(classes = { UserBreakException.class, PollerStoppedException.class, PollerException.class })
void acceptWithExceptions(Class<? extends Throwable> errorClass) throws Exception {
UpgradeCcmStackRequest request = new UpgradeCcmStackRequest(1L, "user");
Event.Headers headers = new Event.Headers();
Event<UpgradeCcmStackRequest> event = new Event<>(headers, request);
when(sdxService.getById(any())).thenReturn(getSdxCluster());
doThrow(errorClass).when(ccmUpgradeService).initAndWaitForStackUpgrade(any(SdxCluster.class), any(PollingConfig.class));
Selectable selectable = new ExceptionCatcherEventHandlerTestSupport<>(underTest).doAccept(event);
UpgradeCcmFailedEvent failedEvent = new UpgradeCcmFailedEvent(1L, "user", new Exception("error"));
assertThat(selectable).usingRecursiveComparison().isEqualTo(failedEvent);
}
use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent in project cloudbreak by hortonworks.
the class UpgradeCcmActions method failedAction.
@Bean(name = "UPGRADE_CCM_FAILED_STATE")
public Action<?, ?> failedAction() {
return new AbstractUpgradeCcmSdxAction<>(UpgradeCcmFailedEvent.class) {
@Override
protected void doExecute(SdxContext context, UpgradeCcmFailedEvent payload, Map<Object, Object> variables) {
Exception exception = payload.getException();
DatalakeStatusEnum failedStatus = DatalakeStatusEnum.DATALAKE_UPGRADE_CCM_FAILED;
LOGGER.info("Update SDX status to {} for resource: {}", failedStatus, payload.getResourceId(), exception);
String statusReason = "Cluster Connectivity Manager upgrade failed";
if (exception.getMessage() != null) {
statusReason = exception.getMessage();
}
SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(failedStatus, statusReason, payload.getResourceId());
metricService.incrementMetricCounter(MetricType.UPGRADE_CCM_FAILED, sdxCluster);
sendEvent(context, UPGRADE_CCM_FAILED_HANDLED_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.datalake.flow.upgrade.ccm.event.UpgradeCcmFailedEvent 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