use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request in project cloudbreak by hortonworks.
the class DistroXScaleV1RequestToStackScaleV4RequestConverter method setStackNetworkScaleRequest.
private void setStackNetworkScaleRequest(NetworkScaleV1Request networkScaleV1Request, StackScaleV4Request stackScaleV4Request) {
if (networkScaleV1Request != null) {
NetworkScaleV4Request networkScaleV4Request = new NetworkScaleV4Request();
networkScaleV4Request.setPreferredSubnetIds(networkScaleV1Request.getPreferredSubnetIds());
stackScaleV4Request.setStackNetworkScaleV4Request(networkScaleV4Request);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request in project cloudbreak by hortonworks.
the class DistroXScaleV1RequestToStackScaleV4RequestConverter method convert.
public StackScaleV4Request convert(DistroXScaleV1Request source) {
StackScaleV4Request stackScaleV4Request = new StackScaleV4Request();
stackScaleV4Request.setDesiredCount(source.getDesiredCount());
stackScaleV4Request.setGroup(source.getGroup());
stackScaleV4Request.setAdjustmentType(source.getAdjustmentType());
stackScaleV4Request.setThreshold(source.getThreshold());
setStackNetworkScaleRequest(source.getNetworkScaleRequest(), stackScaleV4Request);
return stackScaleV4Request;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request in project cloudbreak by hortonworks.
the class DistroXV1Controller method putScalingByName.
@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.SCALE_DATAHUB)
public FlowIdentifier putScalingByName(@ResourceName String name, @Valid DistroXScaleV1Request updateRequest) {
StackScaleV4Request stackScaleV4Request = scaleRequestConverter.convert(updateRequest);
stackScaleV4Request.setStackId(stackOperations.getStackByName(name).getId());
return stackOperations.putScaling(NameOrCrn.ofName(name), getWorkspaceIdForCurrentUser(), stackScaleV4Request);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request in project cloudbreak by hortonworks.
the class StackScaleV4RequestToUpdateClusterV4RequestConverter method convert.
public UpdateClusterV4Request convert(StackScaleV4Request source) {
try {
return transactionService.required(() -> {
UpdateClusterV4Request updateStackJson = new UpdateClusterV4Request();
Stack stack = stackService.getByIdWithListsInTransaction(source.getStackId());
stack.getInstanceGroups().stream().filter(instanceGroup -> source.getGroup().equals(instanceGroup.getGroupName())).findFirst().ifPresentOrElse(instanceGroup -> {
String blueprintText = stack.getCluster().getBlueprint().getBlueprintText();
BlueprintTextProcessor blueprintTextProcessor = clusterDefinitionTextProcessorFactory.createBlueprintTextProcessor(blueprintText);
boolean dataNodeComponentInHostGroup = blueprintTextProcessor.isComponentExistsInHostGroup("DATANODE", instanceGroup.getGroupName());
HostGroupAdjustmentV4Request hostGroupAdjustmentJson = new HostGroupAdjustmentV4Request();
hostGroupAdjustmentJson.setWithStackUpdate(true);
hostGroupAdjustmentJson.setValidateNodeCount(dataNodeComponentInHostGroup);
hostGroupAdjustmentJson.setHostGroup(source.getGroup());
hostGroupAdjustmentJson.setForced(source.getForced());
int scaleNumber = source.getDesiredCount() - instanceGroup.getNotTerminatedInstanceMetaDataSet().size();
hostGroupAdjustmentJson.setScalingAdjustment(scaleNumber);
updateStackJson.setHostGroupAdjustment(hostGroupAdjustmentJson);
}, () -> {
throw new BadRequestException(String.format("Group '%s' not available on stack", source.getGroup()));
});
return updateStackJson;
});
} catch (TransactionExecutionException e) {
throw e.getCause();
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackScaleV4Request in project cloudbreak by hortonworks.
the class StackScaleV4RequestToUpdateStackV4RequestConverter method convert.
public UpdateStackV4Request convert(StackScaleV4Request source) {
UpdateStackV4Request updateStackJson = new UpdateStackV4Request();
updateStackJson.setWithClusterEvent(true);
Optional<InstanceGroup> instanceGroup = instanceGroupService.findOneWithInstanceMetadataByGroupNameInStack(source.getStackId(), source.getGroup());
if (instanceGroup.isPresent()) {
InstanceGroupAdjustmentV4Request instanceGroupAdjustmentJson = new InstanceGroupAdjustmentV4Request();
instanceGroupAdjustmentJson.setInstanceGroup(source.getGroup());
int scaleNumber = source.getDesiredCount() - instanceGroup.get().getNodeCount();
instanceGroupAdjustmentJson.setScalingAdjustment(scaleNumber);
instanceGroupAdjustmentJson.setNetworkScaleRequest(source.getStackNetworkScaleV4Request());
instanceGroupAdjustmentJson.setAdjustmentType(source.getAdjustmentType());
instanceGroupAdjustmentJson.setThreshold(source.getThreshold());
updateStackJson.setInstanceGroupAdjustment(instanceGroupAdjustmentJson);
} else {
throw new BadRequestException(String.format("Group '%s' not available on stack", source.getGroup()));
}
return updateStackJson;
}
Aggregations