use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class CmDiagnosticsCollectionActions method failedAction.
@Bean(name = "CM_DIAGNOSTICS_COLLECTION_FAILED_STATE")
public Action<?, ?> failedAction() {
return new CmDiagnosticsCollectionActions.AbstractCmDiagnosticsCollectionActions<>(CmDiagnosticsCollectionFailureEvent.class) {
@Override
protected void doExecute(CommonContext context, CmDiagnosticsCollectionFailureEvent payload, Map<Object, Object> variables) {
Long resourceId = payload.getResourceId();
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into CM_DIAGNOSTICS_COLLECTION_FAILED_STATE. resourceCrn: '{}'", resourceCrn);
cloudbreakEventService.fireCloudbreakEvent(resourceId, UPDATE_FAILED.name(), ResourceEvent.STACK_CM_DIAGNOSTICS_COLLECTION_FAILED, List.of(payload.getException().getMessage()));
InMemoryStateStore.deleteStack(resourceId);
CmDiagnosticsCollectionEvent event = CmDiagnosticsCollectionEvent.builder().withResourceId(resourceId).withResourceCrn(payload.getResourceCrn()).withSelector(CmDiagnosticsCollectionStateSelectors.HANDLED_FAILED_CM_DIAGNOSTICS_COLLECTION_EVENT.selector()).withParameters(payload.getParameters()).build();
sendEvent(context, event);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class CmDiagnosticsCollectionActions method diagnosticsCleanupAction.
@Bean(name = "CM_DIAGNOSTICS_CLEANUP_STATE")
public Action<?, ?> diagnosticsCleanupAction() {
return new CmDiagnosticsCollectionActions.AbstractCmDiagnosticsCollectionActions<>(CmDiagnosticsCollectionEvent.class) {
@Override
protected void doExecute(CommonContext context, CmDiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
Long resourceId = payload.getResourceId();
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into CM_DIAGNOSTICS_CLEANUP_STATE. resourceCrn: '{}'", resourceCrn);
cloudbreakEventService.fireCloudbreakEvent(resourceId, UPDATE_IN_PROGRESS.name(), ResourceEvent.STACK_CM_DIAGNOSTICS_CLEANUP_RUNNING);
CmDiagnosticsCollectionEvent event = CmDiagnosticsCollectionEvent.builder().withResourceId(resourceId).withResourceCrn(payload.getResourceCrn()).withSelector(CmDiagnosticsCollectionHandlerSelectors.CLEANUP_CM_DIAGNOSTICS_EVENT.selector()).withParameters(payload.getParameters()).build();
sendEvent(context, event);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class CmDiagnosticsCollectionActions method diagnosticsInitAction.
@Bean(name = "CM_DIAGNOSTICS_INIT_STATE")
public Action<?, ?> diagnosticsInitAction() {
return new CmDiagnosticsCollectionActions.AbstractCmDiagnosticsCollectionActions<>(CmDiagnosticsCollectionEvent.class) {
@Override
protected void doExecute(CommonContext context, CmDiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
Long resourceId = payload.getResourceId();
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into CM_DIAGNOSTICS_INIT_STATE. resourceCrn: '{}'", resourceCrn);
InMemoryStateStore.putStack(resourceId, PollGroup.POLLABLE);
cloudbreakEventService.fireCloudbreakEvent(resourceId, UPDATE_IN_PROGRESS.name(), ResourceEvent.STACK_CM_DIAGNOSTICS_INIT_RUNNING);
CmDiagnosticsCollectionEvent event = CmDiagnosticsCollectionEvent.builder().withResourceId(resourceId).withResourceCrn(resourceCrn).withSelector(CmDiagnosticsCollectionHandlerSelectors.INIT_CM_DIAGNOSTICS_EVENT.selector()).withParameters(payload.getParameters()).build();
sendEvent(context, event);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class CmDiagnosticsCollectionActions method diagnosticsCollectionAction.
@Bean(name = "CM_DIAGNOSTICS_COLLECTION_STATE")
public Action<?, ?> diagnosticsCollectionAction() {
return new CmDiagnosticsCollectionActions.AbstractCmDiagnosticsCollectionActions<>(CmDiagnosticsCollectionEvent.class) {
@Override
protected void doExecute(CommonContext context, CmDiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
Long resourceId = payload.getResourceId();
String resourceCrn = payload.getResourceCrn();
LOGGER.debug("Flow entered into CM_DIAGNOSTICS_COLLECTION_STATE. resourceCrn: '{}'", resourceCrn);
cloudbreakEventService.fireCloudbreakEvent(resourceId, UPDATE_IN_PROGRESS.name(), ResourceEvent.STACK_CM_DIAGNOSTICS_COLLECTION_RUNNING, List.of(payload.getParameters().getDestination().toString()));
CmDiagnosticsCollectionEvent event = CmDiagnosticsCollectionEvent.builder().withResourceId(resourceId).withResourceCrn(payload.getResourceCrn()).withSelector(CmDiagnosticsCollectionHandlerSelectors.COLLECT_CM_DIAGNOSTICS_EVENT.selector()).withParameters(payload.getParameters()).build();
sendEvent(context, event);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvStopActions method finishedAction.
@Bean(name = "ENV_STOP_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractEnvStopAction<>(ResourceCrnPayload.class) {
@Override
protected void doExecute(CommonContext context, ResourceCrnPayload payload, Map<Object, Object> variables) {
EnvironmentDto environmentDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.ENV_STOPPED, ResourceEvent.ENVIRONMENT_STOPPED, EnvStopState.ENV_STOP_FINISHED_STATE);
metricService.incrementMetricCounter(MetricType.ENV_STOP_FINISHED, environmentDto);
LOGGER.info("Flow entered into ENV_STOP_FINISHED_STATE");
sendEvent(context, FINALIZE_ENV_STOP_EVENT.event(), payload);
}
};
}
Aggregations