Search in sources :

Example 1 with SingularityDeployHistory

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

the class DeployHistoryHelper method getFromZk.

@Override
protected List<SingularityDeployHistory> getFromZk(String requestId) {
    final List<SingularityDeployKey> deployKeys = deployManager.getDeployIdsFor(requestId);
    final List<SingularityDeployHistory> histories = Lists.newArrayListWithCapacity(deployKeys.size());
    for (SingularityDeployKey key : deployKeys) {
        Optional<SingularityDeployHistory> deployHistory = deployManager.getDeployHistory(key.getRequestId(), key.getDeployId(), false);
        if (deployHistory.isPresent()) {
            histories.add(deployHistory.get());
        }
    }
    Collections.sort(histories);
    return histories;
}
Also used : SingularityDeployKey(com.hubspot.singularity.SingularityDeployKey) SingularityDeployHistory(com.hubspot.singularity.SingularityDeployHistory)

Example 2 with SingularityDeployHistory

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

the class SingularityDeployHistoryPersister method runActionOnPoll.

@Override
public void runActionOnPoll() {
    LOG.info("Checking inactive deploys for deploy history persistance");
    final long start = System.currentTimeMillis();
    final List<SingularityDeployKey> allDeployIds = deployManager.getAllDeployIds();
    final Map<String, SingularityRequestDeployState> byRequestId = deployManager.getAllRequestDeployStatesByRequestId();
    final TreeMultimap<String, SingularityDeployHistory> deployHistoryByRequestId = TreeMultimap.create();
    int numTotal = 0;
    int numTransferred = 0;
    for (SingularityDeployKey deployKey : allDeployIds) {
        SingularityRequestDeployState deployState = byRequestId.get(deployKey.getRequestId());
        if (!shouldTransferDeploy(deployState, deployKey)) {
            continue;
        }
        Optional<SingularityDeployHistory> deployHistory = deployManager.getDeployHistory(deployKey.getRequestId(), deployKey.getDeployId(), true);
        if (deployHistory.isPresent()) {
            deployHistoryByRequestId.put(deployKey.getRequestId(), deployHistory.get());
        } else {
            LOG.info("Deploy history for key {} not found", deployKey);
        }
    }
    for (Collection<SingularityDeployHistory> deployHistoryForRequest : deployHistoryByRequestId.asMap().values()) {
        int i = 0;
        for (SingularityDeployHistory deployHistory : deployHistoryForRequest) {
            if (moveToHistoryOrCheckForPurge(deployHistory, i++)) {
                numTransferred++;
            }
            numTotal++;
        }
    }
    LOG.info("Transferred {} out of {} deploys in {}", numTransferred, numTotal, JavaUtils.duration(start));
}
Also used : SingularityDeployKey(com.hubspot.singularity.SingularityDeployKey) SingularityDeployHistory(com.hubspot.singularity.SingularityDeployHistory) SingularityRequestDeployState(com.hubspot.singularity.SingularityRequestDeployState)

Example 3 with SingularityDeployHistory

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

the class S3LogResource method getS3PrefixesForDeploy.

private Collection<String> getS3PrefixesForDeploy(S3Configuration s3Configuration, String requestId, String deployId, Optional<Long> startArg, Optional<Long> endArg, String group, SingularityUser user) {
    SingularityDeployHistory deployHistory = getDeployHistory(requestId, deployId, user);
    long start = deployHistory.getDeployMarker().getTimestamp();
    if (startArg.isPresent()) {
        start = Math.max(startArg.get(), start);
    }
    long end = System.currentTimeMillis();
    if (!isCurrentDeploy(requestId, deployId) && deployHistory.getDeployStatistics().isPresent() && deployHistory.getDeployStatistics().get().getLastFinishAt().isPresent()) {
        end = deployHistory.getDeployStatistics().get().getLastFinishAt().get() + TimeUnit.DAYS.toMillis(1);
    }
    if (endArg.isPresent()) {
        end = Math.min(endArg.get(), end);
    }
    Optional<String> tag = Optional.absent();
    if (deployHistory.getDeploy().isPresent() && deployHistory.getDeploy().get().getExecutorData().isPresent()) {
        tag = deployHistory.getDeploy().get().getExecutorData().get().getLoggingTag();
    }
    Collection<String> prefixes = SingularityS3FormatHelper.getS3KeyPrefixes(s3Configuration.getS3KeyFormat(), requestId, deployId, tag, start, end, group);
    for (SingularityS3UploaderFile additionalFile : s3Configuration.getS3UploaderAdditionalFiles()) {
        if (additionalFile.getS3UploaderKeyPattern().isPresent() && !additionalFile.getS3UploaderKeyPattern().get().equals(s3Configuration.getS3KeyFormat())) {
            prefixes.addAll(SingularityS3FormatHelper.getS3KeyPrefixes(additionalFile.getS3UploaderKeyPattern().get(), requestId, deployId, tag, start, end, group));
        }
    }
    LOG.trace("Request {}, deploy {} got S3 prefixes {} for start {}, end {}, tag {}", requestId, deployId, prefixes, start, end, tag);
    return prefixes;
}
Also used : SingularityDeployHistory(com.hubspot.singularity.SingularityDeployHistory) SingularityS3UploaderFile(com.hubspot.singularity.SingularityS3UploaderFile)

Example 4 with SingularityDeployHistory

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

SingularityDeployHistory (com.hubspot.singularity.SingularityDeployHistory)4 SingularityDeployKey (com.hubspot.singularity.SingularityDeployKey)2 SingularityDeploy (com.hubspot.singularity.SingularityDeploy)1 SingularityDeployMarker (com.hubspot.singularity.SingularityDeployMarker)1 SingularityDeployResult (com.hubspot.singularity.SingularityDeployResult)1 SingularityDeployStatistics (com.hubspot.singularity.SingularityDeployStatistics)1 SingularityRequestDeployState (com.hubspot.singularity.SingularityRequestDeployState)1 SingularityS3UploaderFile (com.hubspot.singularity.SingularityS3UploaderFile)1