Search in sources :

Example 51 with SingularityDeploy

use of com.hubspot.singularity.SingularityDeploy 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)

Example 52 with SingularityDeploy

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

the class RequestHelper method getTaskIdsByStatusForRequest.

private Optional<SingularityTaskIdsByStatus> getTaskIdsByStatusForRequest(SingularityRequestWithState requestWithState) {
    String requestId = requestWithState.getRequest().getId();
    Optional<SingularityPendingDeploy> pendingDeploy = deployManager.getPendingDeploy(requestId);
    List<SingularityTaskId> cleaningTaskIds = taskManager.getCleanupTaskIds().stream().filter((t) -> t.getRequestId().equals(requestId)).collect(Collectors.toList());
    List<SingularityPendingTaskId> pendingTaskIds = taskManager.getPendingTaskIdsForRequest(requestId);
    List<SingularityTaskId> activeTaskIds = taskManager.getActiveTaskIdsForRequest(requestId);
    activeTaskIds.removeAll(cleaningTaskIds);
    List<SingularityTaskId> healthyTaskIds = new ArrayList<>();
    List<SingularityTaskId> notYetHealthyTaskIds = new ArrayList<>();
    Map<String, List<SingularityTaskId>> taskIdsByDeployId = activeTaskIds.stream().collect(Collectors.groupingBy(SingularityTaskId::getDeployId));
    for (Map.Entry<String, List<SingularityTaskId>> entry : taskIdsByDeployId.entrySet()) {
        Optional<SingularityDeploy> deploy = deployManager.getDeploy(requestId, entry.getKey());
        List<SingularityTaskId> healthyTasksIdsForDeploy = deployHealthHelper.getHealthyTasks(requestWithState.getRequest(), deploy, entry.getValue(), pendingDeploy.isPresent() && pendingDeploy.get().getDeployMarker().getDeployId().equals(entry.getKey()));
        for (SingularityTaskId taskId : entry.getValue()) {
            if (healthyTasksIdsForDeploy.contains(taskId)) {
                healthyTaskIds.add(taskId);
            } else {
                notYetHealthyTaskIds.add(taskId);
            }
        }
    }
    return Optional.of(new SingularityTaskIdsByStatus(healthyTaskIds, notYetHealthyTaskIds, pendingTaskIds, cleaningTaskIds));
}
Also used : DeployManager(com.hubspot.singularity.data.DeployManager) Inject(com.google.inject.Inject) SingularityRequestCleanup(com.hubspot.singularity.SingularityRequestCleanup) RequestManager(com.hubspot.singularity.data.RequestManager) LoggerFactory(org.slf4j.LoggerFactory) SingularityUserSettings(com.hubspot.singularity.SingularityUserSettings) SingularityExpiringScale(com.hubspot.singularity.expiring.SingularityExpiringScale) SingularityBounceRequest(com.hubspot.singularity.api.SingularityBounceRequest) RequestHistoryType(com.hubspot.singularity.SingularityRequestHistory.RequestHistoryType) SingularityExpiringBounce(com.hubspot.singularity.expiring.SingularityExpiringBounce) Optional(com.google.common.base.Optional) Map(java.util.Map) SingularityValidator(com.hubspot.singularity.data.SingularityValidator) TaskManager(com.hubspot.singularity.data.TaskManager) SingularityPendingTaskId(com.hubspot.singularity.SingularityPendingTaskId) SingularityTaskId(com.hubspot.singularity.SingularityTaskId) UserManager(com.hubspot.singularity.data.UserManager) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SingularityExpiringSkipHealthchecks(com.hubspot.singularity.expiring.SingularityExpiringSkipHealthchecks) UUID(java.util.UUID) SingularityExpiringPause(com.hubspot.singularity.expiring.SingularityExpiringPause) Collectors(java.util.stream.Collectors) RequestState(com.hubspot.singularity.RequestState) PendingType(com.hubspot.singularity.SingularityPendingRequest.PendingType) List(java.util.List) JavaUtils(com.hubspot.mesos.JavaUtils) TaskHistoryHelper(com.hubspot.singularity.data.history.TaskHistoryHelper) RequestCleanupType(com.hubspot.singularity.RequestCleanupType) Singleton(com.google.inject.Singleton) SingularityCreateResult(com.hubspot.singularity.SingularityCreateResult) SingularityRequestWithState(com.hubspot.singularity.SingularityRequestWithState) SingularityTaskHistoryQuery(com.hubspot.singularity.SingularityTaskHistoryQuery) SingularityRequest(com.hubspot.singularity.SingularityRequest) SingularityTaskHistoryUpdate(com.hubspot.singularity.SingularityTaskHistoryUpdate) SingularityRequestHistory(com.hubspot.singularity.SingularityRequestHistory) SingularityTaskIdHistory(com.hubspot.singularity.SingularityTaskIdHistory) SingularityUser(com.hubspot.singularity.SingularityUser) SingularityPendingRequest(com.hubspot.singularity.SingularityPendingRequest) CompletableFuture(java.util.concurrent.CompletableFuture) SingularityTaskIdsByStatus(com.hubspot.singularity.SingularityTaskIdsByStatus) ArrayList(java.util.ArrayList) RequestType(com.hubspot.singularity.RequestType) SingularityDeployHealthHelper(com.hubspot.singularity.scheduler.SingularityDeployHealthHelper) Logger(org.slf4j.Logger) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) SingularityPendingDeploy(com.hubspot.singularity.SingularityPendingDeploy) SingularityMailer(com.hubspot.singularity.smtp.SingularityMailer) SingularityRequestDeployState(com.hubspot.singularity.SingularityRequestDeployState) SingularityRequestParent(com.hubspot.singularity.SingularityRequestParent) Collections(java.util.Collections) SingularityPendingTaskId(com.hubspot.singularity.SingularityPendingTaskId) ArrayList(java.util.ArrayList) SingularityDeploy(com.hubspot.singularity.SingularityDeploy) SingularityPendingDeploy(com.hubspot.singularity.SingularityPendingDeploy) List(java.util.List) ArrayList(java.util.ArrayList) SingularityTaskIdsByStatus(com.hubspot.singularity.SingularityTaskIdsByStatus) SingularityTaskId(com.hubspot.singularity.SingularityTaskId) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

