public StreamRequestHandlerState handleRequest(
      DataInputStream inputStream, DataOutputStream outputStream) throws IOException {
    if (!keyIterator.hasNext()) return StreamRequestHandlerState.COMPLETE;

    long startNs = System.nanoTime();
    ByteArray key = keyIterator.next();
    stats.recordDiskTime(handle, System.nanoTime() - startNs);

    throttler.maybeThrottle(key.length());
    if (validPartition(key.get()) && filter.accept(key, null) && counter % skipRecords == 0) {
      VAdminProto.FetchPartitionEntriesResponse.Builder response =
          VAdminProto.FetchPartitionEntriesResponse.newBuilder();
      response.setKey(ProtoUtils.encodeBytes(key));

      fetched++;
      handle.incrementEntriesScanned();
      Message message = response.build();

      startNs = System.nanoTime();
      ProtoUtils.writeMessage(outputStream, message);
      stats.recordNetworkTime(handle, System.nanoTime() - startNs);
    }

    // log progress
    counter++;

    if (0 == counter % 100000) {
      long totalTime = (System.currentTimeMillis() - startTime) / 1000;

      if (logger.isDebugEnabled())
        logger.debug(
            "fetchKeys() scanned "
                + counter
                + " keys, fetched "
                + fetched
                + " keys for store:"
                + storageEngine.getName()
                + " partition:"
                + partitionList
                + " in "
                + totalTime
                + " s");
    }

    if (keyIterator.hasNext()) return StreamRequestHandlerState.WRITING;
    else {
      stats.closeHandle(handle);
      return StreamRequestHandlerState.COMPLETE;
    }
  }
 private VProto.GetAllResponse handleGetAll(
     VProto.GetAllRequest request, Store<ByteArray, byte[]> store) {
   VProto.GetAllResponse.Builder response = VProto.GetAllResponse.newBuilder();
   try {
     List<ByteArray> keys = new ArrayList<ByteArray>(request.getKeysCount());
     for (ByteString string : request.getKeysList()) keys.add(ProtoUtils.decodeBytes(string));
     Map<ByteArray, List<Versioned<byte[]>>> values = store.getAll(keys);
     for (Map.Entry<ByteArray, List<Versioned<byte[]>>> entry : values.entrySet()) {
       VProto.KeyedVersions.Builder keyedVersion =
           VProto.KeyedVersions.newBuilder().setKey(ProtoUtils.encodeBytes(entry.getKey()));
       for (Versioned<byte[]> version : entry.getValue())
         keyedVersion.addVersions(ProtoUtils.encodeVersioned(version));
       response.addValues(keyedVersion);
     }
   } catch (VoldemortException e) {
     response.setError(ProtoUtils.encodeError(getErrorMapper(), e));
   }
   return response.build();
 }