Search in sources :

Example 51 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class ServiceEndpointHealthListenerTask method handleTimeout.

@Override
public void handleTimeout(ServiceEndpointHealthPollerObject clusterProxyHealthPollerObject) {
    String clusterIdentifer = clusterProxyHealthPollerObject.getClusterIdentifier();
    String errorMessage;
    try {
        ClusterProxyRegistrationClient client = clusterProxyHealthPollerObject.getClient();
        errorMessage = client.readConfig(clusterIdentifer).toHumanReadableString();
    } catch (Exception e) {
        errorMessage = String.format("Failed to check cluster proxy endpoint health for %s, error: %s", clusterIdentifer, e.getMessage());
        LOGGER.error(errorMessage);
    }
    throw new CloudbreakServiceException("Operation timed out. Failed to check cluster proxy endpoint health. " + errorMessage);
}
Also used : ClusterProxyRegistrationClient(com.sequenceiq.cloudbreak.clusterproxy.ClusterProxyRegistrationClient) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Example 52 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class ImageCatalogChangeService method changeImageCatalog.

public void changeImageCatalog(String environmentCrn, String accountId, String imageCatalog) {
    try {
        final Stack stack = stackService.getByEnvironmentCrnAndAccountId(environmentCrn, accountId);
        MDCBuilder.buildMdcContext(stack);
        if (flowLogService.isOtherFlowRunning(stack.getId())) {
            throw new CloudbreakServiceException(String.format("Operation is running for stack '%s'. Please try again later.", stack.getName()));
        }
        final ImageSettingsRequest imageRequest = getImageSettingsRequestForNewCatalogWithCurrentImageSettings(imageCatalog, stack.getImage());
        imageService.changeImage(stack, imageRequest);
    } catch (ImageNotFoundException e) {
        LOGGER.info("Could not find current image in new catalog", e);
        throw new CloudbreakServiceException("Could not find current image in new catalog", e);
    }
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 53 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class CloudIdSyncStatusListenerTask method checkStatus.

@Override
public boolean checkStatus(CloudIdSyncPollerObject pollerObject) {
    RangerCloudIdentitySyncStatus syncStatus = sdxEndpoint.getRangerCloudIdentitySyncStatus(pollerObject.getEnvironmentCrn(), pollerObject.getCommandId());
    LOGGER.info("syncStatus = {}", syncStatus);
    switch(syncStatus.getState()) {
        case SUCCESS:
            LOGGER.info("Successfully synced cloud identity, envCrn = {}", pollerObject.getEnvironmentCrn());
            return true;
        case NOT_APPLICABLE:
            LOGGER.info("Cloud identity sync not applicable, envCrn = {}", pollerObject.getEnvironmentCrn());
            return true;
        case FAILED:
            LOGGER.error("Failed to sync cloud identity, envCrn = {}", pollerObject.getEnvironmentCrn());
            throw new CloudbreakServiceException("Failed to sync cloud identity");
        case ACTIVE:
            LOGGER.info("Sync is still in progress");
            return false;
        default:
            LOGGER.error("Encountered unknown cloud identity sync state");
            throw new CloudbreakServiceException("Failed to sync cloud identity");
    }
}
Also used : RangerCloudIdentitySyncStatus(com.sequenceiq.sdx.api.model.RangerCloudIdentitySyncStatus) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Example 54 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class ResourceAttributeUtil method getTypedAttributes.

public Optional<Object> getTypedAttributes(Resource resource) {
    Json attributes = resource.getAttributes();
    Optional<Object> ret = Optional.empty();
    try {
        if (Objects.nonNull(attributes.getValue())) {
            Map<String, Object> map = attributes.get(Map.class);
            String className = map.getOrDefault(CloudResource.ATTRIBUTE_TYPE, VolumeSetAttributes.class.getCanonicalName()).toString();
            LOGGER.debug("Casting resource attributes to class: {}", className);
            ret = Optional.ofNullable(attributes.get(Class.forName(className)));
        }
    } catch (IOException e) {
        throw new CloudbreakServiceException("Failed to parse attributes to type: " + attributes, e);
    } catch (ClassNotFoundException e) {
        LOGGER.debug("Cannot parse class: {}", e.getMessage());
    }
    return ret;
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Json(com.sequenceiq.cloudbreak.common.json.Json) IOException(java.io.IOException)

Example 55 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class StackOperations method changeImageCatalog.

public void changeImageCatalog(@NotNull NameOrCrn nameOrCrn, Long workspaceId, String imageCatalog) {
    LOGGER.info("Updating image catalog of stack '{}' with '{}'", nameOrCrn, imageCatalog);
    Stack stack = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId);
    if (flowLogService.isOtherFlowRunning(stack.getId())) {
        throw new CloudbreakServiceException(String.format("Operation is running for stack '%s'. Please try again later.", stack.getName()));
    }
    stackImageService.changeImageCatalog(stack, imageCatalog);
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

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