mirror of https://github.com/apache/druid.git
TaskStorageQueryAdapter: Fix getSameGroupMergedStatus for nonexistent tasks
This commit is contained in:
parent
862365e1fa
commit
1a2135a0ea
|
@ -109,11 +109,14 @@ public class TaskStorageQueryAdapter
|
||||||
int nSuccesses = 0;
|
int nSuccesses = 0;
|
||||||
int nFailures = 0;
|
int nFailures = 0;
|
||||||
int nTotal = 0;
|
int nTotal = 0;
|
||||||
|
int nPresent = 0;
|
||||||
|
|
||||||
for(final Optional<TaskStatus> statusOption : statuses.values()) {
|
for(final Optional<TaskStatus> statusOption : statuses.values()) {
|
||||||
nTotal ++;
|
nTotal ++;
|
||||||
|
|
||||||
if(statusOption.isPresent()) {
|
if(statusOption.isPresent()) {
|
||||||
|
nPresent ++;
|
||||||
|
|
||||||
final TaskStatus status = statusOption.get();
|
final TaskStatus status = statusOption.get();
|
||||||
|
|
||||||
if(status.isSuccess()) {
|
if(status.isSuccess()) {
|
||||||
|
@ -126,7 +129,7 @@ public class TaskStorageQueryAdapter
|
||||||
|
|
||||||
final Optional<TaskStatus> status;
|
final Optional<TaskStatus> status;
|
||||||
|
|
||||||
if(nTotal == 0) {
|
if(nPresent == 0) {
|
||||||
status = Optional.absent();
|
status = Optional.absent();
|
||||||
} else if(nSuccesses == nTotal) {
|
} else if(nSuccesses == nTotal) {
|
||||||
status = Optional.of(TaskStatus.success(taskid));
|
status = Optional.of(TaskStatus.success(taskid));
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package com.metamx.druid.merger.coordinator;
|
package com.metamx.druid.merger.coordinator;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -206,6 +207,9 @@ public class TaskLifecycleTest
|
||||||
-1
|
-1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final Optional<TaskStatus> preRunTaskStatus = tsqa.getSameGroupMergedStatus(indexTask.getId());
|
||||||
|
Assert.assertTrue("pre run task status not present", !preRunTaskStatus.isPresent());
|
||||||
|
|
||||||
final TaskStatus mergedStatus = runTask(indexTask);
|
final TaskStatus mergedStatus = runTask(indexTask);
|
||||||
final TaskStatus status = ts.getStatus(indexTask.getId()).get();
|
final TaskStatus status = ts.getStatus(indexTask.getId()).get();
|
||||||
final List<DataSegment> publishedSegments = byIntervalOrdering.sortedCopy(mdc.getPublished());
|
final List<DataSegment> publishedSegments = byIntervalOrdering.sortedCopy(mdc.getPublished());
|
||||||
|
|
Loading…
Reference in New Issue