Package com.linkedin.d2.balancer.properties

Examples of com.linkedin.d2.balancer.properties.ServiceProperties


      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"),
View Full Code Here


    if (_balancer != null)
    {
      try
      {
        String serviceName = LoadBalancerUtil.getServiceNameFromUri(uri);
        ServiceProperties serviceProperties = _balancer.getLoadBalancedServiceProperties(serviceName);
        if (serviceProperties != null)
        {
          return Collections.unmodifiableMap(serviceProperties.getServiceMetadataProperties());
        }
      }
      catch (ServiceUnavailableException e)
      {
        error(_log, e);
View Full Code Here

    _state.listenToCluster("cluster-1", new NullStateListenerCallback());
    _clusterRegistry.put("cluster-1", new ClusterProperties("cluster-1"));

    // then add a service
    _state.listenToService("service-1", new NullStateListenerCallback());
    _serviceRegistry.put("service-1", new ServiceProperties("service-1",
                                                            "cluster-1",
                                                            "/test",
                                                            "random",
                                                            Collections.<String>emptyList(),
                                                            Collections.<String, Object>emptyMap(),
                                                            null,
                                                            null,
                                                            schemes,
                                                            null));

    // this should trigger a refresh
    assertEquals(listener.scheme, "http");
    assertTrue(listener.strategy instanceof RandomLoadBalancerStrategy);
    assertEquals(listener.serviceName, "service-1");

    // then update the cluster
    _clusterRegistry.put("cluster-1", new ClusterProperties("cluster-1"));

    // this triggered a second refresh, but also an onStrategyRemoved. The onStrategyRemoved should
    // be done first, and then the onStrategyAdd, so we should still see a valid strategy.
    assertEquals(listener.scheme, "http");
    assertTrue(listener.strategy instanceof RandomLoadBalancerStrategy);
    assertEquals(listener.serviceName, "service-1");

    _state.listenToCluster("partition-cluster-1", new NullStateListenerCallback());
    _clusterRegistry.put("partition-cluster-1", new ClusterProperties("partition-cluster-1", null,
        new HashMap<String, String>(), new HashSet<URI>(), new RangeBasedPartitionProperties("id=(\\d+)", 0, 100, 2)));

    _state.listenToService("partition-service-1", new NullStateListenerCallback());
    _serviceRegistry.put("partition-service-1",
        new ServiceProperties("partition-service-1",
        "partition-cluster-1", "/partition-test", "degraderV3",
        Collections.<String>emptyList(),
        Collections.<String, Object>emptyMap(),
        null,
        null,
View Full Code Here

    _state.listenToCluster("cluster-1", new NullStateListenerCallback());
    _clusterRegistry.put("cluster-1", new ClusterProperties("cluster-1"));

    // then add a service
    _state.listenToService("service-1", new NullStateListenerCallback());
    _serviceRegistry.put("service-1", new ServiceProperties("service-1", "cluster-1", "/test", "random",
                                                            Collections.<String>emptyList(),
                                                            Collections.<String, Object> emptyMap(),
                                                            null, null,
                                                            schemes, null));
View Full Code Here

    // set up state
    _state.listenToCluster("cluster-1", new NullStateListenerCallback());
    _state.listenToService("service-1", new NullStateListenerCallback());
    _clusterRegistry.put("cluster-1", new ClusterProperties("cluster-1", schemes));
    _uriRegistry.put("cluster-1", new UriProperties("cluster-1", uriData));
    _serviceRegistry.put("service-1", new ServiceProperties("service-1",
                                                            "cluster-1",
                                                            "/test",
                                                            "random"));

    TrackerClient client = _state.getClient("cluster-1", uri);
View Full Code Here

            _state.getServiceProperties(possibleService);
        assertTrue(serviceItem == null || serviceItem.getProperty() == null);
      }
      else
      {
        ServiceProperties serviceProperties =
            _expectedServiceProperties.get(possibleService);
        ClusterProperties clusterProperties =
            _expectedClusterProperties.get(serviceProperties.getClusterName());
        UriProperties uriProperties =
            _expectedUriProperties.get(serviceProperties.getClusterName());

        assertEquals(_state.getServiceProperties(possibleService).getProperty(),
                     serviceProperties);

        // verify round robin'ing of the hosts for this service
View Full Code Here

  public void addService(String serviceName,
                         String clusterName,
                         String path,
                         String loadBalancerStrategyName)
  {
    ServiceProperties serviceProperties =
        new ServiceProperties(serviceName, clusterName, path, loadBalancerStrategyName);

    _expectedServiceProperties.put(serviceName, serviceProperties);
    _serviceRegistry.put(serviceName, serviceProperties);
  }
View Full Code Here

      for (final LoadBalancerEchoServer server : servers.getValue())
      {
        for (int i = 1; i <= 3; ++i)
        {
          putService(new ServiceProperties("service-" + i + "-" + servers.getKey(),
                                           servers.getKey(),
                                           File.separator + "service-" + i + "-"
                                               + servers.getKey(),
                                           "degrader"));
        }
View Full Code Here

        for (String serviceGroup : servicesGroupMap.keySet())
        {
          ZooKeeperPermanentStore<ServiceProperties> zkStorePropsForSerivceGroup = zkServiceRegistryMap.get(serviceGroup);
          if (zkStorePropsForSerivceGroup != null)
          {
            ServiceProperties serviceProps = zkStorePropsForSerivceGroup.get(service);
          if (serviceProps != null)
          {
            if (cluster.equals(serviceProps.getClusterName()))
            {
                sb.append("\n-------------------");
                sb.append("\nSERVICE '" + service + "':");

                sb.append(printStore(zkClusterRegistry, zkUriRegistry, zkServiceRegistryMap.get(serviceGroup), cluster, service));
View Full Code Here

  {
    TransportClient client;
    URI uri = request.getURI();
    debug(_log, "get client for uri: ", uri);

    ServiceProperties service = listenToServiceAndCluster(uri);

    String serviceName = service.getServiceName();
    String clusterName = service.getClusterName();
    ClusterProperties cluster = getClusterProperties(serviceName, clusterName);

    // Check if we want to override the service URL and bypass choosing among the existing
    // tracker clients. This is useful when the service we want is not announcing itself to
    // the cluster, ie a private service for a set of clients.
    URI targetService = LoadBalancerUtil.TargetHints.getRequestContextTargetService(requestContext);

    if (targetService == null)
    {
      LoadBalancerStateItem<UriProperties> uriItem = getUriItem(serviceName, clusterName, cluster);
      UriProperties uris = uriItem.getProperty();

      List<LoadBalancerState.SchemeStrategyPair> orderedStrategies =
              _state.getStrategiesForService(serviceName,
                                             service.getPrioritizedSchemes());

      TrackerClient trackerClient = chooseTrackerClient(request, requestContext, serviceName, clusterName, cluster,
                                                        uriItem, uris, orderedStrategies, service);

      String clusterAndServiceUriString = trackerClient.getUri() + service.getPath();
      client = new RewriteClient(serviceName,
                                               URI.create(clusterAndServiceUriString),
                                               trackerClient);

      _serviceAvailableStats.inc();
View Full Code Here

TOP

Related Classes of com.linkedin.d2.balancer.properties.ServiceProperties

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.