Search in sources :

Example 1 with PropertyStoreException

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);
}
Also used : LoadBalancerClientCli(com.linkedin.d2.balancer.util.LoadBalancerClientCli) LoadBalancerEchoServer(com.linkedin.d2.balancer.util.LoadBalancerEchoServer) D2BaseTest(com.linkedin.d2.D2BaseTest) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Example 2 with PropertyStoreException

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);
}
Also used : LoadBalancerClientCli(com.linkedin.d2.balancer.util.LoadBalancerClientCli) HashMap(java.util.HashMap) LoadBalancerEchoServer(com.linkedin.d2.balancer.util.LoadBalancerEchoServer) D2BaseTest(com.linkedin.d2.D2BaseTest) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Example 3 with PropertyStoreException

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;
}
Also used : HashMap(java.util.HashMap) ServicePropertiesJsonSerializer(com.linkedin.d2.balancer.properties.ServicePropertiesJsonSerializer) ZooKeeperPermanentStore(com.linkedin.d2.discovery.stores.zk.ZooKeeperPermanentStore) UriPropertiesMerger(com.linkedin.d2.balancer.properties.UriPropertiesMerger) ZooKeeperEphemeralStore(com.linkedin.d2.discovery.stores.zk.ZooKeeperEphemeralStore) UriPropertiesJsonSerializer(com.linkedin.d2.balancer.properties.UriPropertiesJsonSerializer) ServiceProperties(com.linkedin.d2.balancer.properties.ServiceProperties) UriProperties(com.linkedin.d2.balancer.properties.UriProperties)

Example 4 with PropertyStoreException

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();
}
Also used : UriPropertiesJsonSerializer(com.linkedin.d2.balancer.properties.UriPropertiesJsonSerializer) ServiceProperties(com.linkedin.d2.balancer.properties.ServiceProperties) ClusterPropertiesJsonSerializer(com.linkedin.d2.balancer.properties.ClusterPropertiesJsonSerializer) ServicePropertiesJsonSerializer(com.linkedin.d2.balancer.properties.ServicePropertiesJsonSerializer) UriProperties(com.linkedin.d2.balancer.properties.UriProperties) ClusterProperties(com.linkedin.d2.balancer.properties.ClusterProperties) UriPropertiesMerger(com.linkedin.d2.balancer.properties.UriPropertiesMerger)

Example 5 with PropertyStoreException

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;
}
Also used : UriPropertiesJsonSerializer(com.linkedin.d2.balancer.properties.UriPropertiesJsonSerializer) ServiceProperties(com.linkedin.d2.balancer.properties.ServiceProperties) ServicePropertiesJsonSerializer(com.linkedin.d2.balancer.properties.ServicePropertiesJsonSerializer) UriProperties(com.linkedin.d2.balancer.properties.UriProperties) ZooKeeperPermanentStore(com.linkedin.d2.discovery.stores.zk.ZooKeeperPermanentStore) UriPropertiesMerger(com.linkedin.d2.balancer.properties.UriPropertiesMerger) ZooKeeperEphemeralStore(com.linkedin.d2.discovery.stores.zk.ZooKeeperEphemeralStore) HashSet(java.util.HashSet)

Aggregations

None (com.linkedin.common.util.None)19 FutureCallback (com.linkedin.common.callback.FutureCallback)18 HashMap (java.util.HashMap)18 UriProperties (com.linkedin.d2.balancer.properties.UriProperties)15 Test (org.testng.annotations.Test)14 PartitionData (com.linkedin.d2.balancer.properties.PartitionData)9 PropertyStoreException (com.linkedin.d2.discovery.stores.PropertyStoreException)9 ServiceProperties (com.linkedin.d2.balancer.properties.ServiceProperties)8 URI (java.net.URI)8 ClusterProperties (com.linkedin.d2.balancer.properties.ClusterProperties)7 ServicePropertiesJsonSerializer (com.linkedin.d2.balancer.properties.ServicePropertiesJsonSerializer)7 UriPropertiesJsonSerializer (com.linkedin.d2.balancer.properties.UriPropertiesJsonSerializer)7 UriPropertiesMerger (com.linkedin.d2.balancer.properties.UriPropertiesMerger)7 IOException (java.io.IOException)7 HashSet (java.util.HashSet)6 PropertyEventBusImpl (com.linkedin.d2.discovery.event.PropertyEventBusImpl)5 ZooKeeperEphemeralStore (com.linkedin.d2.discovery.stores.zk.ZooKeeperEphemeralStore)5 ExecutionException (java.util.concurrent.ExecutionException)5 ClusterPropertiesJsonSerializer (com.linkedin.d2.balancer.properties.ClusterPropertiesJsonSerializer)4 PropertyStringSerializer (com.linkedin.d2.discovery.stores.PropertyStringSerializer)4