Source Code Cross Referenced for ServiceStatistics.java in  » ESB » mule » org » mule » management » stats » 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 » ESB » mule » org.mule.management.stats 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: ServiceStatistics.java 11373 2008-03-15 05:03:10Z dfeist $
003:         * --------------------------------------------------------------------------------------
004:         * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
005:         *
006:         * The software in this package is published under the terms of the CPAL v1.0
007:         * license, a copy of which has been included with this distribution in the
008:         * LICENSE.txt file.
009:         */
010:
011:        package org.mule.management.stats;
012:
013:        import org.mule.api.management.stats.Statistics;
014:        import org.mule.management.stats.printers.SimplePrinter;
015:
016:        import java.io.PrintWriter;
017:
018:        public class ServiceStatistics implements  Statistics {
019:            /**
020:             * Serial version
021:             */
022:            private static final long serialVersionUID = -2086999226732861674L;
023:
024:            private String name;
025:            private long receivedEventSync = 0;
026:            private long receivedEventASync = 0;
027:            private long queuedEvent = 0;
028:            private long maxQueuedEvent = 0;
029:            private long averageQueueSize = 0;
030:            private long totalQueuedEvent = 0;
031:            private long executionError = 0;
032:            private long fatalError = 0;
033:
034:            private int threadPoolSize = 0;
035:            private long samplePeriod = 0;
036:            private boolean enabled = false;
037:
038:            private RouterStatistics inboundRouterStat = null;
039:            private ComponentStatistics componentStat = null;
040:            private RouterStatistics outboundRouterStat = null;
041:
042:            public ServiceStatistics(String name) {
043:                this (name, 0);
044:            }
045:
046:            /**
047:             * The constructor
048:             *
049:             * @param name
050:             */
051:            public ServiceStatistics(String name, int threadPoolSize) {
052:                super ();
053:                this .name = name;
054:
055:                this .threadPoolSize = threadPoolSize;
056:                clear();
057:            }
058:
059:            /**
060:             * Are statistics logged
061:             */
062:            public boolean isEnabled() {
063:                return enabled;
064:            }
065:
066:            /**
067:             * Enable statistics logs (this is a dynamic parameter)
068:             */
069:            public synchronized void setEnabled(boolean b) {
070:                enabled = b;
071:
072:                if (inboundRouterStat != null) {
073:                    inboundRouterStat.setEnabled(b);
074:                }
075:                if (componentStat != null) {
076:                    componentStat.setEnabled(b);
077:                }
078:                if (outboundRouterStat != null) {
079:                    outboundRouterStat.setEnabled(b);
080:                }
081:            }
082:
083:            public synchronized void incReceivedEventSync() {
084:                receivedEventSync++;
085:            }
086:
087:            public synchronized void incReceivedEventASync() {
088:                receivedEventASync++;
089:            }
090:
091:            public synchronized void incExecutionError() {
092:                executionError++;
093:            }
094:
095:            public synchronized void incFatalError() {
096:                fatalError++;
097:            }
098:
099:            public synchronized void incQueuedEvent() {
100:                queuedEvent++;
101:                totalQueuedEvent++;
102:                if (queuedEvent > maxQueuedEvent) {
103:                    maxQueuedEvent = queuedEvent;
104:                }
105:                // if(queuedEvent > 1) {
106:                averageQueueSize = Math.round(getAsyncEventsReceived()
107:                        / totalQueuedEvent);
108:                // }
109:            }
110:
111:            public synchronized void decQueuedEvent() {
112:                queuedEvent--;
113:            }
114:
115:            public long getAverageExecutionTime() {
116:                return componentStat.getAverageExecutionTime();
117:            }
118:
119:            public long getAverageQueueSize() {
120:                return averageQueueSize;
121:            }
122:
123:            public long getMaxQueueSize() {
124:                return maxQueuedEvent;
125:            }
126:
127:            /**
128:             * @deprecated
129:             * @return
130:             */
131:            public long getMaxExecutionTime() {
132:                return componentStat.getMaxExecutionTime();
133:            }
134:
135:            public long getFatalErrors() {
136:                return fatalError;
137:            }
138:
139:            /**
140:             * @deprecated
141:             * @return
142:             */
143:            public long getMinExecutionTime() {
144:                return componentStat.getMinExecutionTime();
145:            }
146:
147:            /**
148:             * @deprecated
149:             * @return
150:             */
151:            public long getTotalExecutionTime() {
152:                return componentStat.getTotalExecutionTime();
153:            }
154:
155:            public long getQueuedEvents() {
156:                return queuedEvent;
157:            }
158:
159:            public long getAsyncEventsReceived() {
160:                return receivedEventASync;
161:            }
162:
163:            public long getSyncEventsReceived() {
164:                return receivedEventSync;
165:            }
166:
167:            public long getReplyToEventsSent() {
168:                return componentStat.getReplyToEventsSent();
169:            }
170:
171:            public long getSyncEventsSent() {
172:                return componentStat.getSyncEventsSent();
173:            }
174:
175:            public long getAsyncEventsSent() {
176:                return componentStat.getAsyncEventsSent();
177:            }
178:
179:            public long getTotalEventsSent() {
180:                return getSyncEventsSent() + getAsyncEventsSent();
181:            }
182:
183:            public long getTotalEventsReceived() {
184:                return getSyncEventsReceived() + getAsyncEventsReceived();
185:            }
186:
187:            public long getExecutedEvents() {
188:                return componentStat.getExecutedEvents();
189:            }
190:
191:            public long getExecutionErrors() {
192:                return executionError;
193:            }
194:
195:            public synchronized String getName() {
196:                return name;
197:            }
198:
199:            public synchronized void setName(String name) {
200:                this .name = name;
201:            }
202:
203:            /**
204:             * log in info level the main statistics
205:             */
206:            public void logSummary() {
207:                logSummary(new SimplePrinter(System.out));
208:            }
209:
210:            public void logSummary(PrintWriter printer) {
211:                printer.print(this );
212:            }
213:
214:            public synchronized void clear() {
215:                receivedEventSync = 0;
216:                receivedEventASync = 0;
217:                queuedEvent = 0;
218:                maxQueuedEvent = 0;
219:                totalQueuedEvent = 0;
220:                averageQueueSize = 0;
221:
222:                executionError = 0;
223:                fatalError = 0;
224:
225:                if (getInboundRouterStat() != null) {
226:                    getInboundRouterStat().clear();
227:                }
228:                if (getOutboundRouterStat() != null) {
229:                    getOutboundRouterStat().clear();
230:                }
231:
232:                samplePeriod = System.currentTimeMillis();
233:
234:            }
235:
236:            /**
237:             * @return Returns the inboundRouterStat.
238:             */
239:            public RouterStatistics getInboundRouterStat() {
240:                return inboundRouterStat;
241:            }
242:
243:            /**
244:             * @param inboundRouterStat The inboundRouterStat to set.
245:             */
246:            public void setInboundRouterStat(RouterStatistics inboundRouterStat) {
247:                this .inboundRouterStat = inboundRouterStat;
248:                this .inboundRouterStat.setEnabled(enabled);
249:            }
250:
251:            /**
252:             * @return Returns the outboundRouterStat.
253:             */
254:            public RouterStatistics getOutboundRouterStat() {
255:                return outboundRouterStat;
256:            }
257:
258:            /**
259:             * @param outboundRouterStat The outboundRouterStat to set.
260:             */
261:            public void setOutboundRouterStat(
262:                    RouterStatistics outboundRouterStat) {
263:                this .outboundRouterStat = outboundRouterStat;
264:                this .outboundRouterStat.setEnabled(enabled);
265:            }
266:
267:            /**
268:             * @return Returns the outboundRouterStat.
269:             */
270:            public ComponentStatistics getComponentStat() {
271:                return componentStat;
272:            }
273:
274:            /**
275:             * @param outboundRouterStat The outboundRouterStat to set.
276:             */
277:            public void setComponentStat(ComponentStatistics componentStat) {
278:                this .componentStat = componentStat;
279:                this .componentStat.setEnabled(enabled);
280:            }
281:
282:            public int getThreadPoolSize() {
283:                return threadPoolSize;
284:            }
285:
286:            public long getSamplePeriod() {
287:                return System.currentTimeMillis() - samplePeriod;
288:            }
289:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.