use of io.datarouter.storage.test.TestDatabeanKey in project datarouter by hotpads.
the class SqsPerformanceTester method drainGroupQueueViaPeek.
// timeout is needed, otherwise it will poll forever
private void drainGroupQueueViaPeek(DatarouterSqsGroupTestDao dao, int numThreads) {
var timer = new PhaseTimer("drain queue");
var numDatabeansDrained = new AtomicLong(0L);
var numMessagesDrained = new AtomicLong(0L);
ExecutorService exec = Executors.newCachedThreadPool();
for (int i = 0; i < numThreads; ++i) {
exec.submit(() -> {
for (GroupQueueMessage<TestDatabeanKey, TestDatabean> message : dao.peekUntilEmpty(Duration.ofSeconds(3)).iterable()) {
List<TestDatabean> databeans = message.getDatabeans();
numDatabeansDrained.addAndGet(databeans.size());
dao.ack(message.getKey());
numMessagesDrained.incrementAndGet();
if (numMessagesDrained.get() % 5 == 0) {
logger.info("groupNode drained {}, latest={}", numDatabeansDrained.get(), ListTool.getLast(databeans).getKey());
}
}
});
}
ExecutorServiceTool.shutdown(exec, Duration.ofDays(1));
timer.add("drained " + numMessagesDrained.intValue() + " messages with " + numDatabeansDrained.intValue() + " databeans");
logger.info(timer.toString() + "@" + timer.getItemsPerSecond(numDatabeansDrained.intValue()));
}
use of io.datarouter.storage.test.TestDatabeanKey in project datarouter by hotpads.
the class BaseManagedIndexIntegrationTests method testDeleteMultiUnique.
private void testDeleteMultiUnique(DatarouterTestDatabeanWithIndexDao genericDao) {
List<TestDatabean> databeans = List.of(new TestDatabean("tri", "martolod", "yaouank"), new TestDatabean("i vonet", "da", "veajiƱ"));
List<TestDatabeanKey> keys = Scanner.of(databeans).map(Databean::getKey).list();
List<TestDatabeanWithManagedIndexByBarKey> entryKeys = new ArrayList<>();
for (TestDatabean databean : databeans) {
entryKeys.add(new TestDatabeanWithManagedIndexByBarKey(databean.getBar()));
}
Assert.assertEquals(genericDao.getMulti(keys).size(), 0);
Assert.assertEquals(genericDao.lookupMultiUnique(entryKeys).size(), 0);
genericDao.putMulti(databeans);
Assert.assertEquals(genericDao.getMulti(keys).size(), 2);
Assert.assertEquals(genericDao.lookupMultiUnique(entryKeys).size(), 2);
genericDao.deleteMultiUnique(entryKeys);
Assert.assertEquals(genericDao.getMulti(keys).size(), 0);
Assert.assertEquals(genericDao.lookupMultiUnique(entryKeys).size(), 0);
}
use of io.datarouter.storage.test.TestDatabeanKey in project datarouter by hotpads.
the class HbaseRangeIntegrationTests method testRange.
@Test
public void testRange() {
testDatabeanDao.deleteAll();
testDatabeanDao.putMulti(DATABEANS);
List<TestDatabeanKey> list = testDatabeanDao.scanKeys(new Range<>(new TestDatabeanKey("12"), false)).list();
Assert.assertFalse(list.isEmpty());
Assert.assertEquals(list.get(0), new TestDatabeanKey("120"));
}
use of io.datarouter.storage.test.TestDatabeanKey in project datarouter by hotpads.
the class SqsPerformanceTester method drainQueueViaPeek.
// timeout, otherwise it will poll forever
private void drainQueueViaPeek(DatarouterSqsTestDao dao, int numThreads) {
var timer = new PhaseTimer("drain queue");
var numDatabeansDrained = new AtomicLong(0L);
var numMessagesDrained = new AtomicLong(0L);
ExecutorService exec = Executors.newCachedThreadPool();
for (int i = 0; i < numThreads; ++i) {
exec.submit(() -> {
for (QueueMessage<TestDatabeanKey, TestDatabean> message : dao.peekUntilEmpty(Duration.ofSeconds(3)).iterable()) {
TestDatabean databean = message.getDatabean();
numDatabeansDrained.incrementAndGet();
dao.ack(message.getKey());
numMessagesDrained.incrementAndGet();
if (numMessagesDrained.get() % 200 == 0) {
logger.info("queue drained {}, latest={}", numDatabeansDrained.get(), databean.getKey());
}
}
});
}
ExecutorServiceTool.shutdown(exec, Duration.ofDays(1));
timer.add("drained " + numMessagesDrained.intValue() + " messages with " + numDatabeansDrained.intValue() + " databeans");
logger.info(timer.toString() + "@" + timer.getItemsPerSecond(numDatabeansDrained.intValue()));
}
Aggregations