Interface StreamReplicator.Writer
- All Superinterfaces:
AutoCloseable
,Closeable
,Replicator.Accessor
,Replicator.Writer
- Enclosing interface:
StreamReplicator
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 Summary
Modifier and TypeMethodDescriptiondefault int
write
(byte[] messages) Write complete messages to the log.int
write
(byte[] prefix, byte[] messages, int offset, int length, long highestPosition) Write complete or partial messages to the log.default int
write
(byte[] messages, int offset, int length) Write complete messages to the log.default int
write
(byte[] messages, int offset, int length, long highestPosition) Write complete or partial messages to the log.Methods inherited from interface org.cojen.tupl.repl.Replicator.Accessor
addCommitListener, close, commitPosition, position, term, termEndPosition, termStartPosition, uponCommit, waitForCommit, waitForEndCommit
-
Method Details
-
write
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
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
Write complete or partial messages to the log. ThehighestPosition
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 messagehighestPosition
- 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
-