Package org.jgroups.protocols
Class RSVP
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.RSVP
- All Implemented Interfaces:
Lifecycle
Protocol which implements synchronous messages (https://issues.redhat.com/browse/JGRP-1389). A send of a message M
with flag RSVP set will block until all non-faulty recipients (one for unicasts, N for multicasts) have acked M, or
until a timeout kicks in.
- Since:
- 3.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected shortID to be used to identify messages.protected booleanprotected final ConcurrentMap<Short, RSVP.Entry> Used to store IDs and their acksprotected longprotected Future<?> protected booleanprotected longprotected TimeSchedulerFields 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 TypeMethodDescriptionbooleanackOnDelivery(boolean b) An event is to be sent down the stack.A message is sent down the stack.protected <T extends Protocol>
TfindDownProtocol(Class<? extends Protocol> cl) protected shortintlonglongprotected voidhandleResponse(Address member, short id) booleanhandleUnicasts(boolean b) protected voidhandleView(View view) voidinit()Called after a protocol has been created and before the protocol is started.protected booleanprotected voidsendResponse(Address dest, short id) setResendInterval(long i) setTimeout(long t) voidstart()This method is called on aJChannel.connect(String); starts work.protected voidvoidstop()Called on aJChannel.disconnect(); stops work (e.g.protected voidbooleanthrowExceptionOnTimeout(boolean b) An event was received from the protocol below.A single message was received.voidup(MessageBatch batch) Sends up a multiple messages in aMessageBatch.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, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, toString
-
Field Details
-
timeout
protected long timeout -
throw_exception_on_timeout
protected boolean throw_exception_on_timeout -
ack_on_delivery
protected boolean ack_on_delivery -
resend_interval
protected long resend_interval -
current_id
protected short current_idID to be used to identify messages. Short.MAX_VALUE (ca 32K plus 32K negative) should be enough, and wrap-around shouldn't be an issue. Using Message.Flag.RSVP should be the exception, not the rule... -
timer
-
members
-
ids
Used to store IDs and their acks -
resend_task
-
handle_unicasts
protected boolean handle_unicasts
-
-
Constructor Details
-
RSVP
public RSVP()
-
-
Method Details
-
getPendingRsvpRequests
public int getPendingRsvpRequests() -
getTimeout
public long getTimeout() -
setTimeout
-
throwExceptionOnTimeout
public boolean throwExceptionOnTimeout() -
throwExceptionOnTimeout
-
ackOnDelivery
public boolean ackOnDelivery() -
ackOnDelivery
-
getResendInterval
public long getResendInterval() -
setResendInterval
-
handleUnicasts
public boolean handleUnicasts() -
handleUnicasts
-
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. -
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(). -
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. -
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. -
handleView
-
handleResponse
-
sendResponse
-
getNextId
protected short getNextId() -
startResendTask
protected void startResendTask() -
stopResendTask
protected void stopResendTask() -
isResendTaskRunning
protected boolean isResendTaskRunning() -
findDownProtocol
-