Interface MessageReplicator.Writer

All Superinterfaces:
AutoCloseable, Closeable, Replicator.Accessor, Replicator.Writer
Enclosing interface:
MessageReplicator

public static interface MessageReplicator.Writer extends Replicator.Writer
Interface called by the group leader for proposing messages. When consensus has been reached, the messages are committed and become available for all members to read.
See Also:
  • Method Details

    • writeMessage

      default int writeMessage(byte[] message) throws IOException
      Write a single message to the log. Equivalent to: writeMessage(message, 0, message.length, true)
      Returns:
      1 if successful, -1 if fully deactivated, or 0 if should write any remaining messages and then close the writer
      Throws:
      IOException
    • writeMessage

      default int writeMessage(byte[] message, int offset, int length) throws IOException
      Write a single message to the log. Equivalent to: writeMessage(message, offset, length, true)
      Returns:
      1 if successful, -1 if fully deactivated, or 0 if should write any remaining messages and then close the writer
      Throws:
      IOException
    • writeMessage

      int writeMessage(byte[] message, int offset, int length, boolean finished) throws IOException
      Write a single message to the log, as part of an atomic batch. When read back, all messages in the batch are still separate from each other. Pass false to the finished parameter for all messages in the batch except the last one. To work correctly, no other threads should be granted access to the writer in the middle of a batch.
      Parameters:
      finished - pass true for the last message in the batch
      Returns:
      1 if successful, -1 if fully deactivated, or 0 if should write any remaining messages and then close the writer
      Throws:
      IOException