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);
}
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations