@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 (networkSend.maySetSendStartTimeInMs()) {
      metrics.transmissionSendPendingTime.update(time.milliseconds() - networkSend.getSendCreateTimeInMs());
    }
    long startTimeMs = time.milliseconds();
    long bytesWritten = send.writeTo(socketChannel);
    long writeTimeMs = time.milliseconds() - startTimeMs;
    logger.trace("Bytes written {} to {} using key {} Time: {}", bytesWritten,
        socketChannel.socket().getRemoteSocketAddress(), getConnectionId(), writeTimeMs);
    if (bytesWritten > 0) {
      metrics.transmissionSendTime.update(writeTimeMs);
      metrics.transmissionSendSize.update(bytesWritten);
    }
    return send.isSendComplete();
  }
Writes a sequence of bytes to the channel from the payload in {@link NetworkSend}

@return true if {@link Send} in {@link NetworkSend} is completely written to the channel, false otherwise
@throws IOException If some other I/O error occurs
ambry-network/src/main/java/com/github/ambry/network/PlainTextTransmission.java