edu.virginia.cs.mng.hypercast
Class UDP_HTTP_ServerAdapter

java.lang.Object
  |
  +--edu.virginia.cs.mng.hypercast.UDP_UnicastAdapter
        |
        +--edu.virginia.cs.mng.hypercast.UDP_HTTP_ServerAdapter

public class UDP_HTTP_ServerAdapter
extends UDP_UnicastAdapter
implements I_ServerAdapter

This class extends UDP_HTTP_ServerAdapter. It uses a webserver as a protocol server to process request messages. The messages are translated into hex and sent to the webserver as a parameter in a CGI request. The response from the server gets translated back into a byte[] and placed in the receive queue.

The implemenation uses two threads for each message sent. One thread performs the URL request, the other waits to interrupt the thread if the transaction takes more than MAX_TRANSMISSION_TIME milliseconds.


Field Summary
(package private)  OverlaySocketConfig config
          Config object for overlay.
private  long MAX_TRANSMISSION_TIME
          In milliseconds, the maximum time allowed to receive a response from the server.
private static long MAX_TRANSMISSION_TIME_DEFAULT
          Default for the maximum time allowed to receive a response from the server.
private static java.lang.String MAX_TRANSMISSION_TIME_PROPERTY_NAME
          Name of property containing the maximum time allowed to receive a response from the server.
(package private)  java.lang.String overlayID
          The overlayID (duh).
static java.lang.String OVERLAYID_PROPERTY_NAME
          Name of the property holding the overlayID.
static java.lang.String SERVER_PREFIX
          Prefix for the name of the properties holding the URLs of the servers.
(package private)  java.util.Vector serverQueryPrefixes
          Vector containing the URLs of the protocol's CGI script at the servers.
(package private)  java.util.Vector serverReceivers
          Currently active ServerReceiver objects
(package private)  long SReceivedBytes
          Total number of bytes received from the server
(package private)  long SReceivedPackets
          Total number of packets received from the server
(package private)  long SSentBytes
          Total number of bytes sent to the server
(package private)  long SSentPackets
          Total number of packets sent to the server
 
Fields inherited from class edu.virginia.cs.mng.hypercast.UDP_UnicastAdapter
deathGuard, InputChannel, MaximumPacketLength, MsgProc, MsgProcDebug, MyIPAddress, Node, property, PROPERTY_NAME_PREFIX, STARTED, STARTING, state, stateGuard, STOPPED, STOPPING, TimerProc, TimerProcDebug, UDP_Timer, UReceivedBytes, UReceivedPackets, URecv, URecvDebug, USentBytes, USentPackets, USock, USockLocker
 
Constructor Summary
UDP_HTTP_ServerAdapter(OverlaySocketConfig c, java.net.DatagramSocket usocket, java.lang.String prefix)
          Construct a new adapter.
 
Method Summary
 java.lang.String[] getSchema()
          Gets the Statistics information description of this Adapter.
 java.lang.String getStats(java.lang.String name)
          Gets the Statistics information of this Adapter.
protected  void myStop()
          make sure threads no longer perform callbacks.
 int numOfServers()
          Returns the number of servers available.
 void sendToServer(int serverIndex, I_Message mp)
          Sends a message to the server.
 void setStats(java.lang.String name, java.lang.String value)
          Sets the Statistic information in this Adapter.
 
Methods inherited from class edu.virginia.cs.mng.hypercast.UDP_UnicastAdapter
clearTimer, createPhysicalAddress, getCurrentTime, getNumInQueue, getPhysicalAddress, getTimer, getUReceivedBytes, getUReceivedPackets, getUSentBytes, getUSentPackets, sendUnicastMessage, setCallBack, setTimer, Start, Stop
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

OVERLAYID_PROPERTY_NAME

public static final java.lang.String OVERLAYID_PROPERTY_NAME
Name of the property holding the overlayID.

SERVER_PREFIX

public static final java.lang.String SERVER_PREFIX
Prefix for the name of the properties holding the URLs of the servers.

MAX_TRANSMISSION_TIME_PROPERTY_NAME

private static final java.lang.String MAX_TRANSMISSION_TIME_PROPERTY_NAME
Name of property containing the maximum time allowed to receive a response from the server.

MAX_TRANSMISSION_TIME_DEFAULT

private static final long MAX_TRANSMISSION_TIME_DEFAULT
Default for the maximum time allowed to receive a response from the server.

MAX_TRANSMISSION_TIME

private long MAX_TRANSMISSION_TIME
In milliseconds, the maximum time allowed to receive a response from the server.

SReceivedPackets

long SReceivedPackets
Total number of packets received from the server

SSentPackets

long SSentPackets
Total number of packets sent to the server

SReceivedBytes

long SReceivedBytes
Total number of bytes received from the server

SSentBytes

long SSentBytes
Total number of bytes sent to the server

overlayID

java.lang.String overlayID
The overlayID (duh).

serverQueryPrefixes

java.util.Vector serverQueryPrefixes
Vector containing the URLs of the protocol's CGI script at the servers.

serverReceivers

java.util.Vector serverReceivers
Currently active ServerReceiver objects

config

OverlaySocketConfig config
Config object for overlay.
Constructor Detail

UDP_HTTP_ServerAdapter

public UDP_HTTP_ServerAdapter(OverlaySocketConfig c,
                              java.net.DatagramSocket usocket,
                              java.lang.String prefix)
Construct a new adapter.
Parameters:
config - a OverlaySocketConfig object.
usocket - a DatagramSocket object.
Method Detail

sendToServer

public void sendToServer(int serverIndex,
                         I_Message mp)
Sends a message to the server. The serverIndex is used to select backup servers incase of a problem. serverIndex = 0 is the primary server, 1 = back-up, 2 = secondary back-up, 3 = third back-up, etc.
Specified by:
sendToServer in interface I_ServerAdapter

numOfServers

public int numOfServers()
Returns the number of servers available.
Specified by:
numOfServers in interface I_ServerAdapter

myStop

protected void myStop()
make sure threads no longer perform callbacks.
Overrides:
myStop in class UDP_UnicastAdapter

getStats

public java.lang.String getStats(java.lang.String name)
                          throws StatsException
Gets the Statistics information of this Adapter.
Parameters:
name - the String representation of a Statistic name
Returns:
String representation of the Statistic
Overrides:
getStats in class UDP_UnicastAdapter
See Also:

setStats

public void setStats(java.lang.String name,
                     java.lang.String value)
              throws StatsException
Sets the Statistic information in this Adapter.
Parameters:
name - the String representation of a Statistic name
value - the String representation of the Statistic value
Overrides:
setStats in class UDP_UnicastAdapter
See Also:

getSchema

public java.lang.String[] getSchema()
                             throws StatsException
Gets the Statistics information description of this Adapter.
Returns:
the String description of the Schema.
Overrides:
getSchema in class UDP_UnicastAdapter
See Also: