|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.uiuc.cs.net.DPRPManager.DPRPClient
This class is an overall container for the DPRP Client. It can be instantiated, and once done, contains a vector of all of the leases currently outstanding for this client. Furthermore, it can spawn new 'DPRPClientSession' threads, in order to obtain & update new leases.
This is going to need some major help so that this class can fire events at the GUI. Hell, maybe the thread should be the one firing the events. Well, it should be here, because this is the one that is interrupting the caller thread (ugly like Mike's mom). Anyways, the help for EventListenerList in the JDK 1.3.1 documentation is the most lucid source of information that I have at at this point. I'm still confused as to what sort of interface I need to create (probably DPRPEventListener), and what this interface needs to define.
Everything sucks.
Field Summary | |
private java.lang.Thread |
callerThread
A reference to the thread that started this object. |
private java.net.InetAddress |
cliIP
The IP address on the local machine that we are using. |
private int |
cliPort
The port on the local machine that we are using. |
static boolean |
DEBUG
Controls the printing of debug messages. |
private java.net.InetAddress |
extIP
|
private int |
extPort
|
DPRPLease |
gotLease
Notifies the session that we already have a valid lease, and that it should simply sit on it (i.e. |
private javax.swing.event.EventListenerList |
listenerList
A list of event listeners, who need to be notified whenever we muck with a lease. |
private java.util.Vector |
obtainedLeases
Internal variable, contains a reference to all outstanding leases for this client. |
private int |
reqDuration
The lease duration to request from the gateway. |
private short |
reqFlags
The flags to accompany all messages to the gateway. |
private int |
reqPort
The port to request from the gateway. |
private byte |
reqProtocol
The type of port to request from the gateway. |
DPRPLeaseEvent |
returnLeaseEvent
For the legacy client interrupt method, passes a reference to a DPRPLeaseEvent object, which gives some details about this event.. |
int |
sentRequest
Set by the caller, whenever it wants to interrupt the thread with new instructions. |
private java.lang.Thread |
sessionThreadID
The Thread object for the client session. |
private java.net.InetAddress |
srvIP
The IP address of the gateway, that we connect to. |
private int |
srvPort
The UDP port on the server to connect to. |
Fields inherited from interface edu.uiuc.cs.net.DPRPManager.DPRPLeaseListenerConstants |
NEW_LEASE_EVENT, REMOVE_LEASE_EVENT, UPDATE_LEASE_EVENT |
Fields inherited from interface edu.uiuc.cs.net.DPRPManager.DPRPClientConstants |
CLI_COMMAND, CLI_FORCE_LEASE_TERMINATE, CLI_FORCE_LEASE_UPDATE, CLI_TERMINATE_THREAD, cliIPFieldString, HALT, HALT_ACQUIRE_LEASE, HALT_INTERRUPTED, HALT_INVALID_SLEEP_TIMER, HALT_NO_RESPONSE, HALT_SERVER_NACK, HALT_T2_EXPIRED, NUM_RETRIES, okButtonString, reqDurationFieldString, reqPortFieldString, reqProtocolFieldString, resetButtonString, srvIPFieldString, srvPortFieldString, terminateButtonString, updateButtonString |
Constructor Summary | |
DPRPClient()
Creates a new DPRPClient object instance. |
|
DPRPClient(DPRPLease il)
Creates a new DPRPClient object from a pre-existing lease. |
|
DPRPClient(java.net.InetAddress sIP,
java.net.InetAddress cIP,
int rPort,
int rD,
short rF,
byte rProt)
Creates a new DPRPClient object instance. |
|
DPRPClient(java.lang.Thread ct)
Creates a new DPRPClient object instance. |
Method Summary | |
void |
addDPRPLeaseListener(DPRPLeaseListener pl)
Adds a listener to our internal list. |
void |
addLease(DPRPLease lea)
Add a lease to the internal vector-o-leases. |
void |
dumpParameters()
Prints all of the initial parameters to stdout. |
protected void |
fireReceiveLease(DPRPLease lea,
char reason)
Deprecated. This is only for backwards compatibility. |
protected void |
fireReceiveLease(DPRPLeaseEvent eventToSend)
Send a new event to our listeners. |
java.net.InetAddress |
getClientIP()
Gets our local IP address. |
int |
getDuration()
Gets the duration that we are requesting. |
java.net.InetAddress |
getExternalIP()
Gets the current notion of the external IP address. |
int |
getExternalPort()
Gets the DPRP-leased external port. |
short |
getFlags()
Gets the flags that we are sending in all requests. |
byte |
getProtocol()
Gets the protocol that we are requesting for our port. |
int |
getRequestedPort()
Gets the port that we're requesting from the gateway. |
java.net.InetAddress |
getServerIP()
Gets the servers' internal IP address. |
int |
getServerPort()
Gets the port to connect to on the server. |
java.lang.Thread |
getSessionThreadID()
Returns the Thread object for the session. |
void |
interruptSession()
Used by the GUI in order to pass immediate orders to the session (i.e. |
void |
kickoffNewRequest()
Forces this client object to instantiate a new session thread, which does the actual lease gettin'/renewin'. |
void |
notifyController(DPRPLeaseEvent ev)
Notifies whomever is controlling us that something has happend. |
java.lang.String |
ourAddrString()
Returns our current client IP address, as a string. |
java.lang.String |
ourSrvAddrString()
Returns our current notion of the server's IP address, as a string. |
java.lang.String |
ourSrvPortString()
Returns the port to connect to on the server, as a string. |
void |
removeDPRPLeaseListener(DPRPLeaseListener pl)
Removes a lease listener from our internal list. |
void |
rmLease(DPRPLease lea,
DPRPLeaseEvent ev)
Remove a lease from the internal vector-o-leases. |
void |
setClientIP(java.net.InetAddress cIP)
Sets our local IP address. |
void |
setDuration(int durata)
Sets the duration to request. |
void |
setExternalIP(java.net.InetAddress i)
Sets the external IP address, after the lease has been acquired. |
void |
setExternalPort(int p)
Sets the external port, after the lease has been acquired. |
void |
setFlags(short rF)
Sets the flags that accompany all requests. |
void |
setProtocol(byte p)
Sets the protocol to request. |
void |
setProtocol(java.lang.String str)
Sets the protocol to request. |
void |
setRequestedPort(int rP)
Sets the port number to request. |
void |
setServerIP(java.net.InetAddress sIP)
Sets the server's IP address, to connect to. |
void |
setServerPort(int sPort)
Sets the port on the server to connect to, initially. |
void |
setSessionThreadID(java.lang.Thread tid)
Sets the thread ID of the session, so that we can properly interrupt it. |
void |
updateLease(DPRPLease curLea,
DPRPLease newLea)
Update a lease in the internal vector-o-leases. |
void |
waitForSession()
|
Methods inherited from class java.lang.Object |
|
Field Detail |
public static boolean DEBUG
public DPRPLease gotLease
public int sentRequest
public DPRPLeaseEvent returnLeaseEvent
private java.net.InetAddress srvIP
private int srvPort
private java.net.InetAddress cliIP
private int cliPort
private int reqPort
private int reqDuration
private short reqFlags
private byte reqProtocol
private int extPort
private java.net.InetAddress extIP
private java.util.Vector obtainedLeases
private java.lang.Thread callerThread
private javax.swing.event.EventListenerList listenerList
private java.lang.Thread sessionThreadID
Constructor Detail |
public DPRPClient()
public DPRPClient(java.lang.Thread ct)
ct
- A reference to a thread object, so that we can
interrupt them if we so choose.public DPRPClient(java.net.InetAddress sIP, java.net.InetAddress cIP, int rPort, int rD, short rF, byte rProt)
public DPRPClient(DPRPLease il)
il
- A valid DPRPLease, to base this session
around.Method Detail |
public void addLease(DPRPLease lea)
lea
- The 'DPRPLease' to be added.public void rmLease(DPRPLease lea, DPRPLeaseEvent ev)
lea
- A lease to be removed.public void updateLease(DPRPLease curLea, DPRPLease newLea)
curLea
- The current lease in the database.newLea
- The lease that is to replace the current lease.public void kickoffNewRequest()
public void waitForSession()
public void interruptSession()
public void setSessionThreadID(java.lang.Thread tid)
tid
- A thread ID object, which we'll interrupt later.public void notifyController(DPRPLeaseEvent ev)
ev
- A DPRPLeaseEvent, to be sent to whomever
is controlling us (CLI or GUI).public void setServerPort(int sPort)
public void setDuration(int durata)
public void setRequestedPort(int rP)
public void setFlags(short rF)
public void setProtocol(byte p)
public void setProtocol(java.lang.String str)
public void setClientIP(java.net.InetAddress cIP)
public void setServerIP(java.net.InetAddress sIP)
public int getServerPort()
public java.net.InetAddress getServerIP()
public java.net.InetAddress getClientIP()
public int getRequestedPort()
public int getDuration()
public short getFlags()
public byte getProtocol()
public java.lang.Thread getSessionThreadID()
public void setExternalIP(java.net.InetAddress i)
public void setExternalPort(int p)
public java.net.InetAddress getExternalIP()
public int getExternalPort()
public java.lang.String ourAddrString()
public java.lang.String ourSrvAddrString()
public java.lang.String ourSrvPortString()
public void dumpParameters()
public void addDPRPLeaseListener(DPRPLeaseListener pl)
pl
- A DPRPLeaseListener to be added as the
target of fired events.public void removeDPRPLeaseListener(DPRPLeaseListener pl)
pl
- A DPRPLeaseListener who no longer wishes
to receive events.protected void fireReceiveLease(DPRPLease lea, char reason)
fireReceiveLease()
method.lea
- A lease to send.reason
- Why we're sending said lease.protected void fireReceiveLease(DPRPLeaseEvent eventToSend)
receiveLease()
, and schedules them to occur serially
in the worker thread.eventToSend
- A nice DPRPLeaseEvent object,
which I can customize to my will, passing all sorts of data in
an event.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |