change missigSegments to a static variable

This commit is contained in:
jisookim0513 2014-06-19 18:22:36 -07:00
parent 4e2b5b743f
commit 0244172ccb
6 changed files with 24 additions and 23 deletions

View File

@ -30,7 +30,7 @@ import java.util.Map;
public class RetryQueryRunner<T> implements QueryRunner<T>
{
public static String missingSegments = "missingSegments";
public static String missingSegments = RetryQueryRunner.missingSegments;
private final QueryRunner<T> baseRunner;
private final QueryToolChest<T, Query<T>> toolChest;
private final RetryQueryRunnerConfig config;
@ -74,7 +74,7 @@ public class RetryQueryRunner<T> implements QueryRunner<T>
if (!config.returnPartialResults() && !((List) context.get(missingSegments)).isEmpty()) {
String failedSegments = "";
for (SegmentDescriptor segment : (List<SegmentDescriptor>) context.get("missingSegments")) {
for (SegmentDescriptor segment : (List<SegmentDescriptor>) context.get(RetryQueryRunner.missingSegments)) {
failedSegments = failedSegments + segment.toString() + " ";
}
throw new SegmentMissingException("The following segments are missing: " + failedSegments);

View File

@ -68,7 +68,7 @@ public class SpecificSegmentQueryRunner<T> implements QueryRunner<T>
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;

View File

@ -48,7 +48,7 @@ public class RetryQueryRunnerTest
public void testRunWithMissingSegments() throws Exception
{
Map<String, Object> 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<String, Object> 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<String, Object> context = new MapMaker().makeMap();
context.put("missingSegments", Lists.newArrayList());
context.put(RetryQueryRunner.missingSegments, Lists.newArrayList());
RetryQueryRunner runner = new RetryQueryRunner(
new QueryRunner()
{

View File

@ -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.<AggregatorFactory>asList(
QueryRunnerTestHelper.rowsCount,
new LongSumAggregatorFactory(
"idx",
"index"
),
QueryRunnerTestHelper.qualityUniques
)
)
.build();
.dataSource(QueryRunnerTestHelper.dataSource)
.granularity(QueryRunnerTestHelper.dayGran)
.intervals(QueryRunnerTestHelper.firstToThird)
.aggregators(
Arrays.<AggregatorFactory>asList(
QueryRunnerTestHelper.rowsCount,
new LongSumAggregatorFactory(
"idx",
"index"
),
QueryRunnerTestHelper.qualityUniques
)
)
.build();
List<Result<TimeseriesResultValue>> expectedResults = Arrays.asList(
new Result<TimeseriesResultValue>(

View File

@ -178,7 +178,7 @@ public class DirectDruidClient<T> implements QueryRunner<T>
catch (IOException e) {
e.printStackTrace();
}
((List) context.get("missingSegments")).addAll(missingSegments);
((List) context.get(RetryQueryRunner.missingSegments)).addAll(missingSegments);
return super.handleResponse(response);
}

View File

@ -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<String, Object> 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);
}