public class SEQUENCER extends Protocol
Modifier and Type | Class and Description |
---|---|
protected class |
SEQUENCER.Flusher |
static class |
SEQUENCER.SequencerHeader |
Modifier and Type | Field and Description |
---|---|
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,BoundedHashMap<java.lang.Long,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,Message> |
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 |
after_creation_hook, down_prot, ergonomics, id, log, name, stack, stats, up_prot
Constructor and Description |
---|
SEQUENCER() |
Modifier and Type | Method and Description |
---|---|
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(Message msg,
long seqno,
boolean flush) |
protected void |
forwardToCoord(long seqno,
Message msg) |
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.
|
void |
up(MessageBatch batch)
Sends up a multiple messages in a
MessageBatch . |
accept, afterCreationHook, destroy, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, init, isErgonomics, level, parse, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled
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,Message> 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,BoundedHashMap<java.lang.Long,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
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()
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 flushedpublic 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()
.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()
.public void up(MessageBatch batch)
Protocol
MessageBatch
. 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(org.jgroups.Message)
), and - if true - calls Protocol.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.getMatchingMessages(short,boolean)
), 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.protected void handleViewChange(View v)
protected void flush(Address new_coord) throws java.lang.InterruptedException
java.lang.InterruptedException
protected void flushMessagesInForwardTable()
protected void forwardToCoord(long seqno, Message msg)
protected void forward(Message 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()
Copyright © 1998-2020 Red Hat. All Rights Reserved.