use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationService method handleProvisionOperation.
private void handleProvisionOperation(String resourceCrn, OperationView response, boolean detailed) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
EnvironmentDto envDto = environmentService.getByCrnAndAccountId(resourceCrn, accountId);
boolean needsFreeipa = envDto.getFreeIpaCreation().getCreate();
if (needsFreeipa) {
Optional<OperationView> freeIpaFlows = freeIpaService.getFreeIpaOperation(resourceCrn, detailed);
response.setSubOperationConditions(Map.of(OperationResource.FREEIPA, OperationCondition.REQUIRED));
if (freeIpaFlows.isPresent()) {
OperationView freeIpaOpView = freeIpaFlows.get();
if (OperationType.PROVISION.equals(freeIpaOpView.getOperationType())) {
response.setSubOperations(Map.of(OperationResource.FREEIPA, freeIpaOpView));
}
}
} else {
response.setSubOperationConditions(Map.of(OperationResource.FREEIPA, OperationCondition.NONE));
}
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationService method handleProvisionOperation.
private void handleProvisionOperation(String resourceCrn, OperationView sdxOperationView, boolean detailed) {
String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
SdxCluster sdxCluster = sdxService.getByCrn(userCrn, resourceCrn);
boolean createDb = sdxCluster.isCreateDatabase();
Map<OperationResource, OperationView> subOperations = new HashMap<>();
Map<OperationResource, OperationCondition> conditionMap = new HashMap<>();
conditionMap.put(OperationResource.DATALAKE, OperationCondition.REQUIRED);
if (createDb) {
conditionMap.put(OperationResource.REMOTEDB, OperationCondition.REQUIRED);
try {
OperationView rdbOperationView = databaseService.getOperationProgressStatus(sdxCluster.getDatabaseCrn(), detailed);
if (OperationType.PROVISION.equals(rdbOperationView.getOperationType())) {
subOperations.put(OperationResource.REMOTEDB, rdbOperationView);
}
} catch (Exception e) {
LOGGER.warn("Error during fetching provision progress from remote database API. Skip filling remote database response.", e);
}
} else {
conditionMap.put(OperationResource.REMOTEDB, OperationCondition.NONE);
}
sdxOperationView.setSubOperationConditions(conditionMap);
try {
OperationView stackOperationProgressView = operationV4Endpoint.getOperationProgressByResourceCrn(resourceCrn, detailed);
if (OperationType.PROVISION.equals(stackOperationProgressView.getOperationType())) {
subOperations.put(OperationResource.DATALAKE, stackOperationProgressView);
}
} catch (Exception e) {
LOGGER.warn("Error during fetching provision progress from stack API. Skip filling stack progress response.", e);
}
sdxOperationView.setSubOperations(subOperations);
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationService method getOperationProgressByResourceCrn.
public OperationView getOperationProgressByResourceCrn(String resourceCrn, boolean detailed) {
OperationView sdxOperationView = new OperationView();
Optional<OperationFlowsView> operationFlowsViewOpt = flowService.getLastFlowOperationByResourceCrn(resourceCrn);
if (operationFlowsViewOpt.isPresent()) {
OperationFlowsView operationFlowsView = operationFlowsViewOpt.get();
OperationType operationType = operationFlowsView.getOperationType();
sdxOperationView = operationDetailsPopulator.createOperationView(operationFlowsView, OperationResource.DATALAKE);
if (OperationType.PROVISION.equals(operationType)) {
if (detailed) {
handleProvisionOperation(resourceCrn, sdxOperationView, detailed);
} else {
LOGGER.debug("Skipping detailed SDX provision operation response");
}
}
}
return sdxOperationView;
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class SdxPollerProvider method upgradeCcmPoller.
public AttemptResult<Void> upgradeCcmPoller(Long envId, String datalakeCrn) {
if (PollGroup.CANCELLED.equals(EnvironmentInMemoryStateStore.get(envId))) {
String message = "SDX polling cancelled in inmemory store, environment id: " + envId;
LOGGER.info(message);
throw new PollerStoppedException(message);
}
OperationView operation = sdxService.getOperation(datalakeCrn, false);
OperationProgressStatus progressStatus = operation.getProgressStatus();
switch(progressStatus) {
case CANCELLED:
return AttemptResults.breakFor("SDX Upgrade CCM cancelled for datalake CRN " + datalakeCrn);
case FAILED:
return AttemptResults.breakFor("SDX Upgrade CCM failed for environment CRN " + datalakeCrn);
case FINISHED:
return AttemptResults.justFinish();
case RUNNING:
return AttemptResults.justContinue();
default:
return AttemptResults.breakFor("SDX Upgrade CCM is in ambiguous state " + progressStatus + " for environment CRN " + datalakeCrn);
}
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationDetailsPopulator method populateOperationDetails.
private void populateOperationDetails(OperationView source, List<Optional<FlowProgressResponse>> operations, int expectedNumberOfFlows, Integer progressFromHistory) {
int preProgress = 0;
int overallProgress = 0;
boolean foundFlow = false;
boolean expectFlowChainId = operations.size() > 1;
for (Optional<FlowProgressResponse> operationOpt : operations) {
if (operationOpt.isPresent()) {
if (!foundFlow) {
overallProgress += preProgress;
source.setOperationId(operationOpt.get().getFlowId());
}
foundFlow = true;
FlowProgressResponse flowProgress = operationOpt.get();
if (flowProgress.getProgress() != DEFAULT_PROGRESS) {
overallProgress += flowProgress.getProgress();
}
source.getOperations().add(flowProgress);
} else if (expectFlowChainId && !foundFlow) {
preProgress += MAX_PROGRESS;
operationOpt.ifPresent(flowProgressResponse -> source.setOperationId(flowProgressResponse.getFlowChainId()));
}
}
setProgressAndStatus(source, expectedNumberOfFlows, progressFromHistory, overallProgress);
}
Aggregations