Search in sources :

Example 6 with YarnScalingServiceV1Response

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);
    }
}
Also used : YarnScalingServiceV1Response(com.sequenceiq.periscope.model.yarn.YarnScalingServiceV1Response)

Example 7 with YarnScalingServiceV1Response

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);
}
Also used : YarnScalingServiceV1Response(com.sequenceiq.periscope.model.yarn.YarnScalingServiceV1Response) CloudbreakCommunicator(com.sequenceiq.periscope.monitor.handler.CloudbreakCommunicator) YarnMetricsClient(com.sequenceiq.periscope.monitor.client.YarnMetricsClient) LoggerFactory(org.slf4j.LoggerFactory) LoadAlertConfiguration(com.sequenceiq.periscope.domain.LoadAlertConfiguration) EventPublisher(com.sequenceiq.periscope.monitor.evaluator.EventPublisher) UpdateFailedEvent(com.sequenceiq.periscope.monitor.event.UpdateFailedEvent) Scope(org.springframework.context.annotation.Scope) Inject(javax.inject.Inject) LoadAlertRepository(com.sequenceiq.periscope.repository.LoadAlertRepository) LoggingUtils(com.sequenceiq.periscope.utils.LoggingUtils) Map(java.util.Map) LoadAlert(com.sequenceiq.periscope.domain.LoadAlert) StackResponseUtils(com.sequenceiq.periscope.utils.StackResponseUtils) UpdateFailedDetails(com.sequenceiq.periscope.domain.UpdateFailedDetails) Nonnull(javax.annotation.Nonnull) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) Logger(org.slf4j.Logger) Cluster(com.sequenceiq.periscope.domain.Cluster) EvaluatorExecutor(com.sequenceiq.periscope.monitor.evaluator.EvaluatorExecutor) ScalingEvent(com.sequenceiq.periscope.monitor.event.ScalingEvent) EvaluatorContext(com.sequenceiq.periscope.monitor.context.EvaluatorContext) Instant(java.time.Instant) ClusterIdEvaluatorContext(com.sequenceiq.periscope.monitor.context.ClusterIdEvaluatorContext) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Component(org.springframework.stereotype.Component) Optional(java.util.Optional) ClusterService(com.sequenceiq.periscope.service.ClusterService) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) YarnScalingServiceV1Response(com.sequenceiq.periscope.model.yarn.YarnScalingServiceV1Response)

Aggregations

YarnScalingServiceV1Response (com.sequenceiq.periscope.model.yarn.YarnScalingServiceV1Response)7 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)3 Cluster (com.sequenceiq.periscope.domain.Cluster)3 ScalingEvent (com.sequenceiq.periscope.monitor.event.ScalingEvent)3 List (java.util.List)3 ClusterIdEvaluatorContext (com.sequenceiq.periscope.monitor.context.ClusterIdEvaluatorContext)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Optional (java.util.Optional)2 LoadAlert (com.sequenceiq.periscope.domain.LoadAlert)1 LoadAlertConfiguration (com.sequenceiq.periscope.domain.LoadAlertConfiguration)1 TimeAlert (com.sequenceiq.periscope.domain.TimeAlert)1 UpdateFailedDetails (com.sequenceiq.periscope.domain.UpdateFailedDetails)1 InstanceConfig (com.sequenceiq.periscope.model.InstanceConfig)1 TlsConfiguration (com.sequenceiq.periscope.model.TlsConfiguration)1 YarnScalingServiceV1Request (com.sequenceiq.periscope.model.yarn.YarnScalingServiceV1Request)1 HostGroupInstanceType (com.sequenceiq.periscope.model.yarn.YarnScalingServiceV1Request.HostGroupInstanceType)1 DecommissionCandidate (com.sequenceiq.periscope.model.yarn.YarnScalingServiceV1Response.DecommissionCandidate)1 NewNodeManagerCandidates (com.sequenceiq.periscope.model.yarn.YarnScalingServiceV1Response.NewNodeManagerCandidates)1 YarnMetricsClient (com.sequenceiq.periscope.monitor.client.YarnMetricsClient)1