use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request in project cloudbreak by hortonworks.
the class DistroXV1Controller method putScalingByCrn.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.SCALE_DATAHUB)
public void putScalingByCrn(@ValidCrn(resource = CrnResourceDescriptor.DATAHUB) @TenantAwareParam @ResourceCrn String crn, @Valid DistroXScaleV1Request updateRequest) {
StackScaleV4Request stackScaleV4Request = scaleRequestConverter.convert(updateRequest);
stackScaleV4Request.setStackId(stackOperations.getStackByCrn(crn).getId());
stackOperations.putScaling(NameOrCrn.ofCrn(crn), getWorkspaceIdForCurrentUser(), stackScaleV4Request);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request in project cloudbreak by hortonworks.
the class StackCommonServiceTest method testPutScalingInWorkspaceWhenThereIsPreferredAzAndStackProvisionedInMultipleSubnetButScalingIsNotSupportedOnPlatform.
@Test
public void testPutScalingInWorkspaceWhenThereIsPreferredAzAndStackProvisionedInMultipleSubnetButScalingIsNotSupportedOnPlatform() throws TransactionService.TransactionExecutionException {
Stack stack = new Stack();
stack.setCloudPlatform(AwsConstants.AWS_PLATFORM.value());
String variant = AwsConstants.AwsVariant.AWS_NATIVE_VARIANT.name();
stack.setPlatformVariant(variant);
when(transactionService.required(any(Supplier.class))).thenReturn(stack);
NetworkScaleV4Request networkScaleV4Request = new NetworkScaleV4Request();
networkScaleV4Request.setPreferredSubnetIds(List.of(SUBNET_ID));
StackScaleV4Request updateRequest = new StackScaleV4Request();
updateRequest.setStackNetworkScaleV4Request(networkScaleV4Request);
UpdateStackV4Request updateStackV4Request = new UpdateStackV4Request();
InstanceGroupAdjustmentV4Request instanceGroupAdjustment = new InstanceGroupAdjustmentV4Request();
instanceGroupAdjustment.setScalingAdjustment(1);
updateStackV4Request.setInstanceGroupAdjustment(instanceGroupAdjustment);
when(stackScaleV4RequestToUpdateStackV4RequestConverter.convert(any())).thenReturn(updateStackV4Request);
when(cloudParameterCache.isUpScalingSupported(anyString())).thenReturn(Boolean.FALSE);
BadRequestException actual = assertThrows(BadRequestException.class, () -> underTest.putScalingInWorkspace(STACK_NAME, WORKSPACE_ID, updateRequest));
assertEquals(actual.getMessage(), "Upscaling is not supported on AWS cloudplatform");
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request 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;
}
Aggregations