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);
}
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);
}
}
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");
}
}
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;
}
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);
}
Aggregations