private int readPreamble() throws IOException {
    if (preambleBuffer == null) {
      preambleBuffer = ByteBuffer.allocate(6);
    }
    int count = this.rpcServer.channelRead(channel, preambleBuffer);
    if (count < 0 || preambleBuffer.remaining() > 0) {
      return count;
    }
    preambleBuffer.flip();
    PreambleResponse resp = processPreamble(preambleBuffer);
    switch (resp) {
      case SUCCEED:
        preambleBuffer = null; // do not need it anymore
        connectionPreambleRead = true;
        return count;
      case CONTINUE:
        // wait for the next preamble header
        preambleBuffer.clear();
        return count;
      case CLOSE:
        return -1;
      default:
        throw new IllegalArgumentException("Unknown preamble response: " + resp);
    }
  }
Reads calls from a connection and queues them for handling.
hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerRpcConnection.java