Search in sources :

Example 1 with SingularityDeployUpdate

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

the class DeployManager method saveDeploy.

public SingularityCreateResult saveDeploy(SingularityRequest request, SingularityDeployMarker deployMarker, SingularityDeploy deploy) {
    final SingularityCreateResult deploySaveResult = create(getDeployDataPath(deploy.getRequestId(), deploy.getId()), deploy, deployTranscoder);
    if (deploySaveResult == SingularityCreateResult.EXISTED) {
        LOG.info("Deploy object for {} already existed (new marker: {})", deploy, deployMarker);
    }
    singularityEventListener.deployHistoryEvent(new SingularityDeployUpdate(deployMarker, Optional.of(deploy), DeployEventType.STARTING, Optional.<SingularityDeployResult>absent()));
    create(getDeployMarkerPath(deploy.getRequestId(), deploy.getId()), deployMarker, deployMarkerTranscoder);
    final Optional<SingularityRequestDeployState> currentState = getRequestDeployState(deploy.getRequestId());
    Optional<SingularityDeployMarker> activeDeploy = Optional.absent();
    Optional<SingularityDeployMarker> pendingDeploy = Optional.absent();
    if (request.isDeployable()) {
        if (currentState.isPresent()) {
            activeDeploy = currentState.get().getActiveDeploy();
        }
        pendingDeploy = Optional.of(deployMarker);
    } else {
        activeDeploy = Optional.of(deployMarker);
    }
    final SingularityRequestDeployState newState = new SingularityRequestDeployState(deploy.getRequestId(), activeDeploy, pendingDeploy);
    return saveNewRequestDeployState(newState);
}
Also used : SingularityDeployResult(com.hubspot.singularity.SingularityDeployResult) SingularityDeployMarker(com.hubspot.singularity.SingularityDeployMarker) SingularityDeployUpdate(com.hubspot.singularity.SingularityDeployUpdate) SingularityCreateResult(com.hubspot.singularity.SingularityCreateResult) SingularityRequestDeployState(com.hubspot.singularity.SingularityRequestDeployState)

Example 2 with SingularityDeployUpdate

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

the class SingularityWebhookSender method checkDeployUpdates.

private int checkDeployUpdates(SingularityWebhook webhook, List<CompletableFuture<Response>> webhookFutures) {
    final List<SingularityDeployUpdate> deployUpdates = webhookManager.getQueuedDeployUpdatesForHook(webhook.getId());
    int numDeployUpdates = 0;
    for (SingularityDeployUpdate deployUpdate : deployUpdates) {
        webhookFutures.add(webhookSemaphore.call(() -> executeWebhookAsync(webhook, deployUpdate, new SingularityDeployWebhookAsyncHandler(webhookManager, webhook, deployUpdate, shouldDeleteUpdateOnFailure(numDeployUpdates, deployUpdate.getDeployMarker().getTimestamp())))));
    }
    return deployUpdates.size();
}
Also used : SingularityDeployUpdate(com.hubspot.singularity.SingularityDeployUpdate)

Aggregations

SingularityDeployUpdate (com.hubspot.singularity.SingularityDeployUpdate)2 SingularityCreateResult (com.hubspot.singularity.SingularityCreateResult)1 SingularityDeployMarker (com.hubspot.singularity.SingularityDeployMarker)1 SingularityDeployResult (com.hubspot.singularity.SingularityDeployResult)1 SingularityRequestDeployState (com.hubspot.singularity.SingularityRequestDeployState)1