use of com.sequenceiq.cloudbreak.api.model.UpdateClusterJson in project cloudbreak by hortonworks.
the class StackV2Controller method putScaling.
@Override
public Response putScaling(String name, StackScaleRequestV2 updateRequest) {
IdentityUser user = authenticatedUserService.getCbUser();
Stack stack = stackService.getPublicStack(name, user);
if (!cloudParameterCache.isScalingSupported(stack.cloudPlatform())) {
throw new BadRequestException(String.format("Scaling is not supported on %s cloudplatform", stack.cloudPlatform()));
}
updateRequest.setStackId(stack.getId());
UpdateStackJson updateStackJson = conversionService.convert(updateRequest, UpdateStackJson.class);
if (updateStackJson.getInstanceGroupAdjustment().getScalingAdjustment() > 0) {
return stackCommonService.put(stack.getId(), updateStackJson);
} else {
UpdateClusterJson updateClusterJson = conversionService.convert(updateRequest, UpdateClusterJson.class);
return clusterCommonController.put(stack.getId(), updateClusterJson);
}
}
use of com.sequenceiq.cloudbreak.api.model.UpdateClusterJson in project cloudbreak by hortonworks.
the class StackV2Controller method putReinstall.
@Override
public Response putReinstall(String name, ReinstallRequestV2 reinstallRequestV2) {
IdentityUser user = authenticatedUserService.getCbUser();
reinstallRequestV2.setAccount(user.getAccount());
Stack stack = stackService.getPublicStack(name, user);
UpdateClusterJson updateClusterJson = conversionService.convert(reinstallRequestV2, UpdateClusterJson.class);
return clusterCommonController.put(stack.getId(), updateClusterJson);
}
use of com.sequenceiq.cloudbreak.api.model.UpdateClusterJson in project cloudbreak by hortonworks.
the class UpdateAmbariPasswordToUpdateClusterRequestConverter method convert.
@Override
public UpdateClusterJson convert(UserNamePasswordJson source) {
UpdateClusterJson updateStackJson = new UpdateClusterJson();
updateStackJson.setUserNamePasswordJson(source);
return updateStackJson;
}
use of com.sequenceiq.cloudbreak.api.model.UpdateClusterJson in project cloudbreak by hortonworks.
the class ScalingRequest method scaleDown.
private void scaleDown(int scalingAdjustment, int totalNodes) {
String hostGroup = policy.getHostGroup();
String ambari = cluster.getHost();
AmbariAddressJson ambariAddressJson = new AmbariAddressJson();
ambariAddressJson.setAmbariAddress(ambari);
History history = null;
try {
LOGGER.info("Sending request to remove {} node(s) from host group '{}', triggered policy '{}'", scalingAdjustment, hostGroup, policy.getName());
Long stackId = cloudbreakClient.stackV1Endpoint().getStackForAmbari(ambariAddressJson).getId();
UpdateClusterJson updateClusterJson = new UpdateClusterJson();
HostGroupAdjustmentJson hostGroupAdjustmentJson = new HostGroupAdjustmentJson();
hostGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
hostGroupAdjustmentJson.setWithStackUpdate(true);
hostGroupAdjustmentJson.setHostGroup(hostGroup);
updateClusterJson.setHostGroupAdjustment(hostGroupAdjustmentJson);
cloudbreakClient.clusterEndpoint().put(stackId, updateClusterJson);
history = historyService.createEntry(ScalingStatus.SUCCESS, "Downscale successfully triggered", totalNodes, policy);
} catch (Exception e) {
history = historyService.createEntry(ScalingStatus.FAILED, "Couldn't trigger downscaling due to: " + e.getMessage(), totalNodes, policy);
LOGGER.error("Error removing nodes from the cluster", e);
} finally {
if (history != null) {
notificationSender.send(history);
}
}
}
use of com.sequenceiq.cloudbreak.api.model.UpdateClusterJson in project cloudbreak by hortonworks.
the class UpdateAmbariRequestToUpdateClusterRequestConverter method convert.
@Override
public UpdateClusterJson convert(ReinstallRequestV2 source) {
UpdateClusterJson updateStackJson = new UpdateClusterJson();
updateStackJson.setValidateBlueprint(true);
updateStackJson.setKerberosPassword(source.getKerberosPassword());
updateStackJson.setKerberosPrincipal(source.getKerberosPrincipal());
Blueprint blueprint = blueprintRepository.findOneByName(source.getBlueprintName(), source.getAccount());
if (blueprint != null) {
updateStackJson.setBlueprintId(blueprint.getId());
updateStackJson.setAmbariStackDetails(source.getAmbariStackDetails());
Set<HostGroupRequest> hostgroups = new HashSet<>();
for (InstanceGroupV2Request instanceGroupV2Request : source.getInstanceGroups()) {
HostGroupRequest hostGroupRequest = new HostGroupRequest();
hostGroupRequest.setRecoveryMode(instanceGroupV2Request.getRecoveryMode());
hostGroupRequest.setRecipeNames(instanceGroupV2Request.getRecipeNames());
hostGroupRequest.setName(instanceGroupV2Request.getGroup());
ConstraintJson constraintJson = new ConstraintJson();
constraintJson.setHostCount(instanceGroupV2Request.getNodeCount());
constraintJson.setInstanceGroupName(instanceGroupV2Request.getGroup());
hostGroupRequest.setConstraint(constraintJson);
hostgroups.add(hostGroupRequest);
}
updateStackJson.setHostgroups(hostgroups);
} else {
throw new BadRequestException(String.format("Blueprint '%s' not available", source.getBlueprintName()));
}
return updateStackJson;
}
Aggregations