|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--hypercast.adapters.TCP_UnicastAdapter
This class implements the I_UnicastAdapter interface while using TCP links. TCP links are created when necessary to send data. Links are shutdown when not used for TIMEOUT_TIME millseconds. Each link is unidirectional, so upto 2 TCP sockets can exist for each neighbor. To prevent deadlock, when the thread assigned to receive from a link has not read from it in DROP_TIME seconds, a message is dropped from the link.
In implementation, there are 3 threads plus a thread for each incoming link plus a thread for each dropped message. The 3 threads are responsible for (1) accept()ing connections on the server socket, (2) performing the timer functions and (3) detecting deadlocks and timeouts. When a connection is accepted, a new receiving thread is created for the socket. When the deadlock thread computes that data isn't being read from an incoming socket, it creates a thread to drop a single message from the socket. (The thread dies once the one message has been dropped.)
For each incoming socket and outgoing socket, an object is created. For the incoming socket the IncomingSocketObject object is used to synchronize multiple threads trying to read and manages the buffers for reading messages from the socket. For outgoing sockets, the OutgoingSocketObject is used to synchronize multiple threads trying to write. This class supports INETv4TwoPorts type physical address.
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_UnicastAdapter(hypercast.HyperCastConfig c,
hypercast.I_UnicastAdapter scktAdpt,
java.lang.String AddrString,
java.lang.String prefix)
Constructs a new TCP_UnicastAdapter object from an HyperCastConfig
object. |
|
TCP_UnicastAdapter(hypercast.HyperCastConfig config,
java.net.ServerSocket ssock,
java.lang.String prefix)
Constructs a TCP_UnicastAdapter object with a HyperCastConfig and ServerSocket object. |
Method Summary | |
void |
Adapter_Inilization(hypercast.HyperCastConfig c,
java.lang.String prefix)
Finish the initialization for this TCP_UnicastAdapter object. |
void |
clearTimer(java.lang.Object timerid)
Clear a Timer event. |
void |
close()
Close stops the adapter if it has not already been stopped. |
hypercast.I_PhysicalAddress |
createPhysicalAddress()
Creates a new physical address. |
hypercast.I_PhysicalAddress |
createPhysicalAddress(byte[] byteAddressAndPorts,
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. |
int |
getPhysicalAddressSize()
Returns the size of physical address, when carried in a packet, recognized by this adapter. |
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, of an I_UnicastAdapter object. |
long |
getUReceivedBytes()
Get the number of bytes received by this Adapter. |
long |
getUReceivedPackets()
Get the number of packets recerved by this Adapter. |
long |
getUSentBytes()
Get the number of bytes sent by this Adapter. |
long |
getUSentPackets()
Get the number of packets sent 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 |
Reset(java.lang.Object SocketObj)
Resets the local unicast socket with a ServerSocket object. |
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_Callback object of this adapter. |
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()
Start this TcpAdapter. |
void |
Stop()
Stop this TcpAdapter. |
void |
Stop(long delay)
Stop this TcpAdapter after a delay. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TCP_UnicastAdapter(hypercast.HyperCastConfig c, hypercast.I_UnicastAdapter scktAdpt, java.lang.String AddrString, java.lang.String prefix)
TCP_UnicastAdapter
object from an HyperCastConfig
object.
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.public TCP_UnicastAdapter(hypercast.HyperCastConfig config, java.net.ServerSocket ssock, java.lang.String prefix)
config
- a HyperCastConfig object.ssock
- a ServerSocket object.prefix
- property prefix.Method Detail |
public void Adapter_Inilization(hypercast.HyperCastConfig c, java.lang.String prefix)
c
- a HyperCastConfig object.prefix
- property prefix.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 containing information used to finish reset.public void setCallback(hypercast.I_AdapterCallback cb)
I_Callback
object of this adapter.
setCallback
in interface I_UnicastAdapter
cb
- an object of type I_AdapterCallback
IllegalStateException.
public void setTimer(java.lang.Object timer_id, long time_ms)
Timer
event.
setTimer
in interface I_UnicastAdapter
timer_id
- a time event ID.time_ms
- a time in ms.
IllegalStateException.
public 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()
This function is not supported by TcpAdapter
getCurrentTime
in interface I_UnicastAdapter
public hypercast.I_PhysicalAddress createPhysicalAddress(byte[] byteAddressAndPorts, 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:
byteAddressAndPorts
- 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 void sendUnicastMessage(hypercast.I_NetworkAddress dstaddr, hypercast.I_Message msg)
sendUnicastMessage
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 long getUReceivedPackets()
public long getUReceivedBytes()
public long getUSentPackets()
public long getUSentBytes()
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)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |