Search in sources :

Example 1 with StackPreTerminationSuccess

use of com.sequenceiq.cloudbreak.reactor.api.event.recipe.StackPreTerminationSuccess in project cloudbreak by hortonworks.

the class StackPreTerminationHandler method accept.

@Override
public void accept(Event<StackPreTerminationRequest> requestEvent) {
    StackPreTerminationRequest request = requestEvent.getData();
    Stack stack = stackService.getByIdWithLists(request.getStackId());
    try {
        Cluster cluster = stack.getCluster();
        if (cluster != null) {
            Set<HostGroup> hostGroups = hostGroupService.getByCluster(cluster.getId());
            recipeEngine.executePreTerminationRecipes(stack, hostGroups);
        }
    } catch (Exception ex) {
        LOGGER.error("Pre-termination failed: {}", ex.getMessage(), ex);
    }
    Selectable result = new StackPreTerminationSuccess(stack.getId());
    eventBus.notify(result.selector(), new Event<>(requestEvent.getHeaders(), result));
}
Also used : StackPreTerminationRequest(com.sequenceiq.cloudbreak.reactor.api.event.recipe.StackPreTerminationRequest) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) StackPreTerminationSuccess(com.sequenceiq.cloudbreak.reactor.api.event.recipe.StackPreTerminationSuccess) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

Selectable (com.sequenceiq.cloudbreak.cloud.event.Selectable)1 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)1 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)1 Stack (com.sequenceiq.cloudbreak.domain.Stack)1 StackPreTerminationRequest (com.sequenceiq.cloudbreak.reactor.api.event.recipe.StackPreTerminationRequest)1 StackPreTerminationSuccess (com.sequenceiq.cloudbreak.reactor.api.event.recipe.StackPreTerminationSuccess)1