|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.javagroups.Channel | +--org.javagroups.EnsChannel
EnsChannel is an implementation of Channel based on Ensemble. It maps a process group to a channel. Requirements are the presence of an executable called outboard (which is Ensemble) and gossip running.
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 | |
---|---|
EnsChannel()
|
|
EnsChannel(java.lang.Object props)
Creates a new EnsChannel, which spawns an outboard process and connects to it. |
|
EnsChannel(java.lang.Object props,
java.lang.String transport_props,
int outboard_port)
Creates a new EnsChannel. |
Method Summary | |
---|---|
void |
acceptedView(Hot_GroupContext gctx,
java.lang.Object env,
Hot_ViewState viewState)
Called to update you with the new view |
void |
block(Hot_GroupContext gctx,
java.lang.Object env)
Called to let you know Ensemble is blocking |
void |
blockOk()
Called to acknowledge a block() (callback in MembershipListener or
BlockEvent received from call to Receive ). |
void |
close()
Destroys the channel and its associated resources (e.g. |
void |
connect(java.lang.String channel_name)
Connects the channel to a group. |
void |
disconnect()
Disconnects the channel from the current group (if connected), leaving the group. |
void |
exit(Hot_GroupContext gctx,
java.lang.Object env)
Called upon an Exit |
void |
finalize()
|
boolean |
getAllStates(java.util.Vector targets,
long timeout)
Retrieve all states of the group members. |
java.lang.String |
getChannelName()
Returns the group address of the group of which the channel is a member. |
Address |
getLocalAddress()
Returns the channel's own address. |
java.lang.Object |
getOpt(int option)
Gets an option. |
boolean |
getState(Address target,
long timeout)
Retrieve the state of the group. |
View |
getView()
Gets the current view. |
void |
heartbeat(Hot_GroupContext gctx,
java.lang.Object env,
int rate)
Called to issue you a heartbeat |
boolean |
isConnected()
Determines whether the channel is connected to a group. |
boolean |
isOpen()
Determines whether the channel is open, ie. |
java.lang.Object |
peek(long timeout)
Returns the next message, view, block, suspect or other event without removing it from the queue. |
java.lang.Object |
receive(long timeout)
Receives a message, a view change or a block event. |
void |
receiveCast(Hot_GroupContext gctx,
java.lang.Object env,
Hot_Endpoint origin,
Hot_Message msg)
Called when Ensemble receives a Cast from your group |
void |
receiveSend(Hot_GroupContext gctx,
java.lang.Object env,
Hot_Endpoint origin,
Hot_Message msg)
Called when Ensemble receives a point-to-point message for you |
void |
returnState(byte[] state)
Called by the application is response to receiving a getState() object when calling receive() . |
void |
send(Address dst,
Address src,
java.io.Serializable obj)
Helper method. |
void |
send(Message msg)
Sends a message to a (unicast) destination. |
void |
setOpt(int option,
java.lang.Object value)
Sets an option. |
Methods inherited from class org.javagroups.Channel |
---|
down, getNumMessages, open, option2String, setChannelListener, setUpHandler |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EnsChannel() throws ChannelException
public EnsChannel(java.lang.Object props) throws ChannelException
public EnsChannel(java.lang.Object props, java.lang.String transport_props, int outboard_port) throws ChannelException
outboard_port
.
This allows multiple EnsChannels to share a copy of outboard. If the port is 0, outboard
will be spawned. Parameter transport_props
defines the type
of transport to be used (UDP, ATM, IP MCAST etc).
transport_props
- Transport parameters. Null
means use default (UDP).
Example: "UDP:DEERING"
uses IP multicast (gossip is not
needed in this case).outboard_port
- Port on which the local outboard process is listening. The outboard
process has to be started before. Value of 0 means spawn outboard
nevertheless.Method Detail |
public void connect(java.lang.String channel_name) throws ChannelClosedException
Channel
All channels with the same name form a group, that means all messages sent to the group will be received by all channels connected to the same channel name.
connect
in class Channel
channel_name
- The name of the chanel to connect to.
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()
Channel
disconnect
in class Channel
Channel.connect(String)
public void close()
Channel
ChannelClosed
exception
(or results in a null operation). It is a null operation if the channel is already closed.
If the channel is connected to a group, disconnec()t
will be called first.
close
in class Channel
public boolean isOpen()
Channel
isOpen
in class Channel
public boolean isConnected()
Channel
isConnected
in class Channel
public void finalize()
finalize
in class java.lang.Object
public void send(Message msg) throws ChannelNotConnectedException, ChannelClosedException
Channel
null
address sends the message
to all group members.
oneway
field which determines whether a response is
expected etc.
send
in interface Transport
send
in class Channel
msg
- The message to be sent. Destination and buffer should be set. A null destination
means to send to all group members.
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 send messages.public void send(Address dst, Address src, java.io.Serializable obj) throws ChannelNotConnectedException, ChannelClosedException
Channel
send
in class Channel
dst
- Destination address for message. If null, message will be sent to all current group memberssrc
- Source (sender's) address. If null, it will be set by the protocol's transport layer before
being put on the wire. Can usually be set to null.obj
- Serializable object. Will be serialized into the byte buffer of the Message. If it is
not serializable, the byte buffer will be null.
ChannelNotConnectedException
ChannelClosedException
public java.lang.Object receive(long timeout) throws ChannelNotConnectedException, ChannelClosedException, TimeoutException
Channel
setOpt
, the
type of objects to be received can be determined (e.g. not views and blocks, just
messages).
The possible types returned can be:
Message
. Normal message
Event
. All other events (used by JChannel)
View
. A view change.
BlockEvent
. A block event indicating an impending view change.
SuspectEvent
. A notification of a suspected member.
GetStateEvent
. The current state of the application should be
returned using ReturnState
.
SetStateEvent
. The state of a single/all members as requested previously
by having called Channel.getState(s).
ExitEvent
. Signals that this member was forced to leave the group (e.g. caused
by the member being suspected. The member can rejoin the group by calling
open(). If the AUTO_RECONNECT is set (see setOpt()), the reconnect will be
done automatically.
instanceof
operator can be used to discriminate between different types
returned.
receive
in interface Transport
receive
in class Channel
timeout
- Value in milliseconds. Value <= 0 means wait forever
ChannelClosedException
- 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.
ChannelNotConnectedException
- The channel must be connected to receive messages.public java.lang.Object peek(long timeout) throws ChannelNotConnectedException, ChannelClosedException, TimeoutException
Channel
peek
in class Channel
timeout
- 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()
Channel
Receive
to do so. The view may only be available after a successful
Connect
. The result of calling this method on an unconnected channel
is implementation defined (may return null). Calling it on a channel that is not
enabled to receive view events (via setOpt
) returns
null
. Calling this method on a closed channel returns a null view.
getView
in class Channel
public Address getLocalAddress()
Channel
getLocalAddress
in class Channel
Send
operation.public java.lang.String getChannelName()
Channel
Connect
. Calling this method on a closed
channel returns null
.
getChannelName
in class Channel
public void setOpt(int option, java.lang.Object value)
Channel
BLOCK
. Turn the reception of BLOCK events on/off (value is Boolean).
Default is off. If set to on, receiving VIEW events will be set to on, too.
VIEW
. Turn the reception of VIEW events on/off (value is Boolean).
Default is on.
SUSPECT
. Turn the reception of SUSPECT events on/off (value is Boolean).
Default is on.
LOCAL
. Receive its own broadcast messages to the group
(value is Boolean). Default is on.
GET_STATE_EVENTS
. Turn the reception of GetState events on/off
(value is Boolean). Default is off, which means that no other members can
ask this member for its state (null will be returned).
AUTO_RECONNECT
. Turn auto-reconnection on/off. If on, when a member if forced out
of a group (EXIT event), then we will reconnect.
AUTO_GETSTATE
. Turn automatic fetching of state after an auto-reconnect on/off.
This also sets AUTO_RECONNECT to true (if not yet set).
setOpt
in class Channel
public java.lang.Object getOpt(int option)
Channel
null
.
getOpt
in class Channel
option
- The option to be returned.
public void blockOk()
Channel
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)
Channel
SetStateEvent
will have been
added to the channel's queue, causing receive()
to return the state in one of
the next invocations. If false, no state will be retrieved by receive()
.
getState
in class Channel
target
- The address of the member from which the state is to be retrieved. If it is
null, the coordinator is contacted.timeout
- Milliseconds to wait for the response (0 = wait indefinitely).
public boolean getAllStates(java.util.Vector targets, long timeout)
Channel
SetStateEvent
will have been
added to the channel's queue, causing Receive
to return the states in one of
the next invocations. If false, no states will be retrieved by Receive
.
getAllStates
in class Channel
targets
- A list of members which are contacted for states. If the list is null,
all the current members of the group will be contacted.timeout
- Milliseconds to wait for the response (0 = wait indefinitely).
public void returnState(byte[] state)
Channel
getState()
object when calling receive()
.
returnState
in class Channel
state
- The state of the application as a byte buffer
(to send over the network).public void receiveCast(Hot_GroupContext gctx, java.lang.Object env, Hot_Endpoint origin, Hot_Message msg)
Hot_Callbacks
receiveCast
in interface Hot_Callbacks
public void receiveSend(Hot_GroupContext gctx, java.lang.Object env, Hot_Endpoint origin, Hot_Message msg)
Hot_Callbacks
receiveSend
in interface Hot_Callbacks
public void acceptedView(Hot_GroupContext gctx, java.lang.Object env, Hot_ViewState viewState)
Hot_Callbacks
acceptedView
in interface Hot_Callbacks
public void heartbeat(Hot_GroupContext gctx, java.lang.Object env, int rate)
Hot_Callbacks
heartbeat
in interface Hot_Callbacks
public void block(Hot_GroupContext gctx, java.lang.Object env)
Hot_Callbacks
block
in interface Hot_Callbacks
public void exit(Hot_GroupContext gctx, java.lang.Object env)
Hot_Callbacks
exit
in interface Hot_Callbacks
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |