Package com.linkedin.d2.discovery.stores.zk

Examples of com.linkedin.d2.discovery.stores.zk.ZKConnection


      ZKFSLoadBalancer balancer = getBalancer();
      FutureCallback<None> callback = new FutureCallback<None>();
      balancer.start(callback);
      callback.get(30, TimeUnit.SECONDS);

      ZKConnection conn = new ZKConnection("localhost:" + PORT, 30000);
      conn.start();

      ZooKeeperPermanentStore<ServiceProperties> store =
              new ZooKeeperPermanentStore<ServiceProperties>(conn, new ServicePropertiesJsonSerializer(), ZKFSUtil.servicePath(BASE_PATH));
      callback = new FutureCallback<None>();
      store.start(callback);
      callback.get(30, TimeUnit.SECONDS);


      ServiceProperties props = new ServiceProperties(TEST_SERVICE_NAME, TEST_CLUSTER_NAME, "/somePath", "degrader",
                                                      Collections.<String>emptyList(),
                                                      Collections.<String, Object>emptyMap(),
                                                      null,
                                                      null,
                                                      Arrays.asList("http"),
                                                      null);
      store.put(TEST_SERVICE_NAME, props);

      ZooKeeperPermanentStore<ClusterProperties> clusterStore =
              new ZooKeeperPermanentStore<ClusterProperties>(conn, new ClusterPropertiesJsonSerializer(), ZKFSUtil.clusterPath(BASE_PATH));
      callback = new FutureCallback<None>();
      clusterStore.start(callback);
      callback.get(30, TimeUnit.SECONDS);

      ClusterProperties clusterProps = new ClusterProperties("someCluster");
      clusterStore.put(TEST_CLUSTER_NAME, clusterProps);

      ZKConnection serverConn = new ZKConnection("localhost:" + PORT, 30000);
      serverConn.start();
      ZooKeeperEphemeralStore<UriProperties> uriStore = new ZooKeeperEphemeralStore<UriProperties>(serverConn, new UriPropertiesJsonSerializer(), new UriPropertiesMerger(), ZKFSUtil.uriPath(BASE_PATH));
      callback = new FutureCallback<None>();
      uriStore.start(callback);
      callback.get(30, TimeUnit.SECONDS);
View Full Code Here


      PropertyStoreException,
      ExecutionException
  {
    URI uri1 = URI.create("http://cluster-1/test");
    URI uri2 = URI.create("http://cluster-1-again/test");
    ZKConnection zkClient = new ZKConnection("localhost:" + PORT, 5000);
    zkClient.start();

    ZooKeeperEphemeralStore<UriProperties> store =
        new ZooKeeperEphemeralStore<UriProperties>(zkClient,
                                                   new UriPropertiesJsonSerializer(),
                                                   new UriPropertiesMerger(),
View Full Code Here

    {
      LOG.info("ZK flag file: {}", _zkFlagFile.getAbsolutePath());
      LOG.info("ZK currently suppressed by flag file: {}", suppressZK());
    }

    _zkConnection = new ZKConnection(_connectString, _sessionTimeout, _shutdownAsynchronously, _isSymlinkAware);
    final TogglingLoadBalancer balancer = _loadBalancerFactory.createLoadBalancer(_zkConnection, _executor);

    // _currentLoadBalancer will never be null except the first time this method is called.
    // In this case we want the not-yet-started load balancer to service client requests.  In
    // all other cases, we service requests from the old LoadBalancer until the new one is started
View Full Code Here

    _validPaths = Collections.unmodifiableSet(validPaths);

    // set up the lb announcer. if we can't connect, give up. in production, there would
    // be a JMX hook to "retry" if we're not connected.

    final ZKConnection zkClient = ZKTestUtil.getConnection(zookeeperHost+":"+zookeeperPort, _timeout);

    ZooKeeperEphemeralStore<UriProperties> zk =
        new ZooKeeperEphemeralStore<UriProperties>(zkClient,
                                                   new UriPropertiesJsonSerializer(),
                                                   new UriPropertiesMerger(),
View Full Code Here

    // zk stores
    ZooKeeperPermanentStore<ClusterProperties> zkClusterRegistry = null;
    ZooKeeperPermanentStore<ServiceProperties> zkServiceRegistry = null;
    ZooKeeperEphemeralStore<UriProperties> zkUriRegistry = null;

    ZKConnection zkClient = new ZKConnection(hostPort, 10000);

    zkClusterRegistry =
        new ZooKeeperPermanentStore<ClusterProperties>(zkClient,
                                                       new ClusterPropertiesJsonSerializer(),
                                                       _basePath+"/clusters");
View Full Code Here

  {
    if (!_startupCallback.compareAndSet(null, callback))
    {
      throw new IllegalStateException("Already starting");
    }
    _zkConnection = new ZKConnection(_zkConnectString,
                                    _zkSessionTimeout,
                                    _limit,
                                    _exponentialBackoff,
                                    _scheduler,
                                    _initInterval);
View Full Code Here

  private void putService(ServiceProperties serviceProperties) throws Exception
  {
    System.err.println("put: " + serviceProperties);

    ZKConnection client = new ZKConnection(_zookeeperHost+":"+_zookeeperPort, 30000);

    PropertyStore<ServiceProperties> store =
        new ZooKeeperPermanentStore<ServiceProperties>(client,
                                                       new ServicePropertiesJsonSerializer(),
                                                       _basePath+"/services");

    store.put(serviceProperties.getServiceName(), serviceProperties);
    client.getZooKeeper().close();
  }
View Full Code Here

  private void putCluster(ClusterProperties clusterProperties) throws Exception
  {
    System.err.println("put: " + clusterProperties);

    ZKConnection client = new ZKConnection(_zookeeperHost+":"+_zookeeperPort, 30000);
    PropertyStore<ClusterProperties> store =
        new ZooKeeperPermanentStore<ClusterProperties>(client,
                                                       new ClusterPropertiesJsonSerializer(),
                                                       _basePath+"/clusters");

    store.put(clusterProperties.getClusterName(), clusterProperties);
    client.getZooKeeper().close();
  }
View Full Code Here

    return _service;
  }

  public ZKConnection createZkClient(String zkserverHostPort)
  {
    _zkclient = new ZKConnection(zkserverHostPort.replace("zk://",""), 10000);

    return _zkclient;
  }
View Full Code Here

    _zkServer.shutdown();
  }

  protected ZKConnection getConnection()
  {
    ZKConnection conn = new ZKConnection(CONNECT, TIMEOUT);
    try
    {
      conn.start();
      conn.waitForState(Watcher.Event.KeeperState.SyncConnected, TIMEOUT, TimeUnit.SECONDS);
    }
    catch (Exception e)
    {
      throw new RuntimeException(e);
    }
View Full Code Here

TOP

Related Classes of com.linkedin.d2.discovery.stores.zk.ZKConnection

Copyright © 2018 www.massapicom. 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.