From 666d7857875bd056d91ae84c498eb0b45e22420c Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Fri, 20 Nov 2015 09:09:49 -0800 Subject: [PATCH] Switch TaskActions from Optionals to nullable. Deserialization of Optionals does not work quite right- they come back as actual nulls, rather than absent Optionals. So these probably only ever worked for the local task action client. --- .../common/actions/LockTryAcquireAction.java | 11 +++++------ .../common/actions/SegmentAllocateAction.java | 18 ++++++++---------- .../common/task/AbstractFixedIntervalTask.java | 2 +- .../indexing/common/task/HadoopIndexTask.java | 2 +- .../actions/SegmentAllocateActionTest.java | 2 +- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/indexing-service/src/main/java/io/druid/indexing/common/actions/LockTryAcquireAction.java b/indexing-service/src/main/java/io/druid/indexing/common/actions/LockTryAcquireAction.java index c059352e3aa..78c0a8ed92a 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/actions/LockTryAcquireAction.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/actions/LockTryAcquireAction.java @@ -21,12 +21,11 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.type.TypeReference; -import com.google.common.base.Optional; import io.druid.indexing.common.TaskLock; import io.druid.indexing.common.task.Task; import org.joda.time.Interval; -public class LockTryAcquireAction implements TaskAction> +public class LockTryAcquireAction implements TaskAction { @JsonIgnore private final Interval interval; @@ -45,17 +44,17 @@ public class LockTryAcquireAction implements TaskAction> return interval; } - public TypeReference> getReturnTypeReference() + public TypeReference getReturnTypeReference() { - return new TypeReference>() + return new TypeReference() { }; } @Override - public Optional perform(Task task, TaskActionToolbox toolbox) + public TaskLock perform(Task task, TaskActionToolbox toolbox) { - return toolbox.getTaskLockbox().tryLock(task, interval); + return toolbox.getTaskLockbox().tryLock(task, interval).orNull(); } @Override diff --git a/indexing-service/src/main/java/io/druid/indexing/common/actions/SegmentAllocateAction.java b/indexing-service/src/main/java/io/druid/indexing/common/actions/SegmentAllocateAction.java index 8cb7dcc0f2d..fc7a33a3ee4 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/actions/SegmentAllocateAction.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/actions/SegmentAllocateAction.java @@ -24,7 +24,6 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.api.client.repackaged.com.google.common.base.Preconditions; import com.google.api.client.repackaged.com.google.common.base.Throwables; import com.google.api.client.util.Lists; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import com.google.common.primitives.Longs; import com.metamx.common.Granularity; @@ -53,10 +52,9 @@ import java.util.Set; * This action implicitly acquires locks when it allocates segments. You do not have to acquire them beforehand, * although you *do* have to release them yourself. *

- * If this action cannot acquire an appropriate lock, or if it cannot expand an existing segment set, it will return - * a missing Optional. + * If this action cannot acquire an appropriate lock, or if it cannot expand an existing segment set, it returns null. */ -public class SegmentAllocateAction implements TaskAction> +public class SegmentAllocateAction implements TaskAction { private static final Logger log = new Logger(SegmentAllocateAction.class); @@ -150,15 +148,15 @@ public class SegmentAllocateAction implements TaskAction> getReturnTypeReference() + public TypeReference getReturnTypeReference() { - return new TypeReference>() + return new TypeReference() { }; } @Override - public Optional perform( + public SegmentIdentifier perform( final Task task, final TaskActionToolbox toolbox ) throws IOException @@ -215,7 +213,7 @@ public class SegmentAllocateAction implements TaskAction