Search in sources :

Example 6 with SingularityDeployMarker

use of com.hubspot.singularity.SingularityDeployMarker in project Singularity by HubSpot.

the class SingularitySchedulerTestBase method initSecondDeploy.

protected SingularityDeployMarker initSecondDeploy() {
    secondDeployMarker = new SingularityDeployMarker(requestId, secondDeployId, System.currentTimeMillis(), Optional.<String>absent(), Optional.<String>absent());
    secondDeploy = new SingularityDeployBuilder(requestId, secondDeployId).setCommand(Optional.of("sleep 100")).build();
    deployManager.saveDeploy(request, secondDeployMarker, secondDeploy);
    startDeploy(secondDeployMarker, System.currentTimeMillis());
    return secondDeployMarker;
}
Also used : SingularityDeployMarker(com.hubspot.singularity.SingularityDeployMarker) SingularityDeployBuilder(com.hubspot.singularity.SingularityDeployBuilder)

Example 7 with SingularityDeployMarker

use of com.hubspot.singularity.SingularityDeployMarker in project Singularity by HubSpot.

the class SingularitySchedulerTestBase method initAndFinishDeploy.

protected SingularityDeploy initAndFinishDeploy(SingularityRequest request, SingularityDeployBuilder builder, Optional<Resources> maybeResources) {
    SingularityDeploy deploy = builder.setResources(maybeResources).build();
    SingularityDeployMarker marker = new SingularityDeployMarker(deploy.getRequestId(), deploy.getId(), System.currentTimeMillis(), Optional.<String>absent(), Optional.<String>absent());
    deployManager.saveDeploy(request, marker, deploy);
    finishDeploy(marker, deploy);
    return deploy;
}
Also used : SingularityDeployMarker(com.hubspot.singularity.SingularityDeployMarker) SingularityDeploy(com.hubspot.singularity.SingularityDeploy)

Example 8 with SingularityDeployMarker

use of com.hubspot.singularity.SingularityDeployMarker in project Singularity by HubSpot.

the class SingularitySchedulerTestBase method finishDeploy.

protected void finishDeploy(SingularityDeployMarker marker, SingularityDeploy deploy) {
    deployManager.deletePendingDeploy(marker.getRequestId());
    deployManager.saveDeployResult(marker, Optional.of(deploy), new SingularityDeployResult(DeployState.SUCCEEDED));
    deployManager.saveNewRequestDeployState(new SingularityRequestDeployState(marker.getRequestId(), Optional.of(marker), Optional.<SingularityDeployMarker>absent()));
}
Also used : SingularityDeployResult(com.hubspot.singularity.SingularityDeployResult) SingularityDeployMarker(com.hubspot.singularity.SingularityDeployMarker) SingularityRequestDeployState(com.hubspot.singularity.SingularityRequestDeployState)

Example 9 with SingularityDeployMarker

use of com.hubspot.singularity.SingularityDeployMarker in project Singularity by HubSpot.

the class StateManager method generateState.

