public class SEQUENCER2 extends Protocol
Modifier and Type | Class and Description |
---|---|
static class |
SEQUENCER2.SequencerHeader |
Modifier and Type | Field and Description |
---|---|
protected static BiConsumer<MessageBatch,Message> |
BATCH_ACCUMULATOR |
protected long |
bcasts_delivered |
protected long |
bcasts_received |
protected long |
bcasts_sent |
protected Address |
coord |
protected BlockingQueue<Message> |
fwd_queue |
protected boolean |
is_coord |
protected Address |
local_addr |
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 AtomicLong |
seqno |
protected AtomicInteger |
seqno_reqs |
protected View |
view |
after_creation_hook, down_prot, ergonomics, id, log, 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,
SEQUENCER2.SequencerHeader hdr) |
protected void |
deliverBatch(MessageBatch batch) |
Object |
down(Event evt)
An event is to be sent down the stack.
|
Object |
down(Message msg)
A message is sent down the stack.
|
Address |
getCoordinator() |
int |
getFwdQueueSize() |
Address |
getLocalAddress() |
protected void |
handleViewChange(View v) |
boolean |
isCoordinator() |
protected void |
removeAndDeliver(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
JChannel.connect(String) . |
void |
stop()
This method is called on a
JChannel.disconnect() . |
Object |
up(Event evt)
An event was received from the protocol below.
|
Object |
up(Message msg)
A single message was received.
|
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, setProperties, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled
protected Address local_addr
protected volatile Address coord
protected volatile View view
protected volatile boolean is_coord
protected final AtomicLong seqno
protected final BlockingQueue<Message> fwd_queue
protected final AtomicInteger seqno_reqs
protected volatile boolean running
protected static final BiConsumer<MessageBatch,Message> BATCH_ACCUMULATOR
protected long request_msgs
protected long response_msgs
protected long bcasts_sent
protected long bcasts_received
protected long bcasts_delivered
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 int getFwdQueueSize()
public void resetStats()
resetStats
in class Protocol
public void start() throws Exception
Protocol
JChannel.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
Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack
to fail, so JChannel.connect(String)
will throw an exceptionpublic void stop()
Protocol
JChannel.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 Object down(Event evt)
Protocol
down_prot.down()
.public Object down(Message msg)
Protocol
public 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 Object up(Message msg)
Protocol
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, SEQUENCER2.SequencerHeader hdr)
protected void deliverBatch(MessageBatch batch)
Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.