Search in sources :

Example 1 with QueryPrioritizationStrategy

use of org.apache.druid.server.QueryPrioritizationStrategy in project druid by druid-io.

the class ThresholdBasedQueryPrioritizationStrategyTest method testPrioritizationSegmentCountWithinThreshold.

@Test
public void testPrioritizationSegmentCountWithinThreshold() {
    QueryPrioritizationStrategy strategy = new ThresholdBasedQueryPrioritizationStrategy(null, null, 2, adjustment);
    DateTime startDate = DateTimes.nowUtc().minusDays(1);
    DateTime endDate = DateTimes.nowUtc();
    TimeseriesQuery query = queryBuilder.intervals(ImmutableList.of(new Interval(startDate, endDate))).granularity(Granularities.MINUTE).context(ImmutableMap.of()).build();
    Assert.assertFalse(strategy.computePriority(QueryPlus.wrap(query), ImmutableSet.of(EasyMock.createMock(SegmentServerSelector.class))).isPresent());
}
Also used : QueryPrioritizationStrategy(org.apache.druid.server.QueryPrioritizationStrategy) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 2 with QueryPrioritizationStrategy

use of org.apache.druid.server.QueryPrioritizationStrategy in project druid by druid-io.

the class ThresholdBasedQueryPrioritizationStrategyTest method testPrioritizationSegmentCountOverThreshold.

@Test
public void testPrioritizationSegmentCountOverThreshold() {
    QueryPrioritizationStrategy strategy = new ThresholdBasedQueryPrioritizationStrategy(null, null, 2, adjustment);
    DateTime startDate = DateTimes.nowUtc().minusDays(20);
    DateTime endDate = DateTimes.nowUtc();
    TimeseriesQuery query = queryBuilder.intervals(ImmutableList.of(new Interval(startDate, endDate))).granularity(Granularities.HOUR).context(ImmutableMap.of()).build();
    Assert.assertEquals(-adjustment, (int) strategy.computePriority(QueryPlus.wrap(query), ImmutableSet.of(EasyMock.createMock(SegmentServerSelector.class), EasyMock.createMock(SegmentServerSelector.class), EasyMock.createMock(SegmentServerSelector.class))).get());
}
Also used : QueryPrioritizationStrategy(org.apache.druid.server.QueryPrioritizationStrategy) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) SegmentServerSelector(org.apache.druid.client.SegmentServerSelector) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 3 with QueryPrioritizationStrategy

use of org.apache.druid.server.QueryPrioritizationStrategy in project druid by druid-io.

the class ThresholdBasedQueryPrioritizationStrategyTest method testPrioritizationPeriodThresholdOutsidePeriod.

@Test
public void testPrioritizationPeriodThresholdOutsidePeriod() {
    QueryPrioritizationStrategy strategy = new ThresholdBasedQueryPrioritizationStrategy("P90D", null, null, adjustment);
    DateTime startDate = DateTimes.nowUtc().minusDays(100);
    DateTime endDate = DateTimes.nowUtc().minusDays(80);
    TimeseriesQuery query = queryBuilder.intervals(ImmutableList.of(new Interval(startDate, endDate))).granularity(Granularities.HOUR).context(ImmutableMap.of()).build();
    Assert.assertEquals(-adjustment, (int) strategy.computePriority(QueryPlus.wrap(query), ImmutableSet.of()).get());
}
Also used : QueryPrioritizationStrategy(org.apache.druid.server.QueryPrioritizationStrategy) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 4 with QueryPrioritizationStrategy

use of org.apache.druid.server.QueryPrioritizationStrategy in project druid by druid-io.

the class ThresholdBasedQueryPrioritizationStrategyTest method testPrioritizationDurationThresholdInsideDuration.

@Test
public void testPrioritizationDurationThresholdInsideDuration() {
    QueryPrioritizationStrategy strategy = new ThresholdBasedQueryPrioritizationStrategy(null, "P7D", null, adjustment);
    DateTime startDate = DateTimes.nowUtc().minusDays(1);
    DateTime endDate = DateTimes.nowUtc();
    TimeseriesQuery query = queryBuilder.intervals(ImmutableList.of(new Interval(startDate, endDate))).granularity(Granularities.MINUTE).context(ImmutableMap.of()).build();
    Assert.assertFalse(strategy.computePriority(QueryPlus.wrap(query), ImmutableSet.of()).isPresent());
}
Also used : QueryPrioritizationStrategy(org.apache.druid.server.QueryPrioritizationStrategy) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 5 with QueryPrioritizationStrategy

use of org.apache.druid.server.QueryPrioritizationStrategy in project druid by druid-io.

the class ThresholdBasedQueryPrioritizationStrategyTest method testPrioritizationDurationThresholdOutsideDuration.

@Test
public void testPrioritizationDurationThresholdOutsideDuration() {
    QueryPrioritizationStrategy strategy = new ThresholdBasedQueryPrioritizationStrategy(null, "P7D", null, adjustment);
    DateTime startDate = DateTimes.nowUtc().minusDays(20);
    DateTime endDate = DateTimes.nowUtc();
    TimeseriesQuery query = queryBuilder.intervals(ImmutableList.of(new Interval(startDate, endDate))).granularity(Granularities.HOUR).context(ImmutableMap.of()).build();
    Assert.assertEquals(-adjustment, (int) strategy.computePriority(QueryPlus.wrap(query), ImmutableSet.of()).get());
}
Also used : QueryPrioritizationStrategy(org.apache.druid.server.QueryPrioritizationStrategy) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Test(org.junit.Test)

Aggregations

TimeseriesQuery (org.apache.druid.query.timeseries.TimeseriesQuery)6 QueryPrioritizationStrategy (org.apache.druid.server.QueryPrioritizationStrategy)6 DateTime (org.joda.time.DateTime)6 Interval (org.joda.time.Interval)6 Test (org.junit.Test)6 SegmentServerSelector (org.apache.druid.client.SegmentServerSelector)1