use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class ZooKeeperPermanentStoreStrawMan method main.
public static void main(String[] args) throws IOException, InterruptedException, PropertyStoreException {
ZKConnection zkClient = new ZKConnection("localhost:2181", 1000);
Set<String> listenTos = new HashSet<String>();
ZooKeeperPermanentStore<String> zk = new ZooKeeperPermanentStore<String>(zkClient, new PropertyStringSerializer(), "/test/lb/test-property");
listenTos.add("foo12");
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
PropertyEventBus<String> bus = new PropertyEventBusImpl<String>(executorService, zk);
bus.register(listenTos, new PropertyEventSubscriber<String>() {
@Override
public void onAdd(String propertyName, String propertyValue) {
System.err.println("onAdd: " + propertyName + "\t" + propertyValue);
}
@Override
public void onInitialize(String propertyName, String propertyValue) {
System.err.println("onInitialize: " + propertyName + "\t" + propertyValue);
}
@Override
public void onRemove(String propertyName) {
System.err.println("onRemove: " + propertyName);
}
});
zk.put("foo12", "TEST1");
zk.put("foo12", "TEST2");
zk.put("foo12", "TEST3");
zk.put("foo12", "TEST4");
zk.put("foo12", "TEST5");
zk.remove("foo12");
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
zkClient.getZooKeeper().close();
executorService.shutdown();
}
use of com.linkedin.d2.discovery.stores.PropertyStoreException 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");
}
}
use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class TestD2Config method verifyServiceProperties.
public static void verifyServiceProperties(String cluster, String service, String path, String serviceGroup, boolean defaultRoutingToMaster) throws IOException, URISyntaxException, PropertyStoreException {
ServiceProperties serviceprops = getServiceProperties(_zkclient, service, serviceGroup);
assertEquals(serviceprops.getClusterName(), cluster);
assertEquals(serviceprops.getServiceName(), service);
assertEquals(serviceprops.getPath(), path);
assertEquals(serviceprops.getLoadBalancerStrategyList(), Arrays.asList(new String[] { "degrader", "degraderV3" }));
assertEquals(serviceprops.getLoadBalancerStrategyProperties().get("maxClusterLatencyWithoutDegrading"), String.valueOf(500));
assertEquals(serviceprops.getLoadBalancerStrategyProperties().get("updateIntervalsMs"), String.valueOf(5000));
assertEquals(serviceprops.getLoadBalancerStrategyProperties().get("defaultSuccessfulTransmissionWeight"), String.valueOf(1.0));
assertEquals(serviceprops.getLoadBalancerStrategyProperties().get("pointsPerWeight"), String.valueOf(100));
if (defaultRoutingToMaster) {
String defaultRouting = (String) serviceprops.getServiceMetadataProperties().get(PropertyKeys.DEFAULT_ROUTING_TO_MASTER);
Assert.assertTrue(Boolean.valueOf(defaultRouting));
}
}
use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class TestD2Config method verifyClusterProperties.
public static void verifyClusterProperties(String cluster) throws IOException, URISyntaxException, PropertyStoreException {
ClusterProperties clusterprops = getClusterProperties(_zkclient, cluster);
assertEquals(clusterprops.getClusterName(), cluster);
assertEquals(clusterprops.getPrioritizedSchemes(), Arrays.asList(new String[] { "http" }));
assertEquals(clusterprops.getProperties().get("requestTimeout"), String.valueOf(10000));
assertEquals(clusterprops.getBanned(), new TreeSet<URI>());
}
Aggregations