@Test public void test01_simple() throws Exception { GreedyPolicyScheduler ps = new GreedyPolicyScheduler(); TestTopologyMgmtService mgmtService = createMgmtService(); IScheduleContext context = createScheduleContext(mgmtService); ps.init(context, mgmtService); ps.schedule(new ScheduleOption()); ScheduleState status = ps.getState(); context = ps.getContext(); // context updated! Map<String, SpoutSpec> spec = status.getSpoutSpecs(); LOG.info(mapper.writeValueAsString(spec)); Assert.assertEquals(2, spec.size()); Assert.assertTrue(spec.containsKey(TOPO1)); assertFirstPolicyScheduled(context, status); }
ScheduleState state = ps.getState(); context = ps.getContext(); // context updated!
/** * Add policy after add policy */ @Test public void test_schedule_add2() { TestTopologyMgmtService mgmtService = createMgmtService(); IScheduleContext context = createScheduleContext(mgmtService); GreedyPolicyScheduler ps = new GreedyPolicyScheduler(); ps.init(context, mgmtService); ScheduleOption option = new ScheduleOption(); ps.schedule(option); ScheduleState status = ps.getState(); context = ps.getContext(); // context updated! assertFirstPolicyScheduled(context, status); createSamplePolicy((InMemScheduleConext) context, TEST_POLICY_2, STREAM1, PARALELLISM); ps.init(context, mgmtService); // reinit ps.schedule(option); status = ps.getState(); context = ps.getContext(); // context updated! // now assert two policy on the same queue assertSecondPolicyCreated(context, status); // add one policy on different stream of the same topic createSamplePolicy((InMemScheduleConext) context, TEST_POLICY_3, STREAM2, PARALELLISM); ps.init(context, mgmtService); // re-init ps.schedule(option); status = ps.getState(); context = ps.getContext(); // context updated! assertThridPolicyScheduled(context, status); }