public SingularityState generateState(boolean includeRequestIds) {
    final int launchingTasks = taskManager.getNumLaunchingTasks();
    final int activeTasks = taskManager.getNumActiveTasks() - launchingTasks;
    final int scheduledTasks = taskManager.getNumScheduledTasks();
    final int cleaningTasks = taskManager.getNumCleanupTasks();
    final int lbCleanupTasks = taskManager.getNumLbCleanupTasks();
    final int lbCleanupRequests = requestManager.getNumLbCleanupRequests();
    final SingularityScheduledTasksInfo scheduledTasksInfo = SingularityScheduledTasksInfo.getInfo(taskManager.getPendingTasks(), singularityConfiguration.getDeltaAfterWhichTasksAreLateMillis());
    final List<String> overProvisionedRequestIds = new ArrayList<>();
    final Set<String> possiblyUnderProvisionedRequestIds = new HashSet<>();
    final List<SingularityRequestWithState> requests = requestManager.getRequests();
    final Map<String, Long> numInstances = getNumTasks(requests);
    int numActiveRequests = 0;
    int numPausedRequests = 0;
    int cooldownRequests = 0;
    int numFinishedRequests = 0;
    for (SingularityRequestWithState requestWithState : requests) {
        switch(requestWithState.getState()) {
            case DEPLOYING_TO_UNPAUSE:
            case ACTIVE:
                numActiveRequests++;
                break;
            case FINISHED:
                numFinishedRequests++;
                break;
            case PAUSED:
                numPausedRequests++;
                break;
            case SYSTEM_COOLDOWN:
                cooldownRequests++;
                break;
            case DELETED:
                break;
        }
        updatePossiblyUnderProvisionedAndOverProvisionedIds(requestWithState, numInstances, overProvisionedRequestIds, possiblyUnderProvisionedRequestIds);
    }
    filterForPendingRequests(possiblyUnderProvisionedRequestIds);
    final List<String> underProvisionedRequestIds = getUnderProvisionedRequestIds(possiblyUnderProvisionedRequestIds);
    final int pendingRequests = requestManager.getSizeOfPendingQueue();
    final int cleaningRequests = requestManager.getSizeOfCleanupQueue();
    List<SingularityRack> racks = rackManager.getObjects();
    int activeRacks = 0;
    int deadRacks = 0;
    int decommissioningRacks = 0;
    int unknownRacks = 0;
    for (SingularityRack rack : racks) {
        switch(rack.getCurrentState().getState()) {
            case ACTIVE:
                activeRacks++;
                break;
            case DEAD:
                deadRacks++;
                break;
            case MISSING_ON_STARTUP:
                unknownRacks++;
                break;
            case DECOMMISSIONED:
            case STARTING_DECOMMISSION:
            case DECOMMISSIONING:
                decommissioningRacks++;
                break;
            default:
                unknownRacks++;
                break;
        }
    }
    List<SingularitySlave> slaves = slaveManager.getObjects();
    int activeSlaves = 0;
    int deadSlaves = 0;
    int decommissioningSlaves = 0;
    int unknownSlaves = 0;
    for (SingularitySlave slave : slaves) {
        switch(slave.getCurrentState().getState()) {
            case ACTIVE:
                activeSlaves++;
                break;
            case DEAD:
                deadSlaves++;
                break;
            case MISSING_ON_STARTUP:
                unknownSlaves++;
                break;
            case DECOMMISSIONED:
            case STARTING_DECOMMISSION:
            case DECOMMISSIONING:
                decommissioningSlaves++;
                break;
            default:
                unknownSlaves++;
                break;
        }
    }
    final List<SingularityHostState> states = getHostStates();
    int numDeploys = 0;
    long oldestDeploy = 0;
    long oldestDeployStep = 0;
    List<SingularityDeployMarker> activeDeploys = new ArrayList<>();
    final long now = System.currentTimeMillis();
    for (SingularityPendingDeploy pendingDeploy : deployManager.getPendingDeploys()) {
        activeDeploys.add(pendingDeploy.getDeployMarker());
        if (pendingDeploy.getDeployProgress().isPresent() && !pendingDeploy.getDeployProgress().get().isStepComplete()) {
            long deployStepDelta = now - pendingDeploy.getDeployProgress().get().getTimestamp();
            if (deployStepDelta > oldestDeployStep) {
                oldestDeployStep = deployStepDelta;
            }
        }
        long delta = now - pendingDeploy.getDeployMarker().getTimestamp();
        if (delta > oldestDeploy) {
            oldestDeploy = delta;
        }
        numDeploys++;
    }
    final Optional<Boolean> authDatastoreHealthy = authDatastore.isHealthy();
    final Optional<Double> minimumPriorityLevel = getMinimumPriorityLevel();
    return new SingularityState(activeTasks, launchingTasks, numActiveRequests, cooldownRequests, numPausedRequests, scheduledTasks, pendingRequests, lbCleanupTasks, lbCleanupRequests, cleaningRequests, activeSlaves, deadSlaves, decommissioningSlaves, activeRacks, deadRacks, decommissioningRacks, cleaningTasks, states, oldestDeploy, numDeploys, oldestDeployStep, activeDeploys, scheduledTasksInfo.getNumLateTasks(), scheduledTasksInfo.getNumFutureTasks(), scheduledTasksInfo.getMaxTaskLag(), System.currentTimeMillis(), includeRequestIds ? overProvisionedRequestIds : null, includeRequestIds ? underProvisionedRequestIds : null, overProvisionedRequestIds.size(), underProvisionedRequestIds.size(), numFinishedRequests, unknownRacks, unknownSlaves, authDatastoreHealthy, minimumPriorityLevel, statusUpdateDeltaAvg.get());
}
Also used : SingularityDeployMarker(com.hubspot.singularity.SingularityDeployMarker) ArrayList(java.util.ArrayList) SingularityRack(com.hubspot.singularity.SingularityRack) SingularityState(com.hubspot.singularity.SingularityState) SingularityHostState(com.hubspot.singularity.SingularityHostState) SingularityRequestWithState(com.hubspot.singularity.SingularityRequestWithState) HashSet(java.util.HashSet) SingularityScheduledTasksInfo(com.hubspot.singularity.SingularityScheduledTasksInfo) SingularitySlave(com.hubspot.singularity.SingularitySlave) SingularityPendingDeploy(com.hubspot.singularity.SingularityPendingDeploy) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Example 10 with SingularityDeployMarker

