fix broken ut

This commit is contained in:
fjy 2014-11-14 13:45:42 -08:00
parent e1e171ad20
commit d5c4282766
3 changed files with 21 additions and 11 deletions

View File

@ -73,7 +73,7 @@ public class RetryQueryRunner<T> implements QueryRunner<T>
final List<SegmentDescriptor> missingSegments = getMissingSegments(context);
if (!missingSegments.isEmpty()) {
for (int i = 0; i < config.numTries(); i++) {
for (int i = 0; i < config.getNumTries(); i++) {
log.info("[%,d] missing segments found. Retry attempt [%,d]", missingSegments.size(), i);
context.put(MISSING_SEGMENTS_KEY, Lists.newArrayList());
@ -90,7 +90,7 @@ public class RetryQueryRunner<T> implements QueryRunner<T>
}
final List<SegmentDescriptor> finalMissingSegs = getMissingSegments(context);
if (!finalMissingSegs.isEmpty()) {
if (!config.isReturnPartialResults() && !finalMissingSegs.isEmpty()) {
throw new SegmentMissingException("No results found for segments[%s]", finalMissingSegs);
}
}

View File

@ -26,8 +26,14 @@ public class RetryQueryRunnerConfig
@JsonProperty
private int numTries = 1;
public int numTries()
public int getNumTries()
{
return numTries;
}
// exists for testing and overrides
public boolean isReturnPartialResults()
{
return false;
}
}

View File

@ -69,12 +69,16 @@ public class RetryQueryRunnerTest
),
new RetryQueryRunnerConfig()
{
private int numTries = 0;
private boolean returnPartialResults = true;
@Override
public int getNumTries() {
return 0;
}
public int numTries() { return numTries; }
public boolean returnPartialResults() { return returnPartialResults; }
@Override
public boolean isReturnPartialResults()
{
return true;
}
},
jsonMapper
);
@ -140,7 +144,7 @@ public class RetryQueryRunnerTest
private int numTries = 1;
private boolean returnPartialResults = true;
public int numTries() { return numTries; }
public int getNumTries() { return numTries; }
public boolean returnPartialResults() { return returnPartialResults; }
},
@ -207,7 +211,7 @@ public class RetryQueryRunnerTest
private int numTries = 4;
private boolean returnPartialResults = true;
public int numTries() { return numTries; }
public int getNumTries() { return numTries; }
public boolean returnPartialResults() { return returnPartialResults; }
},
@ -259,7 +263,7 @@ public class RetryQueryRunnerTest
private int numTries = 1;
private boolean returnPartialResults = false;
public int numTries() { return numTries; }
public int getNumTries() { return numTries; }
public boolean returnPartialResults() { return returnPartialResults; }
},