Search in sources :

Example 6 with UpdateStackJson

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);
}
Also used : UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) InstanceGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson) Test(org.junit.Test)

Example 7 with UpdateStackJson

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);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 8 with 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);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 9 with 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);
    }
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) Stack(com.sequenceiq.cloudbreak.domain.Stack) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)

Example 10 with UpdateStackJson

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;
}
Also used : UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) InstanceGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Aggregations

UpdateStackJson (com.sequenceiq.cloudbreak.api.model.UpdateStackJson)19 InstanceGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson)8 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)7 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)7 Test (org.testng.annotations.Test)7 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)5 Stack (com.sequenceiq.cloudbreak.domain.Stack)5 Test (org.junit.Test)5 Parameters (org.testng.annotations.Parameters)5 UpdateClusterJson (com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)4 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)2 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)2 AmbariAddressJson (com.sequenceiq.cloudbreak.api.model.AmbariAddressJson)1 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)1 StackResponse (com.sequenceiq.cloudbreak.api.model.StackResponse)1 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)1 ScalingMock (com.sequenceiq.it.cloudbreak.v2.mock.ScalingMock)1 History (com.sequenceiq.periscope.domain.History)1