use of com.sequenceiq.freeipa.flow.stack.HealthCheckSuccess in project cloudbreak by hortonworks.
the class ChangePrimaryGatewayActions method healthCheckAction.
@Bean(name = "CHANGE_PRIMARY_GATEWAY_HEALTH_CHECK_STATE")
public Action<?, ?> healthCheckAction() {
return new AbstractChangePrimaryGatewayAction<>(StackEvent.class) {
@Override
protected void doExecute(ChangePrimaryGatewayContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
Selectable request;
if (isFinalChain(variables)) {
stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.REPAIR_IN_PROGRESS, "Checking the health");
request = new HealthCheckRequest(stack.getId(), false);
} else {
LOGGER.debug("Repair in progress, skipping the health check");
request = new HealthCheckSuccess(stack.getId(), null);
}
sendEvent(context, request.selector(), request);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.HealthCheckSuccess in project cloudbreak by hortonworks.
the class RebootActions method rebootFinishedAction.
@Bean(name = "REBOOT_FINISHED_STATE")
public Action<?, ?> rebootFinishedAction() {
return new AbstractRebootAction<>(HealthCheckSuccess.class) {
@Inject
private OperationService operationService;
@Override
protected void doExecute(RebootContext context, HealthCheckSuccess payload, Map<Object, Object> variables) {
addMdcOperationId(variables);
rebootService.finishInstanceReboot(context);
LOGGER.info("Finished rebooting {}.", context.getInstanceIds());
Stack stack = context.getStack();
SuccessDetails successDetails = new SuccessDetails(stack.getEnvironmentCrn());
successDetails.getAdditionalDetails().put("InstanceIds", context.getInstanceIdList());
operationService.completeOperation(stack.getAccountId(), getOperationId(variables), List.of(successDetails), Collections.emptyList());
sendEvent(context);
}
@Override
protected Object getFailurePayload(HealthCheckSuccess payload, Optional<RebootContext> flowContext, Exception ex) {
return new InstanceFailureEvent(payload.getResourceId(), ex, payload.getInstanceIds());
}
@Override
protected Selectable createRequest(RebootContext context) {
return new InstanceEvent(RebootEvent.REBOOT_FINALIZED_EVENT.event(), context.getStack().getId(), context.getInstanceIdList());
}
@Override
protected RebootContext createFlowContext(FlowParameters flowParameters, StateContext<RebootState, RebootEvent> stateContext, HealthCheckSuccess payload) {
Long stackId = payload.getResourceId();
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
MDCBuilder.buildMdcContext(stack);
List<InstanceMetaData> instances = instanceMetaDataService.findNotTerminatedForStack(stackId).stream().filter(instanceMetaData -> payload.getInstanceIds().contains(instanceMetaData.getInstanceId())).collect(Collectors.toList());
return new RebootContext(flowParameters, stack, instances, null, null);
}
};
}
Aggregations