Package com.linkedin.d2.balancer.servers

Examples of com.linkedin.d2.balancer.servers.ZooKeeperServer


    // write D2-related configuration to ZooKeeper
    // all the configuration here are permanent, no need to re-write as long as ZooKeeper still has the data
    // therefore in real case, do this "discovery" step separately

    final HttpServer server = RestLiExampleBasicServer.createServer();
    final ZooKeeperConnectionManager zkConn = createZkConn();

    startServer(server, zkConn);

    System.out.println("Example server with D2 is running with URL " + RestLiExampleBasicServer.getServerUrl() + ". Press any key to stop server.");
    System.in.read();
View Full Code Here


      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);

      ZooKeeperServer server = new ZooKeeperServer(uriStore);
      callback = new FutureCallback<None>();
      Map<Integer, PartitionData> partitionDataMap = new HashMap<Integer, PartitionData>();
      partitionDataMap.put(DefaultPartitionAccessor.DEFAULT_PARTITION_ID, new PartitionData(1.0));
      server.markUp(TEST_CLUSTER_NAME, URI.create("http://test.uri"), partitionDataMap, callback);
      callback.get(30, TimeUnit.SECONDS);

      URIRequest request = new URIRequest("d2://" + TEST_SERVICE_NAME + "/foo");
      TransportClient client = balancer.getClient(request, new RequestContext());
View Full Code Here

  {
    ZooKeeperAnnouncer[] zkAnnouncers = new ZooKeeperAnnouncer[d2ServersConfigs.size()];
    for (int i = 0; i < d2ServersConfigs.size(); i++)
    {
      Map<String, Object> d2ServerConfig = d2ServersConfigs.get(i);
      ZooKeeperServer server = new ZooKeeperServer();
      ZooKeeperAnnouncer announcer = new ZooKeeperAnnouncer(server);
      Map<String, Object> partitionDataMap = (Map<String, Object>)
          d2ServerConfig.get("partitionData");
      announcer.setCluster((String) d2ServerConfig.get("d2Cluster"));
      announcer.setUri((String)d2ServerConfig.get("serverUri"));
View Full Code Here

  {
    ZooKeeperAnnouncer[] zkAnnouncers = new ZooKeeperAnnouncer[d2ServersConfigs.size()];
    for (int i = 0; i < d2ServersConfigs.size(); i++)
    {
      Map<String, Object> d2ServerConfig = d2ServersConfigs.get(i);
      ZooKeeperServer server = new ZooKeeperServer();
      ZooKeeperAnnouncer announcer = new ZooKeeperAnnouncer(server);
      Map<String, Object> partitionDataMap = (Map<String, Object>)
          d2ServerConfig.get("partitionData");
      announcer.setCluster((String) d2ServerConfig.get("d2Cluster"));
      announcer.setUri((String)d2ServerConfig.get("serverUri"));
View Full Code Here

      }
    });

    wait.await();

    _announcer = new ZooKeeperServer(zk);

    new JmxManager().registerZooKeeperServer("server", (ZooKeeperServer) _announcer);
    new JmxManager().registerZooKeeperEphemeralStore("uris", zk);
    // announce that the server has started
  }
View Full Code Here

    TogglingPublisher<UriProperties> uriToggle = _factory.createUriToggle(zkUriRegistry, fsUriStore, uriBus);

    SimpleLoadBalancerState state = new SimpleLoadBalancerState(
            executorService, uriBus, clusterBus, serviceBus, _clientFactories, _loadBalancerStrategyFactories,
            _sslContext, _sslParameters, _isSSLEnabled, _clientServicesConfig);
    SimpleLoadBalancer balancer = new SimpleLoadBalancer(state, _lbTimeout, _lbTimeoutUnit);

    TogglingLoadBalancer togLB = _factory.createBalancer(balancer, state, clusterToggle, serviceToggle, uriToggle);
    togLB.start(new Callback<None>() {

      @Override
View Full Code Here

    TogglingPublisher<ServiceProperties> serviceToggle = _factory.createServiceToggle(zkServiceRegistry,
                                                                             fsServiceStore,
                                                                             serviceBus);
    TogglingPublisher<UriProperties> uriToggle = _factory.createUriToggle(zkUriRegistry, fsUriStore, uriBus);

    SimpleLoadBalancerState state = new SimpleLoadBalancerState(
            executorService, uriBus, clusterBus, serviceBus, _clientFactories, _loadBalancerStrategyFactories,
            _sslContext, _sslParameters, _isSSLEnabled, _clientServicesConfig);
    SimpleLoadBalancer balancer = new SimpleLoadBalancer(state, _lbTimeout, _lbTimeoutUnit);

    TogglingLoadBalancer togLB = _factory.createBalancer(balancer, state, clusterToggle, serviceToggle, uriToggle);
View Full Code Here

                                                           List<String> prioritizedSchemes)
  {
    List<SchemeStrategyPair> orderedStrategies = new ArrayList<SchemeStrategyPair>(prioritizedSchemes.size());
    for (String scheme : prioritizedSchemes)
    {
      LoadBalancerStrategy strategy = getStrategy(serviceName, scheme);
      if (strategy != null)
      {
        orderedStrategies.add(new SchemeStrategyPair(
                                scheme,
                                getStrategy(serviceName, scheme))
View Full Code Here

                                                            null,
                                                            null,
                                                            schemes,
                                                            null));

    LoadBalancerStrategy strategy = _state.getStrategy("service-1", "http");

    assertNotNull(strategy);
    assertTrue(strategy instanceof RandomLoadBalancerStrategy);
  }
View Full Code Here

                                                            schemes,
                                                            null));

    assertNotNull(_state.getStrategy("service-1", "http"));

    LoadBalancerStrategy strategy = _state.getStrategy("service-1", "http");

    assertNotNull(strategy);
    assertTrue(strategy instanceof RandomLoadBalancerStrategy);

    // check that we're getting the exact same strategy (by pointer) every time
    assertTrue(strategy == _state.getStrategy("service-1", "http"));
    assertTrue(strategy == _state.getStrategy("service-1", "http"));

    // now make sure adding a cluster property won't change the strategy
    _clusterRegistry.put("cluster-1", new ClusterProperties("cluster-1"));

    // we should still have the same strategy now
    LoadBalancerStrategy newStrategy = _state.getStrategy("service-1", "http");
    assertNotNull(newStrategy);
    assertTrue(strategy == newStrategy);
    assertTrue(newStrategy instanceof RandomLoadBalancerStrategy);

    strategy = newStrategy;
View Full Code Here

TOP

Related Classes of com.linkedin.d2.balancer.servers.ZooKeeperServer

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.