use of com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeVmReplaceEvent in project cloudbreak by hortonworks.
the class DatalakeUpgradeActions method replaceVms.
@Bean(name = "DATALAKE_REPLACE_VMS_STATE")
public Action<?, ?> replaceVms() {
return new AbstractSdxAction<>(DatalakeVmReplaceEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatalakeVmReplaceEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, DatalakeVmReplaceEvent payload, Map<Object, Object> variables) {
if ((boolean) variables.get(REPLACE_VMS_AFTER_UPGRADE)) {
LOGGER.info("Start Datalake upgrade vm replacement for {} ", payload.getResourceId());
sdxUpgradeService.upgradeOs(payload.getResourceId());
sendEvent(context, new SdxEvent(DATALAKE_VM_REPLACE_IN_PROGRESS_EVENT.event(), context));
} else {
LOGGER.info("Vm replacement is not required for {} ", payload.getResourceId());
sendEvent(context, DATALAKE_UPGRADE_SUCCESS_EVENT.event(), new DatalakeUpgradeSuccessEvent(payload.getResourceId(), payload.getUserId()));
}
}
@Override
protected Object getFailurePayload(DatalakeVmReplaceEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return DatalakeUpgradeFailedEvent.from(payload, ex);
}
};
}
use of com.sequenceiq.datalake.flow.datalake.upgrade.event.DatalakeVmReplaceEvent in project cloudbreak by hortonworks.
the class DatalakeChangeImageWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<DatalakeChangeImageWaitRequest> event) {
DatalakeChangeImageWaitRequest request = event.getData();
Long sdxId = request.getResourceId();
String userId = request.getUserId();
Selectable response;
try {
LOGGER.info("Start polling change image process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
upgradeService.waitCloudbreakFlow(sdxId, pollingConfig, "Change image");
String imageId = upgradeService.getImageId(sdxId);
String expectedImageId = request.getUpgradeOption().getUpgrade().getImageId();
if (Objects.equals(imageId, expectedImageId)) {
LOGGER.info("Image changed in cloudbreak side for SDX {}, actual image: {}", sdxId, imageId);
response = new DatalakeVmReplaceEvent(sdxId, userId);
} else {
String message = String.format("Image not changed in cloudbreak side, expected image: %s, actual image: %s", expectedImageId, imageId);
LOGGER.info(message);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, new IllegalStateException(message));
}
} catch (UserBreakException userBreakException) {
LOGGER.error("Change image polling exited before timeout. Cause: ", userBreakException);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Change image poller stopped for cluster: {}", sdxId);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, new PollerStoppedException("Change image poller timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Change image polling failed for cluster: {}", sdxId);
response = new DatalakeUpgradeFailedEvent(sdxId, userId, exception);
}
return response;
}
Aggregations