use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class CmVersionQueryServiceTest method testWhenServerHasMultiplePackageVersionsThenValidateConsistencyShouldFail.
@Test
void testWhenServerHasMultiplePackageVersionsThenValidateConsistencyShouldFail() {
Map<String, List<PackageInfo>> hostPackageMap = Maps.newHashMap();
hostPackageMap.put(HOST_1, getPackageInfoList(true));
hostPackageMap.put(HOST_2, getPackageInfoList(false));
CloudbreakServiceException exception = assertThrows(CloudbreakServiceException.class, () -> underTest.checkCmPackageInfoConsistency(hostPackageMap));
Assertions.assertEquals("Error during sync! The following package(s) has multiple versions present on the machines. " + "Package: [PackageInfo{name='cloudera-manager-server', version='2', buildNumber='2000'}, " + "PackageInfo{name='cloudera-manager-server', version='1', buildNumber='1000'}]", exception.getMessage());
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class AbstractAction method execute.
@Override
public void execute(StateContext<S, E> context) {
FlowParameters flowParameters = (FlowParameters) context.getMessageHeader(MessageFactory.HEADERS.FLOW_PARAMETERS.name());
ThreadBasedUserCrnProvider.doAs(flowParameters.getFlowTriggerUserCrn(), () -> {
MDCBuilder.addFlowId(flowParameters.getFlowId());
P payload = convertPayload(context.getMessageHeader(MessageFactory.HEADERS.DATA.name()));
C flowContext = null;
try {
Map<Object, Object> variables = context.getExtendedState().getVariables();
prepareExecution(payload, variables);
String flowStateName = String.valueOf(variables.get(FLOW_STATE_NAME));
Span activeSpan = tracer.activeSpan();
String operationName = context.getEvent().name();
SpanContext spanContext = flowParameters.getSpanContext();
if (FlowTracingUtil.isActiveSpanReusable(activeSpan, spanContext, operationName)) {
LOGGER.debug("Reusing existing span. {}", activeSpan.context());
flowContext = createFlowContext(flowParameters, context, payload);
executeAction(context, payload, flowContext, variables, flowStateName);
} else {
Span span = FlowTracingUtil.getSpan(tracer, operationName, spanContext, flowParameters.getFlowId(), null, flowParameters.getFlowTriggerUserCrn());
spanContext = FlowTracingUtil.useOrCreateSpanContext(spanContext, span);
flowParameters.setSpanContext(spanContext);
try (Scope ignored = tracer.activateSpan(span)) {
flowContext = createFlowContext(flowParameters, context, payload);
executeAction(context, payload, flowContext, variables, flowStateName);
} finally {
span.finish();
}
}
} catch (Exception ex) {
LOGGER.error("Error during execution of " + getClass().getName(), ex);
if (failureEvent != null) {
sendEvent(flowParameters, failureEvent.event(), getFailurePayload(payload, Optional.ofNullable(flowContext), ex), Map.of());
} else {
LOGGER.error("Missing error handling for " + getClass().getName());
throw new CloudbreakServiceException("Missing error handling for " + getClass().getName());
}
}
});
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverter method convertTelemetryComponent.
private void convertTelemetryComponent(StackV4Response response, Stack source) {
TelemetryResponse telemetryResponse = null;
try {
Telemetry telemetry = componentConfigProviderService.getTelemetry(source.getId());
telemetryResponse = telemetryConverter.convert(telemetry);
} catch (CloudbreakServiceException exc) {
LOGGER.debug(exc.getMessage());
}
response.setTelemetry(telemetryResponse);
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class StackV4RequestToTemplatePreparationObjectConverter method convert.
public TemplatePreparationObject convert(StackV4Request source) {
try {
CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
User user = userService.getOrCreate(cloudbreakUser);
Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
DetailedEnvironmentResponse environment = environmentClientService.getByCrn(source.getEnvironmentCrn());
Credential credential = getCredential(source, environment);
LdapView ldapConfig = getLdapConfig(source, environment);
BaseFileSystemConfigurationsView fileSystemConfigurationView = getFileSystemConfigurationView(source, credential.getAttributes());
Set<RDSConfig> rdsConfigs = getRdsConfigs(source, workspace);
Blueprint blueprint = getBlueprint(source, workspace);
Set<HostgroupView> hostgroupViews = getHostgroupViews(source);
Gateway gateway = source.getCluster().getGateway() == null ? null : stackV4RequestToGatewayConverter.convert(source);
BlueprintView blueprintView = blueprintViewProvider.getBlueprintView(blueprint);
Optional<String> version = Optional.ofNullable(blueprintView.getVersion());
GeneralClusterConfigs generalClusterConfigs = generalClusterConfigsProvider.generalClusterConfigs(source, cloudbreakUser.getEmail(), blueprintService.getBlueprintVariant(blueprint));
String gatewaySignKey = null;
if (gateway != null) {
gatewaySignKey = gateway.getSignKey();
}
String envCrnForVirtualGroups = getEnvironmentCrnForVirtualGroups(environment);
VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(envCrnForVirtualGroups, ldapConfig != null ? ldapConfig.getAdminGroup() : "");
Builder builder = Builder.builder().withCloudPlatform(source.getCloudPlatform()).withRdsConfigs(rdsConfigs).withHostgroupViews(hostgroupViews).withGateway(gateway, gatewaySignKey, exposedServiceCollector.getAllKnoxExposed(version)).withBlueprintView(blueprintView).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigs).withLdapConfig(ldapConfig).withCustomInputs(source.getInputs()).withKerberosConfig(getKerberosConfig(source, environment)).withStackType(source.getType()).withVirtualGroupView(virtualGroupRequest);
decorateBuilderWithPlacement(source, builder);
decorateBuilderWithAccountMapping(source, environment, credential, builder);
decorateBuilderWithProductDetails(source, builder);
decorateDatalakeView(source, builder);
return builder.build();
} catch (BlueprintProcessingException | IOException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class ClusterService method cleanupCluster.
public void cleanupCluster(final Cluster cluster) {
if (StringUtils.isEmpty(cluster.getClusterManagerIp())) {
LOGGER.debug("Cluster server IP was not set before, cleanup cluster operation can be skipped.");
} else {
Stack stack = cluster.getStack();
if (stack != null) {
try {
Telemetry telemetry = componentConfigProviderService.getTelemetry(stack.getId());
clusterApiConnectors.getConnector(stack).clusterModificationService().cleanupCluster(telemetry);
altusMachineUserService.clearFluentMachineUser(stack, telemetry);
} catch (CloudbreakServiceException se) {
LOGGER.error("Cluster specific cleanup failed during obtaining telemetry component.", se);
} catch (CloudbreakException e) {
LOGGER.error("Cluster specific cleanup failed.", e);
}
}
}
}
Aggregations