|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--edu.uiuc.cs.net.DPRPManager.DPRPServerSession
This class, when instantiated, will spawn in its own thread, and handle a single client request (be it to request a new lease, or renew an old one). It contains a reference to the global Server Port Manager, which was instantiated in the SimpleDPRPServer class. Using this reference, this server session is able to check the priviliges of the client, regarding its request. Furthermore, this session allocates a local UDP socket, for use in it's replies to the client. This separates this transaction from other transactions that are going on concurrently in the server.
Field Summary | |
private int |
curXid
The current XID of this session, for sanity checking. |
private java.net.InetAddress |
externalIP
The external IP address of the gateway. |
private java.net.InetAddress |
internalIP
The internal IP address of the gateway. |
private DPRPSocket |
localSock
Local socket, allocated to keep this session separate from the rest. |
private static int |
NUM_RETRIES
Constant directing the number of times to retry sending a message. |
DPRPMessage |
passedMessage
This message reference is set by the server singleton, whenever it receives an errant message from the client, that is really destined for this session. |
private static long |
RETRY_TIMEOUT
The amount of time to wait for a message from the client, where we know that they received our final message of the transaction. |
private ServerPortMgr |
SPM
Reference to the Server Port Manager singleton. |
private DPRPMessage |
startMessage
The message that started this session, to be removed from the server singleton's map. |
Fields inherited from class java.lang.Thread |
contextClassLoader, daemon, eetop, group, inheritableThreadLocals, inheritedAccessControlContext, MAX_PRIORITY, MIN_PRIORITY, name, NORM_PRIORITY, priority, single_step, stillborn, stopThreadPermission, target, threadInitNumber, threadLocals, threadQ |
Constructor Summary | |
DPRPServerSession(DPRPMessage inMessage,
java.lang.String threadName,
java.net.InetAddress extIP)
New session constructor. |
Method Summary | |
private void |
handleNewRequest()
Handles a client request for a new lease. |
private void |
handleRenewRequest()
Takes care of a client renewal request. |
void |
run()
Run method for DPRPServerSession. |
private DPRPMessage |
sendAndMaybeRecv(DPRPMessage outMessage,
byte msgShouldntRecv)
The new way to call the send and maybe receiver, which will eventually take over. |
private DPRPMessage |
sendAndMaybeRecv(DPRPMessage outMessage,
byte msgShouldntRecv,
boolean expectingMsg)
Takes in a fully-formed DPRPMessage, and spits out a response message form the client. |
private void |
sendRenewNack(DPRPLease lea,
short reason)
Constructs and transmits a valid DPRP_SRV_RENEW_NACK packet. |
boolean |
sendRenewResp(DPRPMessage msg)
This method sends a "renew" response to the client. |
Methods inherited from class java.lang.Thread |
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public DPRPMessage passedMessage
private DPRPMessage startMessage
private int curXid
private java.net.InetAddress externalIP
private java.net.InetAddress internalIP
private DPRPSocket localSock
private ServerPortMgr SPM
private static final int NUM_RETRIES
private static final long RETRY_TIMEOUT
Constructor Detail |
public DPRPServerSession(DPRPMessage inMessage, java.lang.String threadName, java.net.InetAddress extIP)
inMessage
- The message that caused the creation of a new
session.threadName
- The name for this thread, as generated by the
server singleton.extIP
- Our external IP address, as specified in a
parameter to the server.Method Detail |
public void run()
run
in class java.lang.Thread
private void handleNewRequest() throws DPRPOfferException
DPRPOfferException
- If a problem occurs after a port has
been allocated. The handler will attempt to cleanup the invalid
state in a sane manner.private void handleRenewRequest()
private void sendRenewNack(DPRPLease lea, short reason)
lea
- The DPRPLease to be terminated.reason
- The reason (according to the
DPRPErrors database) that the lease is being
terminated.DPRPErrors
public boolean sendRenewResp(DPRPMessage msg)
msg
- The DPRPMessage to send to the client.private DPRPMessage sendAndMaybeRecv(DPRPMessage outMessage, byte msgShouldntRecv)
outMessage
- A message to send.msgShouldntRecv
- The message type that we don't want to
get back. If this is zero, then getting back no message is what
we want.private DPRPMessage sendAndMaybeRecv(DPRPMessage outMessage, byte msgShouldntRecv, boolean expectingMsg)
outMessage
- The message to send out to the client.msgShouldntRecv
- The type of message that is expected in
response. If 0, don't expect anything.expectingMsg
- Controls wether a message should be received or not.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |