use of com.linkedin.d2.balancer.servers.ZooKeeperUriStoreFactory in project rest.li by linkedin.
the class SharedZkConnectionProviderTest method prepareConnectionManagers.
/**
* For each given uri, generate a zookeeperConnectionManager for announcement
*/
private List<ZooKeeperConnectionManager> prepareConnectionManagers(List<URI> hostNames) throws Exception {
List<ZooKeeperConnectionManager> connectionManagers = new ArrayList<>();
for (URI uri : hostNames) {
ZooKeeperServer server = new ZooKeeperServer();
ZooKeeperAnnouncer announcer = new ZooKeeperAnnouncer(server, true);
announcer.setCluster(CLUSTER_NAME);
announcer.setUri(uri.toString());
Map<Integer, PartitionData> partitionWeight = new HashMap<>();
partitionWeight.put(DefaultPartitionAccessor.DEFAULT_PARTITION_ID, new PartitionData(0.5d));
announcer.setPartitionData(partitionWeight);
ZooKeeperConnectionManager.ZKStoreFactory<UriProperties, ZooKeeperEphemeralStore<UriProperties>> factory = new ZooKeeperUriStoreFactory();
ZKConnectionBuilder connectionBuilder = new ZKConnectionBuilder("localhost:" + ZK_PORT);
connectionBuilder.setTimeout(ZK_TIMEOUT);
ZKPersistentConnection connection = _provider.getZKPersistentConnection(connectionBuilder);
ZooKeeperConnectionManager connectionManager = new ZooKeeperConnectionManager(connection, ZKBASE_PATH, factory, announcer);
connectionManagers.add(connectionManager);
}
return connectionManagers;
}
Aggregations