Search in sources :

Example 11 with Curator

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);
    }
}
Also used : Curator(com.yahoo.vespa.curator.Curator) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Aggregations

Curator (com.yahoo.vespa.curator.Curator)11 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)6 Test (org.junit.Test)6 MockNameResolver (com.yahoo.vespa.hosted.provision.testutils.MockNameResolver)5 DockerImage (com.yahoo.config.provision.DockerImage)4 NodeRepository (com.yahoo.vespa.hosted.provision.NodeRepository)4 Zone (com.yahoo.config.provision.Zone)3 NodeFlavors (com.yahoo.config.provision.NodeFlavors)2 ManualClock (com.yahoo.test.ManualClock)2 Node (com.yahoo.vespa.hosted.provision.Node)2 JobControl (com.yahoo.vespa.hosted.provision.maintenance.JobControl)2 MetricsReporter (com.yahoo.vespa.hosted.provision.maintenance.MetricsReporter)2 Orchestrator (com.yahoo.vespa.orchestrator.Orchestrator)2 ServiceModel (com.yahoo.vespa.service.monitor.ServiceModel)2 ServiceMonitor (com.yahoo.vespa.service.monitor.ServiceMonitor)2 Before (org.junit.Before)2 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Provisioner (com.yahoo.config.provision.Provisioner)1 FlavorsConfig (com.yahoo.config.provisioning.FlavorsConfig)1 Path (com.yahoo.path.Path)1