Package com.linkedin.d2.balancer.properties

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


  }

  @Override
  public <K> MapKeyResult<Ring<URI>, K> getRings(URI serviceUri, Iterable<K> keys) throws ServiceUnavailableException
  {
    ServiceProperties service = listenToServiceAndCluster(serviceUri);
    String serviceName = service.getServiceName();
    String clusterName = service.getClusterName();
    ClusterProperties cluster = getClusterProperties(serviceName, clusterName);
    LoadBalancerStateItem<UriProperties> uriItem = getUriItem(serviceName, clusterName, cluster);
    UriProperties uris = uriItem.getProperty();

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

    if (! orderedStrategies.isEmpty())
    {
      LoadBalancerState.SchemeStrategyPair pair = orderedStrategies.get(0);
      PartitionAccessor accessor = getPartitionAccessor(serviceName, clusterName);
View Full Code Here


    return ((ClientFactoryProvider)_state).getClientFactory(scheme);
  }

  public Map<Integer, Ring<URI>> getRings(URI serviceUri) throws ServiceUnavailableException
  {
    ServiceProperties service = listenToServiceAndCluster(serviceUri);
    String serviceName = service.getServiceName();
    String clusterName = service.getClusterName();
    ClusterProperties cluster = getClusterProperties(serviceName, clusterName);

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

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

    if (! orderedStrategies.isEmpty())
    {
      final LoadBalancerState.SchemeStrategyPair pair = orderedStrategies.get(0);
      final PartitionAccessor accessor = getPartitionAccessor(serviceName, clusterName);
View Full Code Here

    }

    // get the service for this uri
    String serviceName = LoadBalancerUtil.getServiceNameFromUri(uri);

    ServiceProperties service = getLoadBalancedServiceProperties(serviceName);

    String clusterName = service.getClusterName();

    listenToCluster(serviceName, clusterName);
    return service;
  }
View Full Code Here

    }
  }

  public static void verifyServiceProperties(String cluster, String service, String path, String serviceGroup) throws IOException, URISyntaxException, PropertyStoreException
  {
    ServiceProperties serviceprops = getServiceProperties(_zkclient, service, serviceGroup);

    assertEquals(serviceprops.getClusterName(), cluster);
    assertEquals(serviceprops.getServiceName(), service);

    assertEquals(serviceprops.getPath(), path);
    assertEquals(serviceprops.getLoadBalancerStrategyList(), Arrays.asList(new String[] {"degrader","degraderV3"}));
    assertEquals(serviceprops.getLoadBalancerStrategyProperties().get("maxClusterLatencyWithoutDegrading"), String.valueOf(500));
    assertEquals(serviceprops.getLoadBalancerStrategyProperties().get("updateIntervalsMs"), String.valueOf(5000));
    assertEquals(serviceprops.getLoadBalancerStrategyProperties().get("defaultSuccessfulTransmissionWeight"), String.valueOf(1.0));
    assertEquals(serviceprops.getLoadBalancerStrategyProperties().get("pointsPerWeight"), String.valueOf(100));
  }
View Full Code Here

  {
    if (numHostPerPartition <= 0)
    {
      throw new IllegalArgumentException("limitHostPartition cannot be 0 or less");
    }
    ServiceProperties service = listenToServiceAndCluster(serviceUri);
    String serviceName = service.getServiceName();
    String clusterName = service.getClusterName();
    ClusterProperties cluster = getClusterProperties(serviceName, clusterName);

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

    List<LoadBalancerState.SchemeStrategyPair> orderedStrategies =
        _state.getStrategiesForService(serviceName, service.getPrioritizedSchemes());
    Map<Integer, Integer> partitionWithoutEnoughHost = new HashMap<Integer, Integer>();
    int maxPartitionId = 0;

    //get the partitionId -> host URIs list
    Map<Integer, List<URI>> hostList = new HashMap<Integer, List<URI>>();
View Full Code Here

  {
    if (limitHostPerPartition <= 0)
    {
      throw new IllegalArgumentException("limitHostPartition cannot be 0 or less");
    }
    ServiceProperties service = listenToServiceAndCluster(serviceUri);
    String serviceName = service.getServiceName();
    String clusterName = service.getClusterName();
    ClusterProperties cluster = getClusterProperties(serviceName, clusterName);

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

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

    if (! orderedStrategies.isEmpty())
    {
      //DANGER we assume that the first strategy in the list has to support partitioning. If not then,
View Full Code Here

  @Override
  public PartitionAccessor getPartitionAccessor(URI serviceUri)
      throws ServiceUnavailableException
  {
    ServiceProperties service = listenToServiceAndCluster(serviceUri);
    String serviceName = service.getServiceName();
    String clusterName = service.getClusterName();
    return getPartitionAccessor(serviceName, clusterName);
  }
View Full Code Here

      prioritizedSchemes.add("http");

      clusterRegistry.put("cluster-1", new ClusterProperties("cluster-1"));

      serviceRegistry.put("foo", new ServiceProperties("foo",
                                                        "cluster-1",
                                                        "/foo",
                                                        "degrader",
                                                        Collections.<String>emptyList(),
                                                        Collections.<String,Object>emptyMap(),
View Full Code Here

          break;
        default: break;
      }


      serviceRegistry.put("foo", new ServiceProperties("foo",
                                                        "cluster-1",
                                                        "/foo",
                                                        "degrader",
                                                        Collections.<String>emptyList(),
                                                        Collections.<String,Object>emptyMap(),
View Full Code Here

      {
        //if this service changes its cluster, we should update the cluster -> service map saying that
        //this service is no longer hosted in the old cluster.
        if (oldServicePropertiesItem != null)
        {
          ServiceProperties oldServiceProperties = oldServicePropertiesItem.getProperty();
          if (oldServiceProperties != null && oldServiceProperties.getClusterName() != null &&
              !oldServiceProperties.getClusterName().equals(discoveryProperties.getClusterName()))
          {
            Set<String> serviceNames =
                          _servicesPerCluster.get(oldServiceProperties.getClusterName());
            if (serviceNames != null)
            {
              serviceNames.remove(oldServiceProperties.getServiceName());
            }
          }
        }

        refreshServiceStrategies(discoveryProperties);
        refreshTransportClientsPerService(discoveryProperties);

        // refresh state for which services are on which clusters
        Set<String> serviceNames =
            _servicesPerCluster.get(discoveryProperties.getClusterName());

        if (serviceNames == null)
        {
          serviceNames =
              Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
          _servicesPerCluster.put(discoveryProperties.getClusterName(), serviceNames);
        }

        serviceNames.add(discoveryProperties.getServiceName());
      }
      else if (oldServicePropertiesItem != null)
      {
        // if we've replaced a service properties with null, update the cluster ->
        // service state that the service is no longer on its cluster.
        ServiceProperties oldServiceProperties = oldServicePropertiesItem.getProperty();

        if (oldServiceProperties != null)
        {
          Set<String> serviceNames =
              _servicesPerCluster.get(oldServiceProperties.getClusterName());

          if (serviceNames != null)
          {
            serviceNames.remove(oldServiceProperties.getServiceName());
          }
        }
      }

      if (discoveryProperties == null)
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.