mirror of https://github.com/apache/druid.git
change missigSegments to a static variable
This commit is contained in:
parent
4e2b5b743f
commit
0244172ccb
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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>(
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue