diff --git a/server/src/main/java/com/metamx/druid/coordination/ServerManager.java b/server/src/main/java/com/metamx/druid/coordination/ServerManager.java index 47a3f878b6d..d7655af964d 100644 --- a/server/src/main/java/com/metamx/druid/coordination/ServerManager.java +++ b/server/src/main/java/com/metamx/druid/coordination/ServerManager.java @@ -104,7 +104,7 @@ public class ServerManager implements QuerySegmentWalker } } - public boolean isSegmentLoaded(final DataSegment segment) throws SegmentLoadingException + public boolean isSegmentCached(final DataSegment segment) throws SegmentLoadingException { return segmentLoader.isSegmentLoaded(segment); } diff --git a/server/src/main/java/com/metamx/druid/coordination/ZkCoordinator.java b/server/src/main/java/com/metamx/druid/coordination/ZkCoordinator.java index 56e9e1a6596..11fa98093f7 100644 --- a/server/src/main/java/com/metamx/druid/coordination/ZkCoordinator.java +++ b/server/src/main/java/com/metamx/druid/coordination/ZkCoordinator.java @@ -216,7 +216,7 @@ public class ZkCoordinator implements DataSegmentChangeHandler log.info("Loading segment cache file [%s]", file); try { DataSegment segment = jsonMapper.readValue(file, DataSegment.class); - if (serverManager.isSegmentLoaded(segment)) { + if (serverManager.isSegmentCached(segment)) { addSegment(segment); } } diff --git a/server/src/test/java/com/metamx/druid/coordination/ZkCoordinatorTest.java b/server/src/test/java/com/metamx/druid/coordination/ZkCoordinatorTest.java index 99019ef5568..54811e1ad4d 100644 --- a/server/src/test/java/com/metamx/druid/coordination/ZkCoordinatorTest.java +++ b/server/src/test/java/com/metamx/druid/coordination/ZkCoordinatorTest.java @@ -30,7 +30,7 @@ import com.metamx.druid.client.DruidServerConfig; import com.metamx.druid.client.ZKPhoneBook; import com.metamx.druid.index.v1.IndexIO; import com.metamx.druid.jackson.DefaultObjectMapper; -import com.metamx.druid.loading.NoopSegmentLoader; +import com.metamx.druid.loading.CacheTestSegmentLoader; import com.metamx.druid.metrics.NoopServiceEmitter; import com.metamx.druid.query.NoopQueryRunnerFactoryConglomerate; import com.metamx.druid.shard.NoneShardSpec; @@ -74,7 +74,7 @@ public class ZkCoordinatorTest } serverManager = new ServerManager( - new NoopSegmentLoader(), + new CacheTestSegmentLoader(), new NoopQueryRunnerFactoryConglomerate(), new NoopServiceEmitter(), MoreExecutors.sameThreadExecutor() @@ -194,7 +194,7 @@ public class ZkCoordinatorTest dataSource, interval, version, - ImmutableMap.of("version", version, "interval", interval), + ImmutableMap.of("version", version, "interval", interval, "cacheDir", cacheDir), Arrays.asList("dim1", "dim2", "dim3"), Arrays.asList("metric1", "metric2"), new NoneShardSpec(), diff --git a/server/src/test/java/com/metamx/druid/loading/NoopSegmentLoader.java b/server/src/test/java/com/metamx/druid/loading/CacheTestSegmentLoader.java similarity index 87% rename from server/src/test/java/com/metamx/druid/loading/NoopSegmentLoader.java rename to server/src/test/java/com/metamx/druid/loading/CacheTestSegmentLoader.java index 3a69cfbd8dc..e9be482116e 100644 --- a/server/src/test/java/com/metamx/druid/loading/NoopSegmentLoader.java +++ b/server/src/test/java/com/metamx/druid/loading/CacheTestSegmentLoader.java @@ -19,20 +19,25 @@ package com.metamx.druid.loading; +import com.metamx.common.MapUtils; import com.metamx.druid.StorageAdapter; import com.metamx.druid.client.DataSegment; import com.metamx.druid.index.QueryableIndex; import com.metamx.druid.index.Segment; import org.joda.time.Interval; +import java.io.File; +import java.util.Map; + /** */ -public class NoopSegmentLoader implements SegmentLoader +public class CacheTestSegmentLoader implements SegmentLoader { @Override public boolean isSegmentLoaded(DataSegment segment) throws SegmentLoadingException { - return false; + Map loadSpec = segment.getLoadSpec(); + return new File(MapUtils.getString(loadSpec, "cacheDir")).exists(); } @Override