use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.UpdateClusterV4Request in project cloudbreak by hortonworks.
the class StackCommonService method putScalingInWorkspace.
public FlowIdentifier putScalingInWorkspace(NameOrCrn nameOrCrn, Long workspaceId, StackScaleV4Request stackScaleV4Request) {
User user = userService.getOrCreate(restRequestThreadLocalService.getCloudbreakUser());
Stack stack;
try {
stack = transactionService.required(() -> {
Stack stackInTransaction = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId);
validateNetworkScaleRequest(stackInTransaction, stackScaleV4Request.getStackNetworkScaleV4Request());
return stackInTransaction;
});
} catch (TransactionService.TransactionExecutionException e) {
LOGGER.error("Cannot validate network scaling: {}", e.getMessage(), e);
throw new TransactionService.TransactionRuntimeExecutionException(e);
}
MDCBuilder.buildMdcContext(stack);
stackScaleV4Request.setStackId(stack.getId());
UpdateStackV4Request updateStackJson = stackScaleV4RequestToUpdateStackV4RequestConverter.convert(stackScaleV4Request);
Integer scalingAdjustment = updateStackJson.getInstanceGroupAdjustment().getScalingAdjustment();
validateScalingRequest(stack, scalingAdjustment);
FlowIdentifier flowIdentifier;
if (scalingAdjustment > 0) {
flowIdentifier = put(stack, updateStackJson);
} else {
UpdateClusterV4Request updateClusterJson = stackScaleV4RequestToUpdateClusterV4RequestConverter.convert(stackScaleV4Request);
workspaceService.get(workspaceId, user);
flowIdentifier = clusterCommonService.put(stack.getResourceCrn(), updateClusterJson);
}
return flowIdentifier;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.UpdateClusterV4Request in project cloudbreak by hortonworks.
the class UserNamePasswordV4RequestToUpdateClusterV4RequestConverter method convert.
public UpdateClusterV4Request convert(UserNamePasswordV4Request source) {
UpdateClusterV4Request updateStackJson = new UpdateClusterV4Request();
updateStackJson.setUserNamePassword(source);
return updateStackJson;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.UpdateClusterV4Request in project cloudbreak by hortonworks.
the class ScalingRequest method scaleDown.
private void scaleDown(int scalingAdjustment, int totalNodes) {
metricService.incrementMetricCounter(MetricType.CLUSTER_DOWNSCALE_TRIGGERED);
String hostGroup = policy.getHostGroup();
String statusReason = null;
ScalingStatus scalingStatus = null;
String stackCrn = cluster.getStackCrn();
String userCrn = cluster.getClusterPertain().getUserCrn();
try {
LOGGER.info("Sending request to remove '{}' node(s) from host group '{}', triggered adjustmentType '{}', cluster '{}', user '{}'", scalingAdjustment, hostGroup, policy.getAdjustmentType(), stackCrn, userCrn);
UpdateClusterV4Request updateClusterJson = new UpdateClusterV4Request();
HostGroupAdjustmentV4Request hostGroupAdjustmentJson = new HostGroupAdjustmentV4Request();
hostGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
hostGroupAdjustmentJson.setWithStackUpdate(true);
hostGroupAdjustmentJson.setHostGroup(hostGroup);
hostGroupAdjustmentJson.setValidateNodeCount(false);
updateClusterJson.setHostGroupAdjustment(hostGroupAdjustmentJson);
// TODO CB-14929: CB-15153 List of nodes not provided. Do we really need to support this? Can Periscope always specify the list of nodes?
cloudbreakCrnClient.withInternalCrn().autoscaleEndpoint().putCluster(stackCrn, cluster.getClusterPertain().getUserId(), updateClusterJson);
scalingStatus = ScalingStatus.SUCCESS;
statusReason = getMessageForCBSuccess();
metricService.incrementMetricCounter(MetricType.CLUSTER_DOWNSCALE_SUCCESSFUL);
} catch (Exception e) {
scalingStatus = ScalingStatus.FAILED;
metricService.incrementMetricCounter(MetricType.CLUSTER_DOWNSCALE_FAILED);
statusReason = getMessageForCBException(e);
LOGGER.error("Couldn't trigger downscaling for host group '{}', cluster '{}', desiredNodeCount '{}', error '{}' ", hostGroup, cluster.getStackCrn(), desiredHostGroupNodeCount, statusReason, e);
} finally {
processAutoscalingTriggered(scalingAdjustment, totalNodes, statusReason, scalingStatus);
}
}
Aggregations