use of com.sequenceiq.datalake.service.AbstractSdxAction in project cloudbreak by hortonworks.
the class DatalakeRestoreActions method restoreFailed.
@Bean(name = "DATALAKE_RESTORE_FAILED_STATE")
public Action<?, ?> restoreFailed() {
return new AbstractSdxAction<>(DatalakeRestoreFailedEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatalakeRestoreFailedEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, DatalakeRestoreFailedEvent payload, Map<Object, Object> variables) {
Exception exception = payload.getException();
LOGGER.error("Datalake database restore could not be started for datalake with id: {}", payload.getResourceId(), exception);
SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.RUNNING, ResourceEvent.DATALAKE_RESTORE_FINISHED, "Datalake is running, Datalake restore failed", payload.getResourceId());
eventSenderService.sendEventAndNotification(sdxCluster, context.getFlowTriggerUserCrn(), ResourceEvent.DATALAKE_RESTORE_FAILED, List.of(exception.getMessage()));
Flow flow = getFlow(context.getFlowParameters().getFlowId());
flow.setFlowFailed(payload.getException());
metricService.incrementMetricCounter(MetricType.SDX_RESTORE_FAILED, sdxCluster);
sendEvent(context, DATALAKE_RESTORE_FAILURE_HANDLED_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(DatalakeRestoreFailedEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return null;
}
};
}
use of com.sequenceiq.datalake.service.AbstractSdxAction in project cloudbreak by hortonworks.
the class DatalakeRestoreActions method datalakeFullResoreInProgress.
@Bean(name = "DATALAKE_FULL_RESTORE_IN_PROGRESS_STATE")
public Action<?, ?> datalakeFullResoreInProgress() {
return new AbstractSdxAction<>(SdxEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxEvent payload, Map<Object, Object> variables) {
LOGGER.info("Full datalake restore is in progress for {} ", payload.getResourceId());
String operationId = (String) variables.get(OPERATION_ID);
String restoreId = (String) variables.get(RESTORE_ID);
SdxCluster sdxCluster = sdxService.getById(payload.getResourceId());
SdxDatabaseRestoreStatusResponse restoreStatusResponse = sdxBackupRestoreService.getDatabaseRestoreStatus(sdxCluster, operationId);
if (restoreStatusResponse.getStatus().equals(DatalakeDatabaseDrStatus.INPROGRESS)) {
sdxBackupRestoreService.updateDatabaseStatusEntry(operationId, SdxOperationStatus.SUCCEEDED, null);
}
sendEvent(context, DatalakeFullRestoreWaitRequest.from(context, restoreId));
}
@Override
protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return DatalakeRestoreFailedEvent.from(flowContext, payload, ex);
}
};
}
use of com.sequenceiq.datalake.service.AbstractSdxAction in project cloudbreak by hortonworks.
the class DatalakeUpgradeActions method imageChangeWait.
@Bean(name = "DATALAKE_IMAGE_CHANGE_IN_PROGRESS_STATE")
public Action<?, ?> imageChangeWait() {
return new AbstractSdxAction<>(DatalakeChangeImageWaitRequest.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatalakeChangeImageWaitRequest payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, DatalakeChangeImageWaitRequest payload, Map<Object, Object> variables) {
LOGGER.info("Datalake upgrade image change is in progress for {} ", payload.getResourceId());
sendEvent(context, new DatalakeChangeImageWaitRequest(context, payload.getUpgradeOption()));
}
@Override
protected Object getFailurePayload(DatalakeChangeImageWaitRequest payload, Optional<SdxContext> flowContext, Exception ex) {
return DatalakeUpgradeFailedEvent.from(payload, ex);
}
};
}
use of com.sequenceiq.datalake.service.AbstractSdxAction 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.service.AbstractSdxAction in project cloudbreak by hortonworks.
the class DatalakeUpgradeActions method replaceVmsWait.
@Bean(name = "DATALAKE_REPLACE_VMS_IN_PROGRESS_STATE")
public Action<?, ?> replaceVmsWait() {
return new AbstractSdxAction<>(SdxEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxEvent payload, Map<Object, Object> variables) {
LOGGER.info("Datalake upgrade vm replacement is in progress for {} ", payload.getResourceId());
sendEvent(context, new DatalakeVmReplaceWaitRequest(context));
}
@Override
protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return DatalakeUpgradeFailedEvent.from(payload, ex);
}
};
}
Aggregations