use of com.sequenceiq.flow.core.FlowParameters 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.flow.core.FlowParameters 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.flow.core.FlowParameters 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.flow.core.FlowParameters 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);
}
};
}
use of com.sequenceiq.flow.core.FlowParameters in project cloudbreak by hortonworks.
the class DatahubRefreshActions method datahubRefreshInProgressAction.
@Bean(name = "DATAHUB_REFRESH_IN_PROGRESS_STATE")
public Action<?, ?> datahubRefreshInProgressAction() {
return new AbstractSdxAction<>(DatahubRefreshStartEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatahubRefreshStartEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, DatahubRefreshStartEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Datahub refresh in progress for: {}", payload.getResourceId());
sendEvent(context, new DatahubRefreshWaitEvent(payload.getResourceId(), payload.getUserId()));
}
@Override
protected Object getFailurePayload(DatahubRefreshStartEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new DatahubRefreshFailedEvent(payload.getResourceId(), payload.getUserId(), ex);
}
};
}
Aggregations