use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class CronTimeEvaluator method publish.
private void publish(TimeAlert alert) {
ScalingEvent event = new ScalingEvent(alert);
StackV4Response stackV4Response = cloudbreakCommunicator.getByCrn(alert.getCluster().getStackCrn());
int hostGroupNodeCount = stackResponseUtils.getNodeCountForHostGroup(stackV4Response, alert.getScalingPolicy().getHostGroup());
int desiredAbsoluteNodeCount = scalingPolicyTargetCalculator.getDesiredAbsoluteNodeCount(event, hostGroupNodeCount);
int targetIncrementNodeCount = desiredAbsoluteNodeCount - hostGroupNodeCount;
event.setExistingHostGroupNodeCount(hostGroupNodeCount);
event.setDesiredAbsoluteHostGroupNodeCount(desiredAbsoluteNodeCount);
event.setExistingClusterNodeCount(stackV4Response.getNodeCount());
if (targetIncrementNodeCount < 0) {
populateDecommissionCandidates(event, stackV4Response, alert.getCluster(), alert.getScalingPolicy(), -targetIncrementNodeCount);
}
eventPublisher.publishEvent(event);
LOGGER.debug("Time alert '{}' triggered for cluster '{}'", alert.getName(), alert.getCluster().getStackCrn());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class YarnLoadEvaluator method pollYarnMetricsAndScaleCluster.
protected void pollYarnMetricsAndScaleCluster() throws Exception {
StackV4Response stackV4Response = cloudbreakCommunicator.getByCrn(cluster.getStackCrn());
Map<String, String> hostFqdnsToInstanceId = stackResponseUtils.getCloudInstanceIdsForHostGroup(stackV4Response, policyHostGroup);
int serviceHealthyHostGroupSize = stackResponseUtils.getCloudInstanceIdsWithServicesHealthyForHostGroup(stackV4Response, policyHostGroup);
int existingHostGroupSize = Boolean.TRUE.equals(cluster.isStopStartScalingEnabled()) ? serviceHealthyHostGroupSize : hostFqdnsToInstanceId.size();
int configMaxNodeCount = loadAlertConfiguration.getMaxResourceValue() - existingHostGroupSize;
int configMinNodeCount = serviceHealthyHostGroupSize - loadAlertConfiguration.getMinResourceValue();
int maxAllowedUpScale = configMaxNodeCount < 0 ? 0 : configMaxNodeCount;
int maxAllowedDownScale = configMinNodeCount > 0 ? configMinNodeCount : 0;
LOGGER.info("Various counts: hostFqdnsToInstanceId={}, configMaxNodeCount={}, configMinNodeCount={}, maxAllowedUpScale={}, maxAllowedDownScale={}", existingHostGroupSize, configMaxNodeCount, configMinNodeCount, maxAllowedUpScale, maxAllowedDownScale);
Optional<Integer> mandatoryUpScaleCount = Optional.of(configMinNodeCount).filter(mandatoryUpScale -> mandatoryUpScale < 0).map(upscale -> -1 * upscale);
Optional<Integer> mandatoryDownScaleCount = Optional.of(configMaxNodeCount).filter(mandatoryDownscale -> mandatoryDownscale < 0).map(downscale -> -1 * downscale);
YarnScalingServiceV1Response yarnResponse = yarnMetricsClient.getYarnMetricsForCluster(cluster, stackV4Response, policyHostGroup, pollingUserCrn, mandatoryDownScaleCount);
if (cluster.getUpdateFailedDetails() != null && pollingUserCrn.equals(cluster.getMachineUserCrn())) {
// Successful YARN API call
clusterService.setUpdateFailedDetails(cluster.getId(), null);
}
int yarnRecommendedScaleUpCount = yarnResponseUtils.getYarnRecommendedScaleUpCount(yarnResponse, policyHostGroup, maxAllowedUpScale, mandatoryUpScaleCount, loadAlertConfiguration.getMaxScaleUpStepSize());
List<String> yarnRecommendedDecommissionHosts = yarnResponseUtils.getYarnRecommendedDecommissionHostsForHostGroup(cluster.getStackCrn(), yarnResponse, hostFqdnsToInstanceId, maxAllowedDownScale, mandatoryDownScaleCount, loadAlertConfiguration.getMaxScaleDownStepSize());
LOGGER.info("yarnRecommendedScaleUpCount={}, yarnRecommendedDecommssion={}", yarnRecommendedScaleUpCount, yarnRecommendedDecommissionHosts);
fireAppropriateEvent(yarnRecommendedScaleUpCount, stackV4Response, existingHostGroupSize, serviceHealthyHostGroupSize, yarnRecommendedDecommissionHosts);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class DistroXScaleStartInstancesAction method action.
@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
InstanceGroupAdjustmentV4Request instanceGroupAdjustmentRequest = new InstanceGroupAdjustmentV4Request();
instanceGroupAdjustmentRequest.setInstanceGroup(hostGroup);
instanceGroupAdjustmentRequest.setScalingAdjustment(count);
UpdateStackV4Request updateStackRequest = new UpdateStackV4Request();
updateStackRequest.setInstanceGroupAdjustment(instanceGroupAdjustmentRequest);
updateStackRequest.setWithClusterEvent(true);
Log.when(LOGGER, String.format(" Starting instances [%s] for distrox '%s' Compute scaling... ", testDto.getInstanceIdsForAction(), testDto.getName()));
Log.whenJson(LOGGER, " Distrox Compute scale start instances request: ", testDto.getRequest());
testDto.setFlow("scale start", client.getDefaultClient().autoscaleEndpoint().putStackStartInstancesByName(testDto.getName(), updateStackRequest));
StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().getByName(testDto.getName(), new HashSet<>(Arrays.asList("hardware_info", "events")));
testDto.setResponse(stackV4Response);
Log.whenJson(LOGGER, " Distrox Compute scale start instances response: ", stackV4Response);
LOGGER.info(String.format("Hardware info for distrox '%s' after start instances for Compute scale: %s", testDto.getName(), stackV4Response.getHardwareInfoGroups()));
return testDto;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class DistroXStopAction method action.
@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
Log.when(LOGGER, format(" Stop Distrox: %s ", testDto.getName()));
Log.whenJson(LOGGER, " Distrox stop request: ", testDto.getRequest());
FlowIdentifier flow = client.getDefaultClient().distroXV1Endpoint().putStopByName(testDto.getName());
testDto.setFlow("Distrox stop", flow);
StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().getByName(testDto.getName(), Collections.emptySet());
testDto.setResponse(stackV4Response);
Log.whenJson(LOGGER, " Distrox stop response: ", stackV4Response);
return testDto;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class DistroXUpgradeAction method action.
@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
DistroXUpgradeV1Request upgradeRequest = testDto.getDistroXUpgradeRequest();
Log.when(LOGGER, format(" Starting DistroX upgrade: %s ", testDto.getName()));
Log.whenJson(LOGGER, " DistroX upgrade request: ", upgradeRequest);
DistroXUpgradeV1Response response = client.getDefaultClient().distroXUpgradeV1Endpoint().upgradeClusterByName(testDto.getName(), upgradeRequest);
testDto.setFlow("DistroX upgrade flow identifier", response.getFlowIdentifier());
StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().getByName(testDto.getName(), Collections.emptySet());
testDto.setResponse(stackV4Response);
Log.whenJson(LOGGER, " DistroX upgrade response: ", stackV4Response);
return testDto;
}
Aggregations