Interface MessageReplicator.Writer
- All Superinterfaces:
AutoCloseable
,Closeable
,Replicator.Accessor
,Replicator.Writer
- Enclosing interface:
MessageReplicator
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
writeMessage
(byte[] message) Write a single message to the log.default int
writeMessage
(byte[] message, int offset, int length) Write a single message to the log.int
writeMessage
(byte[] message, int offset, int length, boolean finished) Write a single message to the log, as part of an atomic batch.Methods inherited from interface org.cojen.tupl.repl.Replicator.Accessor
addCommitListener, close, commitPosition, position, term, termEndPosition, termStartPosition, uponCommit, waitForCommit, waitForEndCommit
-
Method Details
-
writeMessage
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
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
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
-