use of org.apache.curator.framework.recipes.atomic.DistributedAtomicLong in project vespa by vespa-engine.
the class CuratorCounterTest method testCounter.
@Test
public void testCounter() throws Exception {
DistributedAtomicLong counter = new MockCurator().createAtomicCounter("/mycounter");
counter.initialize(4l);
assertEquals(4l, counter.get().postValue().longValue());
assertEquals(5l, counter.increment().postValue().longValue());
}
use of org.apache.curator.framework.recipes.atomic.DistributedAtomicLong in project oozie by apache.
the class ZKUUIDService method init.
@Override
public void init(Services services) throws ServiceException {
super.init(services);
try {
zk = ZKUtils.register(this);
PromotedToLock.Builder lockBuilder = PromotedToLock.builder().lockPath(getPromotedLock()).retryPolicy(getRetryPolicy()).timeout(Service.lockTimeout, TimeUnit.MILLISECONDS);
atomicIdGenerator = new DistributedAtomicLong(zk.getClient(), ZK_SEQUENCE_PATH, getRetryPolicy(), lockBuilder.build());
} catch (Exception ex) {
throw new ServiceException(ErrorCode.E1700, ex.getMessage(), ex);
}
}
Aggregations