Source Code Cross Referenced for JBIStatisticsMBeanImpl.java in  » ESB » open-esb » com » sun » jbi » ui » runtime » mbeans » 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.jbi.ui.runtime.mbeans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * BEGIN_HEADER - DO NOT EDIT
0003:         *
0004:         * The contents of this file are subject to the terms
0005:         * of the Common Development and Distribution License
0006:         * (the "License").  You may not use this file except
0007:         * in compliance with the License.
0008:         *
0009:         * You can obtain a copy of the license at
0010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
0011:         * See the License for the specific language governing
0012:         * permissions and limitations under the License.
0013:         *
0014:         * When distributing Covered Code, include this CDDL
0015:         * HEADER in each file and include the License file at
0016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
0017:         * If applicable add the following below this CDDL HEADER,
0018:         * with the fields enclosed by brackets "[]" replaced with
0019:         * your own identifying information: Portions Copyright
0020:         * [year] [name of copyright owner]
0021:         */
0022:
0023:        /*
0024:         * @(#)JBIStatisticsMBeanImpl.java
0025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
0026:         *
0027:         * END_HEADER - DO NOT EDIT
0028:         */
0029:        package com.sun.jbi.ui.runtime.mbeans;
0030:
0031:        import java.util.Date;
0032:        import java.util.Iterator;
0033:        import java.util.List;
0034:        import java.util.ArrayList;
0035:        import java.util.Set;
0036:        import java.util.Map;
0037:        import java.util.HashMap;
0038:
0039:        import javax.management.ObjectName;
0040:        import javax.management.openmbean.ArrayType;
0041:        import javax.management.openmbean.SimpleType;
0042:        import javax.management.openmbean.CompositeData;
0043:        import javax.management.openmbean.CompositeType;
0044:        import javax.management.openmbean.CompositeDataSupport;
0045:        import javax.management.openmbean.TabularData;
0046:        import javax.management.openmbean.TabularDataSupport;
0047:        import javax.management.openmbean.TabularType;
0048:        import javax.management.openmbean.OpenType;
0049:        import javax.management.openmbean.OpenDataException;
0050:        import javax.management.MBeanAttributeInfo;
0051:        import javax.management.MBeanInfo;
0052:
0053:        import com.sun.jbi.ComponentType;
0054:        import com.sun.jbi.ComponentInfo;
0055:        import com.sun.jbi.ComponentQuery;
0056:        import com.sun.jbi.ComponentState;
0057:        import com.sun.jbi.EnvironmentContext;
0058:        import com.sun.jbi.management.MBeanNames;
0059:        import com.sun.jbi.ui.common.I18NBundle;
0060:        import com.sun.jbi.ui.common.JBIRemoteException;
0061:        import com.sun.jbi.ui.common.JBIJMXObjectNames;
0062:        import com.sun.jbi.ui.common.JBIStatisticsItemNames;
0063:        import com.sun.jbi.ui.common.ToolsLogManager;
0064:        import com.sun.jbi.EnvironmentContext;
0065:
0066:        /**
0067:         * This class is used to provide JBI statistics statisticsinformation to clients.
0068:         * @author Sun Microsystems, Inc.
0069:         */
0070:
0071:        public class JBIStatisticsMBeanImpl extends AbstractUIMBeanImpl
0072:                implements  JBIStatisticsMBean {
0073:
0074:            /** comma */
0075:            public static String COMMA = ",";
0076:
0077:            /** colon */
0078:            public static String COLON = ":";
0079:
0080:            /** equal */
0081:            public static String EQUAL = "=";
0082:
0083:            /** statistics service type */
0084:            public static String SERVICE_TYPE_KEY = "CustomControlName";
0085:
0086:            /** ojc components specific marker for provisioning endpoints */
0087:            static String PROVIDER_MARKER = "Provider";
0088:
0089:            /** ojc components specific marker for consuming endpoints */
0090:            static String CONSUMER_MARKER = "Consumer";
0091:
0092:            /**
0093:             * method name in message service statistics MBean to query for endpoints in a
0094:             * delivery channel 
0095:             */
0096:            static String QUERY_ENDPOINT_LIST = "getEndpointsForDeliveryChannel";
0097:
0098:            /**
0099:             * method name in message service statistics MBean to query for endpoints in a
0100:             * delivery channel 
0101:             */
0102:            static String QUERY_CONSUMING_ENDPOINT_LIST = "getConsumingEndpointsForDeliveryChannel";
0103:
0104:            /**
0105:             * mbean names
0106:             */
0107:            MBeanNames mBeanNames = null;
0108:
0109:            /**
0110:             * resource bundle
0111:             */
0112:            I18NBundle mResourceBundle = null;
0113:
0114:            /**
0115:             * constructor
0116:             */
0117:            public JBIStatisticsMBeanImpl(EnvironmentContext anEnvContext) {
0118:                super (anEnvContext);
0119:                this .mBeanNames = anEnvContext.getMBeanNames();
0120:                this .mResourceBundle = getI18NBundle();
0121:            }
0122:
0123:            /**
0124:             * This method is used to provide JBIFramework statistics in the
0125:             * given target.
0126:             * @param target target name.
0127:             * @return TabularData table of framework statistics in the given target.
0128:             *
0129:             * If the target is a standalone instance the table will have one entry.
0130:             * If the target is a cluster the table will have an entry for each instance.
0131:             *
0132:             * For more information about the type of the entries in table please refer
0133:             * to <code>JBIStatisticsMBean</code>
0134:             */
0135:            public TabularData getFrameworkStats(String targetName)
0136:                    throws JBIRemoteException {
0137:                try {
0138:
0139:                    Map<String, ObjectName> frameworkMBeans = getFrameworkStatsMBeans(targetName);
0140:                    Set<String> instances = frameworkMBeans.keySet();
0141:
0142:                    CompositeType frameworkStatsEntriesType = new CompositeType(
0143:                            JBIStatisticsItemNames.FRAMEWORK_STATISTICS_NAME,
0144:                            JBIStatisticsItemNames.FRAMEWORK_STATISTICS_DESCRIPTION,
0145:                            FRAMEWORK_STATS_ITEM_NAMES,
0146:                            FRAMEWORK_STATS_ITEM_DESCRIPTIONS,
0147:                            FRAMEWORK_STATS_ITEM_TYPES);
0148:
0149:                    TabularType frameworkStatsType = new TabularType(
0150:                            JBIStatisticsItemNames.FRAMEWORK_STATISTICS_TABLE_ITEM_NAME,
0151:                            JBIStatisticsItemNames.FRAMEWORK_STATISTICS_TABLE_ITEM_DESCRIPTION,
0152:                            frameworkStatsEntriesType,
0153:                            JBIStatisticsItemNames.STATS_TABLE_INDEX);
0154:
0155:                    TabularData frameworkStatsTable = new TabularDataSupport(
0156:                            frameworkStatsType);
0157:
0158:                    for (String instance : instances) {
0159:                        ObjectName mbean = frameworkMBeans.get(instance);
0160:                        if (mbean != null) {
0161:                            logDebug("Getting framework statistics for "
0162:                                    + instance);
0163:                            frameworkStatsTable
0164:                                    .put(getFrameworkStats(
0165:                                            frameworkStatsEntriesType,
0166:                                            instance, mbean));
0167:                        }
0168:
0169:                    }
0170:
0171:                    return frameworkStatsTable;
0172:                } catch (OpenDataException ex) {
0173:                    Exception exception = this .createManagementException(
0174:                            LocalStringKeys.ERROR_IN_STATS_COMPOSING,
0175:                            new String[] { targetName }, ex);
0176:                    logWarning(ex);
0177:                    throw new JBIRemoteException(exception);
0178:
0179:                }
0180:
0181:            }
0182:
0183:            /**
0184:             * This method is used to provide statistics for the given component
0185:             * in the given target
0186:             * @param targetName target name
0187:             * @param componentName component name
0188:             * @return TabularData table of component statistics
0189:             *
0190:             * If the target is a standalone instance the table will have one entry.
0191:             * If the target is a cluster the table will have an entry for each instance.
0192:             *
0193:             * For more information about the type of the entries in table please refer
0194:             * to <code>JBIStatisticsMBean</code>
0195:             */
0196:            public TabularData getComponentStats(String componentName,
0197:                    String targetName) throws JBIRemoteException {
0198:
0199:                try {
0200:                    //check if the component is up and throw an exception if it is not
0201:                    if (!isComponentUp(componentName, targetName)) {
0202:                        Exception exception = this .createManagementException(
0203:                                LocalStringKeys.STATS_COMP_NOT_STARTED,
0204:                                new String[] { componentName, targetName },
0205:                                null);
0206:                        logWarning(exception);
0207:                        throw new JBIRemoteException(exception);
0208:                    }
0209:
0210:                    Map<String, ObjectName> compStatsFrameworkMBeans = getCompStatsFrameworkMBeans(
0211:                            targetName, componentName);
0212:                    logDebug("Got statistics MBeans for components registered by framework");
0213:
0214:                    Map<String, ObjectName> compStatsExtensionMBeans = getCompStatsExtensionMBeans(
0215:                            targetName, componentName);
0216:                    logDebug("Got statistics MBeans for components registered by components");
0217:
0218:                    Map<String, ObjectName> messageServiceStatsMBeans = getNMRStatsMBeans(targetName);
0219:                    logDebug("Got statistics MBeans for message service");
0220:
0221:                    Set<String> instances = compStatsFrameworkMBeans.keySet();
0222:
0223:                    TabularType componentStatsTableType = null;
0224:                    TabularData componentStatsTable = null;
0225:                    CompositeData[] componentStats = new CompositeData[instances
0226:                            .size()];
0227:                    int i = 0;
0228:                    for (String instance : instances) {
0229:                        ObjectName compFrameworkMBean = compStatsFrameworkMBeans
0230:                                .get(instance);
0231:                        if (compFrameworkMBean != null) {
0232:                            logDebug("Getting component stats for " + instance);
0233:
0234:                            componentStats[i++] = getComponentStats(instance,
0235:                                    componentName, compFrameworkMBean,
0236:                                    messageServiceStatsMBeans.get(instance),
0237:                                    compStatsExtensionMBeans.get(instance));
0238:                        }
0239:                    }
0240:                    //the tabular type could be constructed only after we have the component stats composite type
0241:                    //we need atleast one entry
0242:                    if (i > 0 && componentStats[0] != null) {
0243:                        componentStatsTableType = new TabularType(
0244:                                "ComponentStats",
0245:                                "Component Statistic Information",
0246:                                componentStats[0].getCompositeType(),
0247:                                JBIStatisticsItemNames.STATS_TABLE_INDEX);
0248:                        componentStatsTable = new TabularDataSupport(
0249:                                componentStatsTableType);
0250:
0251:                        for (int j = 0; j < i; j++) {
0252:                            componentStatsTable.put(componentStats[j]);
0253:                        }
0254:                    }
0255:                    return componentStatsTable;
0256:                } catch (OpenDataException ex) {
0257:                    Exception exception = this .createManagementException(
0258:                            LocalStringKeys.ERROR_IN_STATS_COMPOSING,
0259:                            new String[] { componentName }, ex);
0260:                    logWarning(ex);
0261:                    throw new JBIRemoteException(exception);
0262:
0263:                }
0264:            }
0265:
0266:            /**
0267:             * This method is used to provide statistic information about the given 
0268:             * endpoint in the given target
0269:             * @param targetName target name
0270:             * @param endpointName the endpoint Name
0271:             * @return TabularData table of endpoint statistics
0272:             *
0273:             * If the target is a standalone instance the table will have one entry.
0274:             * If the target is a cluster the table will have an entry for each instance.
0275:             *
0276:             * For more information about the type of the entries in table please refer
0277:             * to <code>JBIStatisticsMBean</code>
0278:             */
0279:            public TabularData getEndpointStats(String endpointName,
0280:                    String targetName) throws JBIRemoteException {
0281:                try {
0282:                    logDebug("Entered getEndpointStats");
0283:
0284:                    Map<String, ObjectName> messageServiceStatsMBeans = getNMRStatsMBeans(targetName);
0285:                    logDebug("Obtained statistics MBeans for message service");
0286:
0287:                    Set<String> instances = messageServiceStatsMBeans.keySet();
0288:
0289:                    TabularType endpointStatsTableType = null;
0290:                    TabularData endpointsStatsTable = null;
0291:                    CompositeData[] endpointStats = new CompositeData[instances
0292:                            .size()];
0293:                    int i = 0;
0294:                    for (String instance : instances) {
0295:                        ObjectName messageServiceMBean = messageServiceStatsMBeans
0296:                                .get(instance);
0297:                        if (messageServiceMBean != null) {
0298:                            logDebug("Obtaining endpoint stats for " + instance);
0299:
0300:                            //pass in the targetName to handle cluster cases, need this to get componentquery
0301:                            endpointStats[i++] = getEndpointStats(targetName,
0302:                                    instance, endpointName,
0303:                                    messageServiceStatsMBeans.get(instance));
0304:                        }
0305:                    }
0306:                    //the tabular type could be constructed only after we have the component stats composite type
0307:                    //so we need atleast one entry
0308:                    if (i > 0 && endpointStats[0] != null) {
0309:                        endpointStatsTableType = new TabularType(
0310:                                "EndpointStats",
0311:                                "Endpoint Statistic Information",
0312:                                endpointStats[0].getCompositeType(),
0313:                                JBIStatisticsItemNames.STATS_TABLE_INDEX);
0314:                        endpointsStatsTable = new TabularDataSupport(
0315:                                endpointStatsTableType);
0316:
0317:                        for (int j = 0; j < i; j++) {
0318:                            endpointsStatsTable.put(endpointStats[j]);
0319:                        }
0320:                    }
0321:                    return endpointsStatsTable;
0322:                } catch (OpenDataException ex) {
0323:                    Exception exception = this .createManagementException(
0324:                            LocalStringKeys.ERROR_IN_STATS_COMPOSING,
0325:                            new String[] { endpointName }, ex);
0326:                    logWarning(ex);
0327:                    throw new JBIRemoteException(exception);
0328:
0329:                }
0330:            }
0331:
0332:            /**
0333:             * This method is used to provide statistics about the message service in the
0334:             * given target.
0335:             * @param target target name.
0336:             * @return TabularData table of NMR statistics in the given target.
0337:             *
0338:             * If the target is a standalone instance the table will have one entry.
0339:             * If the target is a cluster the table will have an entry for each instance.
0340:             *
0341:             * For more information about the type of the entries in table please refer
0342:             * to <code>JBIStatisticsMBean</code>
0343:             */
0344:            public TabularData getNMRStats(String targetName)
0345:                    throws JBIRemoteException {
0346:
0347:                try {
0348:
0349:                    Map<String, ObjectName> nmrMBeans = getNMRStatsMBeans(targetName);
0350:                    Set<String> instances = nmrMBeans.keySet();
0351:
0352:                    OpenType[] nmrStatsItemTypes = { SimpleType.STRING,
0353:                            new ArrayType(1, SimpleType.STRING),
0354:                            new ArrayType(1, SimpleType.STRING) };
0355:
0356:                    CompositeType NMRStatsEntriesType = new CompositeType(
0357:                            JBIStatisticsItemNames.NMR_STATISTICS_NAME,
0358:                            JBIStatisticsItemNames.NMR_STATISTICS_DESCRIPTION,
0359:                            NMR_STATS_ITEM_NAMES, NMR_STATS_ITEM_DESCRIPTIONS,
0360:                            nmrStatsItemTypes);
0361:
0362:                    TabularType nmrStatsType = new TabularType(
0363:                            JBIStatisticsItemNames.NMR_STATISTICS_TABLE_ITEM_NAME,
0364:                            JBIStatisticsItemNames.NMR_STATISTICS_TABLE_ITEM_DESCRIPTION,
0365:                            NMRStatsEntriesType,
0366:                            JBIStatisticsItemNames.STATS_TABLE_INDEX);
0367:
0368:                    TabularData nmrStatsTable = new TabularDataSupport(
0369:                            nmrStatsType);
0370:
0371:                    for (String instance : instances) {
0372:                        ObjectName mbean = nmrMBeans.get(instance);
0373:                        if (mbean != null) {
0374:                            logDebug("Getting NMR statistics for " + instance);
0375:                            nmrStatsTable.put(getNMRStats(NMRStatsEntriesType,
0376:                                    instance, mbean));
0377:                        }
0378:
0379:                    }
0380:
0381:                    return nmrStatsTable;
0382:                } catch (OpenDataException ex) {
0383:                    Exception exception = this .createManagementException(
0384:                            LocalStringKeys.ERROR_IN_STATS_COMPOSING,
0385:                            new String[] { targetName }, ex);
0386:                    logWarning(ex);
0387:                    throw new JBIRemoteException(exception);
0388:
0389:                }
0390:            }
0391:
0392:            /**
0393:             * This method is used to provide statistics about a Service Assembly
0394:             * in the given target.
0395:             * @param target target name.
0396:             * @param saName the service assembly name.
0397:             * @return TabularData table of NMR statistics in the given target.
0398:             *
0399:             * If the target is a standalone instance the table will have one entry.
0400:             * If the target is a cluster the table will have an entry for each instance.
0401:             *
0402:             * For more information about the type of the entries in table please refer
0403:             * to <code>JBIStatisticsMBean</code>
0404:             */
0405:            public TabularData getServiceAssemblyStats(String saName,
0406:                    String targetName) throws JBIRemoteException {
0407:                try {
0408:                    Map<String, ObjectName> deploymentServiceStatsMBeans = getDeploymentServiceStatsMBeans(targetName);
0409:
0410:                    Set<String> instances = deploymentServiceStatsMBeans
0411:                            .keySet();
0412:
0413:                    TabularType saStatsTableType = null;
0414:                    TabularData saStatsTable = null;
0415:                    CompositeData[] saStats = new CompositeData[instances
0416:                            .size()];
0417:
0418:                    int i = 0;
0419:                    for (String instance : instances) {
0420:                        ObjectName deploymentServiceMBean = deploymentServiceStatsMBeans
0421:                                .get(instance);
0422:                        if (deploymentServiceMBean != null) {
0423:                            logDebug("Getting service assembly statistics for "
0424:                                    + instance);
0425:                            saStats[i++] = getSAStats(instance, saName,
0426:                                    deploymentServiceStatsMBeans.get(instance));
0427:                        }
0428:                    }
0429:
0430:                    //the tabular type could be constructed only after we have the component stats composite type
0431:                    //so we need atleast one entry
0432:                    if (i > 0 && saStats[0] != null) {
0433:                        saStatsTableType = new TabularType(
0434:                                JBIStatisticsItemNames.SA_STATISTICS_NAME,
0435:                                JBIStatisticsItemNames.SA_STATISTICS_DESCRIPTION,
0436:                                saStats[0].getCompositeType(),
0437:                                JBIStatisticsItemNames.STATS_TABLE_INDEX);
0438:                        saStatsTable = new TabularDataSupport(saStatsTableType);
0439:
0440:                        for (int j = 0; j < i; j++) {
0441:                            saStatsTable.put(saStats[j]);
0442:                        }
0443:                    }
0444:                    return saStatsTable;
0445:                } catch (JBIRemoteException remoteException) {
0446:                    Exception exception = this .createManagementException(
0447:                            LocalStringKeys.ERROR_IN_STATS_COMPOSING,
0448:                            new String[] { saName }, remoteException);
0449:                    logWarning(remoteException);
0450:                    throw new JBIRemoteException(remoteException);
0451:                } catch (OpenDataException ex) {
0452:                    Exception exception = this .createManagementException(
0453:                            LocalStringKeys.ERROR_IN_STATS_COMPOSING,
0454:                            new String[] { saName }, ex);
0455:                    logWarning(ex);
0456:                    throw new JBIRemoteException(ex);
0457:
0458:                }
0459:
0460:            }
0461:
0462:            /**
0463:             * This method is used to return the list of framework stats 
0464:             * MBeans that contain statistic information for the given target
0465:             * @param targetName the target
0466:             * @return map of instance names and corresponding framework MBeans
0467:             */
0468:            private Map<String, ObjectName> getFrameworkStatsMBeans(
0469:                    String targetName) throws JBIRemoteException {
0470:                return getStatsMBeans(targetName,
0471:                        mBeanNames.SERVICE_NAME_FRAMEWORK);
0472:            }
0473:
0474:            /**
0475:             * This method is used to return the list of deploymentservice stats 
0476:             * MBeans that contain statistic information for the given target
0477:             * @param targetName the target
0478:             * @return map of instance names and corresponding deployment service MBeans
0479:             */
0480:            private Map<String, ObjectName> getDeploymentServiceStatsMBeans(
0481:                    String targetName) throws JBIRemoteException {
0482:                return getStatsMBeans(targetName,
0483:                        mBeanNames.SERVICE_NAME_DEPLOY_SERVICE);
0484:            }
0485:
0486:            /**
0487:             * This method is used to return the list of nmr stats 
0488:             * MBeans that contain statistic information for the given target
0489:             * @param targetName the target
0490:             * @return map of instance names and corresponding framework MBeans
0491:             */
0492:            private Map<String, ObjectName> getNMRStatsMBeans(String targetName)
0493:                    throws JBIRemoteException {
0494:                return getStatsMBeans(targetName,
0495:                        mBeanNames.SERVICE_NAME_MESSAGE_SERVICE);
0496:            }
0497:
0498:            /**
0499:             * This method is used to return the list of component stats Mbeans registered by framework 
0500:             * MBeans that contain statistic information for the given target
0501:             * @param targetName the target
0502:             * @return map of instance names and corresponding component stats MBeans
0503:             */
0504:            private Map<String, ObjectName> getCompStatsFrameworkMBeans(
0505:                    String targetName, String componentName)
0506:                    throws JBIRemoteException {
0507:                try {
0508:                    Map<String, ObjectName> mbeanList = new HashMap<String, ObjectName>();
0509:                    if ("domain".equals(targetName)) {
0510:                        logDebug("getCompStatsFrameworkMBeans(): target "
0511:                                + targetName + " type not supported.");
0512:                        Exception exception = this .createManagementException(
0513:                                LocalStringKeys.STATS_TARGET_NOT_SUPPORTED,
0514:                                new String[] { targetName }, null);
0515:                        throw new JBIRemoteException(exception);
0516:                    }
0517:
0518:                    //find out if this is a binding or engine
0519:                    ComponentType compType;
0520:                    try {
0521:
0522:                        ComponentQuery compQuery = mEnvContext
0523:                                .getComponentQuery(targetName);
0524:                        ComponentInfo compInfo = compQuery
0525:                                .getComponentInfo(componentName);
0526:                        compType = compInfo.getComponentType();
0527:                        logDebug("ComponentQuery in target " + targetName
0528:                                + " returned component type " + compType);
0529:                    } catch (Exception ex) {
0530:                        logDebug("getCompStatsFrameworkMBeans(): component "
0531:                                + componentName + " type not known.");
0532:                        Exception exception = this .createManagementException(
0533:                                LocalStringKeys.STATS_COMP_TYPE_NOT_KNOWN,
0534:                                new String[] { componentName }, null);
0535:                        throw new JBIRemoteException(exception);
0536:                    }
0537:
0538:                    if (getPlatformContext().isStandaloneServer(targetName)) {
0539:                        mbeanList.put(targetName, getCompStatsFrameworkMBeans(
0540:                                targetName, componentName, compType));
0541:                    } else if (getPlatformContext().isClusteredServer(
0542:                            targetName)) {
0543:                        mbeanList.put(targetName, getCompStatsFrameworkMBeans(
0544:                                targetName, componentName, compType));
0545:                    } else if (this .getPlatformContext().isCluster(targetName)) {
0546:                        Set<String> servers = getPlatformContext()
0547:                                .getServersInCluster(targetName);
0548:                        for (String server : servers) {
0549:                            mbeanList.put(server, getCompStatsFrameworkMBeans(
0550:                                    server, componentName, compType));
0551:                        }
0552:                    }
0553:                    return mbeanList;
0554:                } catch (Exception ex) {
0555:                    throw new JBIRemoteException(ex);
0556:                }
0557:            }
0558:
0559:            /**
0560:             * This method is used to return the list of component stats Mbeans registered by framework 
0561:             * MBeans that contain statistic information for the given target
0562:             * @param targetName the target
0563:             * @return map of instance names and corresponding component stats MBeans
0564:             */
0565:            private Map<String, ObjectName> getCompStatsExtensionMBeans(
0566:                    String targetName, String componentName)
0567:                    throws JBIRemoteException {
0568:                try {
0569:                    Map<String, ObjectName> mbeanList = new HashMap<String, ObjectName>();
0570:                    if ("domain".equals(targetName)) {
0571:                        logDebug("getCompStatsExtensionMBeans(): target "
0572:                                + targetName + " type not supported.");
0573:                        Exception exception = this .createManagementException(
0574:                                LocalStringKeys.STATS_TARGET_NOT_SUPPORTED,
0575:                                new String[] { targetName }, null);
0576:                        throw new JBIRemoteException(exception);
0577:                    }
0578:
0579:                    //find out if this is a binding or engine
0580:                    ComponentType compType;
0581:                    try {
0582:                        ComponentQuery compQuery = mEnvContext
0583:                                .getComponentQuery(targetName);
0584:                        ComponentInfo compInfo = compQuery
0585:                                .getComponentInfo(componentName);
0586:                        compType = compInfo.getComponentType();
0587:                    } catch (Exception ex) {
0588:                        logDebug("getCompStatsExtensionMBeans(): component "
0589:                                + componentName + " type not known.");
0590:                        Exception exception = this .createManagementException(
0591:                                LocalStringKeys.STATS_COMP_TYPE_NOT_KNOWN,
0592:                                new String[] { componentName }, null);
0593:                        throw new JBIRemoteException(exception);
0594:                    }
0595:
0596:                    if (getPlatformContext().isStandaloneServer(targetName)) {
0597:                        mbeanList.put(targetName, getCompStatsExtensionMBeans(
0598:                                targetName, componentName, compType));
0599:                    } else if (getPlatformContext().isClusteredServer(
0600:                            targetName)) {
0601:                        mbeanList.put(targetName, getCompStatsExtensionMBeans(
0602:                                targetName, componentName, compType));
0603:                    } else if (this .getPlatformContext().isCluster(targetName)) {
0604:                        Set<String> servers = getPlatformContext()
0605:                                .getServersInCluster(targetName);
0606:                        for (String server : servers) {
0607:                            mbeanList.put(server, getCompStatsExtensionMBeans(
0608:                                    server, componentName, compType));
0609:                        }
0610:                    }
0611:                    return mbeanList;
0612:                } catch (Exception ex) {
0613:                    throw new JBIRemoteException(ex);
0614:                }
0615:            }
0616:
0617:            /**
0618:             * This method is used to get the name of the stats mbeans
0619:             */
0620:
0621:            private ObjectName getCompStatsExtensionMBeans(String instance,
0622:                    String componentName, ComponentType compType)
0623:                    throws JBIRemoteException {
0624:
0625:                boolean isUp = getPlatformContext().isInstanceUp(instance);
0626:
0627:                if (!isUp) {
0628:                    logDebug("getCompStatsExtensionMBeans(): instance "
0629:                            + instance + " is down.");
0630:                    Exception exception = this .createManagementException(
0631:                            LocalStringKeys.STATS_SERVER_DOWN,
0632:                            new String[] { instance }, null);
0633:                    throw new JBIRemoteException(exception);
0634:                }
0635:
0636:                String componentType;
0637:                if (compType.equals(ComponentType.BINDING)) {
0638:                    componentType = mBeanNames.INSTALLED_TYPE_BINDING;
0639:                } else if (compType.equals(ComponentType.ENGINE)) {
0640:                    componentType = mBeanNames.INSTALLED_TYPE_ENGINE;
0641:                } else {
0642:                    Exception exception = this .createManagementException(
0643:                            LocalStringKeys.STATS_INVALID_COMP_TYPE,
0644:                            new String[] { componentName }, null);
0645:                    throw new JBIRemoteException(exception);
0646:                }
0647:
0648:                String statsMBeanName = JBIJMXObjectNames.JMX_JBI_DOMAIN
0649:                        + COLON + mBeanNames.INSTANCE_NAME_KEY + EQUAL
0650:                        + instance + COMMA + mBeanNames.COMPONENT_ID_KEY
0651:                        + EQUAL + componentName + COMMA
0652:                        + mBeanNames.CONTROL_TYPE_KEY + EQUAL
0653:                        + mBeanNames.CONTROL_TYPE_CUSTOM + COMMA
0654:                        + mBeanNames.COMPONENT_TYPE_KEY + EQUAL
0655:                        + mBeanNames.COMPONENT_TYPE_INSTALLED + COMMA
0656:                        + mBeanNames.INSTALLED_TYPE_KEY + EQUAL + componentType
0657:                        + COMMA + SERVICE_TYPE_KEY + EQUAL
0658:                        + mBeanNames.CONTROL_TYPE_STATISTICS;
0659:                try {
0660:                    return new ObjectName(statsMBeanName);
0661:                } catch (Exception e) {
0662:                    ToolsLogManager.getRuntimeLogger().warning(
0663:                            mResourceBundle.getMessage(
0664:                                    LocalStringKeys.STATS_MBEAN_NOT_PRESENT,
0665:                                    new Object[] { statsMBeanName }));
0666:                    logWarning(e);
0667:                    return null;
0668:                }
0669:            }
0670:
0671:            /**
0672:             * This method is used to get the name of the stats mbeans
0673:             */
0674:
0675:            private ObjectName getCompStatsFrameworkMBeans(String instance,
0676:                    String componentName, ComponentType compType)
0677:                    throws JBIRemoteException {
0678:
0679:                boolean isUp = getPlatformContext().isInstanceUp(instance);
0680:
0681:                if (!isUp) {
0682:                    logDebug("getCompStatsFrameworkMBeans(): instance "
0683:                            + instance + " is down.");
0684:                    Exception exception = this .createManagementException(
0685:                            LocalStringKeys.STATS_SERVER_DOWN,
0686:                            new String[] { instance }, null);
0687:                    throw new JBIRemoteException(exception);
0688:                }
0689:
0690:                String componentType;
0691:                if (compType.equals(ComponentType.BINDING)) {
0692:                    componentType = mBeanNames.INSTALLED_TYPE_BINDING;
0693:                } else if (compType.equals(ComponentType.ENGINE)) {
0694:                    componentType = mBeanNames.INSTALLED_TYPE_ENGINE;
0695:                } else {
0696:                    Exception exception = this .createManagementException(
0697:                            LocalStringKeys.STATS_INVALID_COMP_TYPE,
0698:                            new String[] { componentName }, null);
0699:                    throw new JBIRemoteException(exception);
0700:                }
0701:
0702:                String statsMBeanName = JBIJMXObjectNames.JMX_JBI_DOMAIN
0703:                        + COLON + mBeanNames.INSTANCE_NAME_KEY + EQUAL
0704:                        + instance + COMMA + mBeanNames.COMPONENT_ID_KEY
0705:                        + EQUAL + componentName + COMMA
0706:                        + mBeanNames.CONTROL_TYPE_KEY + EQUAL
0707:                        + mBeanNames.CONTROL_TYPE_STATISTICS + COMMA
0708:                        + mBeanNames.COMPONENT_TYPE_KEY + EQUAL
0709:                        + mBeanNames.COMPONENT_TYPE_INSTALLED + COMMA
0710:                        + mBeanNames.INSTALLED_TYPE_KEY + EQUAL + componentType;
0711:                try {
0712:                    return new ObjectName(statsMBeanName);
0713:                } catch (Exception e) {
0714:                    ToolsLogManager.getRuntimeLogger().warning(
0715:                            mResourceBundle.getMessage(
0716:                                    LocalStringKeys.STATS_MBEAN_NOT_PRESENT,
0717:                                    new Object[] { statsMBeanName }));
0718:                    logWarning(e);
0719:                    return null;
0720:                }
0721:            }
0722:
0723:            /**
0724:             * This method is used to get a list of statitics MBeans with the following 
0725:             * pattern
0726:             * @param targetName the target
0727:             * @param servicename the mbean pattern
0728:             * @return Map instance name to MBeans
0729:             */
0730:            private Map<String, ObjectName> getStatsMBeans(String targetName,
0731:                    String serviceName) throws JBIRemoteException {
0732:
0733:                Map<String, ObjectName> mbeanList = new HashMap<String, ObjectName>();
0734:                if ("domain".equals(targetName)) {
0735:                    logDebug("getStatsMBeans(): target " + targetName
0736:                            + " type not supported.");
0737:                    Exception exception = this .createManagementException(
0738:                            LocalStringKeys.STATS_TARGET_NOT_SUPPORTED,
0739:                            new String[] { targetName }, null);
0740:                    throw new JBIRemoteException(exception);
0741:                }
0742:                if (getPlatformContext().isStandaloneServer(targetName)) {
0743:                    mbeanList.put(targetName, getStatsMBean(targetName,
0744:                            serviceName));
0745:                } else if (getPlatformContext().isClusteredServer(targetName)) {
0746:                    mbeanList.put(targetName, getStatsMBean(targetName,
0747:                            serviceName));
0748:                } else if (this .getPlatformContext().isCluster(targetName)) {
0749:                    Set<String> servers = getPlatformContext()
0750:                            .getServersInCluster(targetName);
0751:                    for (String server : servers) {
0752:                        mbeanList.put(server,
0753:                                getStatsMBean(server, serviceName));
0754:                    }
0755:                }
0756:                return mbeanList;
0757:            }
0758:
0759:            /**
0760:             * This method is used to get the name of the stats mbeans
0761:             * @param serviceName service name
0762:             * @param instance instance name
0763:             * @return ObjectName object name of the mbean
0764:             */
0765:
0766:            private ObjectName getStatsMBean(String instance, String serviceName)
0767:                    throws JBIRemoteException {
0768:
0769:                boolean isUp = getPlatformContext().isInstanceUp(instance);
0770:                if (!isUp) {
0771:                    logDebug("getStatsMBeans(): instance " + instance
0772:                            + " is down.");
0773:                    Exception exception = this .createManagementException(
0774:                            LocalStringKeys.STATS_SERVER_DOWN,
0775:                            new String[] { instance }, null);
0776:                    throw new JBIRemoteException(exception);
0777:                }
0778:
0779:                String statsMBeanName = JBIJMXObjectNames.JMX_JBI_DOMAIN
0780:                        + COLON + mBeanNames.INSTANCE_NAME_KEY + EQUAL
0781:                        + instance + COMMA + mBeanNames.SERVICE_NAME_KEY
0782:                        + EQUAL + serviceName + COMMA
0783:                        + mBeanNames.CONTROL_TYPE_KEY + EQUAL
0784:                        + mBeanNames.CONTROL_TYPE_STATISTICS + COMMA
0785:                        + mBeanNames.COMPONENT_TYPE_KEY + EQUAL
0786:                        + mBeanNames.CONTROL_TYPE_SYSTEM;
0787:                try {
0788:                    return new ObjectName(statsMBeanName);
0789:                } catch (Exception ex) {
0790:                    //catch all possible exceptions because if stats mbean is not available for
0791:                    //one instance we should be able to report for the rest of the instances.
0792:                    ToolsLogManager.getRuntimeLogger().warning(
0793:                            mResourceBundle.getMessage(
0794:                                    LocalStringKeys.STATS_MBEAN_NOT_PRESENT,
0795:                                    new Object[] { statsMBeanName }));
0796:                    logWarning(ex);
0797:                    return null;
0798:                }
0799:            }
0800:
0801:            /**
0802:             * This method is used to provide query framework statistics from the
0803:             * given mbean
0804:             */
0805:            private CompositeData getFrameworkStats(
0806:                    CompositeType frameworkStatsEntriesType,
0807:                    String instanceName, ObjectName mbean)
0808:                    throws JBIRemoteException {
0809:                try {
0810:                    //get specific attributes and process them
0811:                    Long startTime = (Long) getMBeanAttribute(mbean,
0812:                            FRAMEWORK_MBEAN_STARTUP_TIME_ATTR);
0813:
0814:                    Date lastRestart = (Date) getMBeanAttribute(mbean,
0815:                            FRAMEWORK_MBEAN_LAST_RESTART_TIME_ATTR);
0816:                    long upTime = 0;
0817:
0818:                    if (lastRestart != null) {
0819:                        upTime = System.currentTimeMillis()
0820:                                - lastRestart.getTime();
0821:                    }
0822:
0823:                    Object[] values = { instanceName, startTime, upTime };
0824:
0825:                    return new CompositeDataSupport(frameworkStatsEntriesType,
0826:                            FRAMEWORK_STATS_ITEM_NAMES, values);
0827:
0828:                } catch (OpenDataException ex) {
0829:                    throw new JBIRemoteException(ex);
0830:                }
0831:            }
0832:
0833:            /**
0834:             * This method is used to provide query framework statistics from the
0835:             * given mbean
0836:             */
0837:            private CompositeData getNMRStats(
0838:                    CompositeType NMRStatsEntriesType, String instanceName,
0839:                    ObjectName mbean) throws JBIRemoteException {
0840:                try {
0841:
0842:                    String[] channels = (String[]) getMBeanAttribute(mbean,
0843:                            NMR_MBEAN_ACTIVE_CHANNELS_ATTR);
0844:                    String[] endpoints = (String[]) getMBeanAttribute(mbean,
0845:                            NMR_MBEAN_ACTIVE_ENDPOINTS_ATTR);
0846:
0847:                    Object[] values = { instanceName, channels, endpoints };
0848:
0849:                    return new CompositeDataSupport(NMRStatsEntriesType,
0850:                            NMR_STATS_ITEM_NAMES, values);
0851:
0852:                } catch (OpenDataException ex) {
0853:                    throw new JBIRemoteException(ex);
0854:                }
0855:            }
0856:
0857:            /**
0858:             * This method is used to obtain statistics for a SA by talking to the
0859:             * DeploymentServiceStatistics MBean
0860:             * @param instanceName instance name
0861:             * @param saName sa Name
0862:             * @param deploymentServiceMBean deployment service mbean object name
0863:             */
0864:            private CompositeData getSAStats(String instanceName,
0865:                    String saName, ObjectName deploymentServiceMBean)
0866:                    throws JBIRemoteException {
0867:
0868:                try {
0869:                    return (CompositeData) invokeMBeanOperation(
0870:                            deploymentServiceMBean,
0871:                            "getServiceAssemblyStatistics",
0872:                            new Object[] { saName },
0873:                            new String[] { "java.lang.String" });
0874:                } catch (JBIRemoteException remoteException) {
0875:                    Exception exception = this .createManagementException(
0876:                            LocalStringKeys.ERROR_SA_NOT_EXISTS,
0877:                            new String[] { saName }, null);
0878:                    logWarning(exception);
0879:                    throw new JBIRemoteException(exception);
0880:                }
0881:            }
0882:
0883:            /**
0884:             * This method is used to provide component stats collected from framework 
0885:             * component mbean and component extension stats mbean if one is registered
0886:             * @param instance instance name
0887:             * @param componentName comopnent name
0888:             * @param frameworkMBean mbean registered by framework for this component's stat
0889:             * @param messageServiceStatsMBean nmr stats mbean
0890:             * @param compExtnMBean mbean registered by the component itself
0891:             * @return CompositeData all stats composed from all the mbeans
0892:             * @throws JBIRemoteException if stats could not be collected
0893:             */
0894:            private CompositeData getComponentStats(String instanceName,
0895:                    String componentName, ObjectName frameworkMBean,
0896:                    ObjectName messageServiceStatsMBean,
0897:                    ObjectName compExtnMBean) throws JBIRemoteException {
0898:
0899:                long upTime = 0;
0900:                Date lastRestartTime = (Date) getMBeanAttribute(frameworkMBean,
0901:                        COMPONENT_LAST_RESTART_TIME_ATTR);
0902:                if (lastRestartTime != null) {
0903:                    upTime = System.currentTimeMillis()
0904:                            - lastRestartTime.getTime();
0905:                }
0906:
0907:                CompositeData allDeliveryChannelStats = (CompositeData) invokeMBeanOperation(
0908:                        messageServiceStatsMBean,
0909:                        "getDeliveryChannelStatistics",
0910:                        new Object[] { componentName },
0911:                        new String[] { "java.lang.String" });
0912:
0913:                //compute completedexchanges = sendDONE + receiveDONE + sendERROR + receiveERROR
0914:                long completedExchanges = 0;
0915:                long errorExchanges = 0;
0916:                Long numSendDone = (Long) allDeliveryChannelStats
0917:                        .get(COMPONENT_SEND_DONE);
0918:                Long numReceiveDone = (Long) allDeliveryChannelStats
0919:                        .get(COMPONENT_RECEIVE_DONE);
0920:                Long numSendError = (Long) allDeliveryChannelStats
0921:                        .get(COMPONENT_SEND_ERROR);
0922:                Long numReceiveError = (Long) allDeliveryChannelStats
0923:                        .get(COMPONENT_RECEIVE_ERROR);
0924:                if (numSendDone != null && numReceiveDone != null
0925:                        && numSendError != null && numReceiveError != null) {
0926:                    completedExchanges = numSendDone.longValue()
0927:                            + numReceiveDone.longValue()
0928:                            + numSendError.longValue()
0929:                            + numReceiveError.longValue();
0930:
0931:                    errorExchanges = numSendError.longValue()
0932:                            + numReceiveError.longValue();
0933:                }
0934:
0935:                CompositeData componentExtnStats = null;
0936:
0937:                return composeComponentStats(instanceName, upTime,
0938:                        allDeliveryChannelStats, completedExchanges,
0939:                        errorExchanges, getCompStatsAttributes(compExtnMBean));
0940:
0941:            }
0942:
0943:            /**
0944:             * This method is used compose component stats composite data
0945:             * @param instanceName instance name
0946:             * @param upTime component uptime
0947:             * @param allDeliveryChannelStats stats from messageservice 
0948:             * @param completedExchanges number of completed exchanges - (computed value)
0949:             * @param errorExchanges number of error exchanges - (computed value)
0950:             * @param componentExtnStats attributes exposed by component stats mbean
0951:             * @throws JBIRemoteException if the data could not be composed into CompositeData
0952:             */
0953:            private CompositeData composeComponentStats(String instanceName,
0954:                    long upTime, CompositeData deliveryChannelStats,
0955:                    long completedExchanges, long errorExchanges,
0956:                    CompositeData componentExtnStats) throws JBIRemoteException {
0957:                try {
0958:                    ArrayList<String> itemNames = new ArrayList<String>();
0959:                    itemNames.add(JBIStatisticsItemNames.INSTANCE_NAME);
0960:                    itemNames.add(JBIStatisticsItemNames.COMPONENT_UPTIME);
0961:                    itemNames
0962:                            .add(JBIStatisticsItemNames.NUMBER_OF_ACTIVATED_ENDPOINTS);
0963:                    itemNames
0964:                            .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_REQUESTS);
0965:                    itemNames
0966:                            .add(JBIStatisticsItemNames.NUMBER_OF_SENT_REQUESTS);
0967:                    itemNames
0968:                            .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_REPLIES);
0969:                    itemNames
0970:                            .add(JBIStatisticsItemNames.NUMBER_OF_SENT_REPLIES);
0971:                    itemNames
0972:                            .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_DONES);
0973:                    itemNames.add(JBIStatisticsItemNames.NUMBER_OF_SENT_DONES);
0974:                    itemNames
0975:                            .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_FAULTS);
0976:                    itemNames.add(JBIStatisticsItemNames.NUMBER_OF_SENT_FAULTS);
0977:                    itemNames
0978:                            .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_ERRORS);
0979:                    itemNames.add(JBIStatisticsItemNames.NUMBER_OF_SENT_ERRORS);
0980:                    itemNames
0981:                            .add(JBIStatisticsItemNames.NUMBER_OF_COMPLETED_EXCHANGES);
0982:                    itemNames
0983:                            .add(JBIStatisticsItemNames.NUMBER_OF_ACTIVE_EXCHANGES);
0984:                    itemNames
0985:                            .add(JBIStatisticsItemNames.NUMBER_OF_ERROR_EXCHANGES);
0986:                    itemNames
0987:                            .add(JBIStatisticsItemNames.MESSAGE_EXCHANGE_RESPONSE_TIME);
0988:                    itemNames
0989:                            .add(JBIStatisticsItemNames.MESSAGE_EXCHANGE_COMPONENT_TIME);
0990:                    itemNames
0991:                            .add(JBIStatisticsItemNames.MESSAGE_EXCHANGE_DELIVERY_CHANNEL_TIME);
0992:                    itemNames
0993:                            .add(JBIStatisticsItemNames.MESSAGE_EXCHANGE_NMR_TIME);
0994:                    if (componentExtnStats != null) {
0995:                        itemNames.add("ComponentExtensionStats");
0996:                    }
0997:
0998:                    ArrayList<String> itemDescriptions = new ArrayList<String>();
0999:                    itemDescriptions.add("Instance Name");
1000:                    itemDescriptions.add("Component Uptime");
1001:                    itemDescriptions.add("Number of activated endpoints");
1002:                    itemDescriptions.add("Number of received requests");
1003:                    itemDescriptions.add("Number of sent requests");
1004:                    itemDescriptions.add("Number of received replies");
1005:                    itemDescriptions.add("Number of sent replies");
1006:                    itemDescriptions.add("Number of received DONEs");
1007:                    itemDescriptions.add("Number of sent DONEs");
1008:                    itemDescriptions.add("Number of received faults");
1009:                    itemDescriptions.add("Number of sent faults");
1010:                    itemDescriptions.add("Number of received errors");
1011:                    itemDescriptions.add("Number of sent errors");
1012:                    itemDescriptions.add("Number of completed exchanges");
1013:                    itemDescriptions.add("Number of active exchanges");
1014:                    itemDescriptions.add("Number of error exchanges");
1015:                    itemDescriptions
1016:                            .add("Avg. response time for message exchange");
1017:                    itemDescriptions
1018:                            .add("Avg. time taken in component by message exchange");
1019:                    itemDescriptions
1020:                            .add("Avg. time taken in delivery channel by message exchange");
1021:                    itemDescriptions
1022:                            .add("Avg. time taken in message service by message exchange");
1023:                    if (componentExtnStats != null) {
1024:                        itemDescriptions
1025:                                .add("Statistics reported by component statistics MBeans");
1026:                    }
1027:
1028:                    ArrayList<OpenType> itemTypes = new ArrayList<OpenType>();
1029:                    itemTypes.add(SimpleType.STRING);
1030:                    itemTypes.add(SimpleType.LONG);
1031:                    itemTypes.add(SimpleType.LONG);
1032:                    itemTypes.add(SimpleType.LONG);
1033:                    itemTypes.add(SimpleType.LONG);
1034:                    itemTypes.add(SimpleType.LONG);
1035:                    itemTypes.add(SimpleType.LONG);
1036:                    itemTypes.add(SimpleType.LONG);
1037:                    itemTypes.add(SimpleType.LONG);
1038:                    itemTypes.add(SimpleType.LONG);
1039:                    itemTypes.add(SimpleType.LONG);
1040:                    itemTypes.add(SimpleType.LONG);
1041:                    itemTypes.add(SimpleType.LONG);
1042:                    itemTypes.add(SimpleType.LONG);
1043:                    itemTypes.add(SimpleType.LONG);
1044:                    itemTypes.add(SimpleType.LONG);
1045:                    itemTypes.add(SimpleType.LONG);
1046:                    itemTypes.add(SimpleType.LONG);
1047:                    itemTypes.add(SimpleType.LONG);
1048:                    itemTypes.add(SimpleType.LONG);
1049:                    if (componentExtnStats != null) {
1050:                        itemTypes.add(componentExtnStats.getCompositeType());
1051:                    }
1052:
1053:                    ArrayList<Object> itemValues = new ArrayList<Object>();
1054:                    itemValues.add(instanceName);
1055:                    itemValues.add(new Long(upTime));
1056:                    itemValues.add(deliveryChannelStats
1057:                            .get(COMPONENT_ACTIVE_ENDPOINTS));
1058:                    itemValues.add(deliveryChannelStats
1059:                            .get(COMPONENT_RECEIVE_REQUEST));
1060:                    itemValues.add(deliveryChannelStats
1061:                            .get(COMPONENT_SEND_REQUEST));
1062:                    itemValues.add(deliveryChannelStats
1063:                            .get(COMPONENT_RECEIVE_REPLY));
1064:                    itemValues.add(deliveryChannelStats
1065:                            .get(COMPONENT_SEND_REPLY));
1066:                    itemValues.add(deliveryChannelStats
1067:                            .get(COMPONENT_RECEIVE_DONE));
1068:                    itemValues.add(deliveryChannelStats
1069:                            .get(COMPONENT_SEND_DONE));
1070:                    itemValues.add(deliveryChannelStats
1071:                            .get(COMPONENT_RECEIVE_FAULT));
1072:                    itemValues.add(deliveryChannelStats
1073:                            .get(COMPONENT_SEND_FAULT));
1074:                    itemValues.add(deliveryChannelStats
1075:                            .get(COMPONENT_RECEIVE_ERROR));
1076:                    itemValues.add(deliveryChannelStats
1077:                            .get(COMPONENT_SEND_ERROR));
1078:                    itemValues.add(deliveryChannelStats
1079:                            .get(COMPONENT_ACTIVE_EXCHANGE));
1080:                    itemValues.add(new Long(completedExchanges));
1081:                    itemValues.add(new Long(errorExchanges));
1082:                    itemValues.add(deliveryChannelStats
1083:                            .get(COMPONENT_RESPONSE_TIME));
1084:                    itemValues.add(deliveryChannelStats
1085:                            .get(COMPONENT_COMPONENT_TIME));
1086:                    itemValues.add(deliveryChannelStats
1087:                            .get(COMPONENT_CHANNEL_TIME));
1088:                    itemValues
1089:                            .add(deliveryChannelStats.get(COMPONENT_NMR_TIME));
1090:                    if (componentExtnStats != null) {
1091:                        itemValues.add(componentExtnStats);
1092:                    }
1093:
1094:                    return new CompositeDataSupport(
1095:                            new CompositeType(
1096:                                    JBIStatisticsItemNames.COMPONENT_STATISTICS_TABLE_ITEM_NAME,
1097:                                    JBIStatisticsItemNames.COMPONENT_STATISTICS_TABLE_ITEM_DESCRIPTION,
1098:                                    (String[]) itemNames
1099:                                            .toArray(new String[] {}),
1100:                                    (String[]) itemDescriptions
1101:                                            .toArray(new String[] {}),
1102:                                    (OpenType[]) itemTypes
1103:                                            .toArray(new OpenType[] {})),
1104:                            (String[]) itemNames.toArray(new String[] {}),
1105:                            (Object[]) itemValues.toArray(new Object[] {}));
1106:                } catch (OpenDataException ex) {
1107:                    throw new JBIRemoteException(ex);
1108:                }
1109:
1110:            }
1111:
1112:            /**
1113:             * This method is used to obtain the statistics attributes exposed 
1114:             * by component registered statistics mbeans
1115:             * @param mbeanName stats mbean object name
1116:             * @return CompositeData containing the stats mbean's atributes
1117:             * @throws JBIRemoteException if the attributes could not be obtained
1118:             */
1119:            private CompositeData getCompStatsAttributes(ObjectName mbeanName)
1120:                    throws JBIRemoteException {
1121:                try {
1122:                    if (!isValidTarget(mbeanName)) {
1123:                        //for components that did not register custom stats mbean
1124:                        return null;
1125:                    }
1126:                    MBeanInfo mbeanInfo = getMBeanInfo(mbeanName);
1127:                    MBeanAttributeInfo[] attributes = mbeanInfo.getAttributes();
1128:
1129:                    String[] compExtnItems = new String[attributes.length];
1130:                    String[] compExtnDesc = new String[attributes.length];
1131:                    OpenType[] compExtnTypes = new OpenType[attributes.length];
1132:                    Object[] compAttrValues = new Object[attributes.length];
1133:
1134:                    for (int i = 0; i < attributes.length; i++) {
1135:                        String attrName = attributes[i].getName();
1136:                        String attrType = attributes[i].getType();
1137:                        Object attrValue = getMBeanAttribute(mbeanName,
1138:                                attrName);
1139:
1140:                        //create the composite type
1141:                        compExtnItems[i] = attrName;
1142:                        compExtnDesc[i] = attrName;
1143:                        compExtnTypes[i] = getOpenType(attrType, attrValue);
1144:                        compAttrValues[i] = attrValue;
1145:
1146:                        //logDebug("OpenType for " + attrType + " is " + compExtnTypes[i] );
1147:
1148:                    }
1149:                    return new CompositeDataSupport(new CompositeType(
1150:                            "ComponentExtensionStats",
1151:                            "Component extension stats", compExtnItems,
1152:                            compExtnDesc, compExtnTypes), compExtnItems,
1153:                            compAttrValues);
1154:
1155:                } catch (OpenDataException ex) {
1156:                    throw new JBIRemoteException(ex);
1157:                } catch (JBIRemoteException jbiRemoteEx) {
1158:                    logDebug("Component custom stats are not available: "
1159:                            + jbiRemoteEx.getMessage());
1160:                    return null;
1161:                } catch (Exception exception) {
1162:                    logDebug(exception);
1163:                    return null;
1164:                }
1165:            }
1166:
1167:            /**
1168:             * This method is used to get the stats for an endpoint
1169:             * @param targetName the target name
1170:             * @param instanceName instance name
1171:             * @param endpointName endpoint name
1172:             * @param messageServiceMBean object name
1173:             * @return CompositeData statistic info about the endpoint
1174:             * @throws JBIRemoteException if statistics could not be obtained
1175:             */
1176:            private CompositeData getEndpointStats(String targetName,
1177:                    String instanceName, String endpointName,
1178:                    ObjectName messageServiceStatsMBean)
1179:                    throws JBIRemoteException {
1180:                boolean isProvider = true;
1181:
1182:                CompositeData allEndpointStats = (CompositeData) invokeMBeanOperation(
1183:                        messageServiceStatsMBean, "getEndpointStatistics",
1184:                        new Object[] { endpointName },
1185:                        new String[] { "java.lang.String" });
1186:
1187:                if (allEndpointStats == null) {
1188:                    Exception exception = this .createManagementException(
1189:                            LocalStringKeys.ERROR_ENDPOINT_NOT_EXISTS,
1190:                            new String[] { endpointName }, null);
1191:                    logWarning(exception);
1192:                    throw new JBIRemoteException(exception);
1193:                }
1194:
1195:                Object[] exposedEndpointStatsProvider = null;
1196:                Object[] exposedEndpointStatsConsumer = null;
1197:                String owningComponent = null;
1198:                try {
1199:                    exposedEndpointStatsProvider = allEndpointStats
1200:                            .getAll(ENDPOINT_STATS_PROVIDER_ITEM_NAMES);
1201:                    owningComponent = (String) allEndpointStats
1202:                            .get(OWNING_COMPONENT);
1203:                } catch (javax.management.openmbean.InvalidKeyException invalidKeyException) {
1204:                    logDebug("All provider items are not present, could be consuming endpoint");
1205:                    isProvider = false;
1206:                }
1207:                if (!isProvider) {
1208:                    exposedEndpointStatsConsumer = allEndpointStats
1209:                            .getAll(ENDPOINT_STATS_CONSUMER_ITEM_NAMES);
1210:                }
1211:                TabularData ojcPerfTable = null;
1212:                ObjectName compStatsExtensionMBean = null;
1213:                Map<String, ObjectName> compStatsExtensionMBeans = null;
1214:
1215:                //check if we have a good component name before trying to locate component stats mbeans
1216:                if (owningComponent != null && owningComponent.length() > 0) {
1217:                    compStatsExtensionMBeans = getCompStatsExtensionMBeans(
1218:                            targetName, owningComponent);
1219:                }
1220:
1221:                if (compStatsExtensionMBeans != null) {
1222:                    compStatsExtensionMBean = compStatsExtensionMBeans
1223:                            .get(instanceName);
1224:                }
1225:                if (compStatsExtensionMBean != null) {
1226:                    //OJC components mark the endpoints as follows distinguish Provider/Consumer
1227:                    if (!endpointName.endsWith(COMMA)) {
1228:                        endpointName = endpointName + COMMA;
1229:                    }
1230:                    if (isProvider) {
1231:                        endpointName = endpointName + PROVIDER_MARKER;
1232:                    } else {
1233:                        endpointName = endpointName + CONSUMER_MARKER;
1234:                    }
1235:                    logDebug("Getting extension stats from component");
1236:                    ojcPerfTable = getOJCPerformanceMeasurement(
1237:                            compStatsExtensionMBean, endpointName);
1238:                }
1239:                return composeEndpointStats(instanceName, allEndpointStats,
1240:                        isProvider, ojcPerfTable);
1241:            }
1242:
1243:            /**
1244:             * This method is used to obtain a list of performance measurements 
1245:             * recorded by OJC components
1246:             * @param compMbeanName component stats object name
1247:             * @return TabularData performance measurement categories
1248:             */
1249:            private TabularData getOJCPerformanceMeasurement(
1250:                    ObjectName compMbeanName, String endpointName) {
1251:                try {
1252:                    TabularData allPerformanceStats = (TabularData) invokeMBeanOperation(
1253:                            compMbeanName,
1254:                            "getPerformanceInstrumentationMeasurement",
1255:                            new Object[] { endpointName },
1256:                            new String[] { "java.lang.String" });
1257:
1258:                    CompositeType performanceStatsType = new CompositeType(
1259:                            "PerformanceInstrumentationStats",
1260:                            "Performance Instrumentation Stats",
1261:                            OJC_HULP_STATS_ITEMS, OJC_HULP_STATS_DESCRIPTIONS,
1262:                            OJC_HULP_STATS_TYPES);
1263:
1264:                    TabularType performanceStatsTableType = new TabularType(
1265:                            "PerformanceInstrumentationStats",
1266:                            "Performance Instrumentation Stats",
1267:                            performanceStatsType, OJC_STATS_TABLE_INDEX);
1268:
1269:                    TabularData perfStats = new TabularDataSupport(
1270:                            performanceStatsTableType);
1271:
1272:                    Iterator iter = allPerformanceStats.values().iterator();
1273:
1274:                    while (iter.hasNext()) {
1275:                        CompositeData compositeData = (CompositeData) iter
1276:                                .next();
1277:                        CompositeType compositeType = compositeData
1278:                                .getCompositeType();
1279:                        Iterator perfStatsIter = compositeType.keySet()
1280:                                .iterator();
1281:                        Object[] values = new Object[OJC_HULP_STATS_ITEMS.length];
1282:
1283:                        while (perfStatsIter.hasNext()) {
1284:                            String item = (String) perfStatsIter.next();
1285:                            if (true == item.equals(AVERAGE_KEY)) {
1286:                                values[0] = (Double) compositeData.get(item);
1287:                            }
1288:                            if (true == item
1289:                                    .equals(AVERAGEWITHOUTFIRSTMEASUREMENT_KEY)) {
1290:                                values[1] = (Double) compositeData.get(item);
1291:                            }
1292:                            if (true == item.equals(FIRSTMEASUREMENTTIME_KEY)) {
1293:                                values[2] = (Double) compositeData.get(item);
1294:                            }
1295:                            if (true == item.equals(LOAD_KEY)) {
1296:                                values[3] = (Double) compositeData.get(item);
1297:                            }
1298:                            if (true == item
1299:                                    .equals(NUMBEROFMEASUREMENTOBJECTS_KEY)) {
1300:                                values[4] = (Integer) compositeData.get(item);
1301:                            }
1302:                            if (true == item.equals(NUMBEROFMEASUREMENTS_KEY)) {
1303:                                values[5] = (Integer) compositeData.get(item);
1304:                            }
1305:                            if (true == item.equals(THROUGHPUT_KEY)) {
1306:                                values[6] = (Double) compositeData.get(item);
1307:                            }
1308:                            if (true == item.equals(TIMETAKEN_KEY)) {
1309:                                values[7] = (Double) compositeData.get(item);
1310:                            }
1311:                            if (true == item.equals(TOTALTIME_KEY)) {
1312:                                values[8] = (Double) compositeData.get(item);
1313:                            }
1314:                            if (true == item.equals(MEDIAN_KEY)) {
1315:                                values[9] = (Double) compositeData.get(item);
1316:                            }
1317:                            if (true == item.equals(SOURCE_KEY)) {
1318:                                values[10] = (String) compositeData.get(item);
1319:                            }
1320:                            if (true == item.equals(SUB_TOPIC_KEY)) {
1321:                                values[11] = (String) compositeData.get(item);
1322:                            }
1323:                            if (true == item.equals(TOPIC_KEY)) {
1324:                                values[12] = (String) compositeData.get(item);
1325:                            }
1326:                        }
1327:                        perfStats.put(new CompositeDataSupport(
1328:                                performanceStatsType, OJC_HULP_STATS_ITEMS,
1329:                                values));
1330:
1331:                    }
1332:                    return perfStats;
1333:                } catch (OpenDataException openDataEx) {
1334:                    //issues in composing the perf stats
1335:                    logWarning(openDataEx);
1336:                    return null;
1337:                } catch (JBIRemoteException jbiRemoteEx) {
1338:                    //may not be an OJC component. do not log warning
1339:                    logDebug("Perfomance Instrumentation details are not available: "
1340:                            + jbiRemoteEx.getMessage());
1341:                    return null;
1342:                } catch (Exception ex) {
1343:                    logWarning(ex);
1344:                    return null;
1345:                }
1346:
1347:            }
1348:
1349:            /**
1350:             * This method is used to compose endpoint stats
1351:             * @param instanceName
1352:             * @param endpointStats endpoint stats
1353:             * @param isProvider true if this is a provider endpoint
1354:             * @param ojcStats table of performance data
1355:             * @return CompositeData composite data
1356:             *
1357:             */
1358:            private CompositeData composeEndpointStats(String instanceName,
1359:                    CompositeData endpointStats, boolean isProvider,
1360:                    TabularData ojcStats) {
1361:                try {
1362:                    if (isProvider) {
1363:                        return composeProviderEndpointStats(instanceName,
1364:                                endpointStats, ojcStats);
1365:                    } else {
1366:                        return composeConsumerEndpointStats(instanceName,
1367:                                endpointStats, ojcStats);
1368:                    }
1369:                } catch (Exception ex) {
1370:                    logWarning(ex);
1371:                    return null;
1372:                }
1373:            }
1374:
1375:            /**
1376:             * This method is used to compose provider endpoint stats
1377:             * @param instanceName
1378:             * @param endpointStats endpoint stats
1379:             * @param ojcStats table of performance data
1380:             * @return CompositeData composite data
1381:             *
1382:             */
1383:            private CompositeData composeProviderEndpointStats(
1384:                    String instanceName, CompositeData endpointStats,
1385:                    TabularData ojcStats) {
1386:
1387:                TabularType ojcStatsType = null;
1388:                if (ojcStats != null) {
1389:                    ojcStatsType = ojcStats.getTabularType();
1390:                }
1391:
1392:                ArrayList<String> providerItemNames = new ArrayList<String>();
1393:                providerItemNames.add(JBIStatisticsItemNames.INSTANCE_NAME);
1394:                providerItemNames
1395:                        .add(JBIStatisticsItemNames.PROVIDER_ENDPOINT_ACTIVATION_TIME);
1396:                providerItemNames
1397:                        .add(JBIStatisticsItemNames.PROVIDER_ENDPOINT_UPTIME);
1398:                providerItemNames
1399:                        .add(JBIStatisticsItemNames.NUMBER_OF_ACTIVE_EXCHANGES);
1400:                providerItemNames
1401:                        .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_REQUESTS);
1402:                providerItemNames
1403:                        .add(JBIStatisticsItemNames.NUMBER_OF_SENT_REPLIES);
1404:                providerItemNames
1405:                        .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_DONES);
1406:                providerItemNames
1407:                        .add(JBIStatisticsItemNames.NUMBER_OF_SENT_DONES);
1408:                providerItemNames
1409:                        .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_FAULTS);
1410:                providerItemNames
1411:                        .add(JBIStatisticsItemNames.NUMBER_OF_SENT_FAULTS);
1412:                providerItemNames
1413:                        .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_ERRORS);
1414:                providerItemNames
1415:                        .add(JBIStatisticsItemNames.NUMBER_OF_SENT_ERRORS);
1416:                providerItemNames
1417:                        .add(JBIStatisticsItemNames.ENDPOINT_COMPONENT_NAME);
1418:                providerItemNames
1419:                        .add(JBIStatisticsItemNames.MESSAGE_EXCHANGE_RESPONSE_TIME);
1420:                providerItemNames
1421:                        .add(JBIStatisticsItemNames.MESSAGE_EXCHANGE_COMPONENT_TIME);
1422:                providerItemNames
1423:                        .add(JBIStatisticsItemNames.MESSAGE_EXCHANGE_DELIVERY_CHANNEL_TIME);
1424:                providerItemNames
1425:                        .add(JBIStatisticsItemNames.MESSAGE_EXCHANGE_NMR_TIME);
1426:                if (ojcStatsType != null) {
1427:                    providerItemNames
1428:                            .add(JBIStatisticsItemNames.OJC_PERFORMANCE_STATS);
1429:                }
1430:
1431:                ArrayList<String> providerItemDescriptions = new ArrayList<String>();
1432:                providerItemDescriptions.add("Instance Name");
1433:                providerItemDescriptions.add("Time of activation");
1434:                providerItemDescriptions.add("Endpoint upTime");
1435:                providerItemDescriptions.add("Number of Active Exchanges");
1436:                providerItemDescriptions.add("Number of Received Requests");
1437:                providerItemDescriptions.add("Number of Sent Replies");
1438:                providerItemDescriptions.add("Number of Received DONEs");
1439:                providerItemDescriptions.add("Number of Sent DONEs");
1440:                providerItemDescriptions.add("Number of Received Faults");
1441:                providerItemDescriptions.add("Number of Sent Faults");
1442:                providerItemDescriptions.add("Number of Received Errors");
1443:                providerItemDescriptions.add("Number of Sent Errors");
1444:                providerItemDescriptions.add("Component Name");
1445:                providerItemDescriptions
1446:                        .add("Message Exchange ResponseTime Avg in ns");
1447:                providerItemDescriptions
1448:                        .add("Message Exchange ComponentTime Avg in ns");
1449:                providerItemDescriptions
1450:                        .add("Message Exchange DeliveryChannelTime Avg in ns");
1451:                providerItemDescriptions
1452:                        .add("Message Exchange MessageServiceTime  Avg in ns");
1453:                if (ojcStatsType != null) {
1454:                    providerItemDescriptions
1455:                            .add("Performance Measurements recorded by OJC Components");
1456:                }
1457:
1458:                ArrayList<OpenType> providerItemTypes = new ArrayList<OpenType>();
1459:                providerItemTypes.add(SimpleType.STRING);
1460:                providerItemTypes.add(SimpleType.DATE);
1461:                providerItemTypes.add(SimpleType.LONG);
1462:                providerItemTypes.add(SimpleType.LONG);
1463:                providerItemTypes.add(SimpleType.LONG);
1464:                providerItemTypes.add(SimpleType.LONG);
1465:                providerItemTypes.add(SimpleType.LONG);
1466:                providerItemTypes.add(SimpleType.LONG);
1467:                providerItemTypes.add(SimpleType.LONG);
1468:                providerItemTypes.add(SimpleType.LONG);
1469:                providerItemTypes.add(SimpleType.LONG);
1470:                providerItemTypes.add(SimpleType.LONG);
1471:                providerItemTypes.add(SimpleType.STRING);
1472:                providerItemTypes.add(SimpleType.LONG);
1473:                providerItemTypes.add(SimpleType.LONG);
1474:                providerItemTypes.add(SimpleType.LONG);
1475:                providerItemTypes.add(SimpleType.LONG);
1476:                if (ojcStatsType != null) {
1477:                    providerItemTypes.add(ojcStatsType);
1478:                }
1479:                ;
1480:
1481:                //convert uptime from long to date
1482:                //calculate uptime from activation time        
1483:                Date activationTime = null;
1484:                long upTime = 0;
1485:                Long activationTimeStamp = (Long) endpointStats
1486:                        .get(PROVIDER_ACTIVATION_TIMESTAMP);
1487:                if (activationTimeStamp != null) {
1488:                    activationTime = new Date(activationTimeStamp.longValue());
1489:                    upTime = System.currentTimeMillis()
1490:                            - activationTime.getTime();
1491:                }
1492:
1493:                ArrayList<Object> providerItemValues = new ArrayList<Object>();
1494:                providerItemValues.add(instanceName);
1495:                providerItemValues.add(activationTime);
1496:                providerItemValues.add(new Long(upTime)); //uptime is calculated here
1497:                providerItemValues.add(endpointStats
1498:                        .get(COMPONENT_ACTIVE_EXCHANGE));
1499:                providerItemValues.add(endpointStats
1500:                        .get(COMPONENT_RECEIVE_REQUEST));
1501:                providerItemValues.add(endpointStats.get(COMPONENT_SEND_REPLY));
1502:                providerItemValues.add(endpointStats
1503:                        .get(COMPONENT_RECEIVE_DONE));
1504:                providerItemValues.add(endpointStats.get(COMPONENT_SEND_DONE));
1505:                providerItemValues.add(endpointStats
1506:                        .get(COMPONENT_RECEIVE_FAULT));
1507:                providerItemValues.add(endpointStats.get(COMPONENT_SEND_FAULT));
1508:                providerItemValues.add(endpointStats
1509:                        .get(COMPONENT_RECEIVE_ERROR));
1510:                providerItemValues.add(endpointStats.get(COMPONENT_SEND_ERROR));
1511:                providerItemValues.add(endpointStats.get(OWNING_COMPONENT));
1512:                providerItemValues.add(endpointStats
1513:                        .get(COMPONENT_RESPONSE_TIME));
1514:                providerItemValues.add(endpointStats
1515:                        .get(COMPONENT_CHANNEL_TIME));
1516:                providerItemValues.add(endpointStats
1517:                        .get(COMPONENT_COMPONENT_TIME));
1518:                providerItemValues.add(endpointStats.get(COMPONENT_NMR_TIME));
1519:                if (ojcStatsType != null) {
1520:                    providerItemValues.add(ojcStats);
1521:                }
1522:
1523:                try {
1524:                    return new CompositeDataSupport(new CompositeType(
1525:                            JBIStatisticsItemNames.PROVIDER_STATS_NAME,
1526:                            JBIStatisticsItemNames.PROVIDER_STATS_DESCRIPTION,
1527:                            (String[]) providerItemNames
1528:                                    .toArray(new String[] {}),
1529:                            (String[]) providerItemDescriptions
1530:                                    .toArray(new String[] {}),
1531:                            (OpenType[]) providerItemTypes
1532:                                    .toArray(new OpenType[] {})),
1533:                            (String[]) providerItemNames
1534:                                    .toArray(new String[] {}),
1535:                            (Object[]) providerItemValues
1536:                                    .toArray(new Object[] {}));
1537:                } catch (OpenDataException ode) {
1538:                    //if stats could not be composed return null and proceed with other instances
1539:                    logWarning(ode);
1540:                    return null;
1541:                }
1542:            }
1543:
1544:            /**
1545:             * This method is used to compose consumer endpoint stats
1546:             * @param instanceName
1547:             * @param endpointStats endpoint stats
1548:             * @param ojcStats table of performance data
1549:             * @return CompositeData composite data
1550:             *
1551:             */
1552:            private CompositeData composeConsumerEndpointStats(
1553:                    String instanceName, CompositeData endpointStats,
1554:                    TabularData ojcStats) {
1555:
1556:                TabularType ojcStatsType = null;
1557:                if (ojcStats != null) {
1558:                    ojcStatsType = ojcStats.getTabularType();
1559:                }
1560:
1561:                ArrayList<String> consumerItemNames = new ArrayList<String>();
1562:                consumerItemNames.add(JBIStatisticsItemNames.INSTANCE_NAME);
1563:                consumerItemNames
1564:                        .add(JBIStatisticsItemNames.NUMBER_OF_SENT_REQUESTS);
1565:                consumerItemNames
1566:                        .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_REPLIES);
1567:                consumerItemNames
1568:                        .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_DONES);
1569:                consumerItemNames
1570:                        .add(JBIStatisticsItemNames.NUMBER_OF_SENT_DONES);
1571:                consumerItemNames
1572:                        .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_FAULTS);
1573:                consumerItemNames
1574:                        .add(JBIStatisticsItemNames.NUMBER_OF_SENT_FAULTS);
1575:                consumerItemNames
1576:                        .add(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_ERRORS);
1577:                consumerItemNames
1578:                        .add(JBIStatisticsItemNames.NUMBER_OF_SENT_ERRORS);
1579:                consumerItemNames
1580:                        .add(JBIStatisticsItemNames.NUMBER_OF_ACTIVE_EXCHANGES);
1581:                consumerItemNames
1582:                        .add(JBIStatisticsItemNames.ENDPOINT_COMPONENT_NAME);
1583:                consumerItemNames
1584:                        .add(JBIStatisticsItemNames.CONSUMING_ENDPOINT_STATUS_TIME);
1585:                consumerItemNames
1586:                        .add(JBIStatisticsItemNames.MESSAGE_EXCHANGE_COMPONENT_TIME);
1587:                consumerItemNames
1588:                        .add(JBIStatisticsItemNames.MESSAGE_EXCHANGE_DELIVERY_CHANNEL_TIME);
1589:                consumerItemNames
1590:                        .add(JBIStatisticsItemNames.MESSAGE_EXCHANGE_NMR_TIME);
1591:                if (ojcStatsType != null) {
1592:                    consumerItemNames
1593:                            .add(JBIStatisticsItemNames.OJC_PERFORMANCE_STATS);
1594:                }
1595:
1596:                ArrayList<String> consumerItemDescriptions = new ArrayList<String>();
1597:                consumerItemDescriptions.add("Instance Name");
1598:                consumerItemDescriptions.add("Number of Sent Requests");
1599:                consumerItemDescriptions.add("Number of Received Replies");
1600:                consumerItemDescriptions.add("Number of Received DONEs");
1601:                consumerItemDescriptions.add("Number of Sent DONEs");
1602:                consumerItemDescriptions.add("Number of Received Faults");
1603:                consumerItemDescriptions.add("Number of Sent Faults");
1604:                consumerItemDescriptions.add("Number of Received Errors");
1605:                consumerItemDescriptions.add("Number of Sent Errors");
1606:                consumerItemDescriptions.add("Number of active exchanges");
1607:                consumerItemDescriptions.add("Name of the owning component");
1608:                consumerItemDescriptions
1609:                        .add("Message Exchange Status Time Avg in ns");
1610:                consumerItemDescriptions
1611:                        .add("Message Exchange ComponentTime Avg in ns");
1612:                consumerItemDescriptions
1613:                        .add("Message Exchange DeliveryChannelTime Avg in ns");
1614:                consumerItemDescriptions
1615:                        .add("Message Exchange MessageServiceTime  Avg in ns");
1616:                if (ojcStatsType != null) {
1617:                    consumerItemDescriptions
1618:                            .add("Performance Measurements recorded by OJC Components");
1619:                }
1620:                ;
1621:
1622:                ArrayList<OpenType> consumerItemTypes = new ArrayList<OpenType>();
1623:                consumerItemTypes.add(SimpleType.STRING);
1624:                consumerItemTypes.add(SimpleType.LONG);
1625:                consumerItemTypes.add(SimpleType.LONG);
1626:                consumerItemTypes.add(SimpleType.LONG);
1627:                consumerItemTypes.add(SimpleType.LONG);
1628:                consumerItemTypes.add(SimpleType.LONG);
1629:                consumerItemTypes.add(SimpleType.LONG);
1630:                consumerItemTypes.add(SimpleType.LONG);
1631:                consumerItemTypes.add(SimpleType.LONG);
1632:                consumerItemTypes.add(SimpleType.LONG);
1633:                consumerItemTypes.add(SimpleType.STRING);
1634:                consumerItemTypes.add(SimpleType.LONG);
1635:                consumerItemTypes.add(SimpleType.LONG);
1636:                consumerItemTypes.add(SimpleType.LONG);
1637:                consumerItemTypes.add(SimpleType.LONG);
1638:                if (ojcStatsType != null) {
1639:                    consumerItemTypes.add(ojcStatsType);
1640:                }
1641:
1642:                ArrayList<Object> consumerItemValues = new ArrayList<Object>();
1643:                consumerItemValues.add(instanceName);
1644:                consumerItemValues.add(endpointStats
1645:                        .get(COMPONENT_SEND_REQUEST));
1646:                consumerItemValues.add(endpointStats
1647:                        .get(COMPONENT_RECEIVE_REPLY));
1648:                consumerItemValues.add(endpointStats
1649:                        .get(COMPONENT_RECEIVE_DONE));
1650:                consumerItemValues.add(endpointStats.get(COMPONENT_SEND_DONE));
1651:                consumerItemValues.add(endpointStats
1652:                        .get(COMPONENT_RECEIVE_FAULT));
1653:                consumerItemValues.add(endpointStats.get(COMPONENT_SEND_FAULT));
1654:                consumerItemValues.add(endpointStats
1655:                        .get(COMPONENT_RECEIVE_ERROR));
1656:                consumerItemValues.add(endpointStats.get(COMPONENT_SEND_ERROR));
1657:                consumerItemValues.add(endpointStats
1658:                        .get(COMPONENT_ACTIVE_EXCHANGE));
1659:                consumerItemValues.add(endpointStats.get(OWNING_COMPONENT));
1660:                consumerItemValues.add(endpointStats.get(CONSUMER_STATUS_TIME));
1661:                consumerItemValues.add(endpointStats
1662:                        .get(COMPONENT_COMPONENT_TIME));
1663:                consumerItemValues.add(endpointStats
1664:                        .get(COMPONENT_CHANNEL_TIME));
1665:                consumerItemValues.add(endpointStats.get(COMPONENT_NMR_TIME));
1666:
1667:                if (ojcStatsType != null) {
1668:                    consumerItemValues.add(ojcStats);
1669:                }
1670:
1671:                try {
1672:                    return new CompositeDataSupport(
1673:                            new CompositeType(
1674:                                    JBIStatisticsItemNames.CONSUMING_ENDPOINT_STATS_NAME,
1675:                                    JBIStatisticsItemNames.CONSUMING_ENDPOINT_STATS_DESCRIPTION,
1676:                                    (String[]) consumerItemNames
1677:                                            .toArray(new String[] {}),
1678:                                    (String[]) consumerItemDescriptions
1679:                                            .toArray(new String[] {}),
1680:                                    (SimpleType[]) consumerItemTypes
1681:                                            .toArray(new SimpleType[] {})),
1682:                            (String[]) consumerItemNames
1683:                                    .toArray(new String[] {}),
1684:                            (Object[]) consumerItemValues
1685:                                    .toArray(new Object[] {}));
1686:                } catch (OpenDataException ode) {
1687:                    logWarning(ode);
1688:                    return null;
1689:                }
1690:
1691:            }
1692:
1693:            /**
1694:             * This method is used to construct an OpenType for the given java class
1695:             * @param javaType the java class name
1696:             * @param value the object 
1697:             * @return OpenType OpenType corresponding to the given javaType
1698:             * @throws JBIRemoteException if there are issues in getting the OpenType
1699:             */
1700:            private OpenType getOpenType(String javaType, Object value)
1701:                    throws JBIRemoteException {
1702:
1703:                try {
1704:                    if (javaType
1705:                            .equals("javax.management.openmbean.CompositeType")) {
1706:                        //handle compositetype
1707:                        return ((CompositeData) value).getCompositeType();
1708:                    } else if (javaType
1709:                            .equals("javax.management.openmbean.TabularType")) {
1710:                        //handle tabulartype
1711:                        return ((TabularData) value).getTabularType();
1712:                    } else if (javaType.startsWith("[")) {
1713:                        //handle arraytype
1714:                        String className = javaType.substring(javaType
1715:                                .indexOf("java"), javaType.length() - 1);
1716:                        //TODO find out how many times [ comes to decide the dimension of the array            
1717:                        return new ArrayType(1, JAVATYPE_TO_OPENTYPE
1718:                                .get(className));
1719:                    } else {
1720:                        return JAVATYPE_TO_OPENTYPE.get(javaType);
1721:                    }
1722:                } catch (OpenDataException ex) {
1723:                    throw new JBIRemoteException(ex);
1724:                }
1725:
1726:            }
1727:
1728:            /**
1729:             * This method is used to find out if a component is started in a given target
1730:             * @param componentName componentName
1731:             * @param targetName target name
1732:             * @return true if the component is started
1733:             */
1734:            private boolean isComponentUp(String componentName,
1735:                    String targetName) {
1736:                ComponentQuery compQuery = mEnvContext
1737:                        .getComponentQuery(targetName);
1738:                ComponentInfo compInfo = compQuery
1739:                        .getComponentInfo(componentName);
1740:                logDebug("Component status in target " + targetName + " is "
1741:                        + compInfo.getStatus());
1742:                if (compInfo.getStatus() == ComponentState.STARTED) {
1743:                    return true;
1744:                } else {
1745:                    return false;
1746:                }
1747:            }
1748:
1749:            /**
1750:             * This method is used to find out if a component is installed in a given target
1751:             * @param componentName componentName
1752:             * @param targetName target name
1753:             * @return true if the component is started
1754:             */
1755:            private boolean isComponentInstalled(String componentName,
1756:                    String targetName) {
1757:                ComponentQuery compQuery = mEnvContext
1758:                        .getComponentQuery(targetName);
1759:                if (compQuery.getComponentInfo(componentName) == null) {
1760:                    return false;
1761:                } else {
1762:                    return true;
1763:                }
1764:            }
1765:
1766:            /**
1767:             * This method is used to provide a list of consuming endpoints for a component.
1768:             * @param componentName component name
1769:             * @param target target name.
1770:             * @return TabularData list of consuming endpoints 
1771:             * @throws JBIRemoteException if the list of endpoints could not be obtained.
1772:             *
1773:             * If the target is a standalone instance the table will have one entry.
1774:             * If the target is a cluster the table will have an entry for each instance.
1775:             *
1776:             * For more information about the type of the entries in table please refer
1777:             * to <code>JBIStatisticsMBean</code>
1778:             */
1779:            public TabularData getConsumingEndpointsForComponent(
1780:                    String componentName, String targetName)
1781:                    throws JBIRemoteException {
1782:                return getEndpointListForComponent(componentName, targetName,
1783:                        true);
1784:            }
1785:
1786:            /**
1787:             * This method is used to provide a list of provisioning endpoints for a component.
1788:             * @param componentName component name
1789:             * @param target target name.
1790:             * @return TabularData list of provisioning endpoints 
1791:             * @throws JBIRemoteException if the list of endpoints could not be obtained.
1792:             *
1793:             * If the target is a standalone instance the table will have one entry.
1794:             * If the target is a cluster the table will have an entry for each instance.
1795:             *
1796:             * For more information about the type of the entries in table please refer
1797:             * to <code>JBIStatisticsMBean</code>
1798:             */
1799:            public TabularData getProvidingEndpointsForComponent(
1800:                    String componentName, String targetName)
1801:                    throws JBIRemoteException {
1802:                return getEndpointListForComponent(componentName, targetName,
1803:                        false);
1804:            }
1805:
1806:            /**
1807:             * This method is used to provide a list of consuming endpoints for a component.
1808:             * @param componentName component name
1809:             * @param target target name.
1810:             * @param listConsuming true if you need a list of consuming endpoints
1811:             * @return TabularData list of consuming endpoints 
1812:             *
1813:             * If the target is a standalone instance the table will have one entry.
1814:             * If the target is a cluster the table will have an entry for each instance.
1815:             *
1816:             * For more information about the type of the entries in table please refer
1817:             * to <code>JBIStatisticsMBean</code>
1818:             */
1819:            public TabularData getEndpointListForComponent(
1820:                    String componentName, String targetName,
1821:                    boolean listConsuming) throws JBIRemoteException {
1822:                try {
1823:
1824:                    if (!isComponentInstalled(componentName, targetName)) {
1825:                        Exception exception = this .createManagementException(
1826:                                LocalStringKeys.STATS_COMP_NOT_INSTALLED,
1827:                                new String[] { componentName, targetName },
1828:                                null);
1829:                        logWarning(exception);
1830:                        throw new JBIRemoteException(exception);
1831:                    }
1832:
1833:                    Map<String, ObjectName> nmrMBeans = getNMRStatsMBeans(targetName);
1834:                    Set<String> instances = nmrMBeans.keySet();
1835:
1836:                    OpenType[] endpointListItemTypes = { SimpleType.STRING,
1837:                            new ArrayType(1, SimpleType.STRING), };
1838:
1839:                    CompositeType endpointListCompositeType = new CompositeType(
1840:                            JBIStatisticsItemNames.ENDPOINT_LIST_STATISTICS_NAME,
1841:                            JBIStatisticsItemNames.ENDPOINT_LIST_STATISTICS_DESCRIPTION,
1842:                            ENDPOINT_LIST_STATS_ITEM_NAMES,
1843:                            ENDPOINT_LIST_STATS_ITEM_DESCRIPTIONS,
1844:                            endpointListItemTypes);
1845:
1846:                    TabularType endpointListTabularType = new TabularType(
1847:                            JBIStatisticsItemNames.ENDPOINT_LIST_STATISTICS_TABLE_NAME,
1848:                            JBIStatisticsItemNames.ENDPOINT_LIST_STATISTICS_TABLE_DESCRIPTION,
1849:                            endpointListCompositeType,
1850:                            JBIStatisticsItemNames.STATS_TABLE_INDEX);
1851:
1852:                    TabularData endpointListTable = new TabularDataSupport(
1853:                            endpointListTabularType);
1854:
1855:                    for (String instance : instances) {
1856:                        ObjectName mbean = nmrMBeans.get(instance);
1857:                        if (mbean != null) {
1858:                            logDebug("Getting endpoint list statistics for "
1859:                                    + instance);
1860:                            endpointListTable.put(getEndpointsList(
1861:                                    endpointListCompositeType, instance,
1862:                                    componentName, mbean, listConsuming));
1863:                        }
1864:
1865:                    }
1866:
1867:                    return endpointListTable;
1868:                } catch (OpenDataException ex) {
1869:                    Exception exception = this .createManagementException(
1870:                            LocalStringKeys.ERROR_IN_STATS_COMPOSING,
1871:                            new String[] { targetName }, ex);
1872:                    logWarning(ex);
1873:                    throw new JBIRemoteException(exception);
1874:
1875:                }
1876:            }
1877:
1878:            /**
1879:             * This method is used to query the list of endpoints in a component 
1880:             * in the given service assembly.
1881:             * @param endpointListStatsEntriesType composite type of the endpoint list data
1882:             * @param instanceName instance name 
1883:             * @param componentName the component name
1884:             * @param listConsuming true if consuming endpoints have to be queried
1885:             * @param mbean name of the NMR stats MBean
1886:             */
1887:            private CompositeData getEndpointsList(
1888:                    CompositeType endpointListStatsEntriesType,
1889:                    String instanceName, String componentName,
1890:                    ObjectName mbean, boolean listConsuming)
1891:                    throws JBIRemoteException {
1892:                try {
1893:                    String endpointQueryMethodName;
1894:                    if (listConsuming) {
1895:                        endpointQueryMethodName = QUERY_CONSUMING_ENDPOINT_LIST;
1896:                    } else {
1897:                        endpointQueryMethodName = QUERY_ENDPOINT_LIST;
1898:                    }
1899:
1900:                    String[] endpointsList = (String[]) invokeMBeanOperation(
1901:                            mbean, endpointQueryMethodName,
1902:                            new Object[] { componentName },
1903:                            new String[] { "java.lang.String" });
1904:
1905:                    Object[] values = { instanceName, endpointsList };
1906:
1907:                    return new CompositeDataSupport(
1908:                            endpointListStatsEntriesType,
1909:                            ENDPOINT_LIST_STATS_ITEM_NAMES, values);
1910:
1911:                } catch (OpenDataException ex) {
1912:                    throw new JBIRemoteException(ex);
1913:                }
1914:            }
1915:
1916:            /**  
1917:             * table index for OJC hulp statistics
1918:             */
1919:            static String[] STATS_TABLE_INDEX = new String[] { "InstanceName" };
1920:
1921:            /** 
1922:             * attr. name for startup time in framework stats. mbean
1923:             */
1924:            static String FRAMEWORK_MBEAN_STARTUP_TIME_ATTR = "StartupTime";
1925:
1926:            /** 
1927:             * attr. name for last restart time in framework stats, mbean
1928:             */
1929:            static String FRAMEWORK_MBEAN_LAST_RESTART_TIME_ATTR = "LastRestartTime";
1930:
1931:            /** 
1932:             * FrameworkStats CompositeType item names   
1933:             */
1934:            static String[] FRAMEWORK_STATS_ITEM_NAMES = {
1935:                    JBIStatisticsItemNames.INSTANCE_NAME,
1936:                    JBIStatisticsItemNames.FRAMEWORK_STARTUP_TIME,
1937:                    JBIStatisticsItemNames.FRAMEWORK_UPTIME };
1938:
1939:            /** 
1940:             * FrameworkStats CompositeType item descriptions   
1941:             */
1942:            static String[] FRAMEWORK_STATS_ITEM_DESCRIPTIONS = {
1943:                    "Instance Name",
1944:                    "Time taken to startup the framework (ms)",
1945:                    "Time elapsed since framework has been started (ms)" };
1946:
1947:            /** 
1948:             * FrameworkStats CompositeType item types   
1949:             */
1950:            static OpenType[] FRAMEWORK_STATS_ITEM_TYPES = { SimpleType.STRING,
1951:                    SimpleType.LONG, SimpleType.LONG };
1952:
1953:            /** 
1954:             * attr. name  for active channels in NMR stats MBean.
1955:             */
1956:            static String NMR_MBEAN_ACTIVE_CHANNELS_ATTR = "ActiveChannels";
1957:
1958:            /** 
1959:             * attr. name for active endpoints in NMR stats MBean.
1960:             */
1961:            static String NMR_MBEAN_ACTIVE_ENDPOINTS_ATTR = "ActiveEndpoints";
1962:
1963:            /** 
1964:             * nmr CompositeType item names   
1965:             */
1966:            static String[] NMR_STATS_ITEM_NAMES = {
1967:                    JBIStatisticsItemNames.INSTANCE_NAME,
1968:                    JBIStatisticsItemNames.NMR_STATS_ACTIVE_CHANNELS,
1969:                    JBIStatisticsItemNames.NMR_STATS_ACTIVE_ENDPOINTS };
1970:
1971:            /** 
1972:             * nmr CompositeType item descriptions   
1973:             */
1974:            static String[] NMR_STATS_ITEM_DESCRIPTIONS = { "Instance Name",
1975:                    "List of active delivery channels",
1976:                    "List of active endpoints" };
1977:
1978:            /** 
1979:             * attr. name for last restart time in 
1980:             * component statistics mbean
1981:             */
1982:            static String COMPONENT_LAST_RESTART_TIME_ATTR = "LastRestartTime";
1983:
1984:            /**
1985:             * item name for active endpoints in component statistics data 
1986:             */
1987:            static String COMPONENT_ACTIVE_ENDPOINTS = "ActiveEndpoints";
1988:
1989:            /**
1990:             * item name for number of received requests in component statistics data 
1991:             */
1992:            static String COMPONENT_RECEIVE_REQUEST = "ReceiveRequest";
1993:
1994:            /**
1995:             * item name for number of sent requests in component statistics data 
1996:             */
1997:            static String COMPONENT_SEND_REQUEST = "SendRequest";
1998:
1999:            /**
2000:             * item name for number of received replies in component statistics data 
2001:             */
2002:            static String COMPONENT_RECEIVE_REPLY = "ReceiveReply";
2003:
2004:            /**
2005:             * item name for number of sent replies in component statistics data 
2006:             */
2007:            static String COMPONENT_SEND_REPLY = "SendReply";
2008:
2009:            /**
2010:             * item name for number of received DONEs in component statistics data 
2011:             */
2012:            static String COMPONENT_RECEIVE_DONE = "ReceiveDONE";
2013:
2014:            /**
2015:             * item name for number of sent DONEs requests in component statistics data 
2016:             */
2017:            static String COMPONENT_SEND_DONE = "SendDONE";
2018:
2019:            /**
2020:             * item name for number of received faults in component statistics data 
2021:             */
2022:            static String COMPONENT_RECEIVE_FAULT = "ReceiveFault";
2023:
2024:            /**
2025:             * item name for number of sent faults in component statistics data 
2026:             */
2027:            static String COMPONENT_SEND_FAULT = "SendFault";
2028:
2029:            /**
2030:             * item name for number of received errors in component statistics data 
2031:             */
2032:            static String COMPONENT_RECEIVE_ERROR = "ReceiveERROR";
2033:
2034:            /**
2035:             * item name for number of sent errors in component statistics data 
2036:             */
2037:            static String COMPONENT_SEND_ERROR = "SendERROR";
2038:
2039:            /**
2040:             * item name for number of active exchangesin component statistics data 
2041:             */
2042:            static String COMPONENT_ACTIVE_EXCHANGE = "ActiveExchanges";
2043:
2044:            /**
2045:             * item name for response time in component statistics data 
2046:             */
2047:            static String COMPONENT_RESPONSE_TIME = "ResponseTimeAvg (ns)";
2048:
2049:            /**
2050:             * item name for component time in component statistics data 
2051:             */
2052:            static String COMPONENT_COMPONENT_TIME = "ComponentTimeAvg (ns)";
2053:
2054:            /**
2055:             * item name for channel time in component statistics data 
2056:             */
2057:            static String COMPONENT_CHANNEL_TIME = "ChannelTimeAvg (ns)";
2058:
2059:            /**
2060:             * item name for nmr time in component statistics data 
2061:             */
2062:            static String COMPONENT_NMR_TIME = "NMRTimeAvg (ns)";
2063:
2064:            /**
2065:             * item name for owning component in endpoint statistics data 
2066:             */
2067:            static String OWNING_COMPONENT = "OwningChannel";
2068:
2069:            /**
2070:             * item name for activation time stamp in endpoint statistics data
2071:             */
2072:            static String PROVIDER_ACTIVATION_TIMESTAMP = "ActivationTimestamp";
2073:
2074:            /**
2075:             * item name for status time in endpoint statistics data 
2076:             */
2077:            static String CONSUMER_STATUS_TIME = "StatusTimeAvg (ns)";
2078:
2079:            /** 
2080:             * endpoint stats items - provider specific 
2081:             *  used to find out if the endpoint is a provider
2082:             */
2083:            static String[] ENDPOINT_STATS_PROVIDER_ITEM_NAMES = {
2084:                    PROVIDER_ACTIVATION_TIMESTAMP, COMPONENT_RECEIVE_REQUEST,
2085:                    COMPONENT_SEND_REPLY, COMPONENT_RESPONSE_TIME };
2086:
2087:            /** 
2088:             * endpoint stats items - consumer specific
2089:             *  used to find out if the endpoint is a consumer
2090:             */
2091:            static String[] ENDPOINT_STATS_CONSUMER_ITEM_NAMES = {
2092:                    COMPONENT_SEND_REQUEST, COMPONENT_RECEIVE_REPLY,
2093:                    CONSUMER_STATUS_TIME };
2094:
2095:            /**
2096:             * names of items in the composite data for endpoints list
2097:             */
2098:            static String[] ENDPOINT_LIST_STATS_ITEM_NAMES = {
2099:                    JBIStatisticsItemNames.INSTANCE_NAME,
2100:                    JBIStatisticsItemNames.ENDPOINTS_LIST_ITEM_NAME };
2101:
2102:            /**
2103:             * descriptions of items in the composite data for endpoints list
2104:             */
2105:            static String[] ENDPOINT_LIST_STATS_ITEM_DESCRIPTIONS = {
2106:                    "Instance Name", "List of endpoints" };
2107:
2108:            /** map used to convery a java type to OpenType */
2109:            static Map<String, OpenType> JAVATYPE_TO_OPENTYPE = new HashMap<String, OpenType>();
2110:
2111:            /* populate the map */
2112:            static {
2113:                JAVATYPE_TO_OPENTYPE.put("java.lang.Long", SimpleType.LONG);
2114:                JAVATYPE_TO_OPENTYPE.put("java.lang.String", SimpleType.STRING);
2115:                JAVATYPE_TO_OPENTYPE.put("java.lang.Boolean",
2116:                        SimpleType.BOOLEAN);
2117:                JAVATYPE_TO_OPENTYPE.put("java.lang.Character",
2118:                        SimpleType.CHARACTER);
2119:                JAVATYPE_TO_OPENTYPE.put("java.lang.Byte", SimpleType.BYTE);
2120:                JAVATYPE_TO_OPENTYPE.put("java.lang.Short", SimpleType.SHORT);
2121:                JAVATYPE_TO_OPENTYPE.put("java.lang.Integer",
2122:                        SimpleType.INTEGER);
2123:                JAVATYPE_TO_OPENTYPE.put("java.lang.Float", SimpleType.FLOAT);
2124:                JAVATYPE_TO_OPENTYPE.put("java.lang.Double", SimpleType.DOUBLE);
2125:                JAVATYPE_TO_OPENTYPE.put("java.lang.BigDecimal",
2126:                        SimpleType.BIGDECIMAL);
2127:                JAVATYPE_TO_OPENTYPE.put("java.lang.BigInteger",
2128:                        SimpleType.BIGINTEGER);
2129:                JAVATYPE_TO_OPENTYPE.put("java.lang.Date", SimpleType.DATE);
2130:            }
2131:
2132:            /* ###########################
2133:             * OJC hulp statistics
2134:             * ###########################
2135:             */
2136:            // following fields are for OJC hulp statistics
2137:            // taken from com.sun.esb.management.common.PerformanceData
2138:            /**
2139:             * Number of measurements (or N), i.e. the number of dt-s, i.e. the number
2140:             * of times that Measurement.begin() - end() was called.
2141:             */
2142:            public static final String NUMBEROFMEASUREMENTS_KEY = "n";
2143:
2144:            /** total time (ms) the sum of all dt-s */
2145:            public static final String TOTALTIME_KEY = "total time (ms)";
2146:
2147:            /**
2148:             * average' (ms) (the sum of all dt-s minus the first dt) divided by N. The
2149:             * first measurement is discounted because it typically includes
2150:             * classloading times and distorts the results considerably. If there's only
2151:             * one measurement, the first measurement is not discounted and the value
2152:             * should be equal to total time.
2153:             */
2154:            public static final String AVERAGEWITHOUTFIRSTMEASUREMENT_KEY = "average' (ms)";
2155:
2156:            /**
2157:             * act the number of measurement objects on which begin() was called but not
2158:             * end(). This indicates the number of active measurements. Caveat: there's
2159:             * a problem in the this accounting when the subtopic of the measurement is
2160:             * changed.
2161:             */
2162:            public static final String NUMBEROFMEASUREMENTOBJECTS_KEY = "act";
2163:
2164:            /** first the first dt */
2165:            public static final String FIRSTMEASUREMENTTIME_KEY = "first (ms)";
2166:
2167:            /**
2168:             * average sum of all dt-s divided by N; this does not discount the first
2169:             * measurement
2170:             */
2171:            public static final String AVERAGE_KEY = "average (ms)";
2172:
2173:            /**
2174:             * throughput N divided by (tlast - tfirst); this is the average throughput.
2175:             * This number is meaningful if there were no long pauses in processing.
2176:             */
2177:            public static final String THROUGHPUT_KEY = "throughput (s-1)";
2178:
2179:            /**
2180:             * tlast - tfirst the wallclock time of the first measurement's begin()
2181:             * method is tracked as tfirst and the wallclock time of the last
2182:             * measurement's end() method is tracked as tlast
2183:             */
2184:            public static final String TIMETAKEN_KEY = "last-first (ms)";
2185:
2186:            /**
2187:             * Load The sum of all dt-s divided by (tlast - tfirst). This is a measure
2188:             * of concurrency: the higher the number, the greater the concurrency. In a
2189:             * single threaded scenario this number can never exceed 1.
2190:             */
2191:            public static final String LOAD_KEY = "load";
2192:
2193:            public static final String MEDIAN_KEY = "median (ms)";
2194:
2195:            public static final String SOURCE_KEY = "source";
2196:
2197:            /**
2198:             * sub topic the name of the measurement specified in the second argument of
2199:             * begin() or in setSubTopic().
2200:             */
2201:            public static final String SUB_TOPIC_KEY = "sub topic";
2202:
2203:            /**
2204:             * topic the name of the measurement specified in the first argument of
2205:             * begin() or in setSubTopic().
2206:             */
2207:            public static final String TOPIC_KEY = "topic";
2208:
2209:            /** OJC components hulp stats */
2210:            static String[] OJC_HULP_STATS_ITEMS = { AVERAGE_KEY,
2211:                    AVERAGEWITHOUTFIRSTMEASUREMENT_KEY,
2212:                    FIRSTMEASUREMENTTIME_KEY, LOAD_KEY,
2213:                    NUMBEROFMEASUREMENTOBJECTS_KEY, NUMBEROFMEASUREMENTS_KEY,
2214:                    THROUGHPUT_KEY, TIMETAKEN_KEY, TOTALTIME_KEY, MEDIAN_KEY,
2215:                    SOURCE_KEY, SUB_TOPIC_KEY, TOPIC_KEY };
2216:
2217:            /** OJC components hulp stats item descriptions */
2218:            static String[] OJC_HULP_STATS_DESCRIPTIONS = {
2219:                    "average sum of all dt-s divided by N",
2220:                    "average' (ms) (the sum of all dt-s minus the first dt) divided by N",
2221:                    "first dt",
2222:                    "Load The sum of all dt-s divided by (tlast - tfirst)",
2223:                    "the number of measurement objects on which begin() was called but not * end()",
2224:                    "Number of measurements (or N)",
2225:                    "throughput N divided by (tlast - tfirst)",
2226:                    "tlast - tfirst the wallclock time of the first measurement's begin()method",
2227:                    "total time (ms) the sum of all dt-s", "median key",
2228:                    "source key", "sub topic the name of the measurement",
2229:                    "topic the name of the measurement" };
2230:
2231:            /** OJC components hulp stats item types */
2232:            static OpenType[] OJC_HULP_STATS_TYPES = { SimpleType.DOUBLE,
2233:                    SimpleType.DOUBLE, SimpleType.DOUBLE, SimpleType.DOUBLE,
2234:                    SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.DOUBLE,
2235:                    SimpleType.DOUBLE, SimpleType.DOUBLE, SimpleType.DOUBLE,
2236:                    SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, };
2237:
2238:            /**  table index  for OJC perf stats */
2239:            static String[] OJC_STATS_TABLE_INDEX = new String[] { SUB_TOPIC_KEY };
2240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.