Interface StreamReplicator.Writer

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

public static interface StreamReplicator.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

    • write

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

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

      default int write(byte[] messages, int offset, int length, long highestPosition) throws IOException
      Write complete or partial messages to the log. The highestPosition parameter defines the new absolute log position which can become the commit position. The provided highest position is permitted to exceed the current log size, in anticipation of future writes which will fill in the gap. Until the gap is filled in, the highest position won't be applied. In addition, the highest position can only ever advance. Passing in a smaller value for the highest position won't actually change it. If all of the provided messages are partial, simply pass zero as the highest position. To update the highest position without actually writing anything, pass a length of zero.
      Parameters:
      highestPosition - highest position (exclusive) which can become the commit position
      Returns:
      1 if successful, -1 if fully deactivated, or 0 if should write any remaining messages and then close the writer
      Throws:
      IOException
    • write

      int write(byte[] prefix, byte[] messages, int offset, int length, long highestPosition) throws IOException
      Write complete or partial messages to the log.
      Parameters:
      prefix - optional prefix message to fully write, which advances the log position just like any other message
      highestPosition - highest position (exclusive) which can become the commit position
      Returns:
      1 if successful, -1 if fully deactivated, or 0 if should write any remaining messages and then close the writer
      Throws:
      IOException