All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JavaGroups.ChannelNew

java.lang.Object
   |
   +----JavaGroups.ChannelNew

public abstract class ChannelNew
extends Object
implements Transportable
A channel represents one member of a specific group in a Java VM. Only a single object at a time is allowed to connect to a channel, but there can be more than one channel in an application (for different or the same groups).

Messages can be multicast to all objects connected to all channels with the same name using the Send method and messages can be received using the Receive method.

A channel instance is created using a ChannelFactory. Each implementation of a channel must provide a subclass of Channel and an implementation of ChannelFactory.

Various degrees of sophistication in message exchange can be achieved using building blocks on top of channels, e.g. light-weight groups, synchronous message invocation, or remote method calls. Channels are on the same abstraction level as sockets, and should really be simple to use. Higher-level abstractions are all built on top of channels.


Constructor Index

 o ChannelNew()

Method Index

 o BlockOk()
Called to acknowledge a Block (callback in MembershipListener).
 o Connect(String)
Private constructor.
 o Disconnect()
Disconnects a client from a channel.
 o GetAddress()
Returns the channel's address.
 o GetOpt(int)
Gets an option.
 o GetView()
Gets the current view.
 o Receive(long)
 o Receive(long)
Receives a message, a view change or a block event.
 o Send(Message)
Sends a message to a destination.
 o SetOpt(int, Object)
Sets an option.

Constructors

 o ChannelNew
 public ChannelNew()

Methods

 o Connect
 public abstract void Connect(String group_address)
Private constructor. Channels should be created through ChannelFactories. private ChannelNew() {} /** Connects a client to a channel. The client is now able to receive messages, views and block events (depending on the options set) and to send messages. If the channel is already connected, this is a null operation. All channels with the same name form a group.

Parameters:
group_address - The name of the group to be joined.
 o Disconnect
 public abstract void Disconnect()
Disconnects a client from a channel. This is a null operation if not connected.

 o Send
 public abstract void Send(Message msg) throws NotConnected
Sends a message to a destination. The message contains
  1. a destination address (Object). If it is null, the message is sent to all members of the group.
  2. a source address. Can be left empty. Will be filled in by the protocol stack.
  3. a byte buffer. The message contents.
  4. several additional fields. They can be used by application programs (or patterns). E.g. a message ID, a oneway field which determines whether a response is expected etc.

Parameters:
msg - The message to be sent. Destination and buffer should be set. A null destination (default) means send to all members of the group.
Throws: NotConnected
The channel is not connected. Messages can only be sent in the connected state.
 o Receive
 public abstract Object Receive(long timeout) throws NotConnected, TimeoutException
Receives a message, a view change or a block event. By using SetOpt, the type of objects to be received can be determined (e.g. not views and blocks, just messages). The channel must be connected to receive messages. The possible types returned can be:
  1. Message. Normal message
  2. View. A view change.
  3. BlockEvent. A block event indicating an impending view change.
The instanceof operator can be used to discriminate between different types returned.

Parameters:
timeout - Value in milliseconds. Value <= 0 means wait forever
Returns:
A Message, View or BlockEvent object, depending on what is on top of the internal queue.
Throws: TimeoutException
Thrown when a timeout has occurred.
Throws: NotConnected
The channel is not connected. Messages can only be received in the connected state.
 o GetView
 public abstract View GetView()
Gets the current view. This does not retrieve a new view, use 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).

Returns:
The current view.
 o GetAddress
 public abstract Object GetAddress()
Returns the channel's address. The result of calling this method on an unconnected channel is implementation defined (may return null).

Returns:
The channel's address. Generated by the underlying transport, and opaque. Addresses can be used as destination in the Send operation.
 o SetOpt
 public abstract void SetOpt(int option,
                             Object value)
Sets an option. The following options are currently recognized:
  1. BLOCK (0). 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.
  2. VIEW (1). Turn the reception of VIEW events on/off (value is Boolean). Default is off.
  3. LOCAL (2). Receive its own broadcast messages to the group (value is Boolean). Default is on.
This method can be called on an unconnected channel.

 o GetOpt
 public abstract Object GetOpt(int option)
Gets an option. This method can be called on an unconnected channel.

Parameters:
option - The option to be returned.
Returns:
The object associated with an option.
 o BlockOk
 public abstract void BlockOk()
Called to acknowledge a Block (callback in MembershipListener). After sending BlockOk, no messages should be sent until a new view has been received.


All Packages  Class Hierarchy  This Package  Previous  Next  Index