Examples of ZooKeeperClusterClient


Examples of com.linkedin.norbert.cluster.javaapi.ZooKeeperClusterClient

public class NorbertJavaNetworkClientMain {
  public static void main(String[] args) {
    InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());

    ClusterClient cc = new ZooKeeperClusterClient(args[0], args[1], 30000);
    NetworkClientConfig config = new NetworkClientConfig();
    config.setClusterClient(cc);
    NetworkClient nc = new NettyNetworkClient(config, new RoundRobinLoadBalancerFactory());
//    PartitionedNetworkClient<Integer> nc = new NettyPartitionedNetworkClient<Integer>(config, new IntegerConsistentHashPartitionedLoadBalancerFactory());
    nc.registerRequest(NorbertExampleProtos.Ping.getDefaultInstance(), NorbertExampleProtos.PingResponse.getDefaultInstance());

    Node node = cc.getNodeWithId(1);

    Future<Message> f = nc.sendMessageToNode(NorbertExampleProtos.Ping.newBuilder().setTimestamp(System.currentTimeMillis()).build(), node);
    try {
      NorbertExampleProtos.PingResponse response = (NorbertExampleProtos.PingResponse) f.get(750, TimeUnit.MILLISECONDS);
      System.out.println(String.format("Ping took %dms", System.currentTimeMillis() - response.getTimestamp()));
    } catch (InterruptedException e) {
      e.printStackTrace();
    } catch (ExecutionException e) {
      e.printStackTrace();
    } catch (TimeoutException e) {
      e.printStackTrace();
    }

    cc.shutdown();
  }
View Full Code Here

Examples of com.linkedin.norbert.javacompat.cluster.ZooKeeperClusterClient

    public ClusterClient buildClusterClient() {
        String clusterName = _senseiConf.getString(SENSEI_CLUSTER_NAME);
        String clusterClientName = _senseiConf.getString(SENSEI_CLUSTER_CLIENT_NAME, clusterName);
        String zkUrl = _senseiConf.getString(SENSEI_CLUSTER_URL);
        int zkTimeout = _senseiConf.getInt(SENSEI_CLUSTER_TIMEOUT, 300000);
        ClusterClient clusterClient = new ZooKeeperClusterClient(clusterClientName, clusterName, zkUrl, zkTimeout);

        logger.info("Connecting to cluster: " + clusterName + " ...");
        clusterClient.awaitConnectionUninterruptibly();

        logger.info("Cluster: " + clusterName + " successfully connected ");

        return clusterClient;
    }
View Full Code Here

Examples of com.linkedin.norbert.javacompat.cluster.ZooKeeperClusterClient

    networkClientConfig.setMaxConnectionsPerNode(maxConnectionsPerNode);
    networkClientConfig.setStaleRequestTimeoutMins(staleRequestTimeoutMins);
    networkClientConfig.setStaleRequestCleanupFrequencyMins(staleRequestCleanupFrequencyMins);
    networkClientConfig.setOutlierMuliplier(outlierMultiplier);
    networkClientConfig.setOutlierConstant(outlierConstant);
    clusterClient = new ZooKeeperClusterClient(clusterName, zkurl, zkTimeout);
    networkClientConfig.setClusterClient(clusterClient);
    networkClient = new SenseiNetworkClient(networkClientConfig, this.loadBalancerFactory);
    clusterClient.awaitConnectionUninterruptibly();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.