SingularityDeploy (com.hubspot.singularity.SingularityDeploy)52 Test (org.junit.Test)38 SingularityRequest (com.hubspot.singularity.SingularityRequest)30 SingularityDeployBuilder (com.hubspot.singularity.SingularityDeployBuilder)27 SingularityRequestBuilder (com.hubspot.singularity.SingularityRequestBuilder)22 SingularityTask (com.hubspot.singularity.SingularityTask)12 SingularityTaskRequest (com.hubspot.singularity.SingularityTaskRequest)11 SingularityDeployRequest (com.hubspot.singularity.api.SingularityDeployRequest)10 HealthcheckOptions (com.hubspot.deploy.HealthcheckOptions)9 HealthcheckOptionsBuilder (com.hubspot.deploy.HealthcheckOptionsBuilder)9 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)8 SingularityMesosTaskHolder (com.hubspot.singularity.helpers.SingularityMesosTaskHolder)8 SingularityTaskHealthcheckResult (com.hubspot.singularity.SingularityTaskHealthcheckResult)7 Resources (com.hubspot.mesos.Resources)6 SingularityRunNowRequest (com.hubspot.singularity.api.SingularityRunNowRequest)6 SingularityDeployMarker (com.hubspot.singularity.SingularityDeployMarker)5 SingularityPendingTaskId (com.hubspot.singularity.SingularityPendingTaskId)5 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)5 ArrayList (java.util.ArrayList)5 SingularityContainerInfo (com.hubspot.mesos.SingularityContainerInfo)4