|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--hypercast.adapters.TCP_UDP_Adapter
This class implements an adapter which supports the folowing three kinds of data transmission: 1. UDP unicast; 2. TCP unicast; 3. UDP multicast. This class employs a UDP_MulticastAdapter object and TCP_UnicastAdapter object to fulfill data transmission task, instead of implementing all required functions by itself. This class has its own Timer object and Timer processor. This class defines a INETv4TwoPorts physical address in which the "port-plus-one" is applied.
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 | |
TCP_UDP_Adapter(hypercast.HyperCastConfig c,
hypercast.I_UnicastAdapter scktAdpt,
java.lang.String AddrString,
java.lang.String prefix)
Constructs a TCP_UDP_Adapter object with an HyperCastConfig object and an I_UnicastAdapter object. |
Method Summary | |
void |
clearTimer(java.lang.Object timerid)
Clear a Timer event. |
void |
close()
Close stops the adapter if it has not already been stopped. |
boolean |
createDatagramServerSocket(int portNum,
java.net.InetAddress ipAddr)
Creates a DatagramSocket object and a ServerSocket object. |
hypercast.I_PhysicalAddress |
createPhysicalAddress()
Creates a new physical address. |
hypercast.I_PhysicalAddress |
createPhysicalAddress(byte[] byteAddressAndPort,
int offset)
Creates physical address from a byte array of address - the inverse of toByteArray. |
hypercast.I_PhysicalAddress |
createPhysicalAddress(java.lang.String addrString)
Creates physical address object from a string. |
hypercast.I_UnderlayAddress |
createUnderlayAddress()
Creates a new underlay address. |
hypercast.I_UnderlayAddress |
createUnderlayAddress(byte[] byteAddressAndPort,
int offset)
Creates underlay address from a byte array of address - the inverse of toByteArray. |
hypercast.I_UnderlayAddress |
createUnderlayAddress(java.lang.String addrString)
Creates underlay address object from a string. |
long |
getCurrentTime()
Get current system time. |
java.lang.Object |
getInfo()
Get information of this adapter. |
java.lang.String |
getIPString(java.net.InetAddress addr)
Get string representation of IP address in a InetAddress object. |
hypercast.I_PhysicalAddress |
getMulticastAddress()
Get the multicast address used by this adpater. |
int |
getPhysicalAddressSize()
Returns the size of physical address, when carried in a packet, of an I_UnicastAdapter object. |
org.w3c.dom.Element[] |
getReadSchema(org.w3c.dom.Document doc,
org.apache.xpath.XPath xpath)
Return the schema element which represents the root of the sub-tree, specified by the given xpath, in read schema tree. |
org.w3c.dom.Element[] |
getStats(org.w3c.dom.Document doc,
org.apache.xpath.XPath xpath)
Return the result of query for the statistics specified by the given xpath. |
java.lang.String |
getStatsName()
Gets the element name of this I_Stats instance. |
long |
getTimer(java.lang.Object timerid)
Get a Timer event. |
int |
getUnderlayAddressSize()
Returns the size of underlay address, when carried in a packet, recognized by this adapter. |
org.w3c.dom.Element[] |
getWriteSchema(org.w3c.dom.Document doc,
org.apache.xpath.XPath xpath)
Return the schema element which represents the root of the sub-tree, specified by the given xpath, in write schema tree. |
boolean |
InitializeDatagramServerSocket(hypercast.I_UnicastAdapter ScktAdpter,
hypercast.HyperCastConfig config,
java.lang.String AddrString)
Initialize DatagramSocket and ServerSocket used by this adapter. |
boolean |
Reset(java.lang.Object SocketObj)
Resets the local unicast socket with a object which implemnents an unicast socket. |
void |
sendMulticastMessage(hypercast.I_Message msg)
Sends a message to a multicast address. |
void |
sendUnicastMessage(hypercast.I_NetworkAddress dstaddr,
hypercast.I_Message msg)
Sends a message to a unicast address. |
void |
setCallback(hypercast.I_AdapterCallback cb)
Set I_AdapterCallback object. |
org.w3c.dom.Element[] |
setStats(org.w3c.dom.Document doc,
org.apache.xpath.XPath xpath,
org.w3c.dom.Element newValue)
Set the statistics specified by the given xpath. |
void |
setStatsName(java.lang.String name)
Assigns a name to this I_Stats instance. |
void |
setTimer(java.lang.Object timer_id,
long time_ms)
Set a Timer event. |
void |
Start()
Starts all the threads in this Adapter |
void |
Stop()
Stops all these threads on this Adapter. |
void |
Stop(long delay)
Stops all these threads on this Adapter after a delay. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TCP_UDP_Adapter(hypercast.HyperCastConfig c, hypercast.I_UnicastAdapter scktAdpt, java.lang.String AddrString, java.lang.String prefix)
c
- 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.Method Detail |
public boolean InitializeDatagramServerSocket(hypercast.I_UnicastAdapter ScktAdpter, hypercast.HyperCastConfig config, java.lang.String AddrString)
ScktAdpter
- A I_UnicastAdapter object representing Socket Adapter.
ScktAdpter is null when this method is called in Socket Adapter.config
- a HyperCastConfig object.AddrString
- A string carring physical address information.public boolean createDatagramServerSocket(int portNum, java.net.InetAddress ipAddr)
portNum
- the port number for the TCP and UDP unicast sockets.
If portN is set to 0, the port will be the minimal
available port shosen by system; If portN is -1,
the port number is chosen randomly.ipAddr
- IP address to which the created socket is binded.public java.lang.String getIPString(java.net.InetAddress addr)
addr
- An InetAddress object.public java.lang.Object getInfo()
getInfo
in interface I_UnicastAdapter
public boolean Reset(java.lang.Object SocketObj)
Reset
in interface I_UnicastAdapter
SocketObj
- object passed to do reset.public void setCallback(hypercast.I_AdapterCallback cb)
I_AdapterCallback
object.
setCallback
in interface I_UnicastAdapter
cb
- an object of type I_AdapterCallback
public void setTimer(java.lang.Object timer_id, long time_ms)
Timer
event.
setTimer
in interface I_UnicastAdapter
timer_id
- a time event IDtime_ms
- a time in mspublic long getTimer(java.lang.Object timerid)
Timer
event.
getTimer
in interface I_UnicastAdapter
timerid
- a time event ID
public void clearTimer(java.lang.Object timerid)
Timer
event.
clearTimer
in interface I_UnicastAdapter
timerid
- a time event IDpublic long getCurrentTime()
getCurrentTime
in interface I_UnicastAdapter
public void Start()
Start
in interface I_UnicastAdapter
public void Stop()
Stop
in interface I_UnicastAdapter
public void Stop(long delay)
Stop
in interface I_UnicastAdapter
delay
- delay in millisecondspublic void close()
I_UnicastAdapter
close
in interface I_UnicastAdapter
public hypercast.I_PhysicalAddress createPhysicalAddress(byte[] byteAddressAndPort, int offset)
toByteArray. The first 4 bytes reprsent the IP address,
and the last 8 bytes represent the Node Adapter port number and Socket
Adapter port number.
- Specified by:
createPhysicalAddress
in interface I_UnicastAdapter
- Parameters:
byteAddressAndPort
- an byte array containing a physical addressoffset
- the position in byteAddressAndPort from where availabe
data is read.
- Returns:
- a new instance of
INETv4TwoPorts
- See Also:
INETv4TwoPorts.toByteArray()
public hypercast.I_PhysicalAddress createPhysicalAddress(java.lang.String addrString)
createPhysicalAddress
in interface I_UnicastAdapter
addrString
- an string representing a physical address.
INETv4TwoPorts
public hypercast.I_PhysicalAddress createPhysicalAddress()
createPhysicalAddress
in interface I_UnicastAdapter
INETv4TwoPorts
public int getPhysicalAddressSize()
getPhysicalAddressSize
in interface I_UnicastAdapter
public hypercast.I_UnderlayAddress createUnderlayAddress(byte[] byteAddressAndPort, int offset)
toByteArray. The first 4 bytes reprsent the IP address,
and the last 4 bytes represent the port number.
- Specified by:
createUnderlayAddress
in interface I_UnicastAdapter
- Parameters:
byteAddressAndPort
- an byte array containing a physical addressoffset
- the position in byteAddressAndPort from where availabe
data is read.
- Returns:
- a new instance of
INETv4AndOnePort
- See Also:
INETv4OnePort.toByteArray()
public hypercast.I_UnderlayAddress createUnderlayAddress(java.lang.String addrString)
createUnderlayAddress
in interface I_UnicastAdapter
addrString
- an string representing a physical address.
INETv4AndOnePort
public hypercast.I_UnderlayAddress createUnderlayAddress()
createUnderlayAddress
in interface I_UnicastAdapter
INETv4AndOnePort
public int getUnderlayAddressSize()
getUnderlayAddressSize
in interface I_UnicastAdapter
public java.lang.String getStatsName()
I_Stats
getStatsName
in interface I_Stats
I_Stats.getStatsName()
public void setStatsName(java.lang.String name)
I_Stats
setStatsName
in interface I_Stats
name
- the name assigned to the I_Stats instance.I_Stats.setStatsName(String)
public org.w3c.dom.Element[] getStats(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath) throws HyperCastStatsException
getStats
in interface I_Stats
doc
- Document used for create new elements or nodes.xpath
- XPath instance represents the statistics to be queried.
HyperCastStatsException
- If the xpath does not specify a valid subtree.I_Stats.getStats(org.w3c.dom.Document, org.apache.xpath.XPath)
public org.w3c.dom.Element[] setStats(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath, org.w3c.dom.Element newValue) throws HyperCastStatsException
setStats
in interface I_Stats
doc
- Document used for create new elements or nodes.xpath
- XPath instance represents the statistics to be queried.newValue
- Element representing the value or sub-tree to be set.
HyperCastStatsException
- If the xpath does not specify a
valid subtree or if any part of the the subtree is read-only,
or if the newValue
does not conform with the
expected format.I_Stats.setStats(org.w3c.dom.Document, org.apache.xpath.XPath, org.w3c.dom.Element)
public org.w3c.dom.Element[] getReadSchema(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath) throws HyperCastStatsException
getReadSchema
in interface I_Stats
doc
- Document used for create new elements or nodes.xpath
- XPath instance representing the statistics which is the root
of the sub-tree to be queried.
HyperCastStatsException
- If some part of the specified
subtree does not correctly implement this interface method.I_Stats.getReadSchema(Document, XPath)
public org.w3c.dom.Element[] getWriteSchema(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath) throws HyperCastStatsException
getWriteSchema
in interface I_Stats
doc
- Document used for create new elements or nodes.xpath
- XPath instance representing the statistics which is the root
of the sub-tree to be queried.
HyperCastStatsException
- If some part of the specified
subtree does not correctly implement this interface method.I_Stats.getWriteSchema(Document, XPath)
public void sendUnicastMessage(hypercast.I_NetworkAddress dstaddr, hypercast.I_Message msg)
sendUnicastMessage
in interface I_UnicastAdapter
public void sendMulticastMessage(hypercast.I_Message msg)
sendMulticastMessage
in interface I_MulticastAdapter
public hypercast.I_PhysicalAddress getMulticastAddress()
getMulticastAddress
in interface I_MulticastAdapter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |