Search in sources :

Example 31 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.

the class ChangePrimaryGatewayHandler method accept.

@Override
public void accept(Event<ChangePrimaryGatewayRequest> event) {
    ChangePrimaryGatewayRequest request = event.getData();
    Selectable response;
    try {
        response = new ChangePrimaryGatewaySuccess(request.getStackId(), clusterServiceRunner.changePrimaryGateway(request.getStackId()));
    } catch (Exception e) {
        response = new ChangePrimaryGatewayFailed(request.getStackId(), e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : ChangePrimaryGatewayRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayRequest) ChangePrimaryGatewaySuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewaySuccess) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) ChangePrimaryGatewayFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ChangePrimaryGatewayFailed)

Example 32 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.

the class HostMetadataSetupHandler method accept.

@Override
public void accept(Event<HostMetadataSetupRequest> event) {
    StackEvent request = event.getData();
    Selectable response;
    try {
        hostMetadataSetup.setupHostMetadata(request.getStackId());
        response = new HostMetadataSetupSuccess(request.getStackId());
    } catch (Exception e) {
        response = new HostMetadataSetupFailed(request.getStackId(), e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) HostMetadataSetupFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.HostMetadataSetupFailed) HostMetadataSetupSuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.HostMetadataSetupSuccess)

Example 33 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.

the class StartAmbariServicesHandler method accept.

@Override
public void accept(Event<StartAmbariServicesRequest> event) {
    Long stackId = event.getData().getStackId();
    Selectable response;
    try {
        clusterServiceRunner.runAmbariServices(stackId);
        response = new StartAmbariServicesSuccess(stackId);
    } catch (Exception e) {
        response = new StartAmbariServicesFailed(stackId, e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) StartAmbariServicesFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.StartAmbariServicesFailed) StartAmbariServicesSuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.StartAmbariServicesSuccess)

Example 34 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable 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)

Example 35 with Selectable

use of com.sequenceiq.cloudbreak.cloud.event.Selectable in project cloudbreak by hortonworks.

the class UploadRecipesHandler method accept.

@Override
public void accept(Event<UploadRecipesRequest> event) {
    UploadRecipesRequest request = event.getData();
    Selectable result;
    Long stackId = request.getStackId();
    try {
        Stack stack = stackService.getByIdWithLists(stackId);
        Set<HostGroup> hostGroups = hostGroupService.getByCluster(stack.getCluster().getId());
        recipeEngine.uploadRecipes(stack, hostGroups);
        result = new UploadRecipesSuccess(stackId);
    } catch (Exception e) {
        LOGGER.error("Failed to upload recipes", e);
        result = new UploadRecipesFailed(stackId, e);
    }
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : UploadRecipesFailed(com.sequenceiq.cloudbreak.reactor.api.event.recipe.UploadRecipesFailed) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) UploadRecipesSuccess(com.sequenceiq.cloudbreak.reactor.api.event.recipe.UploadRecipesSuccess) UploadRecipesRequest(com.sequenceiq.cloudbreak.reactor.api.event.recipe.UploadRecipesRequest) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

Selectable (com.sequenceiq.cloudbreak.cloud.event.Selectable)35 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)10 Map (java.util.Map)10 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)10 Bean (org.springframework.context.annotation.Bean)9 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)5 Stack (com.sequenceiq.cloudbreak.domain.Stack)5 AbstractClusterAction (com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction)4 ClusterViewContext (com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext)4 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)3 StackScalingFlowContext (com.sequenceiq.cloudbreak.core.flow2.stack.downscale.StackScalingFlowContext)3 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)3 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)3 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)2 ClusterTerminationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.termination.ClusterTerminationEvent)2 ClusterAndStackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent)2 ClusterDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent)2 ClusterScaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterScaleTriggerEvent)2 StackAndClusterUpscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackAndClusterUpscaleTriggerEvent)2