require default predicate in ServerInventoryViews

This commit is contained in:
Xavier Léauté 2014-05-29 17:07:38 -07:00
parent f32aee7804
commit ea7eaba735
5 changed files with 14 additions and 16 deletions

View File

@ -21,6 +21,7 @@ package io.druid.client;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; 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.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.collect.MapMaker; import com.google.common.collect.MapMaker;
@ -66,11 +67,8 @@ public class BatchServerInventoryView extends ServerInventoryView<Set<DataSegmen
new TypeReference<Set<DataSegment>>(){} new TypeReference<Set<DataSegment>>(){}
); );
if(defaultFilter != null) { Preconditions.checkNotNull(defaultFilter);
this.defaultFilter = defaultFilter; this.defaultFilter = defaultFilter;
} else {
this.defaultFilter = Predicates.alwaysTrue();
}
} }
@Override @Override

View File

@ -21,7 +21,9 @@ package io.druid.client;
import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Predicates;
import io.druid.server.initialization.ZkPathsConfig; import io.druid.server.initialization.ZkPathsConfig;
import io.druid.timeline.DataSegment;
import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFramework;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -45,6 +47,6 @@ public class BatchServerInventoryViewProvider implements ServerInventoryViewProv
@Override @Override
public BatchServerInventoryView get() public BatchServerInventoryView get()
{ {
return new BatchServerInventoryView(zkPaths, curator, jsonMapper, null); return new BatchServerInventoryView(zkPaths, curator, jsonMapper, Predicates.<DataSegment>alwaysTrue());
} }
} }

View File

@ -21,7 +21,9 @@ package io.druid.client;
import com.fasterxml.jackson.annotation.JacksonInject; import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Predicates;
import io.druid.server.initialization.ZkPathsConfig; import io.druid.server.initialization.ZkPathsConfig;
import io.druid.timeline.DataSegment;
import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFramework;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -45,6 +47,6 @@ public class SingleServerInventoryProvider implements ServerInventoryViewProvide
@Override @Override
public ServerInventoryView get() public ServerInventoryView get()
{ {
return new SingleServerInventoryView(zkPaths, curator, jsonMapper, null); return new SingleServerInventoryView(zkPaths, curator, jsonMapper, Predicates.<DataSegment>alwaysTrue());
} }
} }

View File

@ -21,10 +21,10 @@ package io.druid.client;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; 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.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.collect.MapMaker; import com.google.common.collect.MapMaker;
import com.google.common.collect.Sets;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.metamx.emitter.EmittingLogger; import com.metamx.emitter.EmittingLogger;
import io.druid.guice.ManageLifecycle; import io.druid.guice.ManageLifecycle;
@ -33,8 +33,6 @@ import io.druid.server.initialization.ZkPathsConfig;
import io.druid.timeline.DataSegment; import io.druid.timeline.DataSegment;
import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFramework;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
@ -65,11 +63,9 @@ public class SingleServerInventoryView extends ServerInventoryView<DataSegment>
new TypeReference<DataSegment>(){} new TypeReference<DataSegment>(){}
); );
if(defaultFilter != null) { Preconditions.checkNotNull(defaultFilter);
this.defaultFilter = defaultFilter; this.defaultFilter = defaultFilter;
} else { }
this.defaultFilter = Predicates.alwaysTrue();
} }
@Override @Override
protected DruidServer addInnerInventory( protected DruidServer addInnerInventory(

View File

@ -146,7 +146,7 @@ public class BatchServerInventoryViewTest
}, },
cf, cf,
jsonMapper, jsonMapper,
null Predicates.<DataSegment>alwaysTrue()
); );
batchServerInventoryView.start(); batchServerInventoryView.start();