use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method stopTelemetryAction.
@Bean(name = "DOWNSCALE_STOP_TELEMETRY_STATE")
public Action<?, ?> stopTelemetryAction() {
return new AbstractDownscaleAction<>(StackEvent.class) {
@Override
protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Stopping telemetry");
List<String> repairInstanceIds = getInstanceIds(variables);
StopTelemetryRequest stopTelemetryRequest = new StopTelemetryRequest(stack.getId(), repairInstanceIds);
sendEvent(context, stopTelemetryRequest.selector(), stopTelemetryRequest);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method downscaleAddAdditionalHostnamesAction.
@Bean(name = "DOWNSCALE_ADD_ADDITIONAL_HOSTNAMES_STATE")
public Action<?, ?> downscaleAddAdditionalHostnamesAction() {
return new AbstractDownscaleAction<>(CollectAdditionalHostnamesResponse.class) {
@Override
protected void doExecute(StackContext context, CollectAdditionalHostnamesResponse payload, Map<Object, Object> variables) throws Exception {
Stack stack = context.getStack();
Set<String> knownHostnamesFromStack = stack.getNotDeletedInstanceMetaDataList().stream().map(InstanceMetaData::getDiscoveryFQDN).filter(Objects::nonNull).collect(Collectors.toSet());
List<String> currentHostsToRemove = getDownscaleHosts(variables);
Set<String> newHostsToRemove = payload.getHostnames().stream().filter(hostname -> !currentHostsToRemove.contains(hostname)).filter(hostname -> !knownHostnamesFromStack.contains(hostname)).collect(Collectors.toSet());
if (isRepair(variables) && !newHostsToRemove.isEmpty()) {
LOGGER.info("Adding hostnames [{}] to the list of hostnames to remove", newHostsToRemove);
List<String> allHostnamesToRemove = new LinkedList<>(currentHostsToRemove);
allHostnamesToRemove.addAll(newHostsToRemove);
setDownscaleHosts(variables, allHostnamesToRemove);
}
sendEvent(context, DOWNSCALE_ADD_ADDITIONAL_HOSTNAMES_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent in project cloudbreak by hortonworks.
the class ChangePrimaryGatewayActions method clusterProxyRegistrationAction.
@Bean(name = "CHANGE_PRIMARY_GATEWAY_CLUSTERPROXY_REGISTRATION_STATE")
public Action<?, ?> clusterProxyRegistrationAction() {
return new AbstractChangePrimaryGatewayAction<>(StackEvent.class) {
@Override
protected void doExecute(ChangePrimaryGatewayContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.REPAIR_IN_PROGRESS, "Changing the primary gateway cluster proxy registration");
List<String> repairInstanceIds = getInstanceIds(variables);
ClusterProxyUpdateRegistrationRequest request;
if (Objects.nonNull(repairInstanceIds)) {
List<String> instanceIdsToRegister = stack.getNotDeletedInstanceMetaDataList().stream().map(InstanceMetaData::getInstanceId).filter(instanceId -> !repairInstanceIds.contains(instanceId)).collect(Collectors.toList());
LOGGER.debug("When changing the primary gateway cluster proxy in stack {}, [{}] will be reregistered", stack.getId(), instanceIdsToRegister);
request = new ClusterProxyUpdateRegistrationRequest(stack.getId(), instanceIdsToRegister);
} else {
LOGGER.debug("When changing the primary gateway cluster proxy in stack {}, the whole stack will be reregistered", stack.getId());
request = new ClusterProxyUpdateRegistrationRequest(stack.getId());
}
sendEvent(context, request.selector(), request);
}
};
}
use of com.sequenceiq.freeipa.flow.stack.StackEvent 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.StackEvent in project cloudbreak by hortonworks.
the class ChangePrimaryGatewayActions method orchestrationAction.
@Bean(name = "CHANGE_PRIMARY_GATEWAY_METADATA_STATE")
public Action<?, ?> orchestrationAction() {
return new AbstractChangePrimaryGatewayAction<>(ChangePrimaryGatewaySelectionSuccess.class) {
@Inject
private ChangePrimaryGatewayService changePrimaryGatewayService;
@Override
protected void doExecute(ChangePrimaryGatewayContext context, ChangePrimaryGatewaySelectionSuccess payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.REPAIR_IN_PROGRESS, "Changing the primary gateway metadata");
try {
changePrimaryGatewayService.changePrimaryGatewayMetadata(stack, payload.getFormerPrimaryGatewayInstanceId(), payload.getNewPrimaryGatewayInstanceId());
sendEvent(context, CHANGE_PRIMARY_GATEWAY_METADATA_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
} catch (Exception e) {
LOGGER.error("Failed to update the primary gateway metadata", e);
sendEvent(context, CHANGE_PRIMARY_GATEWAY_METADATA_FAILED_EVENT.selector(), new ChangePrimaryGatewayFailureEvent(stack.getId(), "Updating metadata", Set.of(), Map.of(), e));
}
}
};
}
Aggregations