use of com.linkedin.d2.discovery.PropertySerializer 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.PropertySerializer 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);
}
}
Aggregations