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