Search in sources :

Example 6 with UpdateClusterJson

use of com.sequenceiq.cloudbreak.api.model.UpdateClusterJson in project cloudbreak by hortonworks.

the class StackV2Controller method putScaling.

@Override
public Response putScaling(String name, StackScaleRequestV2 updateRequest) {
    IdentityUser user = authenticatedUserService.getCbUser();
    Stack stack = stackService.getPublicStack(name, user);
    if (!cloudParameterCache.isScalingSupported(stack.cloudPlatform())) {
        throw new BadRequestException(String.format("Scaling is not supported on %s cloudplatform", stack.cloudPlatform()));
    }
    updateRequest.setStackId(stack.getId());
    UpdateStackJson updateStackJson = conversionService.convert(updateRequest, UpdateStackJson.class);
    if (updateStackJson.getInstanceGroupAdjustment().getScalingAdjustment() > 0) {
        return stackCommonService.put(stack.getId(), updateStackJson);
    } else {
        UpdateClusterJson updateClusterJson = conversionService.convert(updateRequest, UpdateClusterJson.class);
        return clusterCommonController.put(stack.getId(), updateClusterJson);
    }
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UpdateStackJson(com.sequenceiq.cloudbreak.api.model.UpdateStackJson) Stack(com.sequenceiq.cloudbreak.domain.Stack) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)

Example 7 with UpdateClusterJson

use of com.sequenceiq.cloudbreak.api.model.UpdateClusterJson in project cloudbreak by hortonworks.

the class StackV2Controller method putReinstall.

@Override
public Response putReinstall(String name, ReinstallRequestV2 reinstallRequestV2) {
    IdentityUser user = authenticatedUserService.getCbUser();
    reinstallRequestV2.setAccount(user.getAccount());
    Stack stack = stackService.getPublicStack(name, user);
    UpdateClusterJson updateClusterJson = conversionService.convert(reinstallRequestV2, UpdateClusterJson.class);
    return clusterCommonController.put(stack.getId(), updateClusterJson);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) Stack(com.sequenceiq.cloudbreak.domain.Stack) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)

Example 8 with UpdateClusterJson

use of com.sequenceiq.cloudbreak.api.model.UpdateClusterJson in project cloudbreak by hortonworks.

the class UpdateAmbariPasswordToUpdateClusterRequestConverter method convert.

@Override
public UpdateClusterJson convert(UserNamePasswordJson source) {
    UpdateClusterJson updateStackJson = new UpdateClusterJson();
    updateStackJson.setUserNamePasswordJson(source);
    return updateStackJson;
}
Also used : UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)

Example 9 with UpdateClusterJson

use of com.sequenceiq.cloudbreak.api.model.UpdateClusterJson 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)

Example 10 with UpdateClusterJson

use of com.sequenceiq.cloudbreak.api.model.UpdateClusterJson in project cloudbreak by hortonworks.

the class UpdateAmbariRequestToUpdateClusterRequestConverter method convert.

@Override
public UpdateClusterJson convert(ReinstallRequestV2 source) {
    UpdateClusterJson updateStackJson = new UpdateClusterJson();
    updateStackJson.setValidateBlueprint(true);
    updateStackJson.setKerberosPassword(source.getKerberosPassword());
    updateStackJson.setKerberosPrincipal(source.getKerberosPrincipal());
    Blueprint blueprint = blueprintRepository.findOneByName(source.getBlueprintName(), source.getAccount());
    if (blueprint != null) {
        updateStackJson.setBlueprintId(blueprint.getId());
        updateStackJson.setAmbariStackDetails(source.getAmbariStackDetails());
        Set<HostGroupRequest> hostgroups = new HashSet<>();
        for (InstanceGroupV2Request instanceGroupV2Request : source.getInstanceGroups()) {
            HostGroupRequest hostGroupRequest = new HostGroupRequest();
            hostGroupRequest.setRecoveryMode(instanceGroupV2Request.getRecoveryMode());
            hostGroupRequest.setRecipeNames(instanceGroupV2Request.getRecipeNames());
            hostGroupRequest.setName(instanceGroupV2Request.getGroup());
            ConstraintJson constraintJson = new ConstraintJson();
            constraintJson.setHostCount(instanceGroupV2Request.getNodeCount());
            constraintJson.setInstanceGroupName(instanceGroupV2Request.getGroup());
            hostGroupRequest.setConstraint(constraintJson);
            hostgroups.add(hostGroupRequest);
        }
        updateStackJson.setHostgroups(hostgroups);
    } else {
        throw new BadRequestException(String.format("Blueprint '%s' not available", source.getBlueprintName()));
    }
    return updateStackJson;
}
Also used : InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) ConstraintJson(com.sequenceiq.cloudbreak.api.model.ConstraintJson) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson) HashSet(java.util.HashSet)

Aggregations

UpdateClusterJson (com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)14 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)7 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)7 Test (org.testng.annotations.Test)7 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)5 Parameters (org.testng.annotations.Parameters)5 UpdateStackJson (com.sequenceiq.cloudbreak.api.model.UpdateStackJson)4 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)3 Stack (com.sequenceiq.cloudbreak.domain.Stack)3 StackV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.StackV1Endpoint)2 CloudbreakClient (com.sequenceiq.cloudbreak.client.CloudbreakClient)2 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 AmbariAddressJson (com.sequenceiq.cloudbreak.api.model.AmbariAddressJson)1 ConstraintJson (com.sequenceiq.cloudbreak.api.model.ConstraintJson)1 HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)1 InstanceGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.InstanceGroupAdjustmentJson)1 InstanceGroupV2Request (com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)1 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)1