Search in sources :

Example 6 with CloudbreakServiceException

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);
    }
}
Also used : ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) ClusterDeletionBasedExitCriteriaModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) GrainProperties(com.sequenceiq.cloudbreak.orchestrator.model.GrainProperties) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) IOException(java.io.IOException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 7 with CloudbreakServiceException

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);
    }
}
Also used : ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) ClusterDeletionBasedExitCriteriaModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 8 with CloudbreakServiceException

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;
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Example 9 with CloudbreakServiceException

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();
}
Also used : AttemptResult(com.dyngr.core.AttemptResult) DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) NotFoundException(javax.ws.rs.NotFoundException)

Example 10 with CloudbreakServiceException

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()));
        }
    };
}
Also used : StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Map(java.util.Map) ImageUpdateEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.ImageUpdateEvent) Bean(org.springframework.context.annotation.Bean)

Aggregations

CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)142 Test (org.junit.jupiter.api.Test)25 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)24 List (java.util.List)20 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)18 IOException (java.io.IOException)18 Map (java.util.Map)18 ApiException (com.cloudera.api.swagger.client.ApiException)17 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)16 Collectors (java.util.stream.Collectors)15 Inject (javax.inject.Inject)15 Logger (org.slf4j.Logger)15 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)14 LoggerFactory (org.slf4j.LoggerFactory)14 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)13 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)12 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)12 ApiHostList (com.cloudera.api.swagger.model.ApiHostList)12 Optional (java.util.Optional)12 Set (java.util.Set)12