org.sapia.ubik.mcast
Interface UnicastDispatcher

All Known Implementing Classes:
UDPUnicastDispatcher

public interface UnicastDispatcher

Implementations of this interface dispatch objects over the wire in a point-to-point fashion. It is important to note that implementations are expected to behave in a peer-to-peer fashion - they are at once client and server (for their siblings).

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Method Summary
 void close()
          Closes this instance - which should not be used thereafter.
 void dispatch(ServerAddress addr, java.lang.String type, java.lang.Object data)
          Dispatches the given data to the node whose address is given.
 ServerAddress getAddress()
          Returns the address of this instance.
 RespList send(java.util.List addresses, java.lang.String type, java.lang.Object data)
          Sends the given data to the list of destinations specified, and returning the responses received from each destination.
 Response send(ServerAddress addr, java.lang.String type, java.lang.Object data)
          Sends the given data to the node whose address is given, returning the corresponding response - received from the destination.
 void setBufsize(int size)
          Sets this instance's "buffer size".
 void setSoTimeoutListener(SocketTimeoutListener listener)
          Allows implementations to notify the passed in listener when a socket timeout occurs - this applies if the underlying implementation uses a server restricted to blocking IO.
 void start()
          Starts this instance - should be called prior to using this instance.
 

Method Detail

dispatch

void dispatch(ServerAddress addr,
              java.lang.String type,
              java.lang.Object data)
              throws java.io.IOException
Dispatches the given data to the node whose address is given.

Parameters:
addr - a ServerAddress that corresponds to the destination node for the data passed in.
type - the logical type of the data that is sent - allows the receiver to perform logic according to the "type".
data - the Object to send.
Throws:
java.io.IOException

send

Response send(ServerAddress addr,
              java.lang.String type,
              java.lang.Object data)
              throws java.io.IOException
Sends the given data to the node whose address is given, returning the corresponding response - received from the destination.

Parameters:
addr - a ServerAddress that corresponds to the destination node for the data passed in.
type - the logical type of the data that is sent - allows the receiver to perform logic according to the "type".
data - the Object to send.
Returns:
a Response.
Throws:
java.io.IOException

send

RespList send(java.util.List addresses,
              java.lang.String type,
              java.lang.Object data)
              throws java.io.IOException
Sends the given data to the list of destinations specified, and returning the responses received from each destination.

Parameters:
addresses - a List of ServerAddress instances.
type - the logical type of the data that is sent - allows the receiver to perform logic according to the "type".
data - the Object to send.
Returns:
a RespList.
Throws:
java.io.IOException

start

void start()
Starts this instance - should be called prior to using this instance.


close

void close()
Closes this instance - which should not be used thereafter.


setBufsize

void setBufsize(int size)
Sets this instance's "buffer size". The size is specified in bytes, and can be interpreted differently from one implementation to another - for example, for UDP-based implementation, it can correspond to the datagram packet size.

Parameters:
the - size of this instance's internal buffer, in bytes.

setSoTimeoutListener

void setSoTimeoutListener(SocketTimeoutListener listener)
Allows implementations to notify the passed in listener when a socket timeout occurs - this applies if the underlying implementation uses a server restricted to blocking IO.

See Also:
DatagramSocket.setSoTimeout(int), ServerSocket.setSoTimeout(int)

getAddress

ServerAddress getAddress()
                         throws java.lang.IllegalStateException
Returns the address of this instance.

Returns:
a ServerAddress.
Throws:
java.lang.IllegalStateException - if the address of this instance is not yet available. This can be the case if the start() method has not yet been called; therefore, always call start() before calling this method.
See Also:
start()


Copyright © 2010 Sapia OSS. All Rights Reserved.