Search in sources :

Example 71 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class SdxStartService method start.

public void start(Long sdxId) {
    SdxCluster sdxCluster = sdxService.getById(sdxId);
    try {
        LOGGER.info("Triggering start flow for cluster {}", sdxCluster.getClusterName());
        String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
        FlowIdentifier flowIdentifier = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.putStartInternal(0L, sdxCluster.getClusterName(), initiatorUserCrn));
        cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, flowIdentifier);
        sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.START_IN_PROGRESS, "Datalake start in progress", sdxCluster);
    } catch (NotFoundException e) {
        LOGGER.info("Can not find stack on cloudbreak side {}", sdxCluster.getClusterName());
    } catch (WebApplicationException e) {
        String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
        LOGGER.info("Can not start stack {} from cloudbreak: {}", sdxCluster.getStackId(), errorMessage, e);
        throw new RuntimeException("Cannot start cluster, error happened during operation: " + errorMessage);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) NotFoundException(javax.ws.rs.NotFoundException) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 72 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class SdxCcmUpgradeService method triggerCcmUpgradeFlow.

private SdxCcmUpgradeResponse triggerCcmUpgradeFlow(SdxCluster cluster) {
    MDCBuilder.buildMdcContext(cluster);
    FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerCcmUpgradeFlow(cluster);
    return new SdxCcmUpgradeResponse(CcmUpgradeResponseType.TRIGGERED, flowIdentifier, getMessage(DATALAKE_UPGRADE_CCM, null), cluster.getResourceCrn());
}
Also used : SdxCcmUpgradeResponse(com.sequenceiq.sdx.api.model.SdxCcmUpgradeResponse) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 73 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class DiagnosticsService method collectDiagnostics.

public FlowIdentifier collectDiagnostics(DiagnosticsCollectionRequest request) {
    String userId = ThreadBasedUserCrnProvider.getUserCrn();
    SdxCluster cluster = sdxService.getByCrn(userId, request.getStackCrn());
    StackV4Response stackV4Response = sdxService.getDetail(cluster.getClusterName(), new HashSet<>(), cluster.getAccountId());
    diagnosticsCollectionValidator.validate(request, stackV4Response);
    Map<String, Object> properties = diagnosticsParamsConverter.convertFromRequest(request);
    SdxDiagnosticsCollectionEvent event = new SdxDiagnosticsCollectionEvent(cluster.getId(), userId, properties, null);
    FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerDiagnosticsCollection(event, cluster.getClusterName());
    LOGGER.debug("Start diagnostics collection with flow pollable identifier: {}", flowIdentifier.getPollableId());
    return flowIdentifier;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) SdxDiagnosticsCollectionEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxDiagnosticsCollectionEvent)

Example 74 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class DiagnosticsService method collectCmDiagnostics.

public FlowIdentifier collectCmDiagnostics(CmDiagnosticsCollectionRequest request) {
    String userId = ThreadBasedUserCrnProvider.getUserCrn();
    SdxCluster cluster = sdxService.getByCrn(userId, request.getStackCrn());
    StackV4Response stackV4Response = sdxService.getDetail(cluster.getClusterName(), new HashSet<>(), cluster.getAccountId());
    diagnosticsCollectionValidator.validate(request, stackV4Response);
    Map<String, Object> properties = diagnosticsParamsConverter.convertFromCmRequest(request);
    SdxCmDiagnosticsCollectionEvent event = new SdxCmDiagnosticsCollectionEvent(cluster.getId(), userId, properties, null);
    FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerCmDiagnosticsCollection(event, cluster.getClusterName());
    LOGGER.debug("Start CM based diagnostics collection with flow pollable identifier: {}", flowIdentifier.getPollableId());
    return flowIdentifier;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SdxCmDiagnosticsCollectionEvent(com.sequenceiq.datalake.flow.diagnostics.event.SdxCmDiagnosticsCollectionEvent) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 75 with FlowIdentifier

use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.

the class SdxBackupRestoreService method triggerDatalakeDatabaseBackupFlow.

private SdxDatabaseBackupResponse triggerDatalakeDatabaseBackupFlow(SdxCluster cluster, SdxDatabaseBackupRequest backupRequest) {
    String selector = DATALAKE_DATABASE_BACKUP_EVENT.event();
    String userId = ThreadBasedUserCrnProvider.getUserCrn();
    DatalakeDatabaseBackupStartEvent startEvent = new DatalakeDatabaseBackupStartEvent(selector, cluster.getId(), userId, backupRequest);
    FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerDatalakeDatabaseBackupFlow(startEvent, cluster.getClusterName());
    return new SdxDatabaseBackupResponse(startEvent.getDrStatus().getOperationId(), flowIdentifier);
}
Also used : DatalakeDatabaseBackupStartEvent(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeDatabaseBackupStartEvent) SdxDatabaseBackupResponse(com.sequenceiq.sdx.api.model.SdxDatabaseBackupResponse) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Aggregations

FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)150 Test (org.junit.jupiter.api.Test)55 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)37 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)18 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)15 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)14 SdxClusterDetailResponse (com.sequenceiq.sdx.api.model.SdxClusterDetailResponse)14 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 SdxClusterRequest (com.sequenceiq.sdx.api.model.SdxClusterRequest)10 Supplier (java.util.function.Supplier)10 ImageChangeDto (com.sequenceiq.cloudbreak.service.image.ImageChangeDto)9 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)7 StackImageChangeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackImageChangeV4Request)7 ImageInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)7 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)7 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)7 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)7 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)7