Package org.jgroups.fork
Class ForkProtocolStack
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.stack.ProtocolStack
org.jgroups.fork.ForkProtocolStack
- All Implemented Interfaces:
Lifecycle
Protocol stack which maintains the mapping between fork-channel IDs and ForkChannels
- Since:
- 3.4
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jgroups.stack.ProtocolStack
ProtocolStack.Position -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected final ConcurrentMap<String, JChannel> protected final Stringprotected intprotected UnknownForkHandlerFields inherited from class org.jgroups.stack.ProtocolStack
bottom_prot, channel, max_list_print_size, props_handler, stopped, top_protFields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot -
Constructor Summary
ConstructorsConstructorDescriptionForkProtocolStack(UnknownForkHandler unknownForkHandler, List<Protocol> protocols, String fork_stack_id) -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()This method is called on aJChannel.close().An event is to be sent down the stack.A message is sent down the stack.intintgetInits()Returns all protocols in a list, from top to bottom.voidinit()Called after a protocol has been created and before the protocol is started.putIfAbsent(String id, JChannel fc) voidvoidsetLocalAddress(Address addr) voidvoidStart all protocols.voidIterates through all the protocols from top to bottom and does the following: Waits until all messages in the down queue have been flushed (ie., size is 0) Calls stop() on the protocolAn 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.ProtocolStack
addProtocol, addProtocols, addProtocols, bottomProtocol, callAfterCreationHook, createProtocol, down, dumpStats, dumpStats, findProtocol, findProtocol, findProtocol, findProtocol, findProtocols, getBottomProtocol, getChannel, getName, getTopProtocol, getTransport, initComponents, initProtocolStack, initProtocolStack, insertProtocol, insertProtocol, insertProtocol, insertProtocolAtTop, insertProtocolInStack, printProtocolSpec, printProtocolSpecAsPlainString, printProtocolSpecAsXML, removeProtocol, removeProtocol, removeProtocol, removeProtocol, removeProtocols, removeProtocols, replaceProtocol, setChannel, setup, setup, topProtocolMethods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, providedUpServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, start, statsEnabled, stop, toString
-
Field Details
-
fork_stack_id
-
fork_channels
-
unknownForkHandler
-
protocols
-
inits
protected int inits -
connects
protected int connects
-
-
Constructor Details
-
ForkProtocolStack
public ForkProtocolStack(UnknownForkHandler unknownForkHandler, List<Protocol> protocols, String fork_stack_id)
-
-
Method Details
-
getForkChannels
-
get
-
putIfAbsent
-
remove
-
getInits
public int getInits() -
getConnects
public int getConnects() -
setUnknownForkHandler
-
getUnknownForkHandler
-
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().- Overrides:
downin classProtocolStack
-
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.- Overrides:
downin classProtocolStack
-
setLocalAddress
-
getProtocols
Description copied from class:ProtocolStackReturns all protocols in a list, from top to bottom. These are not copies of protocols, so modifications will affect the actual instances !- Overrides:
getProtocolsin classProtocolStack
-
incrInits
-
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.- Specified by:
initin interfaceLifecycle- Overrides:
initin classProtocolStack- Throws:
Exception- Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the the channel constructor will throw an exception
-
startStack
Description copied from class:ProtocolStackStart all protocols. TheProtocol.start()method is called in each protocol, from bottom to top. Each protocol can perform some initialization, e.g. create a multicast socket- Overrides:
startStackin classProtocolStack- Throws:
Exception
-
stopStack
Description copied from class:ProtocolStackIterates through all the protocols from top to bottom and does the following:- Waits until all messages in the down queue have been flushed (ie., size is 0)
- Calls stop() on the protocol
- Overrides:
stopStackin classProtocolStack
-
destroy
public void destroy()Description copied from class:ProtocolThis method is called on aJChannel.close(). Does some cleanup; after the call, the VM will terminate- Specified by:
destroyin interfaceLifecycle- Overrides:
destroyin classProtocolStack
-
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().- Overrides:
upin classProtocolStack
-
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.- Overrides:
upin classProtocolStack
-
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.- Overrides:
upin classProtocolStack- Parameters:
batch- The message batch
-