use of com.walmartlabs.concord.server.cfg.LockingConfiguration in project concord by walmartlabs.
the class KvDaoTest method test.
@Test
public void test() throws Exception {
assertTimeout(Duration.ofMillis(10000), () -> {
KvDao kvDao = new KvDao(getConfiguration(), new Locks(new LockingConfiguration(8)));
UUID projectId = UUID.randomUUID();
String key = "key_" + System.currentTimeMillis();
int threads = 3;
int iterations = 50;
AtomicLong counter = new AtomicLong(0);
Runnable r = () -> {
for (int i = 0; i < iterations; i++) {
kvDao.inc(projectId, key);
counter.incrementAndGet();
}
};
Thread[] workes = new Thread[threads];
for (int i = 0; i < threads; i++) {
workes[i] = new Thread(r);
workes[i].start();
}
for (Thread w : workes) {
w.join();
}
Long total = counter.get();
assertEquals(total, kvDao.getLong(projectId, key));
});
}
Aggregations