Search in sources :

Example 1 with OrchestratorMetadataFilter

use of com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter in project cloudbreak by hortonworks.

the class CmDiagnosticsFlowService method executeCmDiagnosticOperation.

private void executeCmDiagnosticOperation(Long stackId, String operation, Set<String> excludeHosts, CmDiagnosticsFlowOperation func) throws CloudbreakOrchestratorFailedException {
    LOGGER.debug("CM Diagnostics {} will be called only on the primary gateway address", operation);
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
    String primaryGatewayIp = gatewayConfigService.getPrimaryGatewayIp(stack);
    Set<String> hosts = Set.of(primaryGatewayIp);
    OrchestratorMetadataFilter filter = OrchestratorMetadataFilter.Builder.newBuilder().includeHosts(hosts).exlcudeHosts(excludeHosts).build();
    Set<Node> filteredNodes = filter.apply(stack.getAllNodes());
    ClusterDeletionBasedExitCriteriaModel exitModel = new ClusterDeletionBasedExitCriteriaModel(stackId, stack.getCluster().getId());
    if (filteredNodes.isEmpty()) {
        LOGGER.debug("CM Diagnostics {} has been skipped. (no target minions)", operation);
    } else {
        LOGGER.debug("CM Diagnostics operation '{}' has been started.", operation);
        func.apply(gatewayConfigs, filteredNodes, exitModel);
        LOGGER.debug("CM Diagnostics operation '{}' has been finished.", operation);
    }
}
Also used : OrchestratorMetadataFilter(com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) ClusterDeletionBasedExitCriteriaModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 2 with OrchestratorMetadataFilter

use of com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter in project cloudbreak by hortonworks.

the class DiagnosticsUpgradeTelemetryHandler 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();
    OrchestratorMetadataFilter filter = OrchestratorMetadataFilter.Builder.newBuilder().includeHosts(parameters.getHosts()).includeHostGroups(parameters.getHostGroups()).exlcudeHosts(parameters.getExcludeHosts()).build();
    telemetryUpgradeService.upgradeTelemetryComponent(resourceId, TelemetryComponentType.CDP_TELEMETRY, filter);
    return DiagnosticsCollectionEvent.builder().withResourceCrn(resourceCrn).withResourceId(resourceId).withSelector(START_DIAGNOSTICS_VM_PREFLIGHT_CHECK_EVENT.selector()).withParameters(parameters).withHosts(parameters.getHosts()).withHostGroups(parameters.getHostGroups()).withExcludeHosts(parameters.getExcludeHosts()).build();
}
Also used : OrchestratorMetadataFilter(com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent)

Example 3 with OrchestratorMetadataFilter

use of com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter in project cloudbreak by hortonworks.

the class DiagnosticsUpgradeTelemetryHandler 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 cdp-telemetry upgrade started. resourceCrn: '{}', parameters: '{}'", resourceCrn, parameterMap);
    OrchestratorMetadataFilter filter = OrchestratorMetadataFilter.Builder.newBuilder().exlcudeHosts(parameters.getExcludeHosts()).build();
    telemetryUpgradeService.upgradeTelemetryComponent(resourceId, TelemetryComponentType.CDP_TELEMETRY, filter);
    return DiagnosticsCollectionEvent.builder().withResourceCrn(resourceCrn).withResourceId(resourceId).withSelector(START_DIAGNOSTICS_VM_PREFLIGHT_CHECK_EVENT.selector()).withParameters(parameters).build();
}
Also used : OrchestratorMetadataFilter(com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent)

Example 4 with OrchestratorMetadataFilter

use of com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter in project cloudbreak by hortonworks.

the class DiagnosticsOperationsService method executeDiagnosticsOperation.

private void executeDiagnosticsOperation(Long stackId, DiagnosticParameters parameters, String operationName, DiagnosticsOperationFunction func) throws CloudbreakOrchestratorFailedException {
    OrchestratorMetadata orchestratorMetadata = orchestratorMetadataProvider.getOrchestratorMetadata(stackId);
    OrchestratorMetadataFilter filter = createMetadataFilter(parameters);
    OrchestratorMetadata updatedOrchestratorMetadata = filter.apply(orchestratorMetadata);
    LOGGER.debug("Starting diagnostics {}. stackId: '{}'", operationName, stackId);
    if (CollectionUtils.isEmpty(updatedOrchestratorMetadata.getNodes())) {
        LOGGER.debug("Diagnostics {} has been skipped. (no target minions)", operationName);
    } else {
        func.apply(updatedOrchestratorMetadata, parameters);
    }
}
Also used : OrchestratorMetadataFilter(com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter) OrchestratorMetadata(com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadata)

Example 5 with OrchestratorMetadataFilter

use of com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter in project cloudbreak by hortonworks.

the class DiagnosticsOperationsService method collectUnresponsiveHosts.

private Set<String> collectUnresponsiveHosts(Long stackId, DiagnosticParameters parameters) throws CloudbreakOrchestratorFailedException {
    Set<Node> allUnresponsiveNodes = collectUnresponsiveNodes(stackId);
    OrchestratorMetadataFilter filter = createMetadataFilter(parameters);
    return allUnresponsiveNodes.stream().filter(filter::apply).map(Node::getHostname).collect(Collectors.toSet());
}
Also used : OrchestratorMetadataFilter(com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter) Node(com.sequenceiq.cloudbreak.common.orchestration.Node)

Aggregations

OrchestratorMetadataFilter (com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadataFilter)5 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)2 DiagnosticParameters (com.sequenceiq.common.model.diagnostics.DiagnosticParameters)2 ClusterDeletionBasedExitCriteriaModel (com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel)1 DiagnosticsCollectionEvent (com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 OrchestratorMetadata (com.sequenceiq.cloudbreak.orchestrator.metadata.OrchestratorMetadata)1 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)1 DiagnosticsCollectionEvent (com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent)1