Source Code Cross Referenced for MonitorServlet.java in  » Science » Cougaar12_4 » org » cougaar » core » qos » frame » topology » 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 » Science » Cougaar12_4 » org.cougaar.core.qos.frame.topology 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 1997-2004 BBNT Solutions, LLC
005:         *  under sponsorship of the Defense Advanced Research Projects
006:         *  Agency (DARPA).
007:         * 
008:         *  You can redistribute this software and/or modify it under the
009:         *  terms of the Cougaar Open Source License as published on the
010:         *  Cougaar Open Source Website (www.cougaar.org).
011:         * 
012:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015:         *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016:         *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017:         *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018:         *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019:         *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020:         *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021:         *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022:         *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023:         *  
024:         * </copyright>
025:         */
026:
027:        package org.cougaar.core.qos.frame.topology;
028:
029:        import java.io.PrintWriter;
030:        import java.util.Iterator;
031:        import java.util.Set;
032:
033:        import javax.servlet.http.HttpServletRequest;
034:
035:        import org.cougaar.core.component.ServiceBroker;
036:        import org.cougaar.core.qos.frame.FrameSet;
037:        import org.cougaar.core.qos.frame.FrameSetService;
038:        import org.cougaar.core.qos.metrics.MetricsServlet;
039:        import org.cougaar.core.qos.metrics.ServletUtilities;
040:        import org.cougaar.core.service.LoggingService;
041:        import org.cougaar.util.Sortings;
042:
043:        /**
044:         */
045:        public class MonitorServlet extends MetricsServlet {
046:
047:            FrameSetService fss;
048:            ServiceBroker sb;
049:            private LoggingService log;
050:            private String frameSetName;
051:
052:            public MonitorServlet(ServiceBroker sb, LoggingService log,
053:                    String frameSetName) {
054:                super (sb);
055:                this .sb = sb;
056:                this .frameSetName = frameSetName;
057:                this .log = log;
058:            }
059:
060:            /** @return a default path if a plugin parameter is not specified */
061:            public String getPath() {
062:                return "/metrics/society/monitor";
063:            }
064:
065:            public String getTitle() {
066:                return "Society Monitor";
067:            }
068:
069:            /** 
070:             * This method is called whenever the browser loads our URL. 
071:             * */
072:            public void printPage(HttpServletRequest request, PrintWriter out) {
073:                // Begin our HTML page response
074:                //response.setContentType("text/html");
075:                //PrintWriter out = response.getWriter();
076:                out.println("<html><body><p>");
077:                printTable(out, findOrMakeFrameSet());
078:                out.println("</body></html>");
079:            }
080:
081:            // Delay looking up frameset until first call to the webpage
082:            private FrameSet fs;
083:
084:            private FrameSet findOrMakeFrameSet() {
085:                if (fs != null)
086:                    return fs;
087:                fss = (FrameSetService) sb.getService(this ,
088:                        FrameSetService.class, null);
089:                if (fss == null && log.isWarnEnabled()) {
090:                    log.warn("Unable to obtain FrameSetService");
091:                }
092:                FrameSet fs = fss.findFrameSet(frameSetName, null);
093:                return fs;
094:            }
095:
096:            private static class ThingComparator implements 
097:                    java.util.Comparator {
098:                public int compare(Object x, Object y) {
099:                    String x_name = ((Thing) x).getName();
100:                    String y_name = ((Thing) y).getName();
101:                    return x_name.compareTo(y_name);
102:                }
103:
104:                public boolean equals(Object thing) {
105:                    return thing == this ;
106:                }
107:            }
108:
109:            private static final java.util.Comparator cmp = new ThingComparator();
110:
111:            private void printHeaderRow(PrintWriter out) {
112:                out.println("<tr frame=below>");
113:                out.println("<th>Host</th>");
114:                out.println("<th>Node</th>");
115:                out.println("<th>Agent</th>");
116:                out.println("<th>Heard From</th>");
117:                out.println("<th>Load Avg.</th>");
118:                out.println("<th>Msg In</th>");
119:                out.println("<th>Msg Out</th>");
120:                out.println("<th>Size</th>");
121:                out.println("</tr>");
122:            }
123:
124:            private void printHostRow(PrintWriter out, Host myHost) {
125:                out.println("<tr><td colspan=3>" + myHost.getName() + "</td>");
126:                out.println("<td>&nbsp;</td>"); // Heard From
127:                ServletUtilities.valueTable(myHost.getLoadAverage(), 0.0, 1.0,
128:                        true, f4_2, out);
129:                out.println("<td>&nbsp;</td>"); // Msg In
130:                out.println("<td>&nbsp;</td>"); // Msg Out
131:                out.println("<td>&nbsp;</td>"); // Size
132:                //ServletUtilities.valueTable(myHost.getEffectiveMJips(),0.0, 100000000.0, true, f7_0,out);
133:                out.println("</tr>");
134:            }
135:
136:            private void printNodeRow(PrintWriter out, Node myNode) {
137:                out.println("<tr><td>&nbsp;</td>"); // Host
138:                out.println("<td colspan=2>" + myNode.getName() + "</td>"); // Node column
139:                out.println("<td>&nbsp;</td>"); // Heard From
140:                ServletUtilities.valueTable(myNode.getCpuLoadAverage(), 0.0,
141:                        1.0, true, f4_2, out);
142:                ServletUtilities.valueTable(myNode.getMsgIn(), 0.0, 2.0, true,
143:                        f4_2, out);
144:                ServletUtilities.valueTable(myNode.getMsgOut(), 0.0, 2.0, true,
145:                        f4_2, out);
146:                ServletUtilities.valueTable(myNode.getVmSize(), 0.0,
147:                        100000000.0, true, f7_0, out);
148:                out.println("</tr>");
149:            }
150:
151:            private void printAgentRow(PrintWriter out, Agent myAgent) {
152:                out.println("<tr><td colspan=2>&nbsp;</td>"); // Host Node
153:                out.println("<td>" + myAgent.getName() + "</td>"); // Agent column
154:                ServletUtilities.valueTable(myAgent.getHeardFrom(), 0.0, 60,
155:                        true, f4_0, out);
156:                ServletUtilities.valueTable(myAgent.getCpuLoadAverage(), 0.0,
157:                        1.0, true, f4_2, out);
158:                ServletUtilities.valueTable(myAgent.getMsgIn(), 0.0, 2.0, true,
159:                        f4_2, out);
160:                ServletUtilities.valueTable(myAgent.getMsgOut(), 0.0, 2.0,
161:                        true, f4_2, out);
162:                ServletUtilities.valueTable(myAgent.getPersistSizeLast(), 0.0,
163:                        100000, true, f7_0, out);
164:                out.println("</tr>");
165:            }
166:
167:            private void printTable(PrintWriter out, FrameSet fs) {
168:                out.println("<table border=3 cellpadding=2 rules=groups>");
169:                out
170:                        .println("<colgroup span=3><colgroup><colgroup><colgroup><colgroup>");
171:                out.println("<THEAD>");
172:                printHeaderRow(out);
173:                out.println("</THEAD>");
174:                out.println("<TFOOT></TFOOT>");
175:
176:                Set hostFrames = fs.findFrames("host", null);
177:                for (Iterator h = Sortings.sort(hostFrames, cmp).iterator(); h
178:                        .hasNext();) {
179:                    Host host = (Host) h.next();
180:                    out.println("<TBODY>");
181:                    printHostRow(out, host);
182:
183:                    Set nodeFrames = fs.findRelations(host, "child",
184:                            "NodeOnHost");
185:                    for (Iterator n = Sortings.sort(nodeFrames, cmp).iterator(); n
186:                            .hasNext();) {
187:                        Node node = (Node) n.next();
188:                        out.println("<TBODY>");
189:                        printNodeRow(out, node);
190:
191:                        Set agentFrames = fs.findRelations(node, "child",
192:                                "AgentInNode");
193:                        for (Iterator a = Sortings.sort(agentFrames, cmp)
194:                                .iterator(); a.hasNext();) {
195:                            Agent agent = (Agent) a.next();
196:                            printAgentRow(out, agent);
197:                        }
198:                        //out.println("</TBODY>");
199:                    }
200:                    //out.println("</TBODY>");
201:                }
202:                out.println("</table>");
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.