use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxBackupRestoreService method triggerDatalakeRestoreFlow.
private SdxRestoreResponse triggerDatalakeRestoreFlow(SdxCluster cluster, String backupId, String backupLocation, String backupLocationOverride) {
String selector = DATALAKE_TRIGGER_RESTORE_EVENT.event();
String userId = ThreadBasedUserCrnProvider.getUserCrn();
DatalakeTriggerRestoreEvent startEvent = new DatalakeTriggerRestoreEvent(selector, cluster.getId(), null, userId, backupId, backupLocation, backupLocationOverride, DatalakeRestoreFailureReason.USER_TRIGGERED);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerDatalakeRestoreFlow(startEvent, cluster.getClusterName());
return new SdxRestoreResponse(startEvent.getDrStatus().getOperationId(), flowIdentifier);
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxBackupRestoreService method triggerDatalakeBackupFlow.
private SdxBackupResponse triggerDatalakeBackupFlow(SdxCluster cluster, String backupLocation, String backupName) {
String selector = DATALAKE_TRIGGER_BACKUP_EVENT.event();
String userId = ThreadBasedUserCrnProvider.getUserCrn();
DatalakeTriggerBackupEvent startEvent = new DatalakeTriggerBackupEvent(selector, cluster.getId(), userId, backupLocation, backupName, DatalakeBackupFailureReason.USER_TRIGGERED);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerDatalakeBackupFlow(startEvent, cluster.getClusterName());
return new SdxBackupResponse(startEvent.getDrStatus().getOperationId(), flowIdentifier);
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxBackupRestoreService method triggerDatalakeDatabaseRestoreFlow.
private SdxDatabaseRestoreResponse triggerDatalakeDatabaseRestoreFlow(SdxCluster cluster, String backupId, String restoreId, String backupLocation) {
String selector = DATALAKE_DATABASE_RESTORE_EVENT.event();
String userId = ThreadBasedUserCrnProvider.getUserCrn();
DatalakeDatabaseRestoreStartEvent startEvent = new DatalakeDatabaseRestoreStartEvent(selector, cluster.getId(), userId, backupId, restoreId, backupLocation);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerDatalakeDatabaseRestoreFlow(startEvent, cluster.getClusterName());
return new SdxDatabaseRestoreResponse(startEvent.getDrStatus().getOperationId(), flowIdentifier);
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxCmSyncService method callCmSync.
public void callCmSync(Long sdxId) {
SdxCluster sdxCluster = sdxService.getById(sdxId);
try {
String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
ClouderaManagerSyncV4Request clouderaManagerSyncV4Request = new ClouderaManagerSyncV4Request().withCandidateImageUuids(Set.of());
LOGGER.debug("Calling core: sync CM and parcel versions from CM server for {}", sdxCluster.getClusterName());
FlowIdentifier flowIdentifier = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.syncCm(0L, sdxCluster.getClusterName(), initiatorUserCrn, clouderaManagerSyncV4Request));
cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, flowIdentifier);
} catch (WebApplicationException e) {
String exceptionMessage = exceptionMessageExtractor.getErrorMessage(e);
String message = String.format("Couldn't call cm sync for cluster: [%s]. Message: [%s]", sdxCluster.getClusterName(), exceptionMessage);
LOGGER.info(message);
throw new CloudbreakApiException(message, e);
}
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class ReactorNotifier method checkFlowStatus.
private FlowIdentifier checkFlowStatus(Event<? extends Acceptable> event, String identifier) {
try {
FlowAcceptResult accepted = (FlowAcceptResult) event.getData().accepted().await(WAIT_FOR_ACCEPT, TimeUnit.SECONDS);
if (accepted == null) {
LOGGER.error("Event not accepted: {}", event);
reactorReporter.logErrorReport();
throw new FlowNotAcceptedException(String.format("Timeout happened when trying to start the flow for stack %s.", identifier));
}
switch(accepted.getResultType()) {
case ALREADY_EXISTING_FLOW:
reactorReporter.logErrorReport();
throw new FlowsAlreadyRunningException(String.format("Request not allowed, cluster '%s' already has a running operation. " + "Running operation(s): [%s]", identifier, flowNameFormatService.formatFlows(accepted.getAlreadyRunningFlows())));
case RUNNING_IN_FLOW:
return new FlowIdentifier(FlowType.FLOW, accepted.getAsFlowId());
case RUNNING_IN_FLOW_CHAIN:
return new FlowIdentifier(FlowType.FLOW_CHAIN, accepted.getAsFlowChainId());
default:
throw new IllegalStateException("Unsupported accept result type: " + accepted.getClass());
}
} catch (InterruptedException e) {
throw new CloudbreakApiException(e.getMessage(), e);
}
}
Aggregations