use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class LoadBalancerEchoServer method markDown.
public void markDown() throws PropertyStoreException {
FutureCallback<None> callback = new FutureCallback<None>();
_announcer.markDown(_cluster, _uri, callback);
try {
callback.get(10, TimeUnit.SECONDS);
} catch (Exception e) {
throw new PropertyStoreException(e);
}
}
use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class LoadBalancerEchoServer method markUp.
public void markUp(Map<Integer, Double> partitionWeight) throws PropertyStoreException {
FutureCallback<None> callback = new FutureCallback<None>();
Map<Integer, PartitionData> partitionDataMap = new HashMap<Integer, PartitionData>();
if (partitionWeight != null) {
for (int partitionId : partitionWeight.keySet()) {
partitionDataMap.put(partitionId, new PartitionData(partitionWeight.get(partitionId)));
}
} else {
partitionDataMap.put(DefaultPartitionAccessor.DEFAULT_PARTITION_ID, new PartitionData(1d));
}
_announcer.markUp(_cluster, _uri, partitionDataMap, callback);
try {
callback.get(10, TimeUnit.SECONDS);
} catch (Exception e) {
throw new PropertyStoreException(e);
}
}
use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class ZooKeeperEphemeralStoreTest method testPutGetRemovePartial.
@Test(groups = { "small", "back-end" })
public void testPutGetRemovePartial() throws InterruptedException, IOException, PropertyStoreException, ExecutionException {
ZooKeeperEphemeralStore<String> store = getStore();
store.put("service-1", "1");
store.put("service-1", "2");
store.put("service-2", "3");
assertTrue(store.get("service-1").equals("1,2") || store.get("service-1").equals("2,1"));
assertEquals(store.get("service-2"), "3");
assertNull(store.get("service-3"));
store.removePartial("service-1", "2");
assertEquals(store.get("service-1"), "1");
store.remove("service-2");
assertNull(store.get("service-2"));
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");
}
}
use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class ZooKeeperPermanentStoreTest method getStore.
@Override
public PropertyStore<String> getStore() throws PropertyStoreException {
try {
ZKConnection client = new ZKConnection("localhost:" + PORT, 30000);
client.start();
ZooKeeperPermanentStore<String> store = new ZooKeeperPermanentStore<String>(client, new PropertyStringSerializer(), "/test-path");
FutureCallback<None> callback = new FutureCallback<None>();
store.start(callback);
callback.get();
return store;
} catch (Exception e) {
throw new PropertyStoreException(e);
}
}
use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class TestPartitionsWithZKQuorum method testRegisterUnregisterAllEchoServers.
@Test
public void testRegisterUnregisterAllEchoServers() throws IOException, URISyntaxException, PropertyStoreException, ExecutionException, TimeoutException, InterruptedException, Exception {
_echoServers = new ArrayList<LoadBalancerEchoServer>();
setup();
assertEquals(LoadBalancerClientCli.runDiscovery(_quorum.getHosts(), "/d2", D2_CONFIG_DATA), 0);
_cli = new LoadBalancerClientCli(_quorum.getHosts(), "/d2");
_client = _cli.createZKFSTogglingLBClient(_quorum.getHosts(), "/d2", null);
// Echo servers startup
Map<Integer, Double> partitionWeight = new HashMap<Integer, Double>();
partitionWeight.put(new Integer(1), new Double(1.0d));
startAllEchoServers(partitionWeight);
assertAllEchoServersRegistered(_cli.getZKClient(), _zkUriString, _echoServers);
assertQuorumProcessAllRequests(D2_CONFIG_DATA);
// Markdown echo servers
stopAllEchoServers(_echoServers);
assertAllEchoServersUnregistered(_cli.getZKClient(), _zkUriString, _echoServers);
}
Aggregations