|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.javagroups.Channel | +--org.javagroups.JChannel
JChannel is a pure Java implementation of Channel When a JChannel object is instantiated it automatically sets up the protocol stack
Fields inherited from class org.javagroups.Channel |
AUTO_GETSTATE, AUTO_RECONNECT, BLOCK, channel_listener, GET_STATE_EVENTS, LOCAL, SUSPECT, up_handler, VIEW |
Constructor Summary | |
|
JChannel()
initializes the JChannel with its default settings and default protocol stack |
protected |
JChannel(boolean dummy)
initializes the JChannel with its default settings and default protocol stack |
|
JChannel(java.lang.Object properties)
creates a new JChannel with the protocol stack as defined in the properties parameter. |
Method Summary | |
void |
blockOk()
Called to acknowledge a block() (callback in MembershipListener or
BlockEvent received from call to receive() ). |
void |
close()
Destroys the channel. After this method has been called, the channel us unusable. This operation will disconnect the channel and close the channel receive queue immediately |
void |
connect(java.lang.String channel_name)
Connects the channel to a group. If the channel is already connected, an error message will be printed to the error log If the channel is closed a ChannelClosed exception will be thrown This method starts the protocol stack by calling ProtocolStack.start then it sends an Event.CONNECT event down the stack and waits to receive a CONNECT_OK event Once the CONNECT_OK event arrives from the protocol stack, any channel listeners are notified and the channel is considered connected |
void |
disconnect()
disconnects the channel if it is connected. if the channel is closed, this operation is ignored Otherwise the following actions happen in the listed order 1. |
void |
down(Event evt)
Sends a message through the protocol stack if the stack is available |
boolean |
getAllStates(java.util.Vector targets,
long timeout)
Retrieves the current group state. |
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 |
Address |
getLocalAddress()
returns the local address of the channel returns null if the channel is closed |
java.lang.Object |
getOpt(int option)
returns the value of an option. |
java.lang.String |
getProperties()
returns the protocol stack configuration in string format. |
ProtocolStack |
getProtocolStack()
Returns the protocol stack. |
boolean |
getState(Address target,
long timeout)
Retrieves the current group state. |
View |
getView()
returns the current view. if the channel is not connected or if it is closed it will return null |
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. this does the following actions 1. |
java.lang.Object |
peek(long timeout)
Just peeks at the next message, view or block. |
java.lang.String |
printProtocolSpec(boolean include_properties)
Returns a pretty-printed form of all the protocols. |
java.lang.Object |
receive(long timeout)
Blocking receive method. |
void |
returnState(java.lang.Object state)
Called by the application is response to receiving a 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 application |
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)
implementation of the Transport interface. Sends a message through the protocol stack |
void |
setOpt(int option,
java.lang.Object value)
sets a channel option the options can be either |
void |
up(Event evt)
Callback method Called by the ProtocolStack when a message is received. |
Methods inherited from class org.javagroups.Channel |
option2String, setChannelListener, setUpHandler |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected JChannel(boolean dummy) throws ChannelException
public JChannel() throws ChannelException
public JChannel(java.lang.Object properties) throws ChannelException
properties
- the protocol stack setup, if null, the default protocol stack will be usedproperties
- the properties can also be a java.net.URL object or a string that is a URL spec. The JChannel will validate any
URL object and String object to see if they are a URL. In case of the parameter being a url, the JChannel will try to load the xml
from there.Method Detail |
public ProtocolStack getProtocolStack()
public java.lang.String getProperties()
public java.lang.String printProtocolSpec(boolean include_properties)
public void connect(java.lang.String channel_name) throws ChannelClosedException
connect
in class Channel
channel_name
- A String
denoting the group name. Cannot be null.throws
- a ChannelClosed exception if the close() method has been calledpublic void disconnect()
disconnect
in class Channel
org.javagroups.Channel
Channel.connect
public void close()
close
in class Channel
public void open() throws ChannelException
open
in class Channel
public boolean isOpen()
isOpen
in class Channel
public boolean isConnected()
isConnected
in class Channel
public void send(Message msg) throws ChannelNotConnectedException, ChannelClosedException
send
in class Channel
msg
- the message to be sent through the protocol stack,
the destination of the message is specified inside the message itselfChannelNotConnected
- ChannelClosed
- public void send(Address dst, Address src, java.io.Serializable obj) throws ChannelNotConnectedException, ChannelClosedException
send
in class Channel
dst
- - the destination address of the message, null for all memberssrc
- - the source address of the messageobj
- - the value of the messageChannelNotConnected
- ChannelClosed
- send(org.javagroups.Message)
public java.lang.Object receive(long timeout) throws ChannelNotConnectedException, ChannelClosedException, TimeoutException
receive
in class Channel
timeout,
- the number of milliseconds to wait if the receive queue is empty. 0 means wait foreverTimeoutException
- if a timeout occured prior to a new message was receivedChannelNotConnected
- ChannelClosed
- * @see JChannel#peekpublic java.lang.Object peek(long timeout) throws ChannelNotConnectedException, ChannelClosedException, TimeoutException
peek
in class Channel
org.javagroups.Channel
timeout
- Value in milliseconds. Value <= 0 means wait foreverChannelNotConnected
- The channel must be connected to receive messages.ChannelClosed
- The channel is closed and therefore cannot be used any longer.
A new channel has to be created first.TimeoutException
- Thrown when a timeout has occurred.Receive
public View getView()
getView
in class Channel
public Address getLocalAddress()
getLocalAddress
in class Channel
org.javagroups.Channel
Send
operation.public java.lang.String getChannelName()
getChannelName
in class Channel
org.javagroups.Channel
public void setOpt(int option, java.lang.Object value)
Channel.BLOCK Channel.VIEW Channel.SUSPECT Channel.LOCAL Channel.GET_STATE_EVENTS Channel.AUTO_RECONNECT Channel.AUTO_GETSTATEThere are certain dependencies between the options that you can set, I will try to describe them here
setOpt
in class Channel
option
- the parameter option Channel.VIEW, Channel.SUSPECT, etcvalue
- the value to set for this optionpublic java.lang.Object getOpt(int option)
getOpt
in class Channel
option
- the option you want to see the value forsetOpt(int, java.lang.Object)
public void blockOk()
MembershipListener
or
BlockEvent
received from call to receive()
).
After sending blockOk(), no messages should be sent until a new view has been received.
Calling this method on a closed channel has no effect.blockOk
in class Channel
public boolean getState(Address target, long timeout)
timeout
milliseconds have elapsed. The argument of GET_STATE_OK should be a single object.getState
in class Channel
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 successfullypublic boolean getAllStates(java.util.Vector targets, long timeout)
timeout
milliseconds have elapsed. The argument of GET_STATE_OK should be a vector of objects.getAllStates
in class Channel
target
- - the target members to receive the state from ( an Address list )timeout
- - the number of milliseconds to wait for the operation to complete successfullypublic void returnState(java.lang.Object state)
getState()
object when
calling receive()
.returnState
in class Channel
state
- The state of the application as a Serializable or Externalizable
(to send over the network).public void up(Event evt)
Receive
s will dequeue it.evt
- the event carrying the message from the protocol stackpublic void down(Event evt)
down
in class Channel
evt
- the message to send down, encapsulated in an event
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |