use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class ClusterDownscaleService method updateMetadata.
public void updateMetadata(Long stackId, Collection<String> hostNames, String hostGroupName) {
StackView stackView = stackService.getByIdView(stackId);
ClusterView clusterView = stackView.getClusterView();
hostNames.forEach(hn -> {
HostGroup hostGroup = hostGroupService.getByClusterIdAndName(clusterView.getId(), hostGroupName);
List<HostMetadata> hostMetaToRemove = hostGroup.getHostMetadata().stream().filter(md -> hostNames.contains(md.getHostName())).collect(Collectors.toList());
hostGroup.getHostMetadata().removeAll(hostMetaToRemove);
hostGroupService.save(hostGroup);
});
LOGGER.info("Start updating metadata");
for (String hostName : hostNames) {
stackService.updateMetaDataStatus(stackView.getId(), hostName, InstanceStatus.DECOMMISSIONED);
}
clusterService.updateClusterStatusByStackId(stackView.getId(), AVAILABLE);
flowMessageService.fireEventAndLog(stackId, Msg.AMBARI_CLUSTER_SCALED_DOWN, AVAILABLE.name());
}
use of com.sequenceiq.cloudbreak.domain.HostGroup 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));
}
use of com.sequenceiq.cloudbreak.domain.HostGroup 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));
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class DecommissionHandler method executePreTerminationRecipes.
private void executePreTerminationRecipes(Stack stack, String hostGroupName, Collection<String> hostNames) {
try {
HostGroup hostGroup = hostGroupService.getByClusterIdAndName(stack.getCluster().getId(), hostGroupName);
recipeEngine.executePreTerminationRecipes(stack, Collections.singleton(hostGroup), hostNames);
} catch (Exception ex) {
LOGGER.error(ex.getLocalizedMessage(), ex);
}
}
Aggregations