public class MuxChannel extends JChannel
ChannelFactory.createMultiplexerChannel(String,String,boolean,String). Maintains the multiplexer
ID, which is used to add a header to each message, so that the message can be demultiplexed at the receiverclosed, closer, connected, DEFAULT_PROTOCOL_STACK, log, received_bytes, received_msgs, sent_bytes, sent_msgs, statsAUTO_GETSTATE, AUTO_RECONNECT, BLOCK, channel_listener, channel_listeners, GET_STATE_EVENTS, LOCAL, receiver, SUSPECT, up_handler, VIEW| Constructor and Description |
|---|
MuxChannel(JChannelFactory f,
JChannel ch,
java.lang.String id,
java.lang.String stack_name,
Multiplexer mux) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_close(boolean disconnect,
boolean close_mq)
Disconnects and closes the channel.
|
protected void |
checkClosed()
health check
throws a ChannelClosed exception if the channel is closed |
protected void |
checkNotConnected()
health check.
throws a ChannelNotConnected exception if the channel is not connected |
void |
close()
Destroys the channel.
|
void |
connect(java.lang.String channel_name)
Connects the channel to a group.
|
boolean |
connect(java.lang.String cluster_name,
Address target,
java.lang.String state_id,
long timeout)
Connects the channel to a group and fetches the state
|
void |
disconnect()
Disconnects the channel if it is connected.
|
void |
down(Event evt)
Sends a message through the protocol stack if the stack is available
|
java.util.Map |
dumpStats()
Returns a map of statistics of the various protocols and of the channel itself.
|
JChannel |
getChannel()
This should never be used (just for testing) !
|
java.lang.String |
getChannelName()
returns the name of the channel
if the channel is not connected or if it is closed it will return null
|
java.lang.String |
getClusterName()
Returns the cluster name of the group of which the channel is a member.
|
View |
getClusterView()
Returns the JGroups view of a cluster, e.g.
|
java.lang.String |
getId() |
Address |
getLocalAddress()
returns the local address of the channel
returns null if the channel is closed
|
Multiplexer |
getMultiplexer() |
java.lang.Object |
getOpt(int option)
returns the value of an option.
|
ProtocolStack |
getProtocolStack()
Returns the protocol stack.
|
java.lang.String |
getStackName() |
boolean |
getState(Address target,
long timeout)
Retrieves the current group state.
|
boolean |
getState(Address target,
java.lang.String state_id,
long timeout)
Retrieves a substate (or partial state) from the target.
|
View |
getView()
Returns the service view, ie.
|
boolean |
isConnected()
returns true if the Connect operation has been called successfully
|
boolean |
isOpen()
returns true if the Open operation has been called successfully
|
void |
open()
Opens the channel.
|
void |
returnState(byte[] state)
Called by the application is response to receiving a
getState() object when
calling receive(). |
void |
returnState(byte[] state,
java.lang.String state_id)
Returns a substate as indicated by state_id
|
void |
send(Address dst,
Address src,
java.io.Serializable obj)
creates a new message with the destination address, and the source address
and the object as the message value
|
void |
send(Message msg)
Sends a message through the protocol stack.
|
void |
setClosed(boolean f) |
void |
setConnected(boolean f) |
void |
setOpt(int option,
java.lang.Object value)
Sets a channel option.
|
void |
shutdown()
Shuts down the channel without disconnecting
|
blockOk, closeMessageQueue, dumpQueue, dumpTimerQueue, enableStats, flushSupported, getAllStates, getLog, getNumberOfTasksInTimer, getNumMessages, getProperties, getReceivedBytes, getReceivedMessages, getSentBytes, getSentMessages, init, peek, printProtocolSpec, receive, resetStats, startFlush, startFlush, statsEnabled, stopFlush, toString, upaddChannelListener, notifyChannelClosed, notifyChannelConnected, notifyChannelDisconnected, notifyChannelReconnected, notifyChannelShunned, option2String, removeChannelListener, setChannelListener, setReceiver, setUpHandlerpublic MuxChannel(JChannelFactory f, JChannel ch, java.lang.String id, java.lang.String stack_name, Multiplexer mux)
public java.lang.String getStackName()
public java.lang.String getId()
public Multiplexer getMultiplexer()
public java.lang.String getChannelName()
JChannelgetChannelName in class JChannelpublic java.lang.String getClusterName()
Channelconnect(). Calling this method on a closed
channel returns null.getClusterName in class JChannelpublic Address getLocalAddress()
JChannelgetLocalAddress in class JChannelSend operation.public JChannel getChannel()
public View getView()
getView()) minus the nodes on
which this service is not running, e.g. if S1 runs on A and C, and the cluster view is {A,B,C}, then the service
view is {A,C}public View getClusterView()
public ProtocolStack getProtocolStack()
JChannelgetProtocolStack in class JChannelpublic boolean isOpen()
JChannelpublic boolean isConnected()
JChannelisConnected in class JChannelpublic java.util.Map dumpStats()
JChannelpublic void setClosed(boolean f)
public void setConnected(boolean f)
public java.lang.Object getOpt(int option)
JChannelgetOpt in class JChanneloption - the option you want to see the value forJChannel.setOpt(int, java.lang.Object)public void setOpt(int option,
java.lang.Object value)
JChannelThere are certain dependencies between the options that you can set, I will try to describe them here.
Option: Channel.BLOCK
Value: java.lang.Boolean
Result: set to true will set setOpt(VIEW, true) and the JChannel will receive BLOCKS and VIEW events
Option: LOCAL
Value: java.lang.Boolean
Result: set to true the JChannel will receive messages that it self sent out.
Option: AUTO_RECONNECT
Value: java.lang.Boolean
Result: set to true and the JChannel will try to reconnect when it is being closed
Option: AUTO_GETSTATE
Value: java.lang.Boolean
Result: set to true, the AUTO_RECONNECT will be set to true and the JChannel will try to get the state after a close and reconnect happens
public void connect(java.lang.String channel_name)
throws ChannelException,
ChannelClosedException
JChannelconnect in class JChannelchannel_name - A String denoting the group name. Cannot be null.ChannelException - The protocol stack cannot be startedChannelClosedException - The channel is closed and therefore cannot be used any longer.
A new channel has to be created first.Channel.disconnect()public boolean connect(java.lang.String cluster_name,
Address target,
java.lang.String state_id,
long timeout)
throws ChannelException
Channelconnect in class JChannelstate_id - The ID of a substate. If the full state is to be fetched, set this to nullChannelExceptionpublic void disconnect()
JChanneldisconnect in class JChannelChannel.connect(String)public void open()
throws ChannelException
JChannelopen in class JChannelChannelExceptionpublic void close()
JChannelprotected void _close(boolean disconnect,
boolean close_mq)
JChannelthis.disconnect if the disconnect parameter is true
Queue.close on mq if the close_mq parameter is true
ProtocolStack.stop on the protocol stack
ProtocolStack.destroy on the protocol stack
public void shutdown()
JChannelpublic void send(Message msg) throws ChannelNotConnectedException, ChannelClosedException
JChannelsend in interface Transportsend in class JChannelmsg - the message to be sent through the protocol stack,
the destination of the message is specified inside the message itselfChannelNotConnectedException - The channel must be connected to send messages.ChannelClosedException - The channel is closed and therefore cannot be used any longer.
A new channel has to be created first.public void send(Address dst, Address src, java.io.Serializable obj) throws ChannelNotConnectedException, ChannelClosedException
JChannelsend in class JChanneldst - - the destination address of the message, null for all memberssrc - - the source address of the messageobj - - the value of the messageChannelNotConnectedExceptionChannelClosedExceptionJChannel.send(org.jgroups.Message)public void down(Event evt)
JChannelpublic boolean getState(Address target, long timeout) throws ChannelNotConnectedException, ChannelClosedException
JChanneltimeout
milliseconds have elapsed. The argument of GET_STATE_OK should be a single object.getState in class JChanneltarget - the target member to receive the state from. if null, state is retrieved from coordinatortimeout - the number of milliseconds to wait for the operation to complete successfully. 0 waits until
the state has been receivedChannelNotConnectedException - The channel must be connected to receive messages.ChannelClosedException - The channel is closed and therefore cannot be used
any longer. A new channel has to be created first.public boolean getState(Address target, java.lang.String state_id, long timeout) throws ChannelNotConnectedException, ChannelClosedException
JChannelgetState in class JChanneltarget - State provider. If null, coordinator is usedstate_id - The ID of the substate. If null, the entire state will be transferredtimeout - the number of milliseconds to wait for the operation to complete successfully. 0 waits until
the state has been receivedChannelNotConnectedExceptionChannelClosedExceptionpublic void returnState(byte[] state)
JChannelgetState() object when
calling receive().
When the application receives a getState() message on the receive() method,
it should call returnState() to reply with the state of the applicationreturnState in class JChannelstate - The state of the application as a byte buffer
(to send over the network).public void returnState(byte[] state,
java.lang.String state_id)
JChannelreturnState in class JChannelprotected void checkNotConnected()
throws ChannelNotConnectedException
JChannelcheckNotConnected in class JChannelChannelNotConnectedExceptionprotected void checkClosed()
throws ChannelClosedException
JChannelcheckClosed in class JChannelChannelClosedExceptionCopyright ? 1998-2006 Bela Ban. All Rights Reserved.