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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations