Search in sources :

Example 91 with StackV4Response

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());
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) ScalingEvent(com.sequenceiq.periscope.monitor.event.ScalingEvent)

Example 92 with StackV4Response

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

Example 93 with StackV4Response

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;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) UpdateStackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.UpdateStackV4Request) InstanceGroupAdjustmentV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.InstanceGroupAdjustmentV4Request)

Example 94 with StackV4Response

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;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 95 with StackV4Response

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;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) DistroXUpgradeV1Response(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Response) DistroXUpgradeV1Request(com.sequenceiq.distrox.api.v1.distrox.model.upgrade.DistroXUpgradeV1Request)

Aggregations

StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)101 Test (org.junit.jupiter.api.Test)26 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)22 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)19 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)14 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)13 Test (org.junit.Test)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)8 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)8 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)7 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)7 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)7 ArrayList (java.util.ArrayList)7 Test (org.testng.annotations.Test)7 InstanceGroupV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response)6 TagsV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response)6 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)6 TransactionRuntimeExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)6 BaseDiagnosticsCollectionRequest (com.sequenceiq.common.api.diagnostics.BaseDiagnosticsCollectionRequest)6