use of com.hubspot.singularity.SingularityDeployMarker in project Singularity by HubSpot.

the class DeployManager method getDeployHistory.

public Optional<SingularityDeployHistory> getDeployHistory(String requestId, String deployId, boolean loadEntireHistory) {
    Optional<SingularityDeployMarker> deployMarker = getData(getDeployMarkerPath(requestId, deployId), deployMarkerTranscoder);
    if (!deployMarker.isPresent()) {
        return Optional.absent();
    }
    Optional<SingularityDeployResult> deployState = getDeployResult(requestId, deployId);
    if (!loadEntireHistory) {
        return Optional.of(new SingularityDeployHistory(deployState, deployMarker.get(), Optional.<SingularityDeploy>absent(), Optional.<SingularityDeployStatistics>absent()));
    }
    Optional<SingularityDeploy> deploy = getDeploy(requestId, deployId);
    if (!deploy.isPresent()) {
        return Optional.absent();
    }
    Optional<SingularityDeployStatistics> deployStatistics = getDeployStatistics(requestId, deployId);
    return Optional.of(new SingularityDeployHistory(deployState, deployMarker.get(), deploy, deployStatistics));
}
Also used : SingularityDeployMarker(com.hubspot.singularity.SingularityDeployMarker) SingularityDeployResult(com.hubspot.singularity.SingularityDeployResult) SingularityDeployHistory(com.hubspot.singularity.SingularityDeployHistory) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) SingularityDeployStatistics(com.hubspot.singularity.SingularityDeployStatistics)

Aggregations

SingularityDeployMarker (com.hubspot.singularity.SingularityDeployMarker)11 SingularityDeploy (com.hubspot.singularity.SingularityDeploy)5 SingularityDeployResult (com.hubspot.singularity.SingularityDeployResult)4 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)4 SingularityRequest (com.hubspot.singularity.SingularityRequest)3 SingularityRequestDeployState (com.hubspot.singularity.SingularityRequestDeployState)3 SingularityDeployBuilder (com.hubspot.singularity.SingularityDeployBuilder)2 SingularityPendingDeploy (com.hubspot.singularity.SingularityPendingDeploy)2 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)2 ArrayList (java.util.ArrayList)2 SingularityCreateResult (com.hubspot.singularity.SingularityCreateResult)1 SingularityDeployHistory (com.hubspot.singularity.SingularityDeployHistory)1 SingularityDeployKey (com.hubspot.singularity.SingularityDeployKey)1 SingularityDeployProgress (com.hubspot.singularity.SingularityDeployProgress)1 SingularityDeployStatistics (com.hubspot.singularity.SingularityDeployStatistics)1 SingularityDeployUpdate (com.hubspot.singularity.SingularityDeployUpdate)1 SingularityHostState (com.hubspot.singularity.SingularityHostState)1 SingularityPendingRequest (com.hubspot.singularity.SingularityPendingRequest)1 SingularityRack (com.hubspot.singularity.SingularityRack)1 SingularityRequestHistory (com.hubspot.singularity.SingularityRequestHistory)1