/**
   * returns the request object list for the {@code member}
   *
   * @param member the destination member
   * @return the request object list. It can be empty if no requests are necessary
   */
  public final synchronized ObjectRequest getObjectRequestForAddress(Address member) {
    int addressIndex = clusterSnapshot.indexOf(member);

    if (addressIndex == -1) {
      log.warnf(
          "Trying to get Object Requests to send to %s but it does not exists in cluster snapshot %s",
          member, clusterSnapshot);
      return new ObjectRequest(null, null);
    }

    ObjectRequest request = accessesByPrimaryOwner[addressIndex].toObjectRequest();

    if (log.isInfoEnabled()) {
      log.debugf(
          "Getting request list for %s. Request is %s",
          member, request.toString(log.isDebugEnabled()));
    }

    return request;
  }
  /**
   * sort the keys and number of access by primary owner
   *
   * @param accesses the remote accesses
   * @param remote true if the accesses to process are from remote access, false otherwise
   */
  @SuppressWarnings("unchecked")
  private void sortObjectsByPrimaryOwner(Map<Object, Long> accesses, boolean remote) {
    Map<Object, List<Address>> primaryOwners =
        getDefaultConsistentHash().locateAll(accesses.keySet(), 1);

    for (Entry<Object, Long> entry : accesses.entrySet()) {
      Object key = entry.getKey();
      Address primaryOwner = primaryOwners.remove(key).get(0);
      int addressIndex = clusterSnapshot.indexOf(primaryOwner);

      if (addressIndex == -1) {
        log.warnf(
            "Primary owner [%s] does not exists in cluster snapshot %s",
            primaryOwner, clusterSnapshot);
        continue;
      }

      accessesByPrimaryOwner[addressIndex].add(entry.getKey(), entry.getValue(), remote);
    }
  }