Search in sources :

Example 1 with UpdateStackJson

use of com.sequenceiq.cloudbreak.api.model.UpdateStackJson in project cloudbreak by hortonworks.

the class ScalingRequest method scaleUp.

private void scaleUp(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 add {} instance(s) into host group '{}', triggered policy '{}'", scalingAdjustment, hostGroup, policy.getName());
        Long stackId = cloudbreakClient.stackV1Endpoint().getStackForAmbari(ambariAddressJson).getId();
        UpdateStackJson updateStackJson = new UpdateStackJson();
        updateStackJson.setWithClusterEvent(true);
        InstanceGroupAdjustmentJson instanceGroupAdjustmentJson = new InstanceGroupAdjustmentJson();
        instanceGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
        instanceGroupAdjustmentJson.setInstanceGroup(hostGroup);
        updateStackJson.setInstanceGroupAdjustment(instanceGroupAdjustmentJson);
        cloudbreakClient.stackV1Endpoint().put(stackId, updateStackJson);
        history = historyService.createEntry(ScalingStatus.SUCCESS, "Upscale successfully triggered", totalNodes, policy);
    } catch (RuntimeException e) {
        history = historyService.createEntry(ScalingStatus.FAILED, "Couldn't trigger upscaling due to: " + e.getMessage(), totalNodes, policy);
        LOGGER.error("Error adding nodes to cluster", e);
    } finally {
        if (history != null) {
            notificationSender.send(history);
        }
    }
}
Also used : UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) AmbariAddressJson(com.sequenceiq.cloudbreak.api.model.AmbariAddressJson) InstanceGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson) History(com.sequenceiq.periscope.domain.History)

Example 2 with UpdateStackJson

use of com.sequenceiq.cloudbreak.api.model.UpdateStackJson in project cloudbreak by hortonworks.

the class StackAndClusterStartTest method testStackAndClusterStart.

@Test
@Parameters("waitOn")
public void testStackAndClusterStart(@Optional(NOWAIT) Boolean waitOn) {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    String stackId = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    Integer stackIntId = Integer.valueOf(stackId);
    String ambariUser = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID);
    String ambariPassword = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID);
    String ambariPort = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PORT_ID);
    // WHEN
    UpdateStackJson updateStackJson = new UpdateStackJson();
    updateStackJson.setStatus(StatusRequest.valueOf(STARTED));
    CloudbreakUtil.checkResponse("StartStack", getCloudbreakClient().stackV1Endpoint().put(Long.valueOf(stackIntId), updateStackJson));
    if (Boolean.TRUE.equals(waitOn)) {
        CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackId, "AVAILABLE");
    }
    UpdateClusterJson updateClusterJson = new UpdateClusterJson();
    updateClusterJson.setStatus(StatusRequest.valueOf(STARTED));
    CloudbreakUtil.checkResponse("StartCluster", getCloudbreakClient().clusterEndpoint().put(Long.valueOf(stackIntId), updateClusterJson));
    CloudbreakUtil.waitAndCheckClusterStatus(getCloudbreakClient(), stackId, "AVAILABLE");
    // THEN
    CloudbreakUtil.checkClusterAvailability(getCloudbreakClient().stackV1Endpoint(), ambariPort, stackId, ambariUser, ambariPassword, true);
}
Also used : UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 3 with UpdateStackJson

use of com.sequenceiq.cloudbreak.api.model.UpdateStackJson in project cloudbreak by hortonworks.

the class StackStopTest method testStackStop.

@Test
public void testStackStop() {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    String stackId = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    Integer stackIntId = Integer.valueOf(stackId);
    String ambariUser = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID);
    String ambariPassword = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID);
    String ambariPort = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PORT_ID);
    // WHEN
    UpdateStackJson updateStackJson = new UpdateStackJson();
    updateStackJson.setStatus(StatusRequest.valueOf(STOPPED));
    CloudbreakUtil.checkResponse("StopStack", getCloudbreakClient().stackV1Endpoint().put(Long.valueOf(stackIntId), updateStackJson));
    CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackId, STOPPED);
    // THEN
    CloudbreakUtil.checkClusterStopped(getCloudbreakClient().stackV1Endpoint(), ambariPort, stackId, ambariUser, ambariPassword);
}
Also used : UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 4 with UpdateStackJson

use of com.sequenceiq.cloudbreak.api.model.UpdateStackJson in project cloudbreak by hortonworks.

the class ClusterAndStackStopTest method testClusterAndStackStop.

@Test
@Parameters("waitOn")
public void testClusterAndStackStop(@Optional(NOWAIT) Boolean waitOn) {
    // GIVEN
    IntegrationTestContext itContext = getItContext();
    String stackId = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
    Integer stackIntId = Integer.valueOf(stackId);
    String ambariUser = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID);
    String ambariPassword = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID);
    String ambariPort = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PORT_ID);
    // WHEN
    UpdateClusterJson updateClusterJson = new UpdateClusterJson();
    updateClusterJson.setStatus(StatusRequest.valueOf(STOPPED));
    CloudbreakUtil.checkResponse("StopCluster", getCloudbreakClient().clusterEndpoint().put(Long.valueOf(stackIntId), updateClusterJson));
    if (Boolean.TRUE.equals(waitOn)) {
        CloudbreakUtil.waitAndCheckClusterStatus(getCloudbreakClient(), stackId, STOPPED);
    }
    UpdateStackJson updateStackJson = new UpdateStackJson();
    updateStackJson.setStatus(StatusRequest.valueOf(STOPPED));
    CloudbreakUtil.checkResponse("StopStack", getCloudbreakClient().stackV1Endpoint().put(Long.valueOf(stackIntId), updateStackJson));
    CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackId, STOPPED);
    // THEN
    CloudbreakUtil.checkClusterStopped(getCloudbreakClient().stackV1Endpoint(), ambariPort, stackId, ambariUser, ambariPassword);
}
Also used : UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 5 with UpdateStackJson

use of com.sequenceiq.cloudbreak.api.model.UpdateStackJson in project cloudbreak by hortonworks.

the class UpdateStackRequestValidatorTest method testIsValidShouldReturnFalseWhenRequestContainsOnlyNulls.

@Test
public void testIsValidShouldReturnFalseWhenRequestContainsOnlyNulls() {
    UpdateStackJson updateStackJson = new UpdateStackJson();
    updateStackJson.setInstanceGroupAdjustment(null);
    updateStackJson.setStatus(null);
    boolean valid = underTest.isValid(updateStackJson, constraintValidatorContext);
    assertFalse(valid);
}
Also used : UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) Test(org.junit.Test)

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