use of com.sequenceiq.cloudbreak.api.model.UpdateStackJson in project cloudbreak by hortonworks.
the class UpdateStackRequestValidatorTest method testIsValidShouldReturnFalseWhenRequestContainsNodeCountAndStatus.
@Test
public void testIsValidShouldReturnFalseWhenRequestContainsNodeCountAndStatus() {
UpdateStackJson updateStackJson = new UpdateStackJson();
InstanceGroupAdjustmentJson instanceGroupAdjustmentJson = new InstanceGroupAdjustmentJson();
instanceGroupAdjustmentJson.setScalingAdjustment(4);
instanceGroupAdjustmentJson.setInstanceGroup("slave_1");
updateStackJson.setStatus(StatusRequest.STARTED);
updateStackJson.setInstanceGroupAdjustment(instanceGroupAdjustmentJson);
boolean valid = underTest.isValid(updateStackJson, constraintValidatorContext);
assertFalse(valid);
}
use of com.sequenceiq.cloudbreak.api.model.UpdateStackJson in project cloudbreak by hortonworks.
the class StackV2Controller method putStop.
@Override
public Response putStop(String name) {
IdentityUser user = authenticatedUserService.getCbUser();
Stack stack = stackService.getPublicStack(name, user);
if (!cloudParameterCache.isStartStopSupported(stack.cloudPlatform())) {
throw new BadRequestException(String.format("Stop is not supported on %s cloudplatform", stack.cloudPlatform()));
}
UpdateStackJson updateStackJson = new UpdateStackJson();
updateStackJson.setStatus(StatusRequest.STOPPED);
updateStackJson.setWithClusterEvent(true);
return stackCommonService.put(stack.getId(), updateStackJson);
}
use of com.sequenceiq.cloudbreak.api.model.UpdateStackJson in project cloudbreak by hortonworks.
the class StackV2Controller method putRepair.
@Override
public Response putRepair(String name) {
IdentityUser user = authenticatedUserService.getCbUser();
Stack stack = stackService.getPublicStack(name, user);
UpdateStackJson updateStackJson = new UpdateStackJson();
updateStackJson.setStatus(StatusRequest.REPAIR_FAILED_NODES);
updateStackJson.setWithClusterEvent(true);
return stackCommonService.put(stack.getId(), updateStackJson);
}
use of com.sequenceiq.cloudbreak.api.model.UpdateStackJson 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.UpdateStackJson in project cloudbreak by hortonworks.
the class UpdateStackRequestV2ToUpdateStackRequestConverter method convert.
@Override
public UpdateStackJson convert(StackScaleRequestV2 source) {
UpdateStackJson updateStackJson = new UpdateStackJson();
updateStackJson.setWithClusterEvent(true);
InstanceGroup instanceGroup = instanceGroupRepository.findOneByGroupNameInStack(source.getStackId(), source.getGroup());
if (instanceGroup != null) {
InstanceGroupAdjustmentJson instanceGroupAdjustmentJson = new InstanceGroupAdjustmentJson();
instanceGroupAdjustmentJson.setInstanceGroup(source.getGroup());
int scaleNumber = source.getDesiredCount() - instanceGroup.getNodeCount();
instanceGroupAdjustmentJson.setScalingAdjustment(scaleNumber);
updateStackJson.setInstanceGroupAdjustment(instanceGroupAdjustmentJson);
} else {
throw new BadRequestException(String.format("Group '%s' not available on stack", source.getGroup()));
}
return updateStackJson;
}
Aggregations