use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method updateClusterConfigs.
public void updateClusterConfigs(@Nonnull Stack stack, @Nonnull Cluster cluster) {
try {
Set<Node> allNodes = stackUtil.collectNodes(stack);
Set<Node> reachableNodes = stackUtil.collectReachableNodesByInstanceStates(stack);
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
List<GrainProperties> grainsProperties = grainPropertiesService.createGrainProperties(gatewayConfigs, cluster, reachableNodes);
SaltConfig saltConfig = createSaltConfig(stack, cluster, grainsProperties);
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
hostOrchestrator.initSaltConfig(stack, gatewayConfigs, allNodes, saltConfig, exitCriteriaModel);
hostOrchestrator.runService(gatewayConfigs, reachableNodes, saltConfig, exitCriteriaModel);
} catch (CloudbreakOrchestratorException | IOException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method redeployStates.
public void redeployStates(Stack stack, Cluster cluster) {
throwIfNull(stack, () -> new IllegalArgumentException("Stack should not be null"));
throwIfNull(cluster, () -> new IllegalArgumentException("Cluster should not be null"));
try {
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), cluster.getId());
LOGGER.debug("Calling orchestrator to upload states");
hostOrchestrator.uploadStates(gatewayConfigs, exitCriteriaModel);
} catch (CloudbreakOrchestratorCancelledException e) {
LOGGER.debug("Orchestration cancelled during redeploying states", e);
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException e) {
LOGGER.debug("Orchestration exception during redeploying states", e);
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class MaintenanceModeValidationService method fetchStackRepository.
public String fetchStackRepository(Long stackId) {
String stackRepo = clusterService.getStackRepositoryJson(stackId);
if (stackRepo == null) {
LOGGER.debug("Stack repository info cannot be fetched due missing OS type.");
return null;
} else if (stackRepo.isEmpty()) {
throw new CloudbreakServiceException("Stack repository info cannot be validated!");
}
LOGGER.debug(String.format("Stack repo fetched: %s", stackRepo));
return stackRepo;
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class DatabaseObtainerService method obtainAttemptResult.
AttemptResult<Object> obtainAttemptResult(Cluster cluster, DatabaseOperation databaseOperation, String databaseCrn, boolean cancellable) throws JsonProcessingException {
Optional<AttemptResult<Object>> result = Optional.ofNullable(clusterPollingCheckerService.checkClusterCancelledState(cluster, cancellable));
if (result.isEmpty()) {
checkArgument(cluster != null, "Cluster must not be null");
try {
LOGGER.info("Polling redbeams for database status: '{}'", cluster.getName());
DatabaseServerV4Response rdsStatus = redbeamsClient.getByCrn(databaseCrn);
LOGGER.info("Response from redbeams: {}", JsonUtil.writeValueAsString(rdsStatus));
result = Optional.of(databaseCriteriaResolver.resolveResultByCriteria(databaseOperation, rdsStatus, cluster));
} catch (CloudbreakServiceException e) {
if (e.getCause() instanceof NotFoundException) {
LOGGER.info("Not found returned for database crn: {}", databaseCrn);
result = Optional.of(AttemptResults.finishWith(null));
} else {
throw e;
}
} catch (NotFoundException e) {
LOGGER.info("Not found returned for database crn: {}", databaseCrn);
result = Optional.of(AttemptResults.finishWith(null));
}
}
return result.get();
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class StackImageUpdateActions method updateImage.
@Bean(name = "UPDATE_IMAGE_STATE")
public AbstractStackImageUpdateAction<?> updateImage() {
return new AbstractStackImageUpdateAction<>(ImageUpdateEvent.class) {
@Override
protected void doExecute(StackContext context, ImageUpdateEvent payload, Map<Object, Object> variables) {
try {
variables.put(ORIGINAL_IMAGE, getImageService().getImage(context.getStack().getId()));
} catch (CloudbreakImageNotFoundException e) {
LOGGER.debug("Image not found", e);
throw new CloudbreakServiceException(e.getMessage(), e);
}
getStackImageService().storeNewImageComponent(context.getStack(), payload.getImage());
sendEvent(context, new StackEvent(StackImageUpdateEvent.UPDATE_IMAGE_FINESHED_EVENT.event(), context.getStack().getId()));
}
};
}
Aggregations