use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class SaltUpdateService method clusterInstallationFinished.
public void clusterInstallationFinished(StackView stackView) {
try {
transactionService.required(() -> {
stackUpdater.updateStackStatus(stackView.getId(), DetailedStackStatus.AVAILABLE, "Salt update finished.");
flowMessageService.fireEventAndLog(stackView.getId(), AVAILABLE.name(), CLUSTER_SALT_UPDATE_FINISHED);
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class StackDownscaleService method finishStackDownscale.
public void finishStackDownscale(StackScalingFlowContext context, Collection<Long> privateIds) throws TransactionExecutionException {
Stack stack = context.getStack();
stackScalingService.updateInstancesToTerminated(privateIds, stack.getId());
List<InstanceMetaData> instanceMetaDatas = stack.getInstanceGroups().stream().flatMap(instanceGroup -> instanceGroup.getInstanceMetaDataSet().stream()).filter(im -> privateIds.contains(im.getPrivateId())).collect(toList());
if (context.isRepair()) {
fillDiscoveryFQDNForRepair(stack, instanceMetaDatas);
}
cleanupDnsRecords(stack, instanceMetaDatas);
List<String> deletedInstanceIds = instanceMetaDatas.stream().map(instanceMetaData -> instanceMetaData.getInstanceId() != null ? instanceMetaData.getInstanceId() : instanceMetaData.getPrivateId().toString()).collect(Collectors.toList());
stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.DOWNSCALE_COMPLETED, String.format("Downscale of the cluster infrastructure finished successfully. Terminated node(s): %s", deletedInstanceIds));
flowMessageService.fireEventAndLog(stack.getId(), AVAILABLE.name(), STACK_DOWNSCALE_SUCCESS, String.join(",", deletedInstanceIds));
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class ClusterCommonService method put.
public FlowIdentifier put(String crn, UpdateClusterV4Request updateJson) {
Stack stack = stackService.getByCrnWithLists(crn);
Long stackId = stack.getId();
MDCBuilder.buildMdcContext(stack);
UserNamePasswordV4Request userNamePasswordJson = updateJson.getUserNamePassword();
FlowIdentifier flowIdentifier;
if (userNamePasswordJson != null) {
flowIdentifier = clusterManagerUserNamePasswordChange(stack, userNamePasswordJson);
} else if (updateJson.getStatus() != null) {
LOGGER.debug("Cluster status update request received. Stack id: {}, status: {} ", stackId, updateJson.getStatus());
flowIdentifier = clusterOperationService.updateStatus(stackId, updateJson.getStatus());
} else if (updateJson.getBlueprintName() != null && updateJson.getHostgroups() != null && stack.getCluster().isCreateFailed()) {
LOGGER.debug("Cluster rebuild request received. Stack id: {}", stackId);
try {
flowIdentifier = recreateCluster(stack, updateJson);
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
} else if (updateJson.getHostGroupAdjustment() != null) {
environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.upscalable());
flowIdentifier = clusterHostgroupAdjustmentChange(stackId, updateJson, stack);
} else {
LOGGER.info("Invalid cluster update request received. Stack id: {}", stackId);
throw new BadRequestException("Invalid update cluster request!");
}
return flowIdentifier;
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class ClusterOperationService method handleChangedHosts.
private void handleChangedHosts(Cluster cluster, Set<String> newHealthyNodes, Map<String, List<String>> autoRecoveryNodesMap, Map<String, InstanceMetaData> autoRecoveryHostMetadata, Map<InstanceMetaData, Optional<String>> failedHostMetadata) {
try {
updateAutoRecoverableNodes(cluster, autoRecoveryNodesMap, autoRecoveryHostMetadata);
updateFailedNodes(cluster, failedHostMetadata);
updateNewHealthyNodes(cluster, newHealthyNodes);
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException in project cloudbreak by hortonworks.
the class ClusterOperationService method updateAutoRecoverableNodes.
private void updateAutoRecoverableNodes(Cluster cluster, Map<String, List<String>> autoRecoveryNodesMap, Map<String, InstanceMetaData> autoRecoveryHostMetadata) throws TransactionExecutionException {
if (!autoRecoveryNodesMap.isEmpty()) {
flowManager.triggerClusterRepairFlow(cluster.getStack().getId(), autoRecoveryNodesMap, false);
Map<String, Optional<String>> hostNamesWithReason = autoRecoveryHostMetadata.keySet().stream().collect(Collectors.toMap(host -> host, host -> Optional.empty()));
Set<InstanceStatus> expectedStates = Set.of(SERVICES_HEALTHY);
InstanceStatus newState = InstanceStatus.WAITING_FOR_REPAIR;
ResourceEvent clusterEvent = CLUSTER_AUTORECOVERY_REQUESTED_CLUSTER_EVENT;
ResourceEvent hostEvent = CLUSTER_AUTORECOVERY_REQUESTED_HOST_EVENT;
updateChangedHosts(cluster, hostNamesWithReason, expectedStates, newState, clusterEvent, Optional.of(hostEvent));
}
}
Aggregations