@Override
  public <KEY> URIMappingResult<KEY> mapUris(List<URIKeyPair<KEY>> requestUriKeyPairs)
      throws ServiceUnavailableException
  {
    if (requestUriKeyPairs == null || requestUriKeyPairs.isEmpty())
    {
      return new URIMappingResult<>(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap());
    }

    // API assumes that all requests will be made to the same service, just use the first request to get the service name and act as sample uri
    URI sampleURI = requestUriKeyPairs.get(0).getRequestUri();
    String serviceName = LoadBalancerUtil.getServiceNameFromUri(sampleURI);

    // To achieve scatter-gather, we require the following information
    PartitionAccessor accessor = _partitionInfoProvider.getPartitionAccessor(serviceName);
    Map<Integer, Ring<URI>> rings = _hashRingProvider.getRings(sampleURI);
    HashFunction<Request> hashFunction = _hashRingProvider.getRequestHashFunction(serviceName);

    Map<Integer, Set<KEY>> unmapped = new HashMap<>();

    // Pass One
    Map<Integer, List<URIKeyPair<KEY>>> requestsByPartition =
        distributeToPartitions(requestUriKeyPairs, accessor, unmapped);

    // Pass Two
    Map<URI, Integer> hostToParitionId = new HashMap<>();
    Map<URI, Set<KEY>> hostToKeySet = distributeToHosts(requestsByPartition, rings, hashFunction, hostToParitionId, unmapped);

    return new URIMappingResult<>(hostToKeySet, unmapped, hostToParitionId);
  }
@Test
  public void testStickyAndPartitioning() throws ServiceUnavailableException
  {
    int partitionCount = 10;
    int requestPerPartition = 100;
    int totalHostCount = 100;

    HashRingProvider ringProvider = createStaticHashRingProvider(totalHostCount, partitionCount, getHashFunction(true));
    PartitionInfoProvider infoProvider = createRangeBasedPartitionInfoProvider(partitionCount);
    URIMapper mapper = new RingBasedUriMapper(ringProvider, infoProvider);

    List<URIKeyPair<Integer>> requests = testUtil.generateRequests(partitionCount, requestPerPartition);

    URIMappingResult<Integer> results = mapper.mapUris(requests);
    Map<URI, Set<Integer>> mapping = results.getMappedKeys();
    Map<Integer, Set<Integer>> unmappedKeys = results.getUnmappedKeys();
    Map<URI, Integer> hostToPartition = results.getHostPartitionInfo();

    Assert.assertTrue(unmappedKeys.isEmpty());
    Assert.assertEquals(100, mapping.size());
    Assert.assertEquals(100, hostToPartition.size());
  }