public class ForkChannel extends JChannel implements ChannelListener
JChannel.State
Modifier and Type | Field and Description |
---|---|
protected static Field[] |
copied_fields |
protected String |
fork_channel_id |
protected JChannel |
main_channel |
address_generators, channel_listeners, cluster_name, discard_own_messages, flush_supported, local_addr, log, name, probe_handler, prot_stack, received_bytes, received_msgs, receiver, sent_bytes, sent_msgs, state, state_promise, state_transfer_supported, stats, up_handler, view
Constructor and Description |
---|
ForkChannel(JChannel main_channel,
String fork_stack_id,
String fork_channel_id,
boolean create_fork_if_absent,
ProtocolStack.Position position,
Class<? extends Protocol> neighbor,
Protocol... protocols)
Creates a new fork-channel from a main-channel.
|
ForkChannel(JChannel main_channel,
String fork_stack_id,
String fork_channel_id,
Protocol... protocols)
Creates a new fork-channel from a main-channel.
|
Modifier and Type | Method and Description |
---|---|
ForkChannel |
addAddressGenerator(AddressGenerator address_generator)
Sets the new
AddressGenerator . |
void |
channelClosed(JChannel channel)
Channel has been closed notification callback
|
void |
channelConnected(JChannel channel)
Channel has been connected notification callback
|
void |
channelDisconnected(JChannel channel)
Channel has been disconnected notification callback
|
void |
close()
Closes the fork-channel, essentially setting its state to CLOSED.
|
ForkChannel |
connect(String cluster_name)
Connects the fork-channel, which will be operational after this.
|
ForkChannel |
connect(String cluster_name,
Address target,
long timeout)
Joins the cluster and gets the state from a specified state provider.
|
protected void |
copyFields()
Copies state from main-channel to this fork-channel
|
ForkChannel |
disconnect()
Removes the fork-channel from the fork-stack's hashmap and resets its state.
|
Object |
down(Message msg) |
protected static FORK |
getFORK(JChannel ch,
ProtocolStack.Position position,
Class<? extends Protocol> neighbor,
boolean create_fork_if_absent)
Creates a new FORK protocol, or returns the existing one, or throws an exception.
|
ForkChannel |
getState(Address target,
long timeout)
Retrieves the full state from the target member.
|
JChannel |
name(String name) |
protected void |
nullFields() |
ForkChannel |
send(Message msg)
Sends a message.
|
protected void |
setHeader(Message msg) |
protected ForkChannel |
setLocalAddress(Address local_addr) |
ForkChannel |
setName(String name)
Sets the logical name for the channel.
|
ForkChannel |
startFlush(boolean automatic_resume)
Performs the flush of the cluster, ie.
|
ForkChannel |
startFlush(List<Address> flushParticipants,
boolean automatic_resume)
Performs the flush of the cluster but only for the specified flush participants.
All pending messages are flushed out but only for the flush participants.
|
ForkChannel |
stopFlush()
Stops the current flush round.
|
ForkChannel |
stopFlush(List<Address> flushParticipants)
Stops the current flush of the cluster for the specified flush participants.
|
_close, _connect, _preConnect, addChannelListener, address, checkClosed, checkClosedOrNotConnected, clearChannelListeners, clusterName, connect, connect, determineCoordinator, down, dumpChannelStats, dumpStats, dumpStats, dumpStats, flushSupported, generateAddress, getAddress, getAddressAsString, getAddressAsUUID, getClusterName, getDiscardOwnMessages, getName, getProperties, getProtocolStack, getReceivedBytes, getReceivedMessages, getReceiver, getSentBytes, getSentMessages, getState, getState, getState, getStats, getTimer, getUpHandler, getVersion, getView, getViewAsString, init, init, init, invokeCallback, isClosed, isConnected, isConnecting, isOpen, name, notifyChannelClosed, notifyChannelConnected, notifyChannelDisconnected, notifyListeners, printProtocolSpec, receiver, removeAddressGenerator, removeChannelListener, resetStats, send, send, send, setAddress, setDiscardOwnMessages, setReceiver, setStats, setUpHandler, stack, startStack, stats, stats, stopStack, toString, up, up, up, view
protected final JChannel main_channel
protected final String fork_channel_id
protected static final Field[] copied_fields
public ForkChannel(JChannel main_channel, String fork_stack_id, String fork_channel_id, boolean create_fork_if_absent, ProtocolStack.Position position, Class<? extends Protocol> neighbor, Protocol... protocols) throws Exception
connect(String)
needs to be called to send and receive messages.main_channel
- The main-channel. The lifetime of the newly created channel will be less than or equal to
the main-channelfork_stack_id
- The ID to associate the fork-stack with in FORKfork_channel_id
- The ID used to map fork-channel IDs to ForkChannels in the fork-channels protocol stackcreate_fork_if_absent
- If true, and FORK doesn't exist, a new FORK protocol will be created and inserted
into the main-stack at the given position. If false, and FORK doesn't exist, an
exception will be thrownposition
- The position at which the newly created FORK will be inserted. ProtocolStack.Position#ABOVE
or
ProtocolStack.Position#BELOW
are accepted. Ignored if create_fork_if_absent is false.neighbor
- The class of the neighbor protocol below or above which the newly created FORK protocol will
be inserted. Ignored if create_fork_if_absent is false.protocols
- A list of protocols (from bottom to top !) to insert as the fork_stack in FORK under the
given fork_stack_id. If the fork-stack with fork_stack_id already exists, an exception will be
thrown.
Can be null if no protocols should be added. This may be the case when an app only wants to use
a ForkChannel to mux/demux messages, but doesn't need a different protocol stack.Exception
public ForkChannel(JChannel main_channel, String fork_stack_id, String fork_channel_id, Protocol... protocols) throws Exception
connect(String)
needs to be called to send and receive messages. If FORK is not found in the stack, an exception will be thrown.main_channel
- The main-channel. The lifetime of the newly created channel will be less than or equal to
the main-channelfork_stack_id
- The ID to associate the fork-stack with in FORKfork_channel_id
- The ID used to map fork-channel IDs to ForkChannels in the fork-channels protocol stackprotocols
- A list of protocols (from bottom to top !) to insert as the fork_stack in FORK under the
given fork_stack_id. If the fork-stack with fork_stack_id already exists, an exception will be
thrown.
Can be null if no protocols should be added. This may be the case when an app only wants to use
a ForkChannel to mux/demux messages, but doesn't need a different protocol stack.Exception
public ForkChannel setName(String name)
JChannel
public void channelConnected(JChannel channel)
ChannelListener
channelConnected
in interface ChannelListener
channel
- the channel that has been connectedpublic void channelDisconnected(JChannel channel)
ChannelListener
channelDisconnected
in interface ChannelListener
channel
- the disconnected channelpublic void channelClosed(JChannel channel)
ChannelListener
channelClosed
in interface ChannelListener
channel
- the closed channelpublic ForkChannel connect(String cluster_name) throws Exception
connect
in class JChannel
cluster_name
- Ignored, will be the same as the main-channel's cluster nameException
IllegalStateException
- The channel is closedpublic ForkChannel connect(String cluster_name, Address target, long timeout) throws Exception
JChannel
connect and getState methods successively.
If FLUSH protocol is in channel's stack definition only one flush is executed for both connecting and
fetching state rather than two flushes if we invoke connect and getState in succession.
If the channel is closed an exception will be thrown.
connect
in class JChannel
cluster_name
- the cluster name to connect to. Cannot be null.target
- the state provider. If null state will be fetched from coordinator, unless this channel is coordinator.timeout
- the timeout for state transfer.Exception
- Connecting to the cluster or state transfer was not successfulIllegalStateException
- The channel is closed and therefore cannot be usedpublic ForkChannel disconnect()
disconnect
in class JChannel
JChannel.connect(String)
public void close()
public ForkChannel send(Message msg) throws Exception
JChannel
null
address sends the message to all cluster members.
send
in class JChannel
msg
- the message to be sent. Destination and buffer should be set. A null destination
means to send to all group members.IllegalStateException
- thrown if the channel is disconnected or closedException
public ForkChannel startFlush(List<Address> flushParticipants, boolean automatic_resume) throws Exception
JChannel
JChannel.stopFlush(List)
method with the same list of members used in JChannel.startFlush(List, boolean)
.startFlush
in class JChannel
automatic_resume
- if true call JChannel.stopFlush()
after the flushException
public ForkChannel startFlush(boolean automatic_resume) throws Exception
JChannel
JChannel.stopFlush()
is called.
In the case of flush collisions (another member attempts flush at roughly the same time) start flush will
fail by throwing an Exception. Applications can re-attempt flushing after certain back-off period.
JGroups provides a helper random sleep time backoff algorithm for flush using Util class.startFlush
in class JChannel
automatic_resume
- if true call JChannel.stopFlush()
after the flushException
public ForkChannel stopFlush()
JChannel
public ForkChannel stopFlush(List<Address> flushParticipants)
JChannel
JChannel.startFlush(List, boolean)
method with the
same list of members prior to invocation of this method.public ForkChannel getState(Address target, long timeout) throws Exception
JChannel
The state transfer is initiated by invoking getState() on this channel. The state provider in turn invokes the
StateListener.getState(java.io.OutputStream)
callback and sends the state to this node, the state receiver.
After the state arrives at the state receiver, the StateListener.setState(java.io.InputStream)
callback
is invoked to install the state.
getState
in class JChannel
target
- the state provider. If null the coordinator is used by defaulttimeout
- the number of milliseconds to wait for the operation to complete successfully. 0
waits forever until the state has been receivedIllegalStateException
- the channel was closed or disconnected, or the flush (if present) failedStateTransferException
- raised if there was a problem during the state transferException
StateListener.getState(java.io.OutputStream)
,
StateListener.setState(java.io.InputStream)
public ForkChannel addAddressGenerator(AddressGenerator address_generator)
JChannel
AddressGenerator
. New addresses will be generated using the new generator. This
should not be done while a channel is connected, but before connecting.addAddressGenerator
in class JChannel
protected ForkChannel setLocalAddress(Address local_addr)
protected static FORK getFORK(JChannel ch, ProtocolStack.Position position, Class<? extends Protocol> neighbor, boolean create_fork_if_absent) throws Exception
Exception
protected void setHeader(Message msg)
protected void copyFields()
protected void nullFields()
Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.