|
||||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | 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
| Field Summary |
|---|
| 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. |
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 |
int |
getNumMessages()
Returns the number of messages that are waiting. |
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(byte[] 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 |
java.lang.String |
toString(boolean details)
|
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 used| 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 ChannelException,
ChannelClosedException
connect in class Channelchannel_name - A String denoting the group name. Cannot be null.
ChannelException - The protocol stack cannot be started
ChannelClosedException - The channel is closed and therefore cannot be used any longer.
A new channel has to be created first.Channel.disconnect()public void disconnect()
disconnect in class ChannelChannel.connect(String)public void close()
close in class Channel
public void open()
throws ChannelException
open in class ChannelChannelExceptionpublic boolean isOpen()
isOpen in class Channelpublic boolean isConnected()
isConnected in class Channelpublic int getNumMessages()
ChannelChannel.receive(long). Note that this number could change after
calling this method and before calling receive() (e.g. the latter
method might be called by a different thread).
getNumMessages in class Channel
public void send(Message msg)
throws ChannelNotConnectedException,
ChannelClosedException
send in interface Transportsend in class Channelmsg - the message to be sent through the protocol stack,
the destination of the message is specified inside the message itself
ChannelNotConnectedException
ChannelClosedException
public void send(Address dst,
Address src,
java.io.Serializable obj)
throws ChannelNotConnectedException,
ChannelClosedException
send in class Channeldst - - the destination address of the message, null for all memberssrc - - the source address of the messageobj - - the value of the message
ChannelNotConnectedException
ChannelClosedExceptionsend(org.javagroups.Message)
public java.lang.Object receive(long timeout)
throws ChannelNotConnectedException,
ChannelClosedException,
TimeoutException
receive in interface Transportreceive in class Channeltimeout - the number of milliseconds to wait if the receive queue is empty. 0 means wait forever
TimeoutException - if a timeout occured prior to a new message was received
ChannelNotConnectedException
ChannelClosedExceptionpeek(long)
public java.lang.Object peek(long timeout)
throws ChannelNotConnectedException,
ChannelClosedException,
TimeoutException
peek in class Channeltimeout - Value in milliseconds. Value <= 0 means wait forever
ChannelNotConnectedException - The channel must be connected to receive messages.
TimeoutException - Thrown when a timeout has occurred.
ChannelClosedException - The channel is closed and therefore cannot be used any longer.
A new channel has to be created first.Channel.receive(long)public View getView()
getView in class Channelpublic Address getLocalAddress()
getLocalAddress in class ChannelSend operation.public java.lang.String getChannelName()
getChannelName in class 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_GETSTATE
There are certain dependencies between the options that you can set, I will try to describe them here
setOpt in class Channeloption - the parameter option Channel.VIEW, Channel.SUSPECT, etcvalue - the value to set for this optionpublic java.lang.Object getOpt(int option)
getOpt in class Channeloption - the option you want to see the value for
setOpt(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)
throws ChannelNotConnectedException,
ChannelClosedException
timeout
milliseconds have elapsed. The argument of GET_STATE_OK should be a single object.
getState in class Channeltarget - - 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
ChannelClosedException - The channel is closed and therefore cannot be used
any longer. A new channel has to be created first.
ChannelNotConnectedException - The channel must be connected to receive messages.
public boolean getAllStates(java.util.Vector targets,
long timeout)
throws ChannelNotConnectedException,
ChannelClosedException
timeout
milliseconds have elapsed. The argument of GET_STATE_OK should be a vector of objects.
getAllStates in class Channeltargets - - the target members to receive the state from ( an Address list )timeout - - the number of milliseconds to wait for the operation to complete successfully
ChannelClosedException - The channel is closed and therefore cannot be used
any longer. A new channel has to be created first.
ChannelNotConnectedException - The channel must be connected to
receive messages.public void returnState(byte[] state)
getState() object when
calling receive().
returnState in class Channelstate - The state of the application as a byte buffer
(to send over the network).public void up(Event evt)
Receives will dequeue it.
evt - the event carrying the message from the protocol stackpublic void down(Event evt)
down in class Channelevt - the message to send down, encapsulated in an eventpublic java.lang.String toString(boolean details)
|
||||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||