use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class TestPartitionsWithZKQuorum method testRegisterUnregisterDefaultPartitionEchoServers.
@Test
public void testRegisterUnregisterDefaultPartitionEchoServers() throws IOException, URISyntaxException, PropertyStoreException, ExecutionException, TimeoutException, InterruptedException, Exception {
_echoServers = new ArrayList<LoadBalancerEchoServer>();
setup();
assertEquals(LoadBalancerClientCli.runDiscovery(_quorum.getHosts(), "/d2", D2_CONFIG_DEFAULT_PARTITION_DATA), 0);
_cli = new LoadBalancerClientCli(_quorum.getHosts(), "/d2");
_client = _cli.createZKFSTogglingLBClient(_quorum.getHosts(), "/d2", null);
// Echo servers startup
startDefaultPartitionEchoServers();
assertAllEchoServersRunning(_echoServers);
assertAllEchoServersRegistered(_cli.getZKClient(), _zkUriString, _echoServers);
assertQuorumProcessAllRequests(D2_CONFIG_DEFAULT_PARTITION_DATA);
// Markdown echo servers
stopAllEchoServers(_echoServers);
assertAllEchoServersUnregistered(_cli.getZKClient(), _zkUriString, _echoServers);
}
use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class TestPartitionsWithZKQuorum method testRegisterUnregisterCustomPartitionEchoServers.
@Test
public void testRegisterUnregisterCustomPartitionEchoServers() throws IOException, URISyntaxException, PropertyStoreException, ExecutionException, TimeoutException, InterruptedException, Exception {
_echoServers = new ArrayList<LoadBalancerEchoServer>();
setup();
assertEquals(LoadBalancerClientCli.runDiscovery(_quorum.getHosts(), "/d2", D2_CONFIG_CUSTOM_PARTITION_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));
startCustomPartitionEchoServers(partitionWeight);
assertAllEchoServersRegistered(_cli.getZKClient(), _zkUriString, _echoServers);
assertQuorumProcessAllRequests(D2_CONFIG_CUSTOM_PARTITION_DATA);
// Markdown echo servers
stopAllEchoServers(_echoServers);
assertAllEchoServersUnregistered(_cli.getZKClient(), _zkUriString, _echoServers);
}
use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class LoadBalancerClientCli method getServiceClustersURIsInfo.
public Map<String, UriProperties> getServiceClustersURIsInfo(String zkserver, String d2path, String serviceName) throws IOException, IllegalStateException, URISyntaxException, PropertyStoreException {
Map<String, UriProperties> map = new HashMap<String, UriProperties>();
// zk stores
String scstoreString = zkserver + ZKFSUtil.servicePath(d2path);
String uristoreString = zkserver + ZKFSUtil.uriPath(d2path);
ZooKeeperPermanentStore<ServiceProperties> zkServiceRegistry = (ZooKeeperPermanentStore<ServiceProperties>) getStore(_zkclient, scstoreString, new ServicePropertiesJsonSerializer());
ZooKeeperEphemeralStore<UriProperties> zkUriRegistry = (ZooKeeperEphemeralStore<UriProperties>) getEphemeralStore(_zkclient, uristoreString, new UriPropertiesJsonSerializer(), new UriPropertiesMerger());
List<String> currentservices = zkServiceRegistry.ls();
for (String service : currentservices) {
if (service.equals(serviceName)) {
String clusterName = zkServiceRegistry.get(serviceName).getClusterName();
UriProperties uripros = zkUriRegistry.get(clusterName);
map.put(clusterName, uripros);
}
}
return map;
}
use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class LoadBalancerClientCli method printStore.
public static String printStore(ZKConnection zkclient, String zkserver, String d2path, String cluster, String service, String serviceGroup) throws URISyntaxException, IOException, PropertyStoreException {
StringBuilder sb = new StringBuilder();
ZooKeeperPermanentStore<ClusterProperties> zkClusterRegistry = null;
ZooKeeperPermanentStore<ServiceProperties> zkServiceRegistry = null;
ZooKeeperEphemeralStore<UriProperties> zkUriRegistry = null;
String clstoreString = zkserver + ZKFSUtil.clusterPath(d2path);
String uristoreString = zkserver + ZKFSUtil.uriPath(d2path);
zkClusterRegistry = (ZooKeeperPermanentStore<ClusterProperties>) getStore(zkclient, clstoreString, new ClusterPropertiesJsonSerializer());
zkUriRegistry = (ZooKeeperEphemeralStore<UriProperties>) getEphemeralStore(zkclient, uristoreString, new UriPropertiesJsonSerializer(), new UriPropertiesMerger());
if (serviceGroup != null) {
String scstoreString = zkserver + ZKFSUtil.servicePath(d2path, serviceGroup);
zkServiceRegistry = (ZooKeeperPermanentStore<ServiceProperties>) getStore(zkclient, scstoreString, new ServicePropertiesJsonSerializer());
} else {
String scstoreString = zkserver + ZKFSUtil.servicePath(d2path);
zkServiceRegistry = (ZooKeeperPermanentStore<ServiceProperties>) getStore(zkclient, scstoreString, new ServicePropertiesJsonSerializer());
}
sb.append(printStore(zkClusterRegistry, zkUriRegistry, cluster));
if (zkServiceRegistry.get(service).getClusterName().equals(cluster)) {
sb.append(printService(zkServiceRegistry, service));
}
return sb.toString();
}
use of com.linkedin.d2.discovery.stores.PropertyStoreException in project rest.li by linkedin.
the class LoadBalancerClientCli method getServiceURIsProps.
public Set<UriProperties> getServiceURIsProps(String zkserver, String d2path, String serviceName) throws IOException, IllegalStateException, URISyntaxException, PropertyStoreException {
Set<UriProperties> uriprops = new HashSet<UriProperties>();
// zk stores
String scstoreString = zkserver + ZKFSUtil.servicePath(d2path);
String uristoreString = zkserver + ZKFSUtil.uriPath(d2path);
ZooKeeperPermanentStore<ServiceProperties> zkServiceRegistry = (ZooKeeperPermanentStore<ServiceProperties>) getStore(_zkclient, scstoreString, new ServicePropertiesJsonSerializer());
ZooKeeperEphemeralStore<UriProperties> zkUriRegistry = (ZooKeeperEphemeralStore<UriProperties>) getEphemeralStore(_zkclient, uristoreString, new UriPropertiesJsonSerializer(), new UriPropertiesMerger());
String clusterName = zkServiceRegistry.get(serviceName).getClusterName();
UriProperties uripros = zkUriRegistry.get(clusterName);
uriprops.add(uripros);
return uriprops;
}
Aggregations