use of com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent in project cloudbreak by hortonworks.
the class DiagnosticsCollectionHandler method executeOperation.
@Override
public Selectable executeOperation(HandlerEvent<DiagnosticsCollectionEvent> event) throws Exception {
DiagnosticsCollectionEvent data = event.getData();
Long resourceId = data.getResourceId();
String resourceCrn = data.getResourceCrn();
DiagnosticParameters parameters = data.getParameters();
Map<String, Object> parameterMap = parameters.toMap();
LOGGER.debug("Diagnostics collection started. resourceCrn: '{}', parameters: '{}'", resourceCrn, parameterMap);
diagnosticsOperationsService.collect(resourceId, parameters);
return DiagnosticsCollectionEvent.builder().withResourceCrn(resourceCrn).withResourceId(resourceId).withSelector(START_DIAGNOSTICS_UPLOAD_EVENT.selector()).withParameters(parameters).withHosts(data.getHosts()).withHostGroups(data.getHostGroups()).withExcludeHosts(data.getExcludeHosts()).build();
}
use of com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent in project cloudbreak by hortonworks.
the class DiagnosticsService method startCmDiagnostics.
public FlowIdentifier startCmDiagnostics(BaseCmDiagnosticsCollectionRequest request, String stackCrn, String userCrn) {
Stack stack = stackService.getByCrn(stackCrn);
MDCBuilder.buildMdcContext(stack);
LOGGER.debug("Starting CM based diagnostics collection for Stack. Crn: '{}'", stack.getResourceCrn());
Telemetry telemetry = componentConfigProviderService.getTelemetry(stack.getId());
diagnosticsCollectionValidator.validate(request, stack, telemetry);
CmDiagnosticsParameters parameters = cmDiagnosticsDataToParameterConverter.convert(request, telemetry, stack.getName(), stack.getRegion());
CmDiagnosticsCollectionEvent diagnosticsCollectionEvent = CmDiagnosticsCollectionEvent.builder().withAccepted(new Promise<>()).withResourceId(stack.getId()).withResourceCrn(stack.getResourceCrn()).withSelector(CmDiagnosticsCollectionStateSelectors.START_CM_DIAGNOSTICS_INIT_EVENT.selector()).withParameters(parameters).build();
return reactorNotifier.notify(diagnosticsCollectionEvent, getFlowHeaders(userCrn));
}
use of com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent in project cloudbreak by hortonworks.
the class DiagnosticsService method startDiagnosticsCollection.
public FlowIdentifier startDiagnosticsCollection(BaseDiagnosticsCollectionRequest request, String stackCrn, String userCrn, String uuid) {
Stack stack = stackService.getByCrn(stackCrn);
MDCBuilder.buildMdcContext(stack);
LOGGER.debug("Starting diagnostics collection for Stack. Crn: '{}'", stack.getResourceCrn());
Telemetry telemetry = componentConfigProviderService.getTelemetry(stack.getId());
diagnosticsCollectionValidator.validate(request, stack, telemetry);
String clusterVersion = version;
if (stack.getCluster() != null && stack.getCluster().getBlueprint() != null && StringUtils.isNotBlank(stack.getCluster().getBlueprint().getStackVersion())) {
clusterVersion = stack.getCluster().getBlueprint().getStackVersion();
}
String accountId = Crn.fromString(stack.getResourceCrn()).getAccountId();
boolean useDbusCnameEndpoint = entitlementService.useDataBusCNameEndpointEnabled(accountId);
String databusEndpoint = dataBusEndpointProvider.getDataBusEndpoint(telemetry.getDatabusEndpoint(), useDbusCnameEndpoint);
DiagnosticParameters parameters = diagnosticsDataToParameterConverter.convert(request, telemetry, StringUtils.upperCase(stack.getType().getResourceType()), clusterVersion, accountId, stack.getRegion(), databusEndpoint);
// TODO: use DiagnosticParameters builder for UUID + decrease parameters in the converter above
parameters.setUuid(uuid);
DiagnosticsCollectionEvent diagnosticsCollectionEvent = DiagnosticsCollectionEvent.builder().withAccepted(new Promise<>()).withResourceId(stack.getId()).withResourceCrn(stack.getResourceCrn()).withSelector(DiagnosticsCollectionStateSelectors.START_DIAGNOSTICS_SALT_VALIDATION_EVENT.selector()).withParameters(parameters).withHosts(parameters.getHosts()).withHostGroups(parameters.getHostGroups()).withExcludeHosts(parameters.getExcludeHosts()).build();
return reactorNotifier.notify(diagnosticsCollectionEvent, getFlowHeaders(userCrn));
}
Aggregations