use of com.sequenceiq.flow.core.FlowParameters in project cloudbreak by hortonworks.
the class ExternalDatabaseStartActions method externalDatabaseStartFailureAction.
@Bean(name = "EXTERNAL_DATABASE_START_FAILED_STATE")
public Action<?, ?> externalDatabaseStartFailureAction() {
return new AbstractExternalDatabaseStartAction<>(StartExternalDatabaseFailed.class) {
@Override
protected void doExecute(ExternalDatabaseContext context, StartExternalDatabaseFailed payload, Map<Object, Object> variables) {
stackUpdaterService.updateStatus(context.getStack().getId(), DetailedStackStatus.EXTERNAL_DATABASE_START_FAILED, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_START_FAILED, payload.getException().getMessage());
getMetricService().incrementMetricCounter(MetricType.EXTERNAL_DATABASE_START_FAILED, context.getStack());
sendEvent(context);
}
@Override
protected Selectable createRequest(ExternalDatabaseContext context) {
return new StackEvent(ExternalDatabaseStartEvent.EXTERNAL_DATABASE_START_FAILURE_HANDLED_EVENT.event(), context.getStack().getId());
}
@Override
protected void beforeReturnFlowContext(FlowParameters flowParameters, StateContext<ExternalDatabaseStartState, ExternalDatabaseStartEvent> stateContext, StartExternalDatabaseFailed payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
super.beforeReturnFlowContext(flowParameters, stateContext, payload);
}
};
}
use of com.sequenceiq.flow.core.FlowParameters in project cloudbreak by hortonworks.
the class ExternalDatabaseCreationActions method externalDatabaseCreationFailureAction.
@Bean(name = "EXTERNAL_DATABASE_CREATION_FAILED_STATE")
public Action<?, ?> externalDatabaseCreationFailureAction() {
return new AbstractExternalDatabaseCreationAction<>(CreateExternalDatabaseFailed.class) {
@Override
protected void doExecute(ExternalDatabaseContext context, CreateExternalDatabaseFailed payload, Map<Object, Object> variables) {
stackUpdaterService.updateStatus(context.getStack().getId(), DetailedStackStatus.EXTERNAL_DATABASE_CREATION_FAILED, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_CREATION_FAILED, payload.getException().getMessage());
getMetricService().incrementMetricCounter(MetricType.EXTERNAL_DATABASE_CREATION_FAILED, context.getStack());
sendEvent(context);
}
@Override
protected Selectable createRequest(ExternalDatabaseContext context) {
return new StackEvent(ExternalDatabaseCreationEvent.EXTERNAL_DATABASE_CREATION_FAILURE_HANDLED_EVENT.event(), context.getStack().getId());
}
@Override
protected void beforeReturnFlowContext(FlowParameters flowParameters, StateContext<ExternalDatabaseCreationState, ExternalDatabaseCreationEvent> stateContext, CreateExternalDatabaseFailed payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
super.beforeReturnFlowContext(flowParameters, stateContext, payload);
}
};
}
use of com.sequenceiq.flow.core.FlowParameters in project cloudbreak by hortonworks.
the class CertRenewalActions method startCertRenewAction.
@Bean(name = "START_CERT_RENEWAL_STATE")
public Action<?, ?> startCertRenewAction() {
return new AbstractSdxAction<>(SdxStartCertRenewalEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxStartCertRenewalEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxStartCertRenewalEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Start cert renewal.");
SdxCluster sdxCluster = sdxService.getById(payload.getResourceId());
if (payload.isInternal()) {
certRenewalService.renewInternalCertificate(sdxCluster);
} else {
certRenewalService.renewCertificate(sdxCluster, payload.getUserId());
}
SdxEvent sdxEvent = new SdxEvent(SdxCertRenewalEvent.CERT_RENEWAL_STARTED_EVENT.event(), payload.getResourceId(), payload.getUserId());
sendEvent(context, sdxEvent);
}
@Override
protected Object getFailurePayload(SdxStartCertRenewalEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCertRenewalFailedEvent(payload, ex.getMessage());
}
};
}
use of com.sequenceiq.flow.core.FlowParameters in project cloudbreak by hortonworks.
the class CertRenewalActions method certRenewInProgressAction.
@Bean(name = "CERT_RENEWAL_IN_PROGRESS_STATE")
public Action<?, ?> certRenewInProgressAction() {
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) throws Exception {
LOGGER.info("Cert renewal is in progress. Start waiting to finish.");
sendEvent(context, new SdxCertRenewalWaitEvent(context));
}
@Override
protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCertRenewalFailedEvent(payload, ex.getMessage());
}
};
}
use of com.sequenceiq.flow.core.FlowParameters in project cloudbreak by hortonworks.
the class SdxCmSyncActions method cmSyncFailedAction.
@Bean(name = "SDX_CM_SYNC_FAILED_STATE")
public Action<?, ?> cmSyncFailedAction() {
return new AbstractSdxAction<>(SdxCmSyncFailedEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxCmSyncFailedEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxCmSyncFailedEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Sdx cm sync failure, error: ", payload.getException());
Flow flow = getFlow(context.getFlowParameters().getFlowId());
flow.setFlowFailed(payload.getException());
sendEvent(context, SDX_CM_SYNC_FAILED_HANDLED_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(SdxCmSyncFailedEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCmSyncFailedEvent(payload.getResourceId(), payload.getUserId(), ex);
}
};
}
Aggregations