|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.directwebremoting.impl.AbstractServerLoadMonitor
org.directwebremoting.impl.DefaultServerLoadMonitor
public class DefaultServerLoadMonitor
A smart implementation of ServerLoadMonitor.
What a browser does:
connected disconnected connected ... ____________ ____________ | | | | | | | | _____| |__________| |______ [---cT---] [---dT---] [---cT---] ...
Where cT is the connectedTime and dT is the disconnectedTime.
We impose some limits: a maximum number of symultaneously connected
browsers maxWaitingThreads
, and the maximum number of
connections per second maxHitsPerSecond
.
We attempt to keep the actual waitingThreads and hitsPerSecond within bounds by vairying connectedTime and disconnectedTime.
The system is in one of 3 modes: USAGE_LOW, USAGE_HIGH and USAGE_DIGG. The boundary between USAGE_LOW and USAGE_HIGH is called threadOut. The boundary between USAGE_HIGH and USAGE_DIGG is called hitOut.
The system starts in USAGE_LOW mode. This mode uses constant values of connectedTime=60 secs and disconnectedTime=0 secs. We could use much bigger values for connectedTime (like infinite) however the servlet spec does not enable servlet engines to inform us if the browser goes away so we check by asking the browser to reconnect periodically.
In USAGE_LOW mode we measure the number of clients using the number of concurrently connected browsers (waitingThreads), when this goes above maxWaitingThreads we move into USAGE_HIGH mode.
On entering USAGE_HIGH mode, the settings (initially) change to connectedTime=49 secs and disconnectedTime=1 sec. As the load increases the connectedTime decreases linearly from 49 secs down to prevent the hits per second from going above maxHitsPerSecond. If the connectedTime goes below 1sec then the mode switches to USAGE_DIGG. If the connectedTime goes above 49 secs then mode switches to USAGE_LOW.
Note: there is some danger of an overlap where the system toggles between USAGE_HIGH and USAGE_LOW. We need some way to prevent this from happening.
On entering USAGE_DIGG mode, the connectedTime changes to 0 secs, and the disconnectedTime changes to 2 secs (to keep the round trip time at 2 secs). The disconnectedTime alters to prevent the hitsPerSecond from going above maxHitsPerSecond (In USAGE_HIGH mode the connectedTime was altered). When the disconnectedTime would go under 2 secs, we switch back to USAGE_HIGH mode.
Constructor Summary | |
---|---|
DefaultServerLoadMonitor()
|
Method Summary | |
---|---|
long |
getConnectedTime()
What's the longest time that we should wait before asking the client to reconnect? |
int |
getDisconnectedTime()
Controller for poll times. |
void |
setMaxHitsPerSecond(int maxHitsPerSecond)
|
void |
setMaxWaitingThreads(int maxWaitingThreads)
|
boolean |
supportsStreaming()
If the server is not going to be streaming then we need to tell browsers to just use XHR rather than anything fancier. |
void |
threadWaitEnding(WaitController controller)
A thread has just ended a wait period. |
void |
threadWaitStarting(WaitController controller)
A thread is about to begin a wait period. |
Methods inherited from class org.directwebremoting.impl.AbstractServerLoadMonitor |
---|
shutdown, shutdownRandomWaitControllers |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.directwebremoting.extend.ServerLoadMonitor |
---|
shutdown |
Constructor Detail |
---|
public DefaultServerLoadMonitor()
Method Detail |
---|
public boolean supportsStreaming()
ServerLoadMonitor
supportsStreaming
in interface ServerLoadMonitor
public long getConnectedTime()
ServerLoadMonitor
getConnectedTime
in interface ServerLoadMonitor
public int getDisconnectedTime()
ServerLoadMonitor
TODO: We should probably get rid of this and leave it to PollHandler?
getDisconnectedTime
in interface ServerLoadMonitor
public void threadWaitStarting(WaitController controller)
ServerLoadMonitor
threadWaitStarting
in interface ServerLoadMonitor
threadWaitStarting
in class AbstractServerLoadMonitor
controller
- An object that we can use to control the waitpublic void threadWaitEnding(WaitController controller)
ServerLoadMonitor
threadWaitEnding
in interface ServerLoadMonitor
threadWaitEnding
in class AbstractServerLoadMonitor
controller
- An object that we can use to control the waitpublic void setMaxWaitingThreads(int maxWaitingThreads)
maxWaitingThreads
- the maxWaitingThreads to setpublic void setMaxHitsPerSecond(int maxHitsPerSecond)
maxHitsPerSecond
- the maxHitsPerSecond to set
|
Copyright ? 2005 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |