Search in sources :

Example 6 with PropertyStore

use of com.linkedin.d2.discovery.stores.PropertyStore in project rest.li by linkedin.

the class LoadBalancerClientCli method shutdownPropertyStore.

private void shutdownPropertyStore(PropertyStore<?> store, long timeout, TimeUnit unit) throws Exception {
    final CountDownLatch registryLatch = new CountDownLatch(1);
    store.shutdown(new PropertyEventShutdownCallback() {

        @Override
        public void done() {
            registryLatch.countDown();
        }
    });
    try {
        registryLatch.await(timeout, unit);
    } catch (InterruptedException e) {
        System.err.println("unable to shutdown store: " + store);
    }
}
Also used : PropertyEventShutdownCallback(com.linkedin.d2.discovery.event.PropertyEventThread.PropertyEventShutdownCallback) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 7 with PropertyStore

use of com.linkedin.d2.discovery.stores.PropertyStore in project rest.li by linkedin.

the class ZooKeeperEphemeralStoreTest method testShutdown.

@Test(groups = { "small", "back-end" })
public void testShutdown() throws InterruptedException, IOException, PropertyStoreException, ExecutionException {
    PropertyStore<String> store = getStore();
    final CountDownLatch latch = new CountDownLatch(1);
    store.shutdown(new PropertyEventShutdownCallback() {

        @Override
        public void done() {
            latch.countDown();
        }
    });
    if (!latch.await(5, TimeUnit.SECONDS)) {
        fail("unable to shut down store");
    }
}
Also used : PropertyEventShutdownCallback(com.linkedin.d2.discovery.event.PropertyEventThread.PropertyEventShutdownCallback) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.testng.annotations.Test)

Example 8 with PropertyStore

use of com.linkedin.d2.discovery.stores.PropertyStore in project rest.li by linkedin.

the class PropertyStoreTest method testShutdown.

@Test(groups = { "small", "back-end" })
public void testShutdown() throws InterruptedException, PropertyStoreException {
    PropertyStore<String> store = getStore();
    final CountDownLatch latch = new CountDownLatch(1);
    store.shutdown(new PropertyEventShutdownCallback() {

        @Override
        public void done() {
            latch.countDown();
        }
    });
    if (!latch.await(5, TimeUnit.SECONDS)) {
        fail("unable to shut down store");
    }
}
Also used : PropertyEventShutdownCallback(com.linkedin.d2.discovery.event.PropertyEventThread.PropertyEventShutdownCallback) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.testng.annotations.Test)

Example 9 with PropertyStore

use of com.linkedin.d2.discovery.stores.PropertyStore in project rest.li by linkedin.

the class LoadBalancerClientCli method startStore.

private static <T> void startStore(PropertyStore<T> store) throws PropertyStoreException {
    try {
        FutureCallback<None> callback = new FutureCallback<>();
        store.start(callback);
        callback.get(30, TimeUnit.SECONDS);
    } catch (Exception e) {
        throw new PropertyStoreException("Failed to start store", e);
    }
}
Also used : PropertyStoreException(com.linkedin.d2.discovery.stores.PropertyStoreException) None(com.linkedin.common.util.None) FutureCallback(com.linkedin.common.callback.FutureCallback) URISyntaxException(java.net.URISyntaxException) TimeoutException(java.util.concurrent.TimeoutException) ParseException(org.apache.commons.cli.ParseException) PropertyStoreException(com.linkedin.d2.discovery.stores.PropertyStoreException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

PropertyEventShutdownCallback (com.linkedin.d2.discovery.event.PropertyEventThread.PropertyEventShutdownCallback)3 ZooKeeperPermanentStore (com.linkedin.d2.discovery.stores.zk.ZooKeeperPermanentStore)3 URISyntaxException (java.net.URISyntaxException)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 FutureCallback (com.linkedin.common.callback.FutureCallback)2 None (com.linkedin.common.util.None)2 PropertyStoreException (com.linkedin.d2.discovery.stores.PropertyStoreException)2 FileStore (com.linkedin.d2.discovery.stores.file.FileStore)2 ZKConnection (com.linkedin.d2.discovery.stores.zk.ZKConnection)2 IOException (java.io.IOException)2 URI (java.net.URI)2 Test (org.testng.annotations.Test)2 ClusterProperties (com.linkedin.d2.balancer.properties.ClusterProperties)1 ClusterPropertiesJsonSerializer (com.linkedin.d2.balancer.properties.ClusterPropertiesJsonSerializer)1 ServiceProperties (com.linkedin.d2.balancer.properties.ServiceProperties)1 ServicePropertiesJsonSerializer (com.linkedin.d2.balancer.properties.ServicePropertiesJsonSerializer)1 PropertyStringSerializer (com.linkedin.d2.discovery.stores.PropertyStringSerializer)1 ZooKeeperEphemeralStore (com.linkedin.d2.discovery.stores.zk.ZooKeeperEphemeralStore)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1