public SingularityCreateResult saveDeployResult(SingularityDeployMarker deployMarker, Optional<SingularityDeploy> deploy, SingularityDeployResult result) { singularityEventListener.deployHistoryEvent(new SingularityDeployUpdate(deployMarker, deploy, DeployEventType.FINISHED, Optional.of(result))); return save(getDeployResultPath(deployMarker.getRequestId(), deployMarker.getDeployId()), result, deployStateTranscoder); }
private String getDeployUpdateId(SingularityDeployUpdate deployUpdate) { return SingularityDeployKey.fromDeployMarker(deployUpdate.getDeployMarker()) + "-" + deployUpdate.getEventType().name(); }
private String applyPlaceholders(String uri, SingularityDeployUpdate deployUpdate) { return uri .replaceAll("\\$REQUEST_ID", deployUpdate.getDeployMarker().getRequestId()) .replaceAll("\\$DEPLOY_ID", deployUpdate.getDeployMarker().getDeployId()); }
private int checkDeployUpdates(SingularityWebhook webhook, List<CompletableFuture<Response>> webhookFutures) { final List<SingularityDeployUpdate> deployUpdates = webhookManager.getQueuedDeployUpdatesForHook(webhook.getId()); int numDeployUpdates = 0; for (SingularityDeployUpdate deployUpdate : deployUpdates) { String concreteUri = applyPlaceholders(webhook.getUri(), deployUpdate); webhookFutures.add(webhookSemaphore.call(() -> executeWebhookAsync( concreteUri, deployUpdate, new SingularityDeployWebhookAsyncHandler(webhookManager, webhook, deployUpdate, shouldDeleteUpdateOnFailure(numDeployUpdates, deployUpdate.getDeployMarker().getTimestamp()))) )); } return deployUpdates.size(); }
private String getDeployUpdateId(SingularityDeployUpdate deployUpdate) { return SingularityDeployKey.fromDeployMarker(deployUpdate.getDeployMarker()) + "-" + deployUpdate.getEventType().name(); }
private String applyPlaceholders(String uri, SingularityDeployUpdate deployUpdate) { return uri .replaceAll("\\$REQUEST_ID", deployUpdate.getDeployMarker().getRequestId()) .replaceAll("\\$DEPLOY_ID", deployUpdate.getDeployMarker().getDeployId()); }
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); }
private int checkDeployUpdates(SingularityWebhook webhook, List<CompletableFuture<Response>> webhookFutures) { final List<SingularityDeployUpdate> deployUpdates = webhookManager.getQueuedDeployUpdatesForHook(webhook.getId()); int numDeployUpdates = 0; for (SingularityDeployUpdate deployUpdate : deployUpdates) { String concreteUri = applyPlaceholders(webhook.getUri(), deployUpdate); webhookFutures.add(webhookSemaphore.call(() -> executeWebhookAsync( concreteUri, deployUpdate, new SingularityDeployWebhookAsyncHandler(webhookManager, webhook, deployUpdate, shouldDeleteUpdateOnFailure(numDeployUpdates, deployUpdate.getDeployMarker().getTimestamp()))) )); } return deployUpdates.size(); }
public SingularityCreateResult saveDeployResult(SingularityDeployMarker deployMarker, Optional<SingularityDeploy> deploy, SingularityDeployResult result) { singularityEventListener.deployHistoryEvent(new SingularityDeployUpdate(deployMarker, deploy, DeployEventType.FINISHED, Optional.of(result))); return save(getDeployResultPath(deployMarker.getRequestId(), deployMarker.getDeployId()), result, deployStateTranscoder); }
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); }