public class SEQUENCER2 extends Protocol
Modifier and Type | Class and Description |
---|---|
static class |
SEQUENCER2.SequencerHeader |
Modifier and Type | Field and Description |
---|---|
protected long |
bcast_msgs |
protected long |
broadcasts_sent |
protected Address |
coord |
protected long |
delivered_bcasts |
protected java.util.concurrent.BlockingQueue<Message> |
fwd_queue |
protected boolean |
is_coord |
protected Address |
local_addr |
protected long |
received_bcasts |
protected Table<Message> |
received_msgs |
protected long |
received_requests |
protected long |
received_responses |
protected long |
request_msgs |
protected long |
response_msgs |
protected boolean |
running |
protected long |
sent_requests |
protected long |
sent_responses |
protected java.util.concurrent.atomic.AtomicLong |
seqno |
protected java.util.concurrent.atomic.AtomicInteger |
seqno_reqs |
protected View |
view |
after_creation_hook, down_prot, ergonomics, id, log, name, stack, stats, up_prot
Constructor and Description |
---|
SEQUENCER2() |
Modifier and Type | Method and Description |
---|---|
protected void |
broadcast(Message msg,
long seqno) |
protected void |
deliver(Message msg,
Event evt,
SEQUENCER2.SequencerHeader hdr) |
protected void |
deliverBatch(MessageBatch batch) |
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() |
long |
getBroadcast() |
long |
getBroadcastsSent() |
Address |
getCoordinator() |
int |
getFwdQueueSize() |
Address |
getLocalAddress() |
long |
getReceivedBroadcasts() |
long |
getReceivedRequests() |
protected void |
handleViewChange(View v) |
boolean |
isCoordinator() |
java.lang.String |
printStats() |
protected void |
removeAndDeliver(java.util.concurrent.atomic.AtomicBoolean processing,
Table<Message> win,
Address sender) |
void |
resetStats() |
protected void |
sendSeqnoRequest(int num_seqnos) |
protected void |
sendSeqnoResponse(Address original_sender,
long seqno,
int num_seqnos) |
void |
start()
This method is called on a
Channel.connect(String) . |
void |
stop()
This method is called on a
Channel.disconnect() . |
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.concurrent.BlockingQueue<Message> fwd_queue
protected final java.util.concurrent.atomic.AtomicInteger seqno_reqs
protected volatile boolean running
protected long request_msgs
protected long response_msgs
protected long bcast_msgs
protected long received_bcasts
protected long delivered_bcasts
protected long broadcasts_sent
protected long sent_requests
protected long received_requests
protected long sent_responses
protected long received_responses
public boolean isCoordinator()
public Address getCoordinator()
public Address getLocalAddress()
public long getBroadcast()
public long getReceivedRequests()
public long getReceivedBroadcasts()
public int getFwdQueueSize()
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 long getBroadcastsSent()
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()
.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 sendSeqnoRequest(int num_seqnos)
protected void sendSeqnoResponse(Address original_sender, long seqno, int num_seqnos)
protected void broadcast(Message msg, long seqno)
protected void deliver(Message msg, Event evt, SEQUENCER2.SequencerHeader hdr)
protected void removeAndDeliver(java.util.concurrent.atomic.AtomicBoolean processing, Table<Message> win, Address sender)
protected void deliverBatch(MessageBatch batch)
Copyright © 1998-2020 Red Hat. All Rights Reserved.