use of com.sequenceiq.cloudbreak.event.ResourceEvent in project cloudbreak by hortonworks.
the class StackTerminationService method handleStackTerminationError.
public void handleStackTerminationError(StackView stackView, Exception errorDetails, boolean forced) {
Long stackId = stackView.getId();
String stackUpdateMessage;
ResourceEvent resourceEvent;
DetailedStackStatus status;
if (!forced) {
stackUpdateMessage = "Termination failed: " + errorDetails.getMessage();
status = DetailedStackStatus.DELETE_FAILED;
resourceEvent = STACK_INFRASTRUCTURE_DELETE_FAILED;
stackUpdater.updateStackStatus(stackId, status, stackUpdateMessage);
LOGGER.debug("Error during stack termination flow: ", errorDetails);
} else {
clusterService.updateClusterStatusByStackId(stackId, DetailedStackStatus.CLUSTER_DELETE_COMPLETED);
terminationService.finalizeTermination(stackId, true);
stackUpdateMessage = "Stack was force terminated.";
status = DetailedStackStatus.DELETE_COMPLETED;
resourceEvent = STACK_FORCED_DELETE_COMPLETED;
}
flowMessageService.fireEventAndLog(stackId, status.name(), resourceEvent, stackUpdateMessage);
metricService.incrementMetricCounter(MetricType.STACK_TERMINATION_FAILED, stackView, errorDetails);
}
use of com.sequenceiq.cloudbreak.event.ResourceEvent in project cloudbreak by hortonworks.
the class ClusterOperationService method updateAutoRecoverableNodes.
private void updateAutoRecoverableNodes(Cluster cluster, Map<String, List<String>> autoRecoveryNodesMap, Map<String, InstanceMetaData> autoRecoveryHostMetadata) throws TransactionExecutionException {
if (!autoRecoveryNodesMap.isEmpty()) {
flowManager.triggerClusterRepairFlow(cluster.getStack().getId(), autoRecoveryNodesMap, false);
Map<String, Optional<String>> hostNamesWithReason = autoRecoveryHostMetadata.keySet().stream().collect(Collectors.toMap(host -> host, host -> Optional.empty()));
Set<InstanceStatus> expectedStates = Set.of(SERVICES_HEALTHY);
InstanceStatus newState = InstanceStatus.WAITING_FOR_REPAIR;
ResourceEvent clusterEvent = CLUSTER_AUTORECOVERY_REQUESTED_CLUSTER_EVENT;
ResourceEvent hostEvent = CLUSTER_AUTORECOVERY_REQUESTED_HOST_EVENT;
updateChangedHosts(cluster, hostNamesWithReason, expectedStates, newState, clusterEvent, Optional.of(hostEvent));
}
}
use of com.sequenceiq.cloudbreak.event.ResourceEvent in project cloudbreak by hortonworks.
the class InteractiveCredentialCreationStatusHandler method accept.
@Override
public void accept(Event<InteractiveCredentialCreationStatus> interactiveCredentialCreationStatusEvent) {
InteractiveCredentialCreationStatus interactiveCredentialCreationStatus = interactiveCredentialCreationStatusEvent.getData();
String userCrn = interactiveCredentialCreationStatus.getExtendedCloudCredential().getUserCrn();
ThreadBasedUserCrnProvider.doAs(userCrn, () -> {
String message = interactiveCredentialCreationStatus.getMessage();
InteractiveCredentialNotification notification = new InteractiveCredentialNotification().withEventTimestamp(new Date().getTime()).withUserId(interactiveCredentialCreationStatus.getExtendedCloudCredential().getUserCrn()).withCloud(interactiveCredentialCreationStatus.getExtendedCloudCredential().getCloudPlatform()).withEventMessage(message);
ResourceEvent event;
if (interactiveCredentialCreationStatus.isError()) {
event = CREDENTIAL_AZURE_INTERACTIVE_FAILED;
notification.withEventType(event.name());
LOGGER.info("Interactive credential creation failed status: {}", new Json(notification).getValue());
} else {
event = CREDENTIAL_AZURE_INTERACTIVE_STATUS;
notification.withEventType(event.name());
LOGGER.info("Interactive credential creation success status: {}", new Json(notification).getValue());
}
notificationService.send(event, notification, ThreadBasedUserCrnProvider.getUserCrn());
});
}
use of com.sequenceiq.cloudbreak.event.ResourceEvent in project cloudbreak by hortonworks.
the class EnvStopActions method stopDatalake.
@Bean(name = "STOP_DATALAKE_STATE")
public Action<?, ?> stopDatalake() {
return new AbstractEnvStopAction<>(EnvStopEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvStopEvent payload, Map<Object, Object> variables) {
EnvironmentStatus environmentStatus = EnvironmentStatus.STOP_DATALAKE_STARTED;
ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_STOP_DATALAKE_STARTED;
EnvStopState envStopState = EnvStopState.STOP_DATALAKE_STATE;
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, environmentStatus, resourceEvent, envStopState);
sendEvent(context, EnvStopHandlerSelectors.STOP_DATALAKE_HANDLER_EVENT.selector(), envDto);
}
};
}
use of com.sequenceiq.cloudbreak.event.ResourceEvent in project cloudbreak by hortonworks.
the class EnvStartActions method startFreeipa.
@Bean(name = "START_FREEIPA_STATE")
public Action<?, ?> startFreeipa() {
return new AbstractEnvStartAction<>(EnvStartEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvStartEvent payload, Map<Object, Object> variables) {
EnvironmentStatus environmentStatus = EnvironmentStatus.START_FREEIPA_STARTED;
ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_START_FREEIPA_STARTED;
EnvStartState envStartState = EnvStartState.START_FREEIPA_STATE;
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, environmentStatus, resourceEvent, envStartState);
EnvironmentStartDto environmentStartDto = EnvironmentStartDto.builder().withDataHubStart(payload.getDataHubStartAction()).withEnvironmentDto(envDto).withId(envDto.getId()).build();
sendEvent(context, EnvStartHandlerSelectors.START_FREEIPA_HANDLER_EVENT.selector(), environmentStartDto);
}
};
}
Aggregations