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, stats
AUTO_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, up
addChannelListener, notifyChannelClosed, notifyChannelConnected, notifyChannelDisconnected, notifyChannelReconnected, notifyChannelShunned, option2String, removeChannelListener, setChannelListener, setReceiver, setUpHandler
public 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()
JChannel
getChannelName
in class JChannel
public java.lang.String getClusterName()
Channel
connect()
. Calling this method on a closed
channel returns null
.getClusterName
in class JChannel
public Address getLocalAddress()
JChannel
getLocalAddress
in class JChannel
Send
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()
JChannel
getProtocolStack
in class JChannel
public boolean isOpen()
JChannel
public boolean isConnected()
JChannel
isConnected
in class JChannel
public java.util.Map dumpStats()
JChannel
public void setClosed(boolean f)
public void setConnected(boolean f)
public java.lang.Object getOpt(int option)
JChannel
getOpt
in class JChannel
option
- the option you want to see the value forJChannel.setOpt(int, java.lang.Object)
public void setOpt(int option, java.lang.Object value)
JChannel
There 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
JChannel
connect
in class JChannel
channel_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
Channel
connect
in class JChannel
state_id
- The ID of a substate. If the full state is to be fetched, set this to nullChannelException
public void disconnect()
JChannel
disconnect
in class JChannel
Channel.connect(String)
public void open() throws ChannelException
JChannel
open
in class JChannel
ChannelException
public void close()
JChannel
protected void _close(boolean disconnect, boolean close_mq)
JChannel
this.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()
JChannel
public void send(Message msg) throws ChannelNotConnectedException, ChannelClosedException
JChannel
send
in interface Transport
send
in class JChannel
msg
- 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
JChannel
send
in class JChannel
dst
- - the destination address of the message, null for all memberssrc
- - the source address of the messageobj
- - the value of the messageChannelNotConnectedException
ChannelClosedException
JChannel.send(org.jgroups.Message)
public void down(Event evt)
JChannel
public boolean getState(Address target, long timeout) throws ChannelNotConnectedException, ChannelClosedException
JChannel
timeout
milliseconds have elapsed. The argument of GET_STATE_OK should be a single object.getState
in class JChannel
target
- 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
JChannel
getState
in class JChannel
target
- 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 receivedChannelNotConnectedException
ChannelClosedException
public void returnState(byte[] state)
JChannel
getState()
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 JChannel
state
- The state of the application as a byte buffer
(to send over the network).public void returnState(byte[] state, java.lang.String state_id)
JChannel
returnState
in class JChannel
protected void checkNotConnected() throws ChannelNotConnectedException
JChannel
checkNotConnected
in class JChannel
ChannelNotConnectedException
protected void checkClosed() throws ChannelClosedException
JChannel
checkClosed
in class JChannel
ChannelClosedException
Copyright ? 1998-2006 Bela Ban. All Rights Reserved.