use of com.linkedin.d2.discovery.stores.PropertyStore in project rest.li by linkedin.
the class LoadBalancerClientCli method getStore.
public static <T> PropertyStore<T> getStore(ZKConnection zkclient, String store, PropertySerializer<T> serializer) throws URISyntaxException, IOException, PropertyStoreException {
URI storeUri = URI.create(store);
if (storeUri.getScheme() != null) {
if (storeUri.getScheme().equals("zk")) {
ZooKeeperPermanentStore<T> zkStore = new ZooKeeperPermanentStore<>(zkclient, serializer, storeUri.getPath());
startStore(zkStore);
return zkStore;
} else {
throw new URISyntaxException(store, "Unable to parse store uri. Only zk and file stores are supported.");
}
} else {
// assume it's a local file
return new FileStore<>(storeUri.getPath(), ".json", serializer);
}
}
use of com.linkedin.d2.discovery.stores.PropertyStore in project rest.li by linkedin.
the class LoadBalancerClientCli method getEphemeralStore.
public static <T> PropertyStore<T> getEphemeralStore(ZKConnection zkclient, String store, PropertySerializer<T> serializer, ZooKeeperPropertyMerger<T> merger) throws URISyntaxException, IOException, PropertyStoreException {
URI storeUri = URI.create(store);
if (storeUri.getScheme() != null) {
if (storeUri.getScheme().equals("zk")) {
ZooKeeperEphemeralStore<T> zkStore = new ZooKeeperEphemeralStore<>(zkclient, serializer, merger, storeUri.getPath());
startStore(zkStore);
return zkStore;
} else {
throw new URISyntaxException(store, "Unable to parse store uri. Only zk and file stores are supported.");
}
} else {
// assume it's a local file
return new FileStore<>(storeUri.getPath(), ".json", serializer);
}
}
use of com.linkedin.d2.discovery.stores.PropertyStore in project rest.li by linkedin.
the class R2D2Server method putService.
private void putService(ServiceProperties serviceProperties) throws Exception {
System.err.println("put: " + serviceProperties);
ZKConnection client = new ZKConnection(_zookeeperHost + ":" + _zookeeperPort, 30000);
PropertyStore<ServiceProperties> store = new ZooKeeperPermanentStore<>(client, new ServicePropertiesJsonSerializer(), _basePath + "/services");
store.put(serviceProperties.getServiceName(), serviceProperties);
client.getZooKeeper().close();
}
use of com.linkedin.d2.discovery.stores.PropertyStore in project rest.li by linkedin.
the class R2D2Server method putCluster.
private void putCluster(ClusterProperties clusterProperties) throws Exception {
System.err.println("put: " + clusterProperties);
ZKConnection client = new ZKConnection(_zookeeperHost + ":" + _zookeeperPort, 30000);
PropertyStore<ClusterProperties> store = new ZooKeeperPermanentStore<>(client, new ClusterPropertiesJsonSerializer(), _basePath + "/clusters");
store.put(clusterProperties.getClusterName(), clusterProperties);
client.getZooKeeper().close();
}
use of com.linkedin.d2.discovery.stores.PropertyStore 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<>(client, new PropertyStringSerializer(), "/test-path");
FutureCallback<None> callback = new FutureCallback<>();
store.start(callback);
callback.get();
return store;
} catch (Exception e) {
throw new PropertyStoreException(e);
}
}
Aggregations