From ea7eaba735fa946b9991dbba482c567d0dccfccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Thu, 29 May 2014 17:07:38 -0700 Subject: [PATCH] require default predicate in ServerInventoryViews --- .../io/druid/client/BatchServerInventoryView.java | 8 +++----- .../client/BatchServerInventoryViewProvider.java | 4 +++- .../druid/client/SingleServerInventoryProvider.java | 4 +++- .../io/druid/client/SingleServerInventoryView.java | 12 ++++-------- .../client/client/BatchServerInventoryViewTest.java | 2 +- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/server/src/main/java/io/druid/client/BatchServerInventoryView.java b/server/src/main/java/io/druid/client/BatchServerInventoryView.java index 2adf5eb9257..509c4a5c793 100644 --- a/server/src/main/java/io/druid/client/BatchServerInventoryView.java +++ b/server/src/main/java/io/druid/client/BatchServerInventoryView.java @@ -21,6 +21,7 @@ package io.druid.client; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.api.client.repackaged.com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.MapMaker; @@ -66,11 +67,8 @@ public class BatchServerInventoryView extends ServerInventoryView>(){} ); - if(defaultFilter != null) { - this.defaultFilter = defaultFilter; - } else { - this.defaultFilter = Predicates.alwaysTrue(); - } + Preconditions.checkNotNull(defaultFilter); + this.defaultFilter = defaultFilter; } @Override diff --git a/server/src/main/java/io/druid/client/BatchServerInventoryViewProvider.java b/server/src/main/java/io/druid/client/BatchServerInventoryViewProvider.java index dd9304f8a4a..c35fdc6fe74 100644 --- a/server/src/main/java/io/druid/client/BatchServerInventoryViewProvider.java +++ b/server/src/main/java/io/druid/client/BatchServerInventoryViewProvider.java @@ -21,7 +21,9 @@ package io.druid.client; import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Predicates; import io.druid.server.initialization.ZkPathsConfig; +import io.druid.timeline.DataSegment; import org.apache.curator.framework.CuratorFramework; import javax.validation.constraints.NotNull; @@ -45,6 +47,6 @@ public class BatchServerInventoryViewProvider implements ServerInventoryViewProv @Override public BatchServerInventoryView get() { - return new BatchServerInventoryView(zkPaths, curator, jsonMapper, null); + return new BatchServerInventoryView(zkPaths, curator, jsonMapper, Predicates.alwaysTrue()); } } diff --git a/server/src/main/java/io/druid/client/SingleServerInventoryProvider.java b/server/src/main/java/io/druid/client/SingleServerInventoryProvider.java index 214a2331b7c..6c572f59019 100644 --- a/server/src/main/java/io/druid/client/SingleServerInventoryProvider.java +++ b/server/src/main/java/io/druid/client/SingleServerInventoryProvider.java @@ -21,7 +21,9 @@ package io.druid.client; import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Predicates; import io.druid.server.initialization.ZkPathsConfig; +import io.druid.timeline.DataSegment; import org.apache.curator.framework.CuratorFramework; import javax.validation.constraints.NotNull; @@ -45,6 +47,6 @@ public class SingleServerInventoryProvider implements ServerInventoryViewProvide @Override public ServerInventoryView get() { - return new SingleServerInventoryView(zkPaths, curator, jsonMapper, null); + return new SingleServerInventoryView(zkPaths, curator, jsonMapper, Predicates.alwaysTrue()); } } diff --git a/server/src/main/java/io/druid/client/SingleServerInventoryView.java b/server/src/main/java/io/druid/client/SingleServerInventoryView.java index cafdd4dcc3a..4acdbabf786 100644 --- a/server/src/main/java/io/druid/client/SingleServerInventoryView.java +++ b/server/src/main/java/io/druid/client/SingleServerInventoryView.java @@ -21,10 +21,10 @@ package io.druid.client; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.api.client.repackaged.com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.MapMaker; -import com.google.common.collect.Sets; import com.google.inject.Inject; import com.metamx.emitter.EmittingLogger; import io.druid.guice.ManageLifecycle; @@ -33,8 +33,6 @@ import io.druid.server.initialization.ZkPathsConfig; import io.druid.timeline.DataSegment; import org.apache.curator.framework.CuratorFramework; -import java.util.Map; -import java.util.Set; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executor; @@ -65,11 +63,9 @@ public class SingleServerInventoryView extends ServerInventoryView new TypeReference(){} ); - if(defaultFilter != null) { - this.defaultFilter = defaultFilter; - } else { - this.defaultFilter = Predicates.alwaysTrue(); - } } + Preconditions.checkNotNull(defaultFilter); + this.defaultFilter = defaultFilter; + } @Override protected DruidServer addInnerInventory( diff --git a/server/src/test/java/io/druid/client/client/BatchServerInventoryViewTest.java b/server/src/test/java/io/druid/client/client/BatchServerInventoryViewTest.java index f19138a6621..720ee14bef8 100644 --- a/server/src/test/java/io/druid/client/client/BatchServerInventoryViewTest.java +++ b/server/src/test/java/io/druid/client/client/BatchServerInventoryViewTest.java @@ -146,7 +146,7 @@ public class BatchServerInventoryViewTest }, cf, jsonMapper, - null + Predicates.alwaysTrue() ); batchServerInventoryView.start();