Пример #1
0
 protected byte[] returnPossiblePrevValue(Transport transport) {
   if (hasForceReturn(flags)) {
     byte[] bytes = transport.readArray();
     if (log.isTraceEnabled())
       log.tracef("Previous value bytes is: %s", Util.printArray(bytes, false));
     // 0-length response means null
     return bytes.length == 0 ? null : bytes;
   } else {
     return null;
   }
 }
    @Override
    public SocketAddress getServer(Object key) {
      int keyHashCode = getNormalizedHash(key);
      if (keyHashCode == Integer.MIN_VALUE) keyHashCode += 1;
      int hash = Math.abs(keyHashCode);

      SortedMap<Integer, SocketAddress> candidates = positions.tailMap(hash % hashSpace);
      if (log.isTraceEnabled()) {
        log.tracef("Found possible candidates: %s", candidates);
      }
      return (candidates.size() > 0 ? candidates : positions)
          .entrySet()
          .iterator()
          .next()
          .getValue();
    }