use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class StackOperationService method updateStatus.
public FlowIdentifier updateStatus(Long stackId, StatusRequest status, boolean updateCluster) {
Stack stack = stackService.getByIdWithLists(stackId);
Cluster cluster = null;
if (stack.getCluster() != null) {
cluster = clusterService.findOneWithLists(stack.getCluster().getId()).orElse(null);
}
switch(status) {
case SYNC:
return sync(stack, false);
case FULL_SYNC:
return sync(stack, true);
case REPAIR_FAILED_NODES:
return repairFailedNodes(stack);
case STOPPED:
return stop(stack, cluster, updateCluster);
case STARTED:
return start(stack);
default:
throw new BadRequestException("Cannot update the status of stack because status request not valid.");
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class TelemetryService method createTelemetryConfigs.
@Override
public Map<String, SaltPillarProperties> createTelemetryConfigs(Long stackId, Set<TelemetryComponentType> components) {
Stack stack = stackService.getById(stackId);
Cluster cluster = stack.getCluster();
DataBusCredential dataBusCredential = getDatabusCredential(cluster).orElse(null);
Telemetry telemetry = componentConfigProviderService.getTelemetry(stackId);
LOGGER.debug("Generating telemetry configs for stack '{}'", stack.getResourceCrn());
return telemetryDecorator.decoratePillar(new HashMap<>(), stack, telemetry, dataBusCredential);
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ClusterTemplateService method prepareCreation.
@Override
protected void prepareCreation(ClusterTemplate resource) {
measure(() -> validateBeforeCreate(resource), LOGGER, "Cluster definition validated in {}ms");
if (resource.getStatus().isNonDefault()) {
Stack stackTemplate = resource.getStackTemplate();
stackTemplate.setName(UUID.randomUUID().toString());
if (stackTemplate.getOrchestrator() != null) {
orchestratorService.save(stackTemplate.getOrchestrator());
}
Network network = stackTemplate.getNetwork();
if (network != null) {
network.setWorkspace(stackTemplate.getWorkspace());
networkService.pureSave(network);
}
Cluster cluster = stackTemplate.getCluster();
if (cluster != null) {
cluster.setWorkspace(stackTemplate.getWorkspace());
clusterService.saveWithRef(cluster);
}
stackTemplate.setResourceCrn(createCRN(ThreadBasedUserCrnProvider.getAccountId()));
stackTemplate = stackTemplateService.pureSave(stackTemplate);
componentConfigProviderService.store(new ArrayList<>(stackTemplate.getComponents()));
if (cluster != null) {
cluster.setStack(stackTemplate);
clusterService.save(cluster);
}
if (stackTemplate.getInstanceGroups() != null && !stackTemplate.getInstanceGroups().isEmpty()) {
instanceGroupService.saveAll(stackTemplate.getInstanceGroups(), stackTemplate.getWorkspace());
}
}
resource.setCreated(System.currentTimeMillis());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method stopCluster.
@Override
public void stopCluster(boolean disableKnoxAutorestart) throws CloudbreakException {
Cluster cluster = stack.getCluster();
ClustersResourceApi clustersResourceApi = clouderaManagerApiFactory.getClustersResourceApi(apiClient);
try {
LOGGER.debug("Stopping all Cloudera Runtime services");
if (clouderaManagerPollingServiceProvider.checkCmStatus(stack, apiClient).isTimeout()) {
skipStopWithStoppedCm();
} else {
stopWithRunningCm(disableKnoxAutorestart, cluster, clustersResourceApi);
}
} catch (ApiException e) {
LOGGER.info("Couldn't stop Cloudera Manager services", e);
throw new ClouderaManagerOperationFailedException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method doRestartServicesIfNeeded.
private int doRestartServicesIfNeeded(ClustersResourceApi clustersResourceApi, boolean waitForCommandExecutionOnly) throws ApiException, CloudbreakException {
ApiCommandList apiCommandList = clustersResourceApi.listActiveCommands(stack.getName(), SUMMARY);
Optional<ApiCommand> optionalRestartCommand = apiCommandList.getItems().stream().filter(cmd -> "Restart".equals(cmd.getName())).findFirst();
ApiCommand restartCommand = null;
if (optionalRestartCommand.isPresent()) {
restartCommand = optionalRestartCommand.get();
LOGGER.debug("Restart for Cluster services is already running with id: [{}]", restartCommand.getId());
} else if (!waitForCommandExecutionOnly) {
LOGGER.info("Restarting cluster services.");
ApiRestartClusterArgs restartClusterArgs = new ApiRestartClusterArgs();
restartClusterArgs.setRedeployClientConfiguration(true);
restartCommand = clustersResourceApi.restartCommand(stack.getName(), restartClusterArgs);
eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), CLUSTER_CM_CLUSTER_SERVICES_RESTARTING);
}
if (restartCommand != null) {
ExtendedPollingResult pollingResult = clouderaManagerPollingServiceProvider.startPollingCmServicesRestart(stack, apiClient, restartCommand.getId());
handlePollingResult(pollingResult, "Cluster was terminated while restarting services.", "Timeout happened while restarting services.");
}
return getCommandId(restartCommand);
}
Aggregations