@Override public Interval getInterval() { return Intervals.of(start + "/" + end); }
@Override public Interval getInterval() { return Intervals.of("2012-01-01/P1D"); } },
@Override public Interval getInterval() { return Intervals.of("2012-01-01T01/PT1H"); } },
@Override public Interval getInterval() { return Intervals.of("2014-01-05/P1D"); } },
@Override public Interval getInterval() { return Intervals.of("2015-01-20T02/PT1H"); } }
@Override public Interval getInterval() { return Intervals.of("2015-01-19T01/PT1H"); } },
@Override public Interval getInterval() { return Intervals.of("2012-01-01/P1D"); } },
@Override public Interval getInterval() { return Intervals.of("2012-01-01T01/PT1H"); } },
@Override public Interval getInterval() { return Intervals.of("2013-01-01T01/PT1H"); } },
@Override public Interval getInterval() { return Intervals.of("2013-01-05/P1D"); } },
@Override public Interval getInterval() { return Intervals.of("2015-01-20T02/PT1H"); } }
@Override public Interval deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { return Intervals.of(jsonParser.getText()); } }
@Override public List<Interval> getIntervals() { return Collections.singletonList(Intervals.of("2016-01-01T00Z/2016-01-02T00Z")); }
@Test public void testSerde() throws Exception { IntervalLoadRule rule = new IntervalLoadRule( Intervals.of("0/3000"), ImmutableMap.of(DruidServer.DEFAULT_TIER, 2) ); ObjectMapper jsonMapper = new DefaultObjectMapper(); Rule reread = jsonMapper.readValue(jsonMapper.writeValueAsString(rule), Rule.class); Assert.assertEquals(rule, reread); }
@Test public void testRemovePartitionMakesIncomplete() { testIncompletePartitionDoesNotOvershadow(); final IntegerPartitionChunk<Integer> chunk = IntegerPartitionChunk.make(null, 10, 0, 60); Assert.assertEquals(chunk, timeline.remove(Intervals.of("2011-10-05/2011-10-07"), "6", chunk)); assertValues( ImmutableList.of(createExpected("2011-10-05/2011-10-06", "5", 5)), timeline.lookup(Intervals.of("2011-10-05/2011-10-07")) ); Assert.assertTrue("Expected no overshadowed entries", timeline.findOvershadowed().isEmpty()); }
@Test(expected = IllegalStateException.class) public void testTryLockForInactiveTask() { Assert.assertFalse(lockbox.tryLock(TaskLockType.EXCLUSIVE, NoopTask.create(), Intervals.of("2015-01-01/2015-01-02")).isOk()); }
@Test public void testLock() throws InterruptedException { Task task = NoopTask.create(); lockbox.add(task); Assert.assertNotNull(lockbox.lock(TaskLockType.EXCLUSIVE, task, Intervals.of("2015-01-01/2015-01-02"))); }
@Test public void testTimeoutForLock() throws InterruptedException { Task task1 = NoopTask.create(); Task task2 = NoopTask.create(); lockbox.add(task1); lockbox.add(task2); Assert.assertTrue(lockbox.lock(TaskLockType.EXCLUSIVE, task1, Intervals.of("2015-01-01/2015-01-02"), 5000).isOk()); Assert.assertFalse(lockbox.lock(TaskLockType.EXCLUSIVE, task2, Intervals.of("2015-01-01/2015-01-15"), 1000).isOk()); }
@Test public void testLockAfterTaskComplete() throws InterruptedException { Task task = NoopTask.create(); exception.expect(ISE.class); exception.expectMessage("Unable to grant lock to inactive Task"); lockbox.add(task); lockbox.remove(task); lockbox.lock(TaskLockType.EXCLUSIVE, task, Intervals.of("2015-01-01/2015-01-02")); }
@Test public void testFindEntryWithOverlap() { timeline = makeStringIntegerTimeline(); add("2011-01-01/2011-01-10", "1", 1); add("2011-01-02/2011-01-05", "2", 1); Assert.assertEquals( new ImmutablePartitionHolder<Integer>(new PartitionHolder<Integer>(makeSingle(1))), timeline.findEntry(Intervals.of("2011-01-02T02/2011-01-04"), "1") ); }