Class STABLE
- All Implemented Interfaces:
Lifecycle
Works as follows: periodically (desired_avg_gossip) or when having received a number of bytes (max_bytes), every member sends its digest (highest seqno delivered, received) to the current coordinator
The coordinator updates a stability vector, which maintains the highest seqno delivered/receive for each member and initially contains no data, when such a message is received.
When messages from all members have been received, a stability message is mcast, which causes all members to send a STABLE event down the stack (triggering garbage collection in the NAKACK{2,3} layer).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classstatic classprotected classMcast periodic STABLE message. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Addressprotected longSends a STABLE gossip every 20 seconds on average.protected MutableDigestprotected booleanprotected final Lockprotected longTotal amount of bytes from incoming messages (default = 0 = disabled).protected static final longprotected longThe total number of bytes received from unicast and multicast messagesprotected final LongAdderprotected final LongAdderprotected final LongAdderprotected final LongAdderprotected final Lockprotected Future<?> protected final Objectprotected Future<?> protected final Lockprotected booleanWhen true, don't take part in garbage collection: neither send STABLE messages nor handle STABILITY messagesprotected TimeSchedulerprotected Viewprotected FixedSizeBitSetKeeps track of who we already heard from (STABLE_GOSSIP msgs).Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanaddVote(int rank) Adds mbr to votes and returns true if we have all the votes, otherwise false.protected static booleanallVotesReceived(FixedSizeBitSet votes) Votes is already locked and guaranteed to be non-nullAn event is to be sent down the stack.A message is sent down the stack.voidgc()longgetBytes()longprotected Digestlongintprotected static intlonglonglonglongbooleanprotected Objecthandle(STABLE.StableHeader hdr, Address sender, Digest digest) protected voidprotected voidhandleStabilityMessage(Digest stable_digest, Address sender, ViewId view_id) protected voidhandleStableMessage(Digest d, Address sender, ViewId view_id) Digest d contains (a) the highest seqnos deliverable for each sender and (b) the highest seqnos seen for each member.protected voidvoidinit()Called after a protocol has been created and before the protocol is started.protected booleanmaxBytesExceeded(int len) protected StringprintDigest(Digest digest) List of events that are required to be answered by some layer belowprotected voidprotected voidvoidprotected voidresume()protected voidsendStabilityMessage(Digest d, ViewId view_id) Sends a stability message to all members except self.protected voidsendStableMessage(boolean send_in_background) Broadcasts a STABLE message of the current digest to all members (or the coordinator only).setDesiredAverageGossip(long g) setMaxBytes(long m) voidstart()This method is called on aJChannel.connect(String); starts work.protected voidstartResumeTask(long max_suspend_time) protected voidvoidstop()Called on aJChannel.disconnect(); stops work (e.g.protected voidprotected voidprotected voidsuspend(long timeout) An event was received from the protocol below.A single message was received.voidup(MessageBatch batch) Sends up a multiple messages in aMessageBatch.protected voidupdateLocalDigest(Digest d, Address sender) Update my own digest from a digest received by somebody else.Methods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, destroy, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, providedUpServices, removePolicy, requiredUpServices, resetStatistics, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, toString
-
Field Details
-
MAX_SUSPEND_TIME
protected static final long MAX_SUSPEND_TIME- See Also:
-
desired_avg_gossip
protected long desired_avg_gossipSends a STABLE gossip every 20 seconds on average. 0 disables gossiping of STABLE messages -
max_bytes
protected long max_bytesTotal amount of bytes from incoming messages (default = 0 = disabled). When exceeded, a STABLE message will be broadcast andnum_bytes_receivedreset to 0 . If this is > 0, then ideallystability_delayshould be set to a low number as well -
num_stable_msgs_sent
-
num_stable_msgs_received
-
num_stability_msgs_sent
-
num_stability_msgs_received
-
view
-
digest
-
votes
Keeps track of who we already heard from (STABLE_GOSSIP msgs). This is all 0's, and we set the sender when a STABLE message is received. When the bitset is all 1's (responses from all members), we send a STABILITY message -
lock
-
stable_task_future
-
stable_task_lock
-
timer
-
num_bytes_received
protected long num_bytes_receivedThe total number of bytes received from unicast and multicast messages -
received
-
suspended
protected volatile boolean suspendedWhen true, don't take part in garbage collection: neither send STABLE messages nor handle STABILITY messages -
initialized
protected boolean initialized -
resume_task_future
-
resume_task_mutex
-
coordinator
-
-
Constructor Details
-
STABLE
public STABLE()
-
-
Method Details
-
getDesiredAverageGossip
public long getDesiredAverageGossip() -
setDesiredAverageGossip
-
getMaxBytes
public long getMaxBytes() -
setMaxBytes
-
getBytes
public long getBytes() -
getNumVotes
public int getNumVotes() -
getStableReceived
public long getStableReceived() -
getStableSent
public long getStableSent() -
getStabilityReceived
public long getStabilityReceived() -
getStabilitySent
public long getStabilitySent() -
getStableTaskRunning
public boolean getStableTaskRunning() -
gc
public void gc() -
printDigest
-
printVotes
-
resetStats
public void resetStats()- Overrides:
resetStatsin classProtocol
-
requiredDownServices
Description copied from class:ProtocolList of events that are required to be answered by some layer below- Overrides:
requiredDownServicesin classProtocol
-
suspend
protected void suspend(long timeout) -
resume
protected void resume() -
init
Description copied from class:ProtocolCalled after a protocol has been created and before the protocol is started. Attributes are already set. Other protocols are not yet connected and events cannot yet be sent. -
start
Description copied from class:ProtocolThis method is called on aJChannel.connect(String); starts work. Protocols are connected ready to receive events. Will be called from bottom to top. -
stop
public void stop()Description copied from class:ProtocolCalled on aJChannel.disconnect(); stops work (e.g. by closing multicast socket). Will be called from top to bottom. -
up
Description copied from class:ProtocolAn event was received from the protocol below. Usually the current protocol will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally, the event is either a) discarded, or b) an event is sent down the stack usingdown_prot.down()or c) the event (or another event) is sent up the stack usingup_prot.up(). -
up
Description copied from class:ProtocolA single message was received. Protocols may examine the message and do something (e.g. add a header) with it before passing it up. -
up
Description copied from class:ProtocolSends up a multiple messages in aMessageBatch. The sender of the batch is always the same, and so is the destination (null == multicast messages). Messages in a batch can be OOB messages, regular messages, or mixed messages, although the transport itself will create initial MessageBatches that contain only either OOB or regular messages.The default processing below sends messages up the stack individually, based on a matching criteria (calling
Protocol.accept(Message)), and - if true - callsProtocol.up(org.jgroups.Event)for that message and removes the message. If the batch is not empty, it is passed up, or else it is dropped.Subclasses should check if there are any messages destined for them (e.g. using
MessageBatch.iterator(Predicate)), then possibly remove and process them and finally pass the batch up to the next protocol. Protocols can also modify messages in place, e.g. ENCRYPT could decrypt all encrypted messages in the batch, not remove them, and pass the batch up when done. -
down
Description copied from class:ProtocolA message is sent down the stack. Protocols may examine the message and do something (e.g. add a header) with it, before passing it down. -
down
Description copied from class:ProtocolAn event is to be sent down the stack. A protocol may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the protocol may need to add a header to it (or do nothing at all) before sending it down the stack usingdown_prot.down(). -
handle
-
handleRegularMessage
-
maxBytesExceeded
protected boolean maxBytesExceeded(int len) -
handleViewChange
-
updateLocalDigest
Update my own digest from a digest received by somebody else. Returns whether the update was successful. Needs to be called with a lock on digest -
resetDigest
protected void resetDigest() -
addVote
protected boolean addVote(int rank) Adds mbr to votes and returns true if we have all the votes, otherwise false.- Parameters:
rank-
-
allVotesReceived
Votes is already locked and guaranteed to be non-null -
getRank
-
startStableTask
protected void startStableTask() -
stopStableTask
protected void stopStableTask() -
startResumeTask
protected void startResumeTask(long max_suspend_time) -
stopResumeTask
protected void stopResumeTask() -
handleStableMessage
Digest d contains (a) the highest seqnos deliverable for each sender and (b) the highest seqnos seen for each member. (Difference: with 1,2,4,5, the highest seqno seen is 5, whereas the highest seqno deliverable is 2). The minimum of all highest seqnos deliverable will be taken to send a stability message, which results in garbage collection of messages lower than the ones in the stability vector. The maximum of all seqnos will be taken to trigger possible retransmission of last missing seqno (see DESIGN for details). -
resetNumBytes
protected void resetNumBytes() -
handleStabilityMessage
-
sendStableMessage
protected void sendStableMessage(boolean send_in_background) Broadcasts a STABLE message of the current digest to all members (or the coordinator only). The message contains the highest seqno delivered and received for all members. The seqnos are retrieved from the NAKACK layer below. -
sendStabilityMessage
Sends a stability message to all members except self.- Parameters:
d- A copy of the stability digest, so we don't need to copy it again
-
getDigest
-
printDigest
-