use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxRecoveryService method recoverCluster.
public void recoverCluster(Long clusterId) {
SdxCluster sdxCluster = sdxService.getById(clusterId);
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.RECOVERY_IN_PROGRESS, DATALAKE_RECOVERY_REQUESTED, "Recovering datalake stack", sdxCluster);
try {
String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
FlowIdentifier flowIdentifier = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.recoverClusterByNameInternal(0L, sdxCluster.getClusterName(), initiatorUserCrn)).getFlowIdentifier();
cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, flowIdentifier);
} catch (WebApplicationException e) {
String exceptionMessage = exceptionMessageExtractor.getErrorMessage(e);
String message = String.format("Stack recovery failed on cluster: [%s]. Message: [%s]", sdxCluster.getClusterName(), exceptionMessage);
throw new CloudbreakApiException(message, e);
}
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxRepairService method startRepairInCb.
protected void startRepairInCb(SdxCluster sdxCluster, SdxRepairSettings repairRequest) {
try {
LOGGER.info("Triggering repair flow for cluster {} with hostgroups {}", sdxCluster.getClusterName(), repairRequest.getHostGroupNames());
String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
FlowIdentifier flowIdentifier = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.repairClusterInternal(0L, sdxCluster.getClusterName(), createRepairRequest(repairRequest), initiatorUserCrn));
cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, flowIdentifier);
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.REPAIR_IN_PROGRESS, "Datalake repair in progress", sdxCluster);
} catch (NotFoundException e) {
LOGGER.info("Can not find stack on cloudbreak side {}", sdxCluster.getClusterName());
} catch (ClientErrorException e) {
String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
LOGGER.info("Can not repair stack {} from cloudbreak: {}", sdxCluster.getStackId(), errorMessage, e);
throw new RuntimeException("Cannot repair cluster, error happened during operation: " + errorMessage);
} catch (WebApplicationException e) {
LOGGER.info("Can not repair stack {} from cloudbreak: {}", sdxCluster.getStackId(), e.getMessage(), e);
throw new RuntimeException("Cannot repair cluster, error happened during the operation: " + e.getMessage());
}
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxService method deleteSdxCluster.
private FlowIdentifier deleteSdxCluster(SdxCluster sdxCluster, boolean forced) {
checkIfSdxIsDeletable(sdxCluster, forced);
MDCBuilder.buildMdcContext(sdxCluster);
sdxClusterRepository.save(sdxCluster);
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.DELETE_REQUESTED, "Datalake deletion requested", sdxCluster);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerSdxDeletion(sdxCluster, forced);
flowCancelService.cancelRunningFlows(sdxCluster.getId());
return flowIdentifier;
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxUpgradeService method changeImage.
public void changeImage(Long id, UpgradeOptionV4Response upgradeOption) {
SdxCluster cluster = sdxService.getById(id);
String targetImageId = upgradeOption.getUpgrade().getImageId();
StackImageChangeV4Request stackImageChangeRequest = new StackImageChangeV4Request();
stackImageChangeRequest.setImageId(targetImageId);
stackImageChangeRequest.setImageCatalogName(upgradeOption.getUpgrade().getImageCatalogName());
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.CHANGE_IMAGE_IN_PROGRESS, "Changing image", cluster);
try {
String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
FlowIdentifier flowIdentifier = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.changeImageInternal(0L, cluster.getClusterName(), stackImageChangeRequest, initiatorUserCrn));
cloudbreakFlowService.saveLastCloudbreakFlowChainId(cluster, flowIdentifier);
} catch (WebApplicationException e) {
String exceptionMessage = exceptionMessageExtractor.getErrorMessage(e);
String message = String.format("Stack change image failed on cluster: [%s]. Message: [%s]", cluster.getClusterName(), exceptionMessage);
throw new CloudbreakApiException(message, e);
}
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxUpgradeService method upgradeRuntime.
public void upgradeRuntime(Long id, String imageId) {
SdxCluster sdxCluster = sdxService.getById(id);
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.DATALAKE_UPGRADE_IN_PROGRESS, "Upgrading datalake stack", sdxCluster);
try {
String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
FlowIdentifier flowIdentifier = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.upgradeClusterByNameInternal(0L, sdxCluster.getClusterName(), imageId, initiatorUserCrn));
cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, flowIdentifier);
} catch (WebApplicationException e) {
String exceptionMessage = exceptionMessageExtractor.getErrorMessage(e);
String message = String.format("Stack upgrade failed on cluster: [%s]. Message: [%s]", sdxCluster.getClusterName(), exceptionMessage);
throw new CloudbreakApiException(message, e);
}
}
Aggregations