use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class AmbariClusterSetupService method waitForServer.
@Override
public void waitForServer(Stack stack) throws CloudbreakException {
AmbariClient defaultClient = clientFactory.getDefaultAmbariClient(stack);
AmbariClient client = clientFactory.getAmbariClient(stack, stack.getCluster());
PollingResult pollingResult = ambariPollingServiceProvider.ambariStartupPollerObjectPollingService(stack, defaultClient, client);
if (isSuccess(pollingResult)) {
LOGGER.info("Ambari has successfully started! Polling result: {}", pollingResult);
} else if (isExited(pollingResult)) {
throw new CancellationException("Polling of Ambari server start has been cancelled.");
} else {
LOGGER.info("Could not start Ambari. polling result: {}", pollingResult);
throw new CloudbreakException(String.format("Could not start Ambari. polling result: '%s'", pollingResult));
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class RecipeEngine method addFsRecipes.
private void addFsRecipes(Stack stack, Iterable<HostGroup> hostGroups) throws CloudbreakException {
String orchestrator = stack.getOrchestrator().getType();
if (SALT.equals(orchestrator)) {
Cluster cluster = stack.getCluster();
String blueprintText = cluster.getBlueprint().getBlueprintText();
FileSystem fs = cluster.getFileSystem();
if (fs != null) {
try {
addFsRecipesToHostGroups(stack.getCredential(), hostGroups, blueprintText, fs);
} catch (IOException e) {
throw new CloudbreakException("can not add FS recipes to host groups", e);
}
}
addHDFSRecipe(cluster, blueprintText, hostGroups);
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class ClusterCreationService method startingAmbariServices.
public void startingAmbariServices(StackView stack) throws CloudbreakException {
OrchestratorView orchestrator = stack.getOrchestrator();
OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(orchestrator.getType());
stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.STARTING_AMBARI_SERVICES, "Running cluster services.");
if (orchestratorType.containerOrchestrator()) {
flowMessageService.fireEventAndLog(stack.getId(), Msg.AMBARI_CLUSTER_RUN_CONTAINERS, UPDATE_IN_PROGRESS.name());
} else if (orchestratorType.hostOrchestrator()) {
flowMessageService.fireEventAndLog(stack.getId(), Msg.AMBARI_CLUSTER_RUN_SERVICES, UPDATE_IN_PROGRESS.name());
} else {
LOGGER.info(String.format("Please implement %s orchestrator because it is not on classpath.", orchestrator.getType()));
throw new CloudbreakException(String.format("Please implement %s orchestrator because it is not on classpath.", orchestrator.getType()));
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class ChangePrimaryGatewayService method primaryGatewayChanged.
@Transactional
public void primaryGatewayChanged(long stackId, String newPrimaryGatewayFQDN) throws CloudbreakException {
Set<InstanceMetaData> imds = instanceMetaDataRepository.findNotTerminatedForStack(stackId);
Optional<InstanceMetaData> formerPrimaryGateway = imds.stream().filter(imd -> imd.getInstanceMetadataType() == InstanceMetadataType.GATEWAY_PRIMARY).findFirst();
Optional<InstanceMetaData> newPrimaryGateway = imds.stream().filter(imd -> imd.getDiscoveryFQDN().equals(newPrimaryGatewayFQDN)).findFirst();
if (newPrimaryGateway.isPresent() && formerPrimaryGateway.isPresent()) {
InstanceMetaData fpg = formerPrimaryGateway.get();
fpg.setInstanceMetadataType(InstanceMetadataType.GATEWAY);
instanceMetaDataRepository.save(fpg);
InstanceMetaData npg = newPrimaryGateway.get();
npg.setInstanceMetadataType(InstanceMetadataType.GATEWAY_PRIMARY);
instanceMetaDataRepository.save(npg);
Stack updatedStack = stackService.getByIdWithLists(stackId);
String gatewayIp = gatewayConfigService.getPrimaryGatewayIp(updatedStack);
Cluster cluster = updatedStack.getCluster();
cluster.setAmbariIp(gatewayIp);
clusterRepository.save(cluster);
} else {
throw new CloudbreakException("Primary gateway change was not successful.");
}
}
use of com.sequenceiq.cloudbreak.service.CloudbreakException in project cloudbreak by hortonworks.
the class AmbariClusterResetService method resetCluster.
public void resetCluster(Long stackId) throws CloudbreakOrchestratorException {
Stack stack = stackRepository.findOneWithLists(stackId);
try {
InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gatewayInstance, stack.getCluster().getGateway().getEnableGateway());
OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(stack.getOrchestrator().getType());
if (orchestratorType.hostOrchestrator()) {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
Set<String> gatewayFQDN = Collections.singleton(gatewayInstance.getDiscoveryFQDN());
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId());
hostOrchestrator.resetAmbari(gatewayConfig, gatewayFQDN, stackUtil.collectNodes(stack), exitCriteriaModel);
} else {
throw new UnsupportedOperationException("ambari reset cluster works only with host orchestrator");
}
} catch (CloudbreakException e) {
throw new CloudbreakOrchestratorFailedException(e);
}
}
Aggregations