use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method startingDownscaleAction.
@Bean(name = "STARTING_DOWNSCALE_STATE")
public Action<?, ?> startingDownscaleAction() {
return new AbstractDownscaleAction<>(DownscaleEvent.class) {
@Override
protected void doExecute(StackContext context, DownscaleEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
List<String> instanceIds = payload.getInstanceIds();
setInstanceIds(variables, instanceIds);
String operationId = payload.getOperationId();
setOperationId(variables, operationId);
List<String> fqdns = getInstanceMetadataFromStack(stack, instanceIds).stream().map(InstanceMetaData::getDiscoveryFQDN).filter(Objects::nonNull).collect(Collectors.toList());
setDownscaleHosts(variables, fqdns);
setRepair(variables, payload.isRepair());
setChainedAction(variables, payload.isChained());
setFinalChain(variables, payload.isFinalChain());
setInstanceCountByGroup(variables, payload.getInstanceCountByGroup());
LOGGER.info("Starting downscale {}", payload);
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Starting downscale");
sendEvent(context, STARTING_DOWNSCALE_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method downscaleFinsihedAction.
@Bean(name = "DOWNSCALE_FINISHED_STATE")
public Action<?, ?> downscaleFinsihedAction() {
return new AbstractDownscaleAction<>(StackEvent.class) {
@Inject
private OperationService operationService;
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getDownscaleCompleteStatus(variables), "Downscale complete");
if (shouldCompleteOperation(variables)) {
SuccessDetails successDetails = new SuccessDetails(stack.getEnvironmentCrn());
successDetails.getAdditionalDetails().put("Hosts", getDownscaleHosts(variables));
operationService.completeOperation(stack.getAccountId(), getOperationId(variables), List.of(successDetails), Collections.emptyList());
}
sendEvent(context, DOWNSCALE_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method downscaleClusterProxyRegistrationAction.
@Bean(name = "DOWNSCALE_CLUSTERPROXY_REGISTRATION_STATE")
public Action<?, ?> downscaleClusterProxyRegistrationAction() {
return new AbstractDownscaleAction<>(StackEvent.class) {
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) throws Exception {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Updating cluster proxy registration.");
List<String> repairInstanceIds = getInstanceIds(variables);
List<String> instanceIdsToRegister = stack.getNotDeletedInstanceMetaDataList().stream().map(InstanceMetaData::getInstanceId).filter(instanceId -> !repairInstanceIds.contains(instanceId)).collect(Collectors.toList());
ClusterProxyUpdateRegistrationRequest request = new ClusterProxyUpdateRegistrationRequest(stack.getId(), instanceIdsToRegister);
sendEvent(context, request.selector(), request);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class StackProvisionActions method stackCreationFailureAction.
@Bean(name = "STACK_CREATION_FAILED_STATE")
public Action<?, ?> stackCreationFailureAction() {
return new AbstractStackFailureAction<StackProvisionState, StackProvisionEvent>() {
@Override
protected StackFailureContext createFlowContext(FlowParameters flowParameters, StateContext<StackProvisionState, StackProvisionEvent> stateContext, StackFailureEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
Stack stack = stackService.getStackById(payload.getResourceId());
MDCBuilder.buildMdcContext(stack);
flow.setFlowFailed(payload.getException());
return new StackFailureContext(flowParameters, stack);
}
@Override
protected void doExecute(StackFailureContext context, StackFailureEvent payload, Map<Object, Object> variables) {
stackProvisionService.handleStackCreationFailure(context.getStack(), payload.getException());
sendEvent(context);
}
@Override
protected Selectable createRequest(StackFailureContext context) {
return new StackEvent(StackProvisionEvent.STACKCREATION_FAILURE_HANDLED_EVENT.event(), context.getStack().getId());
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class StackProvisionActions method getTlsInfoAction.
@Bean(name = "GET_TLS_INFO_STATE")
public Action<?, ?> getTlsInfoAction() {
return new AbstractStackProvisionAction<>(GetTlsInfoResult.class) {
@Override
protected void doExecute(StackContext context, GetTlsInfoResult payload, Map<Object, Object> variables) {
stackProvisionService.saveTlsInfo(context, payload.getTlsInfo());
sendEvent(context, new StackEvent(StackProvisionEvent.SETUP_TLS_EVENT.event(), context.getStack().getId()));
}
};
}
Aggregations