use of com.yahoo.vespa.curator.Curator in project vespa by vespa-engine.
the class ZookeeperStatusServiceTest method locks_are_exclusive.
@Test
public void locks_are_exclusive() throws Exception {
try (Curator curator = createConnectedCuratorFramework(testingServer)) {
ZookeeperStatusService zookeeperStatusService2 = new ZookeeperStatusService(curator);
final CompletableFuture<Void> lockedSuccessfullyFuture;
try (MutableStatusRegistry statusRegistry = zookeeperStatusService.lockApplicationInstance_forCurrentThreadOnly(TestIds.APPLICATION_INSTANCE_REFERENCE)) {
lockedSuccessfullyFuture = CompletableFuture.runAsync(() -> {
try (MutableStatusRegistry statusRegistry2 = zookeeperStatusService2.lockApplicationInstance_forCurrentThreadOnly(TestIds.APPLICATION_INSTANCE_REFERENCE)) {
}
});
try {
lockedSuccessfullyFuture.get(3, TimeUnit.SECONDS);
fail("Both zookeeper host status services locked simultaneously for the same application instance");
} catch (TimeoutException ignored) {
}
}
lockedSuccessfullyFuture.get(1, TimeUnit.MINUTES);
}
}
Aggregations