Search in sources :

Example 1 with History

use of com.sequenceiq.periscope.domain.History in project cloudbreak by hortonworks.

the class AutoScaleClusterCommonService method createHistoryAndNotification.

private void createHistoryAndNotification(Cluster cluster) {
    History history;
    history = cluster.isAutoscalingEnabled() ? historyService.createEntry(ScalingStatus.ENABLED, "Autoscaling has been enabled for the cluster.", 0, cluster) : historyService.createEntry(ScalingStatus.DISABLED, "Autoscaling has been disabled for the cluster.", 0, cluster);
    notificationSender.send(history);
}
Also used : History(com.sequenceiq.periscope.domain.History)

Example 2 with History

use of com.sequenceiq.periscope.domain.History 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);
        }
    }
}
Also used : UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) AmbariAddressJson(com.sequenceiq.cloudbreak.api.model.AmbariAddressJson) InstanceGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson) History(com.sequenceiq.periscope.domain.History)

Example 3 with History

use of com.sequenceiq.periscope.domain.History in project cloudbreak by hortonworks.

the class ClusterCreationEvaluator method createOrUpdateCluster.

private void createOrUpdateCluster(AutoscaleStackResponse stack, Optional<Cluster> clusterOptional) {
    AmbariStack resolvedAmbari = createAmbariStack(stack);
    Cluster cluster;
    boolean sendNotification = false;
    if (clusterOptional.isPresent()) {
        cluster = clusterOptional.get();
        MDCBuilder.buildMdcContext(cluster);
        if (PENDING.equals(cluster.getState()) || SUSPENDED.equals(cluster.getState())) {
            ambariHealthCheck(cluster.getUser(), resolvedAmbari);
            LOGGER.info("Update cluster and set it's state to 'RUNNING' for Ambari host: {}", resolvedAmbari.getAmbari().getHost());
            cluster = clusterService.update(cluster.getId(), resolvedAmbari, false, RUNNING, cluster.isAutoscalingEnabled());
            sendNotification = true;
        }
    } else {
        PeriscopeUser user = new PeriscopeUser(stack.getOwner(), null, stack.getAccount());
        MDCBuilder.buildMdcContext(user, stack.getStackId(), null);
        LOGGER.info("Creating cluster for Ambari host: {}", resolvedAmbari.getAmbari().getHost());
        ambariHealthCheck(user, resolvedAmbari);
        cluster = clusterService.create(user, resolvedAmbari, null);
        sendNotification = true;
    }
    if (sendNotification) {
        History history = historyService.createEntry(ScalingStatus.ENABLED, "Autoscaling has been enabled for the cluster.", 0, cluster);
        notificationSender.send(history);
    }
}
Also used : AmbariStack(com.sequenceiq.periscope.model.AmbariStack) PeriscopeUser(com.sequenceiq.periscope.domain.PeriscopeUser) Cluster(com.sequenceiq.periscope.domain.Cluster) History(com.sequenceiq.periscope.domain.History)

Example 4 with History

use of com.sequenceiq.periscope.domain.History in project cloudbreak by hortonworks.

the class ScalingRequest method scaleDown.

private void scaleDown(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 remove {} node(s) from host group '{}', triggered policy '{}'", scalingAdjustment, hostGroup, policy.getName());
        Long stackId = cloudbreakClient.stackV1Endpoint().getStackForAmbari(ambariAddressJson).getId();
        UpdateClusterJson updateClusterJson = new UpdateClusterJson();
        HostGroupAdjustmentJson hostGroupAdjustmentJson = new HostGroupAdjustmentJson();
        hostGroupAdjustmentJson.setScalingAdjustment(scalingAdjustment);
        hostGroupAdjustmentJson.setWithStackUpdate(true);
        hostGroupAdjustmentJson.setHostGroup(hostGroup);
        updateClusterJson.setHostGroupAdjustment(hostGroupAdjustmentJson);
        cloudbreakClient.clusterEndpoint().put(stackId, updateClusterJson);
        history = historyService.createEntry(ScalingStatus.SUCCESS, "Downscale successfully triggered", totalNodes, policy);
    } catch (Exception e) {
        history = historyService.createEntry(ScalingStatus.FAILED, "Couldn't trigger downscaling due to: " + e.getMessage(), totalNodes, policy);
        LOGGER.error("Error removing nodes from the cluster", e);
    } finally {
        if (history != null) {
            notificationSender.send(history);
        }
    }
}
Also used : AmbariAddressJson(com.sequenceiq.cloudbreak.api.model.AmbariAddressJson) HostGroupAdjustmentJson(com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson) History(com.sequenceiq.periscope.domain.History) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)

Aggregations

History (com.sequenceiq.periscope.domain.History)4 AmbariAddressJson (com.sequenceiq.cloudbreak.api.model.AmbariAddressJson)2 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)1 InstanceGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson)1 UpdateClusterJson (com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)1 UpdateStackJson (com.sequenceiq.cloudbreak.api.model.UpdateStackJson)1 Cluster (com.sequenceiq.periscope.domain.Cluster)1 PeriscopeUser (com.sequenceiq.periscope.domain.PeriscopeUser)1 AmbariStack (com.sequenceiq.periscope.model.AmbariStack)1