use of com.sequenceiq.flow.core.Flow in project cloudbreak by hortonworks.
the class SdxCreateActions method failedAction.
@Bean(name = "SDX_CREATION_FAILED_STATE")
public Action<?, ?> failedAction() {
return new AbstractSdxAction<>(SdxCreateFailedEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxCreateFailedEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxCreateFailedEvent payload, Map<Object, Object> variables) throws Exception {
Exception exception = payload.getException();
String statusReason = "Datalake creation failed";
String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(exception);
if (StringUtils.hasText(errorMessage)) {
statusReason = statusReason + ". " + errorMessage;
} else if (exception.getMessage() != null) {
statusReason = statusReason + ". " + exception.getMessage();
}
LOGGER.error(statusReason, exception);
try {
SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.PROVISIONING_FAILED, statusReason, payload.getResourceId());
metricService.incrementMetricCounter(MetricType.SDX_CREATION_FAILED, sdxCluster);
eventSenderService.notifyEvent(context, ResourceEvent.SDX_CLUSTER_CREATION_FAILED);
} catch (NotFoundException notFoundException) {
LOGGER.info("Can not set status to SDX_CREATION_FAILED because data lake was not found");
} catch (DatalakeStatusUpdateException datalakeStatusUpdateException) {
LOGGER.info("Status update for data lake failed (possible reason: ongoing parallel deletion flow): {}", exception.getMessage());
}
Flow flow = getFlow(context.getFlowParameters().getFlowId());
flow.setFlowFailed(payload.getException());
sendEvent(context, SDX_CREATE_FAILED_HANDLED_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(SdxCreateFailedEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return null;
}
};
}
use of com.sequenceiq.flow.core.Flow in project cloudbreak by hortonworks.
the class ClusterUpgradeValidationActions method clusterUpgradeValidationFailed.
@Bean(name = "CLUSTER_UPGRADE_VALIDATION_FAILED_STATE")
public Action<?, ?> clusterUpgradeValidationFailed() {
return new AbstractAction<ClusterUpgradeValidationState, ClusterUpgradeValidationStateSelectors, ClusterUpgradeContext, ClusterUpgradeValidationFailureEvent>(ClusterUpgradeValidationFailureEvent.class) {
@Inject
private CloudbreakMessagesService messagesService;
@Inject
private StackUpdater stackUpdater;
@Override
protected ClusterUpgradeContext createFlowContext(FlowParameters flowParameters, StateContext<ClusterUpgradeValidationState, ClusterUpgradeValidationStateSelectors> stateContext, ClusterUpgradeValidationFailureEvent payload) {
StackView stackView = stackService.getViewByIdWithoutAuth(payload.getResourceId());
MDCBuilder.buildMdcContext(stackView);
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return ClusterUpgradeContext.from(flowParameters, payload);
}
@Override
protected void doExecute(ClusterUpgradeContext context, ClusterUpgradeValidationFailureEvent payload, Map<Object, Object> variables) {
String errorMessage = payload.getException().getMessage();
Long resourceId = payload.getResourceId();
LOGGER.debug("Cluster upgrade validation failed with validation error: {}", errorMessage);
ResourceEvent validationFailedResourceEvent = ResourceEvent.CLUSTER_UPGRADE_VALIDATION_FAILED;
cloudbreakEventService.fireCloudbreakEvent(resourceId, UPDATE_FAILED.name(), validationFailedResourceEvent, List.of(errorMessage));
String reason = messagesService.getMessage(validationFailedResourceEvent.getMessage(), List.of(errorMessage));
stackUpdater.updateStackStatus(resourceId, DetailedStackStatus.AVAILABLE, reason);
sendEvent(context, HANDLED_FAILED_CLUSTER_UPGRADE_VALIDATION_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(ClusterUpgradeValidationFailureEvent payload, Optional<ClusterUpgradeContext> flowContext, Exception ex) {
LOGGER.warn("No failure payload in case of CLUSTER_UPGRADE_VALIDATION_FAILED_STATE. This should not happen.", ex);
return null;
}
@Override
protected void initPayloadConverterMap(List<PayloadConverter<ClusterUpgradeValidationFailureEvent>> payloadConverters) {
payloadConverters.add(new ClusterUpgradeUpdateCheckFailedToClusterUpgradeValidationFailureEvent());
}
};
}
use of com.sequenceiq.flow.core.Flow in project cloudbreak by hortonworks.
the class CmSyncActions method cmSyncFailedAction.
@Bean(name = "CM_SYNC_FAILED_STATE")
public Action<?, ?> cmSyncFailedAction() {
return new AbstractStackFailureAction<CmSyncState, CmSyncEvent>() {
@Override
protected void doExecute(StackFailureContext context, StackFailureEvent payload, Map<Object, Object> variables) {
LOGGER.warn("Error during executing syncing Cloudera Manager and parcels versions from CM.", payload.getException());
flowMessageService.fireEventAndLog(context.getStackView().getId(), EVENT_TYPE, ResourceEvent.STACK_SYNC_VERSIONS_FROM_CM_TO_DB_FAILED, payload.getException().getMessage());
Flow flow = getFlow(context.getFlowParameters().getFlowId());
flow.setFlowFailed(payload.getException());
sendEvent(context);
}
@Override
protected Selectable createRequest(StackFailureContext context) {
return new StackEvent(CmSyncEvent.CM_SYNC_FAIL_HANDLED_EVENT.event(), context.getStackView().getId());
}
};
}
use of com.sequenceiq.flow.core.Flow in project cloudbreak by hortonworks.
the class DatabaseRestoreActions method databaseRestoreFailedAction.
@Bean(name = "DATABASE_RESTORE_FAILED_STATE")
public Action<?, ?> databaseRestoreFailedAction() {
return new AbstractBackupRestoreActions<>(DatabaseRestoreFailedEvent.class) {
@Override
protected BackupRestoreContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatabaseRestoreFailedEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return BackupRestoreContext.from(flowParameters, payload, null, null, true);
}
@Override
protected void doExecute(BackupRestoreContext context, DatabaseRestoreFailedEvent payload, Map<Object, Object> variables) {
backupRestoreStatusService.handleDatabaseRestoreFailure(context.getStackId(), payload.getException().getMessage(), payload.getDetailedStatus());
sendEvent(context, DATABASE_RESTORE_FAIL_HANDLED_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.flow.core.Flow in project cloudbreak by hortonworks.
the class DatabaseBackupActions method databaseBackupFailedAction.
@Bean(name = "DATABASE_BACKUP_FAILED_STATE")
public Action<?, ?> databaseBackupFailedAction() {
return new AbstractBackupRestoreActions<>(DatabaseBackupFailedEvent.class) {
@Override
protected BackupRestoreContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatabaseBackupFailedEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return BackupRestoreContext.from(flowParameters, payload, null, null, true);
}
@Override
protected void doExecute(BackupRestoreContext context, DatabaseBackupFailedEvent payload, Map<Object, Object> variables) {
backupRestoreStatusService.handleDatabaseBackupFailure(context.getStackId(), payload.getException().getMessage(), payload.getDetailedStatus());
sendEvent(context, DATABASE_BACKUP_FAIL_HANDLED_EVENT.event(), payload);
}
};
}
Aggregations