@Override
  public boolean write() throws IOException {
    Send send = networkSend.getPayload();
    if (send == null) {
      throw new IllegalStateException("Registered for write interest but no response attached to key.");
    }
    if (!closing && handshakeComplete) {
      if (!flush(netWriteBuffer)) {
        return false;
      }
    }
    if (networkSend.maySetSendStartTimeInMs()) {
      metrics.transmissionSendPendingTime.update(time.milliseconds() - networkSend.getSendCreateTimeInMs());
    }
    long startTimeMs = time.milliseconds();
    long bytesWritten = send.writeTo(this);
    long writeTimeMs = time.milliseconds() - startTimeMs;
    logger.trace("Bytes written {} to {} using key {} Time: {} ms", bytesWritten,
        socketChannel.socket().getRemoteSocketAddress(), getConnectionId(), writeTimeMs);
    if (bytesWritten > 0) {
      metrics.transmissionSendTime.update(writeTimeMs);
      metrics.transmissionSendSize.update(bytesWritten);
    }
    return (send.isSendComplete() && netWriteBuffer.remaining() == 0);
  }
Reads a sequence of bytes from this channel into the given buffer. Reads as much as possible
until either the dst buffer is full or there is no more data in the socket.

@param dst The buffer into which bytes are to be transferred
@return The number of bytes read, possible zero or -1 if the channel has reached end-of-stream
        and no more data is available
@throws IOException if some other I/O error occurs
ambry-network/src/main/java/com/github/ambry/network/SSLTransmission.java