mirror of https://github.com/apache/druid.git
Fix priority parsing in HiLoQueryLaningStrategy (#11302)
This commit is contained in:
parent
44d629319d
commit
7ffe402b87
|
@ -67,8 +67,12 @@ public class HiLoQueryLaningStrategy implements QueryLaningStrategy
|
|||
public <T> Optional<String> computeLane(QueryPlus<T> query, Set<SegmentServerSelector> segments)
|
||||
{
|
||||
final Query<T> theQuery = query.getQuery();
|
||||
// QueryContexts.getPriority gives a default, since we are setting priority
|
||||
final Integer priority = theQuery.getContextValue(QueryContexts.PRIORITY_KEY);
|
||||
// QueryContexts.getPriority gives a default, but it can parse the value to integer. Before calling QueryContexts.getPriority
|
||||
// we make sure that priority has been set.
|
||||
Integer priority = null;
|
||||
if (null != theQuery.getContextValue(QueryContexts.PRIORITY_KEY)) {
|
||||
priority = QueryContexts.getPriority(theQuery);
|
||||
}
|
||||
final String lane = theQuery.getContextValue(QueryContexts.LANE_KEY);
|
||||
if (lane == null && priority != null && priority < 0) {
|
||||
return Optional.of(LOW);
|
||||
|
|
|
@ -155,6 +155,13 @@ public class HiLoQueryLaningStrategyTest
|
|||
Assert.assertFalse(strategy.computeLane(QueryPlus.wrap(query), ImmutableSet.of()).isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaningInteractivePriority_String()
|
||||
{
|
||||
TimeseriesQuery query = queryBuilder.context(ImmutableMap.of(QueryContexts.PRIORITY_KEY, "100")).build();
|
||||
Assert.assertFalse(strategy.computeLane(QueryPlus.wrap(query), ImmutableSet.of()).isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaningLowPriority()
|
||||
{
|
||||
|
@ -166,6 +173,17 @@ public class HiLoQueryLaningStrategyTest
|
|||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaningLowPriority_String()
|
||||
{
|
||||
TimeseriesQuery query = queryBuilder.context(ImmutableMap.of(QueryContexts.PRIORITY_KEY, "-1")).build();
|
||||
Assert.assertTrue(strategy.computeLane(QueryPlus.wrap(query), ImmutableSet.of()).isPresent());
|
||||
Assert.assertEquals(
|
||||
HiLoQueryLaningStrategy.LOW,
|
||||
strategy.computeLane(QueryPlus.wrap(query), ImmutableSet.of()).get()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLaningPreservesManualSetLane()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue