Search in sources :

Example 1 with PropertySerializer

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);
    }
}
Also used : FileStore(com.linkedin.d2.discovery.stores.file.FileStore) ZooKeeperPermanentStore(com.linkedin.d2.discovery.stores.zk.ZooKeeperPermanentStore) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 2 with PropertySerializer

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);
    }
}
Also used : FileStore(com.linkedin.d2.discovery.stores.file.FileStore) URISyntaxException(java.net.URISyntaxException) ZooKeeperEphemeralStore(com.linkedin.d2.discovery.stores.zk.ZooKeeperEphemeralStore) URI(java.net.URI)

Aggregations

FileStore (com.linkedin.d2.discovery.stores.file.FileStore)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 ZooKeeperEphemeralStore (com.linkedin.d2.discovery.stores.zk.ZooKeeperEphemeralStore)1 ZooKeeperPermanentStore (com.linkedin.d2.discovery.stores.zk.ZooKeeperPermanentStore)1