|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jgroups.stack.Protocol org.jgroups.protocols.SEQUENCER
public class SEQUENCER
Implementation of total order protocol using a sequencer. Consult SEQUENCER.txt for details
Nested Class Summary | |
---|---|
protected class |
SEQUENCER.Flusher
|
static class |
SEQUENCER.SequencerHeader
|
Field Summary | |
---|---|
protected boolean |
ack_mode
When ack_mode is set, we need to wait for an ack for each forwarded message until we can send the next one |
protected Promise<java.lang.Long> |
ack_promise
Used for each resent message to wait until the message has been received |
protected long |
bcast_msgs
|
protected Address |
coord
|
protected long |
delivered_bcasts
|
protected java.util.concurrent.ConcurrentMap<Address,java.util.NavigableSet<java.lang.Long>> |
delivery_table
|
protected int |
delivery_table_max_size
|
protected SEQUENCER.Flusher |
flusher
|
protected boolean |
flushing
Set when we block all sending threads to resend all messages from forward_table |
protected java.util.NavigableMap<java.lang.Long,byte[]> |
forward_table
Maintains messages forwarded to the coord which which no ack has been received yet. |
protected long |
forwarded_msgs
|
protected java.util.concurrent.atomic.AtomicInteger |
in_flight_sends
Keeps track of the threads sending messages |
protected boolean |
is_coord
|
protected Address |
local_addr
|
protected int |
num_acks
|
protected long |
received_bcasts
|
protected long |
received_forwards
|
protected boolean |
running
|
protected java.util.concurrent.locks.Condition |
send_cond
|
protected java.util.concurrent.locks.Lock |
send_lock
|
protected java.util.concurrent.atomic.AtomicLong |
seqno
|
protected int |
threshold
|
protected View |
view
|
Fields inherited from class org.jgroups.stack.Protocol |
---|
down_prot, ergonomics, id, log, name, stack, stats, up_prot |
Constructor Summary | |
---|---|
SEQUENCER()
|
Method Summary | |
---|---|
protected void |
block()
|
protected void |
broadcast(Message msg,
boolean copy,
Address original_sender,
long seqno,
boolean resend)
|
protected boolean |
canDeliver(Address sender,
long seqno)
Checks if seqno has already been received from sender. |
protected void |
deliver(Message msg,
Event evt,
SEQUENCER.SequencerHeader hdr)
|
java.lang.Object |
down(Event evt)
An event is to be sent down the stack. |
java.util.Map<java.lang.String,java.lang.Object> |
dumpStats()
|
protected void |
flush(Address new_coord)
|
protected void |
flushMessagesInForwardTable()
Sends all messages currently in forward_table to the new coordinator (changing the dest field). |
protected void |
forward(byte[] marshalled_msg,
long seqno,
boolean flush)
|
protected void |
forwardToCoord(byte[] marshalled_msg,
long seqno)
|
long |
getBroadcast()
|
Address |
getCoordinator()
|
long |
getForwarded()
|
int |
getForwardTableSize()
|
Address |
getLocalAddress()
|
long |
getReceivedBroadcasts()
|
long |
getReceivedForwards()
|
protected void |
handleViewChange(View v)
|
boolean |
isCoordinator()
|
java.lang.String |
printStats()
|
void |
resetStats()
|
void |
setDeliveryTableMaxSize(int size)
|
void |
setThreshold(int new_threshold)
|
void |
start()
This method is called on a Channel.connect(String) . |
protected void |
startFlusher(Address new_coord)
|
void |
stop()
This method is called on a Channel.disconnect() . |
protected void |
stopFlusher()
|
protected void |
unblockAll()
|
protected void |
unwrapAndDeliver(Message msg,
boolean flush_ack)
Unmarshal the original message (in the payload) and then pass it up (unless already delivered) |
java.lang.Object |
up(Event evt)
An event was received from the layer below. |
Methods inherited from class org.jgroups.stack.Protocol |
---|
destroy, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, init, isErgonomics, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Address local_addr
protected volatile Address coord
protected volatile View view
protected volatile boolean is_coord
protected final java.util.concurrent.atomic.AtomicLong seqno
protected final java.util.NavigableMap<java.lang.Long,byte[]> forward_table
protected final java.util.concurrent.locks.Lock send_lock
protected final java.util.concurrent.locks.Condition send_cond
protected volatile boolean ack_mode
protected volatile boolean flushing
protected volatile boolean running
protected final java.util.concurrent.atomic.AtomicInteger in_flight_sends
protected final java.util.concurrent.ConcurrentMap<Address,java.util.NavigableSet<java.lang.Long>> delivery_table
protected volatile SEQUENCER.Flusher flusher
protected final Promise<java.lang.Long> ack_promise
protected int delivery_table_max_size
protected int threshold
protected int num_acks
protected long forwarded_msgs
protected long bcast_msgs
protected long received_forwards
protected long received_bcasts
protected long delivered_bcasts
Constructor Detail |
---|
public SEQUENCER()
Method Detail |
---|
public boolean isCoordinator()
public Address getCoordinator()
public Address getLocalAddress()
public long getForwarded()
public long getBroadcast()
public long getReceivedForwards()
public long getReceivedBroadcasts()
public int getForwardTableSize()
public void setThreshold(int new_threshold)
public void setDeliveryTableMaxSize(int size)
public void resetStats()
resetStats
in class Protocol
public java.util.Map<java.lang.String,java.lang.Object> dumpStats()
dumpStats
in class Protocol
public java.lang.String printStats()
printStats
in class Protocol
public void start() throws java.lang.Exception
Protocol
Channel.connect(String)
. Starts work.
Protocols are connected and queues are ready to receive events.
Will be called from bottom to top. This call will replace
the START and START_OK events.
start
in class Protocol
java.lang.Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack
to fail, so Channel.connect(String)
will throw an exceptionpublic void stop()
Protocol
Channel.disconnect()
. Stops work (e.g. by closing multicast socket).
Will be called from top to bottom. This means that at the time of the method invocation the
neighbor protocol below is still working. This method will replace the
STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that
when this method is called all messages in the down queue will have been flushed
stop
in class Protocol
public java.lang.Object down(Event evt)
Protocol
down_prot.down()
. In case of a GET_ADDRESS event (which tries to
retrieve the stack's address from one of the bottom layers), the layer may need to send
a new response event back up the stack using up_prot.up()
.
down
in class Protocol
public java.lang.Object up(Event evt)
Protocol
down_prot.down()
or c) the event (or another event) is sent up
the stack using up_prot.up()
.
up
in class Protocol
protected void handleViewChange(View v)
protected void flush(Address new_coord) throws java.lang.InterruptedException
java.lang.InterruptedException
protected void flushMessagesInForwardTable()
protected void forwardToCoord(byte[] marshalled_msg, long seqno)
protected void forward(byte[] marshalled_msg, long seqno, boolean flush)
protected void broadcast(Message msg, boolean copy, Address original_sender, long seqno, boolean resend)
protected void unwrapAndDeliver(Message msg, boolean flush_ack)
msg
- protected void deliver(Message msg, Event evt, SEQUENCER.SequencerHeader hdr)
protected boolean canDeliver(Address sender, long seqno)
protected void block()
protected void unblockAll()
protected void startFlusher(Address new_coord)
protected void stopFlusher()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |