Search in sources :

Example 1 with SingularityTaskWebhook

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

the class SingularityWebhookSender method checkTaskUpdates.

private int checkTaskUpdates(SingularityWebhook webhook, List<CompletableFuture<Response>> webhookFutures) {
    final List<SingularityTaskHistoryUpdate> taskUpdates = webhookManager.getQueuedTaskUpdatesForHook(webhook.getId());
    int numTaskUpdates = 0;
    for (SingularityTaskHistoryUpdate taskUpdate : taskUpdates) {
        Optional<SingularityTask> task = taskHistoryHelper.getTask(taskUpdate.getTaskId());
        // TODO compress
        if (!task.isPresent()) {
            LOG.warn("Couldn't find task for taskUpdate {}", taskUpdate);
            webhookManager.deleteTaskUpdate(webhook, taskUpdate);
            continue;
        }
        webhookFutures.add(webhookSemaphore.call(() -> executeWebhookAsync(webhook, new SingularityTaskWebhook(task.get(), taskUpdate), new SingularityTaskWebhookAsyncHandler(webhookManager, webhook, taskUpdate, shouldDeleteUpdateOnFailure(numTaskUpdates, taskUpdate.getTimestamp())))));
    }
    return taskUpdates.size();
}
Also used : SingularityTask(com.hubspot.singularity.SingularityTask) SingularityTaskHistoryUpdate(com.hubspot.singularity.SingularityTaskHistoryUpdate) SingularityTaskWebhook(com.hubspot.singularity.SingularityTaskWebhook)

Aggregations

SingularityTask (com.hubspot.singularity.SingularityTask)1 SingularityTaskHistoryUpdate (com.hubspot.singularity.SingularityTaskHistoryUpdate)1 SingularityTaskWebhook (com.hubspot.singularity.SingularityTaskWebhook)1