From 1a2135a0eaddc24d3db3b42f1ae8c7a1be157bc8 Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Wed, 1 May 2013 12:26:36 +0300 Subject: [PATCH] TaskStorageQueryAdapter: Fix getSameGroupMergedStatus for nonexistent tasks --- .../druid/merger/coordinator/TaskStorageQueryAdapter.java | 5 ++++- .../metamx/druid/merger/coordinator/TaskLifecycleTest.java | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/merger/src/main/java/com/metamx/druid/merger/coordinator/TaskStorageQueryAdapter.java b/merger/src/main/java/com/metamx/druid/merger/coordinator/TaskStorageQueryAdapter.java index 983bf47e502..3680f57c253 100644 --- a/merger/src/main/java/com/metamx/druid/merger/coordinator/TaskStorageQueryAdapter.java +++ b/merger/src/main/java/com/metamx/druid/merger/coordinator/TaskStorageQueryAdapter.java @@ -109,11 +109,14 @@ public class TaskStorageQueryAdapter int nSuccesses = 0; int nFailures = 0; int nTotal = 0; + int nPresent = 0; for(final Optional statusOption : statuses.values()) { nTotal ++; if(statusOption.isPresent()) { + nPresent ++; + final TaskStatus status = statusOption.get(); if(status.isSuccess()) { @@ -126,7 +129,7 @@ public class TaskStorageQueryAdapter final Optional status; - if(nTotal == 0) { + if(nPresent == 0) { status = Optional.absent(); } else if(nSuccesses == nTotal) { status = Optional.of(TaskStatus.success(taskid)); diff --git a/merger/src/test/java/com/metamx/druid/merger/coordinator/TaskLifecycleTest.java b/merger/src/test/java/com/metamx/druid/merger/coordinator/TaskLifecycleTest.java index 3f89ff56f43..0134984f6cd 100644 --- a/merger/src/test/java/com/metamx/druid/merger/coordinator/TaskLifecycleTest.java +++ b/merger/src/test/java/com/metamx/druid/merger/coordinator/TaskLifecycleTest.java @@ -19,6 +19,7 @@ package com.metamx.druid.merger.coordinator; +import com.google.common.base.Optional; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -206,6 +207,9 @@ public class TaskLifecycleTest -1 ); + final Optional preRunTaskStatus = tsqa.getSameGroupMergedStatus(indexTask.getId()); + Assert.assertTrue("pre run task status not present", !preRunTaskStatus.isPresent()); + final TaskStatus mergedStatus = runTask(indexTask); final TaskStatus status = ts.getStatus(indexTask.getId()).get(); final List publishedSegments = byIntervalOrdering.sortedCopy(mdc.getPublished());