Skip to content

Commit

Permalink
change missigSegments to a static variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jisookim0513 authored and jisookim0513 committed Jun 20, 2014
1 parent 4e2b5b7 commit 0244172
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions processing/src/main/java/io/druid/query/RetryQueryRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

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;
Expand Down Expand Up @@ -74,7 +74,7 @@ public <OutType> Yielder<OutType> toYielder(

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Sequence<T> call() throws Exception
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -122,7 +122,7 @@ public void testRetry() throws Exception
{
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()
{
Expand Down Expand Up @@ -214,7 +214,7 @@ public Ordering<Result<TimeseriesResultValue>> getOrdering()
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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,20 +252,20 @@ public void testFullOnTimeseriesWithFilter()
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>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public ClientResponse<AppendableByteArrayInputStream> handleResponse(HttpRespons
catch (IOException e) {
e.printStackTrace();
}
((List) context.get("missingSegments")).addAll(missingSegments);
((List) context.get(RetryQueryRunner.missingSegments)).addAll(missingSegments);

return super.handleResponse(response);
}
Expand Down
5 changes: 3 additions & 2 deletions server/src/main/java/io/druid/server/QueryResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
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;

Expand Down Expand Up @@ -144,7 +145,7 @@ public Response doPost(
}

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) {
Expand All @@ -167,7 +168,7 @@ public Object accumulate(Object accumulated, Object in)
) {

String headerContext = "";
if (!((List)context.get("missingSegments")).isEmpty()) {
if (!((List)context.get(RetryQueryRunner.missingSegments)).isEmpty()) {
headerContext = jsonMapper.writeValueAsString(context);
}

Expand Down

0 comments on commit 0244172

Please sign in to comment.