use of com.sequenceiq.freeipa.flow.stack.HealthCheckRequest 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.HealthCheckRequest in project cloudbreak by hortonworks.
the class RebootActions method rebootWaitUntilAvailableAction.
@Bean(name = "REBOOT_WAIT_UNTIL_AVAILABLE_STATE")
public Action<?, ?> rebootWaitUntilAvailableAction() {
return new AbstractRebootAction<>(RebootInstancesResult.class) {
@Override
protected void doExecute(RebootContext context, RebootInstancesResult payload, Map<Object, Object> variables) {
LOGGER.info("Starting reboot polling FreeIpa until it is available for {}", context.getInstanceIds());
rebootService.waitForAvailableStatus(context);
sendEvent(context);
}
@Override
protected Object getFailurePayload(RebootInstancesResult payload, Optional<RebootContext> flowContext, Exception ex) {
return new InstanceFailureEvent(payload.getResourceId(), ex, payload.getInstanceIds());
}
@Override
protected Selectable createRequest(RebootContext context) {
return new HealthCheckRequest(context.getStack().getId(), true, context.getInstanceIdList());
}
@Override
protected RebootContext createFlowContext(FlowParameters flowParameters, StateContext<RebootState, RebootEvent> stateContext, RebootInstancesResult payload) {
Long stackId = payload.getResourceId();
Stack stack = stackService.getStackById(stackId);
MDCBuilder.buildMdcContext(stack);
List<InstanceMetaData> instances = instanceMetaDataService.findNotTerminatedForStack(stackId).stream().filter(instanceMetaData -> payload.getInstanceIds().contains(instanceMetaData.getInstanceId())).collect(Collectors.toList());
CloudContext cloudContext = getCloudContext(stack);
Credential credential = credentialService.getCredentialByEnvCrn(stack.getEnvironmentCrn());
CloudCredential cloudCredential = credentialConverter.convert(credential);
return new RebootContext(flowParameters, stack, instances, cloudContext, cloudCredential);
}
};
}
Aggregations