params.put("processor.priority.s2", "2");
params.put("processor.priority.s3", "1");
params.put("processor.maxpenalty", "10000");
context.putAll(params);
Configurables.configure(group, context);
SinkRunner runner = new SinkRunner(group.getProcessor());
runner.start();
Assert.assertEquals(LifecycleState.START, s1.getLifecycleState());
Assert.assertEquals(LifecycleState.START, s2.getLifecycleState());
Assert.assertEquals(LifecycleState.START, s3.getLifecycleState());
for(int i = 0; i < 15; i++) {
Transaction tx = ch.getTransaction();
tx.begin();
ch.put(EventBuilder.withBody("test".getBytes()));
tx.commit();
tx.close();
}
Thread.sleep(100);
Assert.assertEquals(new Integer(10), s1.getWritten());
Assert.assertEquals(new Integer(5), s2.getWritten());
for(int i = 0; i < 50; i++) {
Transaction tx = ch.getTransaction();
tx.begin();
ch.put(EventBuilder.withBody("test".getBytes()));
tx.commit();
tx.close();
}
Thread.sleep(100);
Assert.assertEquals(new Integer(50), s2.getWritten());
Assert.assertEquals(new Integer(5), s3.getWritten());
// test rollover to recovered servers
s2.setRemaining(20);
// get us past the retry time for the failed sink
Thread.sleep(5000);
for(int i = 0; i < 100; i++) {
Transaction tx = ch.getTransaction();
tx.begin();
ch.put(EventBuilder.withBody("test".getBytes()));
tx.commit();
tx.close();
}
Thread.sleep(1000);
Assert.assertEquals(new Integer(10), s1.getWritten());
Assert.assertEquals(new Integer(70), s2.getWritten());
Assert.assertEquals(new Integer(85), s3.getWritten());
runner.stop();
ch.stop();
}