hypercast.adapters
Class UDP_MulticastAdapter

java.lang.Object
  |
  +--hypercast.adapters.UDP_UnicastAdapter
        |
        +--hypercast.adapters.UDP_MulticastAdapter
All Implemented Interfaces:
I_IPv4_UnicastAdapter, I_MulticastAdapter, I_Stats, I_UnicastAdapter

public class UDP_MulticastAdapter
extends UDP_UnicastAdapter
implements I_MulticastAdapter

This class extends the UDP_UnicastAdapter_INETv4AndOnePort. It handles sending messages to a multicast address. It starts a MulticastReceive Thread to receive multicast messages from a multicast socket.


Field Summary
 
Fields inherited from interface hypercast.I_IPv4_UnicastAdapter
MAX_RETRIES_TO_OPEN_SOCKET
 
Fields inherited from interface hypercast.I_UnicastAdapter
CLOSED, STARTED, STARTING, STOPPED, STOPPING
 
Constructor Summary
UDP_MulticastAdapter(hypercast.HyperCastConfig config, java.net.DatagramSocket usock, java.lang.String prefix)
          Constructs a UDP_MulticastAdapter object with a HyperCastConfig and DataGramSocket object.
UDP_MulticastAdapter(hypercast.HyperCastConfig config, hypercast.I_UnicastAdapter scktAdpt, java.lang.String AddrString, java.lang.String prefix)
          Constructs a UDP_MulticastAdapter object with a HyperCastConfig object and an I_UnicastAdapter object.
 
Method Summary
 void close()
          Close stops the adapter if it has not already been stopped.
 void CreateMulticastAddress(java.lang.String mcastAddressString)
          Create local INETv4OnePort-type multicast address.
 long getMReceivedBytes()
          Gets the number of bytes received from the Multicast address
 long getMReceivedPackets()
          Gets the number of packets received from the Multicast address
 long getMSentBytes()
          Gets the number of bytes sent to the Multicast address
 long getMSentPackets()
          Gets the number of packets sent to the Multicast address
 hypercast.I_PhysicalAddress getMulticastAddress()
          Gets the Multicast address used in this adapter.
 void MulticastAdapter_Inilization(hypercast.HyperCastConfig config, java.lang.String AddrStr, java.lang.String prefix)
          Finish the initialization for this UDP_MulticastAdapter object.
 void sendMulticastMessage(hypercast.I_Message msg)
          Sends a message to the Multicast address.
 void Start()
          Start the Multicast receiver thread
 
Methods inherited from class hypercast.adapters.UDP_UnicastAdapter
clearTimer, createDatagramSocket, createPhysicalAddress, createPhysicalAddress, createPhysicalAddress, createUnderlayAddress, createUnderlayAddress, createUnderlayAddress, getCurrentTime, getInfo, getIPString, getNumInQueue, getPhysicalAddressSize, getReadSchema, getStats, getStatsName, getTimer, getUnderlayAddressSize, getUReceivedBytes, getUReceivedPackets, getUSentBytes, getUSentPackets, getWriteSchema, ProcessingSocketInitialization, Reset, sendUnicastMessage, setCallback, setStats, setStatsName, setTimer, Stop, Stop
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hypercast.I_UnicastAdapter
clearTimer, createPhysicalAddress, createPhysicalAddress, createPhysicalAddress, createUnderlayAddress, createUnderlayAddress, createUnderlayAddress, getCurrentTime, getInfo, getPhysicalAddressSize, getTimer, getUnderlayAddressSize, Reset, sendUnicastMessage, setCallback, setTimer, Stop, Stop
 
Methods inherited from interface hypercast.I_Stats
getReadSchema, getStats, getStatsName, getWriteSchema, setStats, setStatsName
 

Constructor Detail

UDP_MulticastAdapter

public UDP_MulticastAdapter(hypercast.HyperCastConfig config,
                            hypercast.I_UnicastAdapter scktAdpt,
                            java.lang.String AddrString,
                            java.lang.String prefix)
Constructs a UDP_MulticastAdapter object with a HyperCastConfig object and an I_UnicastAdapter object.

Parameters:
config - a HyperCastConfig object.
scktAdpt - object representing the Socket Adapter. It is set to null when creating the Socket Adapter.
AddrString - string containing physical address information.
prefix - property prefix. sockets.

UDP_MulticastAdapter

public UDP_MulticastAdapter(hypercast.HyperCastConfig config,
                            java.net.DatagramSocket usock,
                            java.lang.String prefix)
Constructs a UDP_MulticastAdapter object with a HyperCastConfig and DataGramSocket object.

Parameters:
config - a HyperCastConfig object.
usock - a DatagramSocket object.
prefix - property prefix.
Method Detail

MulticastAdapter_Inilization

public void MulticastAdapter_Inilization(hypercast.HyperCastConfig config,
                                         java.lang.String AddrStr,
                                         java.lang.String prefix)
Finish the initialization for this UDP_MulticastAdapter object.

Parameters:
config - a HyperCastConfig object.
AddrStr - string containing address information for underlying unicast socket.
prefix - property prefix.

Start

public void Start()
Start the Multicast receiver thread

Specified by:
Start in interface I_UnicastAdapter
Overrides:
Start in class UDP_UnicastAdapter

close

public void close()
Description copied from interface: I_UnicastAdapter
Close stops the adapter if it has not already been stopped. It then closes the physical sockets. This should only be called if the adapter will no longer be used. After a close call, any further calls to adapter methods will return an IllegalStateException. If a delayed stop was called before the close method is called, then close will block until that delayed stop is completed. A closed adapter is always stopped as well.

Specified by:
close in interface I_UnicastAdapter
Overrides:
close in class UDP_UnicastAdapter

CreateMulticastAddress

public void CreateMulticastAddress(java.lang.String mcastAddressString)
Create local INETv4OnePort-type multicast address.

Parameters:
mcastAddressString - the string representing the multicast address.

sendMulticastMessage

public void sendMulticastMessage(hypercast.I_Message msg)
Sends a message to the Multicast address.

Algorithm:
1. Create a byte array containing the information
2. Create a DatagramPacket
3. Send Packet.

Specified by:
sendMulticastMessage in interface I_MulticastAdapter
Parameters:
msg - a protocol specific message

getMulticastAddress

public hypercast.I_PhysicalAddress getMulticastAddress()
Gets the Multicast address used in this adapter.

Specified by:
getMulticastAddress in interface I_MulticastAdapter

getMReceivedPackets

public long getMReceivedPackets()
Gets the number of packets received from the Multicast address

Returns:
the number of packets received

getMReceivedBytes

public long getMReceivedBytes()
Gets the number of bytes received from the Multicast address


getMSentPackets

public long getMSentPackets()
Gets the number of packets sent to the Multicast address


getMSentBytes

public long getMSentBytes()
Gets the number of bytes sent to the Multicast address