use of com.sequenceiq.periscope.model.yarn.YarnScalingServiceV1Response in project cloudbreak by hortonworks.
the class CronTimeEvaluator method populateDecommissionCandidates.
private void populateDecommissionCandidates(ScalingEvent event, StackV4Response stackV4Response, Cluster cluster, ScalingPolicy policy, int mandatoryDownScaleCount) {
try {
String pollingUserCrn = Optional.ofNullable(getMachineUserCrnIfApplicable(cluster)).orElse(cluster.getClusterPertain().getUserCrn());
YarnScalingServiceV1Response yarnResponse = yarnMetricsClient.getYarnMetricsForCluster(cluster, stackV4Response, policy.getHostGroup(), pollingUserCrn, Optional.of(mandatoryDownScaleCount));
Map<String, String> hostFqdnsToInstanceId = stackResponseUtils.getCloudInstanceIdsForHostGroup(stackV4Response, policy.getHostGroup());
List<String> decommissionNodes = yarnResponseUtils.getYarnRecommendedDecommissionHostsForHostGroup(cluster.getStackCrn(), yarnResponse, hostFqdnsToInstanceId, mandatoryDownScaleCount, Optional.of(mandatoryDownScaleCount), DEFAULT_MAX_SCALE_DOWN_STEP_SIZE);
event.setDecommissionNodeIds(decommissionNodes);
} catch (Exception ex) {
LOGGER.error("Error retrieving decommission candidates for policy '{}', adjustment type '{}', cluster '{}'", policy.getName(), policy.getAdjustmentType(), cluster.getStackCrn(), ex);
}
}
use of com.sequenceiq.periscope.model.yarn.YarnScalingServiceV1Response 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);
}
Aggregations