Java Doc for DefaultServerLoadMonitor.java in  » Ajax » dwr » org » directwebremoting » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » dwr » org.directwebremoting.impl 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.directwebremoting.impl.AbstractServerLoadMonitor
      org.directwebremoting.impl.DefaultServerLoadMonitor

DefaultServerLoadMonitor
public class DefaultServerLoadMonitor extends AbstractServerLoadMonitor implements ServerLoadMonitor(Code)
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.


author:
   Joe Walker [joe at getahead dot org]


Field Summary
final protected static  intSECONDS_MONITORED
     We are recording the number of hits in the last 5 seconds.
final protected static  intUSAGE_DIGG
     The system is very heavily used, polling only.
final protected static  intUSAGE_HIGH
     This system can't cope with everyone on comet, we are in mixed mode.
final protected static  intUSAGE_LOW
     The system is under-utilized.
final protected static  String[]USAGE_NAMES
    
protected  intconnectedTime
     The time we are currently waiting before sending a browser away and asking it to reconnect.
protected  intdisconnectedTime
    
protected  HitMonitorhitMonitor
    
final protected static  inthitOutRoundTripTime
    
protected  intmaxConnectedTime
     Static configuration data: What is the longest we wait for extra input after detecting output.
protected  intmaxHitsPerSecond
     Static configuration data: The max number of hits per second. We increase the poll time to compensate and reduce the load.
protected  intmaxWaitingThreads
     Static configuration data: The max number of threads we keep waiting.
protected  intmode
     What is the current usage mode.
final protected static  intthreadOutRoundTripTime
    
final protected static  intusageDiggConnectedTime
    
final protected static  intusageDiggMinDisconnectedTime
    
final protected static  intusageHighDisconnectedTime
    
final protected static  intusageHighFinalConnectedTime
    
final protected static  intusageHighInitialConnectedTime
    
protected  intwaitingThreads
    


Method Summary
public  longgetConnectedTime()
    
public  intgetDisconnectedTime()
    
 voidsetMaxConnectedTime(int maxConnectedTime)
     It might be good top expose this, however there are currently assumptions in the code that the value is set to 60000.
public  voidsetMaxHitsPerSecond(int maxHitsPerSecond)
    
public  voidsetMaxWaitingThreads(int maxWaitingThreads)
    
protected  voidsetMode(int mode)
     For debug purposes we keep a track of what mode we are in.
public  booleansupportsStreaming()
    
public  voidthreadWaitEnding(WaitController controller)
    
public  voidthreadWaitStarting(WaitController controller)
    

Field Detail
SECONDS_MONITORED
final protected static int SECONDS_MONITORED(Code)
We are recording the number of hits in the last 5 seconds. Maybe we should think about making this configurable.



USAGE_DIGG
final protected static int USAGE_DIGG(Code)
The system is very heavily used, polling only.



USAGE_HIGH
final protected static int USAGE_HIGH(Code)
This system can't cope with everyone on comet, we are in mixed mode.



USAGE_LOW
final protected static int USAGE_LOW(Code)
The system is under-utilized. Everyone does comet.



USAGE_NAMES
final protected static String[] USAGE_NAMES(Code)
Some Strings to help us give some debug output



connectedTime
protected int connectedTime(Code)
The time we are currently waiting before sending a browser away and asking it to reconnect.



disconnectedTime
protected int disconnectedTime(Code)
How long are we telling users to wait before they come back next



hitMonitor
protected HitMonitor hitMonitor(Code)
Our record of the server loading



hitOutRoundTripTime
final protected static int hitOutRoundTripTime(Code)



maxConnectedTime
protected int maxConnectedTime(Code)
Static configuration data: What is the longest we wait for extra input after detecting output.



maxHitsPerSecond
protected int maxHitsPerSecond(Code)
Static configuration data: The max number of hits per second. We increase the poll time to compensate and reduce the load. If this number is not at least half maxWaitingThreads then the USAGE_HIGH mode will not exist and the system will sublime from USAGE_LOW to USAGE_DIGG



maxWaitingThreads
protected int maxWaitingThreads(Code)
Static configuration data: The max number of threads we keep waiting. We reduce the timeWithinPoll*Stream variables to reduce the load



mode
protected int mode(Code)
What is the current usage mode.



threadOutRoundTripTime
final protected static int threadOutRoundTripTime(Code)



usageDiggConnectedTime
final protected static int usageDiggConnectedTime(Code)



usageDiggMinDisconnectedTime
final protected static int usageDiggMinDisconnectedTime(Code)



usageHighDisconnectedTime
final protected static int usageHighDisconnectedTime(Code)



usageHighFinalConnectedTime
final protected static int usageHighFinalConnectedTime(Code)



usageHighInitialConnectedTime
final protected static int usageHighInitialConnectedTime(Code)



waitingThreads
protected int waitingThreads(Code)
How many sleepers are there?





Method Detail
getConnectedTime
public long getConnectedTime()(Code)



getDisconnectedTime
public int getDisconnectedTime()(Code)



setMaxConnectedTime
void setMaxConnectedTime(int maxConnectedTime)(Code)
It might be good top expose this, however there are currently assumptions in the code that the value is set to 60000. See DefaultServerLoadMonitor.usageHighInitialConnectedTime .
Parameters:
  maxConnectedTime - the maxConnectedTime to set



setMaxHitsPerSecond
public void setMaxHitsPerSecond(int maxHitsPerSecond)(Code)

Parameters:
  maxHitsPerSecond - the maxHitsPerSecond to set



setMaxWaitingThreads
public void setMaxWaitingThreads(int maxWaitingThreads)(Code)

Parameters:
  maxWaitingThreads - the maxWaitingThreads to set



setMode
protected void setMode(int mode)(Code)
For debug purposes we keep a track of what mode we are in.
Parameters:
  mode - The new usage mode



supportsStreaming
public boolean supportsStreaming()(Code)



threadWaitEnding
public void threadWaitEnding(WaitController controller)(Code)



threadWaitStarting
public void threadWaitStarting(WaitController controller)(Code)



Fields inherited from org.directwebremoting.impl.AbstractServerLoadMonitor
final protected List<WaitController> waitControllers(Code)(Java Doc)

Methods inherited from org.directwebremoting.impl.AbstractServerLoadMonitor
public void shutdown()(Code)(Java Doc)
public void shutdownRandomWaitControllers(int count)(Code)(Java Doc)
public void threadWaitEnding(WaitController controller)(Code)(Java Doc)
public void threadWaitStarting(WaitController controller)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.