From 0244172ccbd7a29ad1584c252f0a35c230f6cae8 Mon Sep 17 00:00:00 2001 From: jisookim0513 Date: Thu, 19 Jun 2014 18:22:36 -0700 Subject: [PATCH] change missigSegments to a static variable --- .../java/io/druid/query/RetryQueryRunner.java | 4 +-- .../spec/SpecificSegmentQueryRunner.java | 2 +- .../io/druid/query/RetryQueryRunnerTest.java | 6 ++-- .../timeseries/TimeseriesQueryRunnerTest.java | 28 +++++++++---------- .../io/druid/client/DirectDruidClient.java | 2 +- .../java/io/druid/server/QueryResource.java | 5 ++-- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/processing/src/main/java/io/druid/query/RetryQueryRunner.java b/processing/src/main/java/io/druid/query/RetryQueryRunner.java index a6f267c371a..62d7b4e8da4 100644 --- a/processing/src/main/java/io/druid/query/RetryQueryRunner.java +++ b/processing/src/main/java/io/druid/query/RetryQueryRunner.java @@ -30,7 +30,7 @@ import java.util.Map; public class RetryQueryRunner implements QueryRunner { - public static String missingSegments = "missingSegments"; + public static String missingSegments = RetryQueryRunner.missingSegments; private final QueryRunner baseRunner; private final QueryToolChest> toolChest; private final RetryQueryRunnerConfig config; @@ -74,7 +74,7 @@ public class RetryQueryRunner implements QueryRunner if (!config.returnPartialResults() && !((List) context.get(missingSegments)).isEmpty()) { String failedSegments = ""; - for (SegmentDescriptor segment : (List) context.get("missingSegments")) { + for (SegmentDescriptor segment : (List) context.get(RetryQueryRunner.missingSegments)) { failedSegments = failedSegments + segment.toString() + " "; } throw new SegmentMissingException("The following segments are missing: " + failedSegments); diff --git a/processing/src/main/java/io/druid/query/spec/SpecificSegmentQueryRunner.java b/processing/src/main/java/io/druid/query/spec/SpecificSegmentQueryRunner.java index 9a457b96e04..add0b2c754e 100644 --- a/processing/src/main/java/io/druid/query/spec/SpecificSegmentQueryRunner.java +++ b/processing/src/main/java/io/druid/query/spec/SpecificSegmentQueryRunner.java @@ -68,7 +68,7 @@ public class SpecificSegmentQueryRunner implements QueryRunner try { returningSeq = base.run(query, context); } catch (SegmentMissingException e) { - ((List)context.get("missingSegments")).add(((SpecificSegmentSpec) specificSpec).getDescriptor()); + ((List)context.get(RetryQueryRunner.missingSegments)).add(((SpecificSegmentSpec) specificSpec).getDescriptor()); returningSeq = Sequences.empty(); } return returningSeq; diff --git a/processing/src/test/java/io/druid/query/RetryQueryRunnerTest.java b/processing/src/test/java/io/druid/query/RetryQueryRunnerTest.java index 8391d36544a..595f3133ec6 100644 --- a/processing/src/test/java/io/druid/query/RetryQueryRunnerTest.java +++ b/processing/src/test/java/io/druid/query/RetryQueryRunnerTest.java @@ -48,7 +48,7 @@ public class RetryQueryRunnerTest public void testRunWithMissingSegments() throws Exception { Map context = new MapMaker().makeMap(); - context.put("missingSegments", Lists.newArrayList()); + context.put(RetryQueryRunner.missingSegments, Lists.newArrayList()); RetryQueryRunner runner = new RetryQueryRunner( new QueryRunner() { @@ -122,7 +122,7 @@ public class RetryQueryRunnerTest { Map context = new MapMaker().makeMap(); context.put("count", 0); - context.put("missingSegments", Lists.newArrayList()); + context.put(RetryQueryRunner.missingSegments, Lists.newArrayList()); RetryQueryRunner runner = new RetryQueryRunner( new QueryRunner() { @@ -214,7 +214,7 @@ public class RetryQueryRunnerTest public void testException() throws Exception { Map context = new MapMaker().makeMap(); - context.put("missingSegments", Lists.newArrayList()); + context.put(RetryQueryRunner.missingSegments, Lists.newArrayList()); RetryQueryRunner runner = new RetryQueryRunner( new QueryRunner() { diff --git a/processing/src/test/java/io/druid/query/timeseries/TimeseriesQueryRunnerTest.java b/processing/src/test/java/io/druid/query/timeseries/TimeseriesQueryRunnerTest.java index acd60aa051e..1d1fcb21b00 100644 --- a/processing/src/test/java/io/druid/query/timeseries/TimeseriesQueryRunnerTest.java +++ b/processing/src/test/java/io/druid/query/timeseries/TimeseriesQueryRunnerTest.java @@ -252,20 +252,20 @@ public class TimeseriesQueryRunnerTest public void testTimeseries() { TimeseriesQuery query = Druids.newTimeseriesQueryBuilder() - .dataSource(QueryRunnerTestHelper.dataSource) - .granularity(QueryRunnerTestHelper.dayGran) - .intervals(QueryRunnerTestHelper.firstToThird) - .aggregators( - Arrays.asList( - QueryRunnerTestHelper.rowsCount, - new LongSumAggregatorFactory( - "idx", - "index" - ), - QueryRunnerTestHelper.qualityUniques - ) - ) - .build(); + .dataSource(QueryRunnerTestHelper.dataSource) + .granularity(QueryRunnerTestHelper.dayGran) + .intervals(QueryRunnerTestHelper.firstToThird) + .aggregators( + Arrays.asList( + QueryRunnerTestHelper.rowsCount, + new LongSumAggregatorFactory( + "idx", + "index" + ), + QueryRunnerTestHelper.qualityUniques + ) + ) + .build(); List> expectedResults = Arrays.asList( new Result( diff --git a/server/src/main/java/io/druid/client/DirectDruidClient.java b/server/src/main/java/io/druid/client/DirectDruidClient.java index e69cea4e417..204da241ff9 100644 --- a/server/src/main/java/io/druid/client/DirectDruidClient.java +++ b/server/src/main/java/io/druid/client/DirectDruidClient.java @@ -178,7 +178,7 @@ public class DirectDruidClient implements QueryRunner catch (IOException e) { e.printStackTrace(); } - ((List) context.get("missingSegments")).addAll(missingSegments); + ((List) context.get(RetryQueryRunner.missingSegments)).addAll(missingSegments); return super.handleResponse(response); } diff --git a/server/src/main/java/io/druid/server/QueryResource.java b/server/src/main/java/io/druid/server/QueryResource.java index ce6e255cd0d..dffb66de79d 100644 --- a/server/src/main/java/io/druid/server/QueryResource.java +++ b/server/src/main/java/io/druid/server/QueryResource.java @@ -42,6 +42,7 @@ import io.druid.query.DataSourceUtil; import io.druid.query.Query; import io.druid.query.QueryInterruptedException; import io.druid.query.QuerySegmentWalker; +import io.druid.query.RetryQueryRunner; import io.druid.server.log.RequestLogger; import org.joda.time.DateTime; @@ -144,7 +145,7 @@ public class QueryResource } Map context = new MapMaker().makeMap(); - context.put("missingSegments", Lists.newArrayList()); + context.put(RetryQueryRunner.missingSegments, Lists.newArrayList()); Sequence results = query.run(texasRanger, context); if (results == null) { @@ -167,7 +168,7 @@ public class QueryResource ) { String headerContext = ""; - if (!((List)context.get("missingSegments")).isEmpty()) { + if (!((List)context.get(RetryQueryRunner.missingSegments)).isEmpty()) { headerContext = jsonMapper.writeValueAsString(context); }