public interface StateMachine
Zab
.Modifier and Type | Method and Description |
---|---|
void |
deliver(Zxid zxid,
ByteBuffer stateUpdate,
String clientId,
Object ctx)
Callback for
Zab.send(java.nio.ByteBuffer, java.lang.Object) . |
void |
flushed(Zxid zxid,
ByteBuffer flushRequest,
Object ctx)
Callback for
Zab.flush(java.nio.ByteBuffer, java.lang.Object) . |
void |
following(String leader,
Set<String> clusterMembers)
Notifies the state machine that
Zab is in following phase with
given leader and cluster members. |
void |
leading(Set<String> activeFollowers,
Set<String> clusterMembers)
Notifies the state machine that
Zab is in leading phase with given
sets of active followers and cluster members. |
ByteBuffer |
preprocess(Zxid zxid,
ByteBuffer message)
Converts a message to an idempotent transaction.
|
void |
recovering(PendingRequests pendingRequests)
Notifies the state machine that
Zab is in recovering phase. |
void |
removed(String serverId,
Object ctx)
Callback for
Zab.remove(java.lang.String, java.lang.Object) . |
void |
restore(FileInputStream fis)
Deserializes the application state from a
FileInputStream . |
void |
save(FileOutputStream fos)
Serializes the application state to a
FileOutputStream . |
void |
snapshotDone(String filePath,
Object ctx)
Callback for
Zab.takeSnapshot(java.lang.Object) . |
ByteBuffer preprocess(Zxid zxid, ByteBuffer message)
zxid
- zxid of the message.message
- the original messagevoid deliver(Zxid zxid, ByteBuffer stateUpdate, String clientId, Object ctx)
Zab.send(java.nio.ByteBuffer, java.lang.Object)
. This method is called from a single
thread to ensure that the state updates are applied in the same order
as they arrived. Zab
assumes that the transaction is successfully
applied to the state machine when this method returns.zxid
- zxid of the messagestateUpdate
- the incremental state updateclientId
- the id of the client who sends the request. The request
delivered in RECOVERING phase has clientId sets to null.ctx
- the context object.void flushed(Zxid zxid, ByteBuffer flushRequest, Object ctx)
Zab.flush(java.nio.ByteBuffer, java.lang.Object)
. This method is called from the same
thread as the deliver(com.github.zk1931.jzab.Zxid, java.nio.ByteBuffer, java.lang.String, java.lang.Object)
callback.flushRequest
- the flush request.ctx
- the context object.void snapshotDone(String filePath, Object ctx)
Zab.takeSnapshot(java.lang.Object)
.filePath
- the path for the snapshot file.ctx
- the context object.void removed(String serverId, Object ctx)
Zab.remove(java.lang.String, java.lang.Object)
.serverId
- the ID of the server whom gets removed.ctx
- the context object.void save(FileOutputStream fos)
FileOutputStream
.fos
- file to write the state to.void restore(FileInputStream fis)
FileInputStream
.fis
- file to read the state from.void recovering(PendingRequests pendingRequests)
Zab
is in recovering phase. When
Zab
goes from leading/following phase to recovering phase, there
might be requests that have been submitted to Zab
but haven't been
delivered back to the state machine. These requests, along with their
associated contexts, are passed backed to the state machine. Note that
these requests might or might not have been committed by Zab
.pendingRequests
- the pending requests, see PendingRequests
.void leading(Set<String> activeFollowers, Set<String> clusterMembers)
Zab
is in leading phase with given
sets of active followers and cluster members. This method gets called when
Zab
transitions from recovering phase to leading phase. It also
gets called when there is a change in active followers or cluster
membership while Zab
is in leading phase. This method is called
from the same thread as deliver(com.github.zk1931.jzab.Zxid, java.nio.ByteBuffer, java.lang.String, java.lang.Object)
.activeFollowers
- current alive followers.clusterMembers
- the members of new configuration.void following(String leader, Set<String> clusterMembers)
Zab
is in following phase with
given leader and cluster members. This method gets called when Zab
transitions from recovering phase to following phase. It also gets called
when there is a change in cluster membership while Zab
is in
following phase. This method is called from the same thread as
deliver(com.github.zk1931.jzab.Zxid, java.nio.ByteBuffer, java.lang.String, java.lang.Object)
.leader
- current leader.clusterMembers
- the members of new configuration.Copyright © 2015. All rights reserved.