Source Code Cross Referenced for PerformanceData.java in  » ESB » open-esb » com » sun » esb » management » common » data » 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 » open esb » com.sun.esb.management.common.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)PerformanceData.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.esb.management.common.data;
030:
031:        import java.io.Serializable;
032:        import java.util.HashMap;
033:        import java.util.Iterator;
034:        import java.util.Map;
035:
036:        import javax.management.openmbean.CompositeData;
037:        import javax.management.openmbean.CompositeType;
038:        import javax.management.openmbean.TabularData;
039:        import javax.xml.parsers.ParserConfigurationException;
040:        import javax.xml.transform.TransformerException;
041:
042:        import com.sun.esb.management.common.ManagementRemoteException;
043:        import com.sun.esb.management.common.data.helper.PerformanceDataMapWriter;
044:
045:        /**
046:         * @author graj
047:         * 
048:         */
049:        public class PerformanceData implements  Serializable {
050:
051:            static final long serialVersionUID = -1L;
052:
053:            /**
054:             * Number of measurements (or N), i.e. the number of dt-s, i.e. the number
055:             * of times that Measurement.begin() - end() was called.
056:             */
057:            public static final String NUMBEROFMEASUREMENTS_KEY = "n";
058:
059:            /** total time (ms) the sum of all dt-s */
060:            public static final String TOTALTIME_KEY = "total time (ms)";
061:
062:            /**
063:             * average' (ms) (the sum of all dt-s minus the first dt) divided by N. The
064:             * first measurement is discounted because it typically includes
065:             * classloading times and distorts the results considerably. If there's only
066:             * one measurement, the first measurement is not discounted and the value
067:             * should be equal to total time.
068:             */
069:            public static final String AVERAGEWITHOUTFIRSTMEASUREMENT_KEY = "average' (ms)";
070:
071:            /**
072:             * act the number of measurement objects on which begin() was called but not
073:             * end(). This indicates the number of active measurements. Caveat: there's
074:             * a problem in the this accounting when the subtopic of the measurement is
075:             * changed.
076:             */
077:            public static final String NUMBEROFMEASUREMENTOBJECTS_KEY = "act";
078:
079:            /** first the first dt */
080:            public static final String FIRSTMEASUREMENTTIME_KEY = "first (ms)";
081:
082:            /**
083:             * average sum of all dt-s divided by N; this does not discount the first
084:             * measurement
085:             */
086:            public static final String AVERAGE_KEY = "average (ms)";
087:
088:            /**
089:             * throughput N divided by (tlast - tfirst); this is the average throughput.
090:             * This number is meaningful if there were no long pauses in processing.
091:             */
092:            public static final String THROUGHPUT_KEY = "throughput (s-1)";
093:
094:            /**
095:             * tlast - tfirst the wallclock time of the first measurement's begin()
096:             * method is tracked as tfirst and the wallclock time of the last
097:             * measurement's end() method is tracked as tlast
098:             */
099:            public static final String TIMETAKEN_KEY = "last-first (ms)";
100:
101:            /**
102:             * Load The sum of all dt-s divided by (tlast - tfirst). This is a measure
103:             * of concurrency: the higher the number, the greater the concurrency. In a
104:             * single threaded scenario this number can never exceed 1.
105:             */
106:            public static final String LOAD_KEY = "load";
107:
108:            public static final String MEDIAN_KEY = "median (ms)";
109:
110:            public static final String SOURCE_KEY = "source";
111:
112:            /**
113:             * sub topic the name of the measurement specified in the second argument of
114:             * begin() or in setSubTopic().
115:             */
116:            public static final String SUB_TOPIC_KEY = "sub topic";
117:
118:            /**
119:             * topic the name of the measurement specified in the first argument of
120:             * begin() or in setSubTopic().
121:             */
122:            public static final String TOPIC_KEY = "topic";
123:
124:            double median;
125:
126:            /** The name of the class that is instrumented with performance statistics gathering */
127:            String sourceClassName;
128:
129:            /** The endpoint for which the statistics are reported for */
130:            String endpoint;
131:
132:            /**
133:             * sub topic the name of the measurement specified in the second argument of
134:             * begin() or in setSubTopic().
135:             */
136:            String category;
137:
138:            /**
139:             * average sum of all dt-s divided by N; this does not discount the first
140:             * measurement
141:             */
142:            double average;
143:
144:            /**
145:             * average' (ms) (the sum of all dt-s minus the first dt) divided by N. The
146:             * first measurement is discounted because it typically includes
147:             * classloading times and distorts the results considerably. If there's only
148:             * one measurement, the first measurement is not discounted and the value
149:             * should be equal to total time.
150:             */
151:            double averageWithoutFirstMeasurement;
152:
153:            /** first the first dt */
154:            double firstMeasurementTime;
155:
156:            /**
157:             * Load The sum of all dt-s divided by (tlast - tfirst). This is a measure
158:             * of concurrency: the higher the number, the greater the concurrency. In a
159:             * single threaded scenario this number can never exceed 1.
160:             */
161:            double load;
162:
163:            /**
164:             * act the number of measurement objects on which begin() was called but not
165:             * end(). This indicates the number of active measurements. Caveat: there's
166:             * a problem in the this accounting when the subtopic of the measurement is
167:             * changed.
168:             */
169:            int numberOfMeasurementObjects;
170:
171:            /**
172:             * Number of measurements (or N), i.e. the number of dt-s, i.e. the number
173:             * of times that Measurement.begin() - end() was called.
174:             */
175:            int numberOfMeasurements;
176:
177:            /**
178:             * throughput N divided by (tlast - tfirst); this is the average throughput.
179:             * This number is meaningful if there were no long pauses in processing.
180:             */
181:            double throughput;
182:
183:            /**
184:             * tlast - tfirst the wallclock time of the first measurement's begin()
185:             * method is tracked as tfirst and the wallclock time of the last
186:             * measurement's end() method is tracked as tlast
187:             */
188:            double timeTaken;
189:
190:            /** total time (ms) the sum of all dt-s */
191:            double totalTime;
192:
193:            /**
194:             * Retrieves the Performance Data Map
195:             * 
196:             * @param valueObject
197:             * @return Performance Data Map
198:             */
199:            @SuppressWarnings("unchecked")
200:            public static Map<String /* Category */, PerformanceData> retrieveDataMap(
201:                    TabularData tabularData) {
202:                Map<String /* Category */, PerformanceData> dataMap = new HashMap<String /* Category */, PerformanceData>();
203:                for (Iterator dataIterator = tabularData.values().iterator(); dataIterator
204:                        .hasNext();) {
205:                    CompositeData compositeData = (CompositeData) dataIterator
206:                            .next();
207:                    CompositeType compositeType = compositeData
208:                            .getCompositeType();
209:                    PerformanceData performanceData = new PerformanceData();
210:                    for (Iterator<String> itemIterator = compositeType.keySet()
211:                            .iterator(); itemIterator.hasNext();) {
212:                        String item = (String) itemIterator.next();
213:                        if (true == item.equals(PerformanceData.AVERAGE_KEY)) {
214:                            Double value = (Double) compositeData.get(item);
215:                            performanceData.setAverage(value.doubleValue());
216:                        }
217:                        if (true == item
218:                                .equals(PerformanceData.AVERAGEWITHOUTFIRSTMEASUREMENT_KEY)) {
219:                            Double value = (Double) compositeData.get(item);
220:                            performanceData
221:                                    .setAverageWithoutFirstMeasurement(value
222:                                            .doubleValue());
223:                        }
224:                        if (true == item
225:                                .equals(PerformanceData.FIRSTMEASUREMENTTIME_KEY)) {
226:                            Double value = (Double) compositeData.get(item);
227:                            performanceData.setFirstMeasurementTime(value
228:                                    .doubleValue());
229:                        }
230:                        if (true == item.equals(PerformanceData.LOAD_KEY)) {
231:                            Double value = (Double) compositeData.get(item);
232:                            performanceData.setLoad(value.doubleValue());
233:                        }
234:                        if (true == item
235:                                .equals(PerformanceData.NUMBEROFMEASUREMENTOBJECTS_KEY)) {
236:                            Integer value = (Integer) compositeData.get(item);
237:                            performanceData.setNumberOfMeasurementObjects(value
238:                                    .intValue());
239:                        }
240:                        if (true == item
241:                                .equals(PerformanceData.NUMBEROFMEASUREMENTS_KEY)) {
242:                            Integer value = (Integer) compositeData.get(item);
243:                            performanceData.setNumberOfMeasurements(value
244:                                    .intValue());
245:                        }
246:                        if (true == item.equals(PerformanceData.THROUGHPUT_KEY)) {
247:                            Double value = (Double) compositeData.get(item);
248:                            performanceData.setThroughput(value.doubleValue());
249:                        }
250:                        if (true == item.equals(PerformanceData.TIMETAKEN_KEY)) {
251:                            Double value = (Double) compositeData.get(item);
252:                            performanceData.setTimeTaken(value.doubleValue());
253:                        }
254:                        if (true == item.equals(PerformanceData.TOTALTIME_KEY)) {
255:                            Double value = (Double) compositeData.get(item);
256:                            performanceData.setTotalTime(value.doubleValue());
257:                        }
258:                        if (true == item.equals(PerformanceData.MEDIAN_KEY)) {
259:                            Double value = (Double) compositeData.get(item);
260:                            performanceData.setMedian(value.doubleValue());
261:                        }
262:                        if (true == item.equals(PerformanceData.SOURCE_KEY)) {
263:                            String value = (String) compositeData.get(item);
264:                            performanceData.setSourceClassName(value);
265:                        }
266:                        if (true == item.equals(PerformanceData.SUB_TOPIC_KEY)) {
267:                            String value = (String) compositeData.get(item);
268:                            performanceData.setCategory(value);
269:                        }
270:                        if (true == item.equals(PerformanceData.TOPIC_KEY)) {
271:                            String value = (String) compositeData.get(item);
272:                            performanceData.setEndpoint(value);
273:                        }
274:                    }
275:                    dataMap.put(performanceData.getCategory(), performanceData);
276:                }
277:
278:                return dataMap;
279:            }
280:
281:            /**
282:             * Converts a Performance Data Map to an XML String
283:             * 
284:             * @param dataMap
285:             * @return XML string representing a performance data map
286:             * @throws ManagementRemoteException
287:             */
288:            public static String convertDataMapToXML(
289:                    Map<String /* Category */, PerformanceData> dataMap)
290:                    throws ManagementRemoteException {
291:                String xmlText = null;
292:                try {
293:                    xmlText = PerformanceDataMapWriter.serialize(dataMap);
294:                } catch (ParserConfigurationException e) {
295:                    throw new ManagementRemoteException(e);
296:                } catch (TransformerException e) {
297:                    throw new ManagementRemoteException(e);
298:                }
299:
300:                return xmlText;
301:
302:            }
303:
304:            /**
305:             * @return the average
306:             */
307:            public double getAverage() {
308:                return this .average;
309:            }
310:
311:            /**
312:             * @return the averageWithoutFirstMeasurement
313:             */
314:            public double getAverageWithoutFirstMeasurement() {
315:                return this .averageWithoutFirstMeasurement;
316:            }
317:
318:            /**
319:             * @return the firstMeasurementTime
320:             */
321:            public double getFirstMeasurementTime() {
322:                return this .firstMeasurementTime;
323:            }
324:
325:            /**
326:             * @return the load
327:             */
328:            public double getLoad() {
329:                return this .load;
330:            }
331:
332:            /**
333:             * @return the numberOfMeasurementObjects
334:             */
335:            public int getNumberOfMeasurementObjects() {
336:                return this .numberOfMeasurementObjects;
337:            }
338:
339:            /**
340:             * @return the numberOfMeasurements
341:             */
342:            public int getNumberOfMeasurements() {
343:                return this .numberOfMeasurements;
344:            }
345:
346:            /**
347:             * @return the throughput
348:             */
349:            public double getThroughput() {
350:                return this .throughput;
351:            }
352:
353:            /**
354:             * @return the timeTaken
355:             */
356:            public double getTimeTaken() {
357:                return this .timeTaken;
358:            }
359:
360:            /**
361:             * @return the totalTime
362:             */
363:            public double getTotalTime() {
364:                return this .totalTime;
365:            }
366:
367:            /**
368:             * @return the serialVersionUID
369:             */
370:            public static long getSerialVersionUID() {
371:                return serialVersionUID;
372:            }
373:
374:            /**
375:             * @param average
376:             *            the average to set
377:             */
378:            public void setAverage(double average) {
379:                this .average = average;
380:            }
381:
382:            /**
383:             * @param averageWithoutFirstMeasurement
384:             *            the averageWithoutFirstMeasurement to set
385:             */
386:            public void setAverageWithoutFirstMeasurement(
387:                    double averageWithoutFirstMeasurement) {
388:                this .averageWithoutFirstMeasurement = averageWithoutFirstMeasurement;
389:            }
390:
391:            /**
392:             * @param firstMeasurementTime
393:             *            the firstMeasurementTime to set
394:             */
395:            public void setFirstMeasurementTime(double firstMeasurementTime) {
396:                this .firstMeasurementTime = firstMeasurementTime;
397:            }
398:
399:            /**
400:             * @param load
401:             *            the load to set
402:             */
403:            public void setLoad(double load) {
404:                this .load = load;
405:            }
406:
407:            /**
408:             * @param numberOfMeasurementObjects
409:             *            the numberOfMeasurementObjects to set
410:             */
411:            public void setNumberOfMeasurementObjects(
412:                    int numberOfMeasurementObjects) {
413:                this .numberOfMeasurementObjects = numberOfMeasurementObjects;
414:            }
415:
416:            /**
417:             * @param numberOfMeasurements
418:             *            the numberOfMeasurements to set
419:             */
420:            public void setNumberOfMeasurements(int numberOfMeasurements) {
421:                this .numberOfMeasurements = numberOfMeasurements;
422:            }
423:
424:            /**
425:             * @param throughput
426:             *            the throughput to set
427:             */
428:            public void setThroughput(double throughput) {
429:                this .throughput = throughput;
430:            }
431:
432:            /**
433:             * @param timeTaken
434:             *            the timeTaken to set
435:             */
436:            public void setTimeTaken(double timeTaken) {
437:                this .timeTaken = timeTaken;
438:            }
439:
440:            /**
441:             * @param totalTime
442:             *            the totalTime to set
443:             */
444:            public void setTotalTime(double totalTime) {
445:                this .totalTime = totalTime;
446:            }
447:
448:            /**
449:             * @return the median
450:             */
451:            public double getMedian() {
452:                return this .median;
453:            }
454:
455:            /**
456:             * @param median
457:             *            the median to set
458:             */
459:            public void setMedian(double median) {
460:                this .median = median;
461:            }
462:
463:            /**
464:             * @return the sourceClassName
465:             */
466:            public String getSourceClassName() {
467:                return this .sourceClassName;
468:            }
469:
470:            /**
471:             * @param sourceClassName
472:             *            the sourceClassName to set
473:             */
474:            public void setSourceClassName(String sourceClassName) {
475:                this .sourceClassName = sourceClassName;
476:            }
477:
478:            /**
479:             * @return the endpoint
480:             */
481:            public String getEndpoint() {
482:                return this .endpoint;
483:            }
484:
485:            /**
486:             * @param endpoint
487:             *            the endpoint to set
488:             */
489:            public void setEndpoint(String anEndpoint) {
490:                this .endpoint = anEndpoint;
491:            }
492:
493:            /**
494:             * @return the category
495:             */
496:            public String getCategory() {
497:                return this .category;
498:            }
499:
500:            /**
501:             * @param category
502:             *            the category to set
503:             */
504:            public void setCategory(String subTopic) {
505:                this .category = subTopic;
506:            }
507:
508:            /**
509:             * 
510:             * @return
511:             */
512:            public String getDisplayString() {
513:                StringBuffer buffer = new StringBuffer();
514:                buffer.append("\n  Category" + "=" + this .getCategory());
515:                buffer.append("\n  Endpoint" + "=" + this .getEndpoint());
516:                buffer.append("\n  Source Class Name" + "="
517:                        + this .getSourceClassName());
518:                buffer.append("\n  Median" + "=" + this .getMedian());
519:                buffer.append("\n  Average" + "=" + this .getAverage());
520:                buffer.append("\n  Average Without First Measurement" + "="
521:                        + this .getAverageWithoutFirstMeasurement());
522:                buffer.append("\n  First Measurement Time" + "="
523:                        + this .getFirstMeasurementTime());
524:                buffer.append("\n  Load" + "=" + this .getLoad());
525:                buffer.append("\n  Number Of Measurement Objects" + "="
526:                        + this .getNumberOfMeasurementObjects());
527:                buffer.append("\n  Number Of Measurements" + "="
528:                        + this .getNumberOfMeasurements());
529:                buffer.append("\n  Throughput" + "=" + this .getThroughput());
530:                buffer.append("\n  Time Taken" + "=" + this .getTimeTaken());
531:                buffer.append("\n  Total Time" + "=" + this .getTotalTime());
532:                buffer.append("\n  ========================================\n");
533:                return buffer.toString();
534:
535:            }
536:
537:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.