Package com.linkedin.d2.balancer.clients

Examples of com.linkedin.d2.balancer.clients.TrackerClient


  public static void overrideMinCallCount(int partitionId, double newOverrideDropRate, List<TrackerClientUpdater> trackerClientUpdaters,
                                   Map<URI,Integer> pointsMap, int pointsPerWeight)
  {
    for (TrackerClientUpdater clientUpdater : trackerClientUpdaters)
    {
      TrackerClient client = clientUpdater.getTrackerClient();
      DegraderControl degraderControl = client.getDegraderControl(partitionId);
      int currentOverrideMinCallCount = client.getDegraderControl(partitionId).getOverrideMinCallCount();
      double hashFactor = pointsMap.get(client.getUri()) / pointsPerWeight;
      double transmitFactor = 1.0 - newOverrideDropRate;
      int newOverrideMinCallCount = (int) Math.max(Math.round(degraderControl.getMinCallCount() *
                                                       hashFactor * transmitFactor), 1);

      if (newOverrideMinCallCount != currentOverrideMinCallCount)
      {
        clientUpdater.setOverrideMinCallCount(newOverrideMinCallCount);
        warn(_log,
             "partitionId=",
             partitionId,
             "overriding Min Call Count to ",
             newOverrideMinCallCount,
             " for client: ",
             client.getUri());
      }
    }
  }
View Full Code Here


  @Override
  public TrackerClient getClient(String serviceName, URI uri)
  {
    Map<URI, TrackerClient> trackerClients = _trackerClients.get(serviceName);
    TrackerClient trackerClient = null;

    if (trackerClients != null)
    {
      trackerClient = trackerClients.get(uri);
    }
View Full Code Here

    {
      _log.error("getTrackerClient: invalid scheme for service {}, URI {} and partitionDataMap {}",
          new Object[]{ serviceName, uri, partitionDataMap });
      return null;
    }
    TrackerClient trackerClient = new TrackerClient(uri, partitionDataMap, client, SystemClock.instance(), config,
                                                    callTrackerInterval);
    return trackerClient;
  }
View Full Code Here

      // clients-by-uri map may be edited later by UriPropertiesListener.handlePut
      newTrackerClients = new ConcurrentHashMap<URI, TrackerClient>((int)Math.ceil(uris.size() / 0.75f), 0.75f, 1);
      long trackerClientInterval = getTrackerClientInterval (serviceProperties);
      for (URI uri : uris)
      {
        TrackerClient trackerClient = getTrackerClient(serviceName, uri, uriProperties.getPartitionDataMap(uri),
                                                       config, trackerClientInterval);
        if (trackerClient != null)
        {
          newTrackerClients.put(uri, trackerClient);
        }
View Full Code Here

            }
            long trackerClientInterval = getTrackerClientInterval (serviceProperties.getProperty());
            for (URI uri : discoveryProperties.Uris())
            {
              Map<Integer, PartitionData> partitionDataMap = discoveryProperties.getPartitionDataMap(uri);
              TrackerClient client = trackerClients.get(uri);
              if (client == null || !client.getParttitionDataMap().equals(partitionDataMap))
              {
                 client = getTrackerClient(serviceName,
                    uri,
                    partitionDataMap,
                    config,
                    trackerClientInterval);

                if (client != null)
                {
                  info(_log,
                       "adding new tracker client from updated uri properties: ",
                       client);

                  // notify listeners of the added client
                  for (SimpleLoadBalancerStateListener listener : _listeners)
                  {
                    listener.onClientAdded(serviceName, client);
                  }

                  trackerClients.put(uri, client);
                }
              }
            }
          }
        }

      }

      // replace the URI properties
      _uriProperties.put(listenTo,
                         new LoadBalancerStateItem<UriProperties>(discoveryProperties,
                                                                  _version.incrementAndGet(),
                                                                  System.currentTimeMillis()));

      // now remove URIs that we're tracking, but have been removed from the new uri
      // properties
      if (discoveryProperties != null)
      {
        Set<String> serviceNames = _servicesPerCluster.get(discoveryProperties.getClusterName());
        if (serviceNames != null)
        {
          for (String serviceName : serviceNames)
          {
            Map<URI, TrackerClient> trackerClients = _trackerClients.get(serviceName);
            if (trackerClients != null)
            {
              for (Iterator<URI> it = trackerClients.keySet().iterator(); it.hasNext();)
              {
                URI uri = it.next();

                if (!discoveryProperties.Uris().contains(uri))
                {
                  TrackerClient client = trackerClients.remove(uri);

                  info(_log, "removing dead tracker client: ", client);

                  // notify listeners of the removed client
                  for (SimpleLoadBalancerStateListener listener : _listeners)
View Full Code Here

  @Override
  public TrackerClient getClient(String clusterName, URI uri)
  {
    Map<Integer, PartitionData> partitionDataMap = new HashMap<Integer, PartitionData>(2);
    partitionDataMap.put(DefaultPartitionAccessor.DEFAULT_PARTITION_ID, new PartitionData(1));
    return (getClient) ? new TrackerClient(uri, partitionDataMap, new TestClient()) : null;
  }
View Full Code Here

  }

  @Override
  public TransportClient getClient(String clusterName, String Scheme)
  {
    return (getClient) ? new TestClient() : null;
  }
View Full Code Here

  @Test
  public void testPathAppend()
  {
    URI uri = URI.create("http://test.linkedin.com:9876/test");
    String serviceName = "HistoryService";
    TestClient wrappedClient = new TestClient();
    RewriteClient client = new RewriteClient(serviceName, uri, wrappedClient);

    assertEquals(client.getUri(), uri);
    assertEquals(client.getServiceName(), serviceName);
    assertEquals(client.getWrappedClient(), wrappedClient);
View Full Code Here

  @Override
  public LoadBalancerStateItem<ClusterProperties> getClusterProperties(String clusterName)
  {
    List<String> prioritizedSchemes = new ArrayList<String>();
    prioritizedSchemes.add("http");
    ClusterProperties clusterProperties = new ClusterProperties(_cluster, prioritizedSchemes);
    return new LoadBalancerStateItem<ClusterProperties>(clusterProperties, 1, 1);
  }
View Full Code Here

  @Override
  public LoadBalancerStateItem<ClusterProperties> getClusterProperties(String clusterName)
  {
    return (getClusterProperties)
        ? new LoadBalancerStateItem<ClusterProperties>(new ClusterProperties("cluster-1"),
                                                       0,
                                                       0) : null;
  }
View Full Code Here

TOP

Related Classes of com.linkedin.d2.balancer.clients.TrackerClient

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.