Search in sources :

Example 6 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class ClusterSyncHandler method accept.

@Override
public void accept(Event<ClusterSyncRequest> event) {
    ClusterSyncRequest request = event.getData();
    ClusterSyncResult result;
    try {
        Stack stack = stackService.getByIdWithLists(request.getStackId());
        String proxyIp = stackUtil.extractAmbariIp(stack);
        String contextPath = stack.getCluster().getGateway().getPath();
        proxyRegistrator.register(stack.getName(), contextPath, proxyIp);
        Cluster cluster = clusterService.retrieveClusterByStackId(request.getStackId());
        ambariClusterStatusUpdater.updateClusterStatus(stack, cluster);
        result = new ClusterSyncResult(request);
    } catch (Exception e) {
        result = new ClusterSyncResult(e.getMessage(), e, request);
    }
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : ClusterSyncRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.ClusterSyncRequest) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) ClusterSyncResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.ClusterSyncResult) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 7 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class AbstractStackUpscaleAction method createFlowContext.

@Override
protected StackScalingFlowContext createFlowContext(String flowId, StateContext<StackUpscaleState, StackUpscaleEvent> stateContext, P payload) {
    Map<Object, Object> variables = stateContext.getExtendedState().getVariables();
    Stack stack = stackService.getByIdWithLists(payload.getStackId());
    MDCBuilder.buildMdcContext(stack);
    Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
    CloudContext cloudContext = new CloudContext(stack.getId(), stack.getName(), stack.cloudPlatform(), stack.getOwner(), stack.getPlatformVariant(), location);
    CloudCredential cloudCredential = credentialConverter.convert(stack.getCredential());
    CloudStack cloudStack = cloudStackConverter.convert(stack);
    return new StackScalingFlowContext(flowId, stack, cloudContext, cloudCredential, cloudStack, getInstanceGroupName(variables), Collections.emptySet(), getAdjustment(variables), getHostNames(variables));
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) StackScalingFlowContext(com.sequenceiq.cloudbreak.core.flow2.stack.downscale.StackScalingFlowContext) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Stack(com.sequenceiq.cloudbreak.domain.Stack) Location(com.sequenceiq.cloudbreak.cloud.model.Location)

Example 8 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class RegisterProxyHandler method accept.

@Override
public void accept(Event<RegisterProxyRequest> event) {
    Long stackId = event.getData().getStackId();
    Selectable response;
    try {
        Stack stack = stackRepository.findOneWithLists(stackId);
        String proxyIp = stackUtil.extractAmbariIp(stack);
        String contextPath = stack.getCluster().getGateway().getPath();
        proxyRegistrator.register(stack.getName(), contextPath, proxyIp);
        response = new RegisterProxySuccess(stackId);
    } catch (RuntimeException e) {
        response = new RegisterProxyFailed(stackId, e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : RegisterProxySuccess(com.sequenceiq.cloudbreak.reactor.api.event.proxy.RegisterProxySuccess) Selectable(com.sequenceiq.cloudbreak.cloud.event.Selectable) RegisterProxyFailed(com.sequenceiq.cloudbreak.reactor.api.event.proxy.RegisterProxyFailed) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 9 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class DecommissionHandler method accept.

@Override
public void accept(Event<DecommissionRequest> event) {
    DecommissionRequest request = event.getData();
    DecommissionResult result;
    try {
        Stack stack = stackService.getByIdWithLists(request.getStackId());
        Map<String, HostMetadata> hostsToRemove = ambariDecommissioner.collectHostsToRemove(stack, request.getHostGroupName(), request.getHostNames());
        Set<String> hostNames;
        if (!hostsToRemove.isEmpty()) {
            executePreTerminationRecipes(stack, request.getHostGroupName(), hostsToRemove.keySet());
            hostNames = ambariDecommissioner.decommissionAmbariNodes(stack, hostsToRemove);
        } else {
            hostNames = request.getHostNames();
        }
        result = new DecommissionResult(request, hostNames);
    } catch (Exception e) {
        result = new DecommissionResult(e.getMessage(), e, request);
    }
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : DecommissionRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionRequest) DecommissionResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.DecommissionResult) Stack(com.sequenceiq.cloudbreak.domain.Stack) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Example 10 with Stack

use of com.sequenceiq.cloudbreak.domain.Stack in project cloudbreak by hortonworks.

the class UnhealthyInstancesDetectionHandler method accept.

@Override
public void accept(Event<UnhealthyInstancesDetectionRequest> event) {
    UnhealthyInstancesDetectionRequest request = event.getData();
    UnhealthyInstancesDetectionResult result;
    Long stackId = request.getStackId();
    Stack stack = stackService.getById(stackId);
    try {
        Set<InstanceMetaData> candidateUnhealthyInstances = unhealthyInstanceSelector.selectCandidateUnhealthyInstances(stack.getId());
        if (candidateUnhealthyInstances.isEmpty()) {
            result = new UnhealthyInstancesDetectionResult(request, Collections.emptySet());
        } else {
            Set<String> unhealthyInstances = unhealthyInstancesFinalizer.finalizeUnhealthyInstances(stack, candidateUnhealthyInstances);
            result = new UnhealthyInstancesDetectionResult(request, unhealthyInstances);
        }
    } catch (RuntimeException e) {
        String msg = String.format("Could not get statuses for unhealty instances: %s", e.getMessage());
        LOG.error(msg, e);
        result = new UnhealthyInstancesDetectionResult(msg, e, request);
    }
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : UnhealthyInstancesDetectionResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.UnhealthyInstancesDetectionResult) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) UnhealthyInstancesDetectionRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.UnhealthyInstancesDetectionRequest) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.Stack)207 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)74 Test (org.junit.Test)70 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)32 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)30 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)26 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)23 ArrayList (java.util.ArrayList)20 List (java.util.List)20 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)18 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)18 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)18 HashMap (java.util.HashMap)18 HashSet (java.util.HashSet)18 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)17 Map (java.util.Map)17 Matchers.anyString (org.mockito.Matchers.anyString)16 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)15 Set (java.util.Set)15 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)14