001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)PerformanceMeasurementServiceImpl.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.esb.management.impl.performance;
030:
031: import java.io.Serializable;
032:
033: import javax.management.MBeanServerConnection;
034: import javax.management.ObjectName;
035: import javax.management.openmbean.TabularData;
036:
037: import com.sun.esb.management.api.performance.PerformanceMeasurementService;
038: import com.sun.esb.management.base.services.AbstractServiceImpl;
039: import com.sun.esb.management.common.ManagementRemoteException;
040:
041: /**
042: * Defines client operations to measure performance statistics.
043: * e.g., time taken to normalize/denormalize, encode/decode, wire-to-NMR
044: * on the endpoints, etc.
045: *
046: * @author graj
047: *
048: */
049: public class PerformanceMeasurementServiceImpl extends
050: AbstractServiceImpl implements Serializable,
051: PerformanceMeasurementService {
052:
053: static final long serialVersionUID = -1L;
054:
055: /** Constructor - Constructs a new instance of PerformanceMeasurementServiceImpl */
056: public PerformanceMeasurementServiceImpl() {
057: super (null, false);
058: }
059:
060: /**
061: * Constructor - Constructs a new instance of PerformanceMeasurementServiceImpl
062: *
063: * @param serverConnection
064: */
065: public PerformanceMeasurementServiceImpl(
066: MBeanServerConnection serverConnection) {
067: super (serverConnection, false);
068: }
069:
070: /**
071: * Constructor - Constructs a new instance of PerformanceMeasurementServiceImpl
072: *
073: * @param serverConnection
074: * @param isRemoteConnection
075: */
076: public PerformanceMeasurementServiceImpl(
077: MBeanServerConnection serverConnection,
078: boolean isRemoteConnection) {
079: super (serverConnection, isRemoteConnection);
080: }
081:
082: /**
083: * Resets the performance measurements on the endpoint.
084: * @param componentName
085: * @param endpoint
086: * @param targetName
087: * @param targetInstanceName
088: * @throws ManagementRemoteException
089: *
090: * @see com.sun.esb.management.api.performance.PerformanceMeasurementService#clearPeformaceInstrumentationMeasurement(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
091: */
092: public void clearPeformaceInstrumentationMeasurement(
093: String componentName, String endpoint, String targetName,
094: String targetInstanceName) throws ManagementRemoteException {
095: ObjectName mbeanName = this
096: .getPerformanceMeasurementServiceMBeanObjectName();
097: Object[] params = new Object[4];
098: params[0] = componentName;
099: params[1] = endpoint;
100: params[2] = targetName;
101: params[3] = targetInstanceName;
102:
103: String[] signature = new String[4];
104: signature[0] = "java.lang.String";
105: signature[1] = "java.lang.String";
106: signature[2] = "java.lang.String";
107: signature[3] = "java.lang.String";
108:
109: this .invokeMBeanOperation(mbeanName,
110: "clearPeformaceInstrumentationMeasurement", params,
111: signature);
112: }
113:
114: /**
115: * Retrieves the performance measurement enabling flag.
116: * @param componentName
117: * @param targetName
118: * @param targetInstanceName
119: * @return true if measurement enabled, false if not
120: * @throws ManagementRemoteException
121: *
122: * @see com.sun.esb.management.api.performance.PerformanceMeasurementService#getPerformanceInstrumentationEnabled(java.lang.String, java.lang.String, java.lang.String)
123: */
124: public boolean getPerformanceInstrumentationEnabled(
125: String componentName, String targetName,
126: String targetInstanceName) throws ManagementRemoteException {
127: ObjectName mbeanName = this
128: .getPerformanceMeasurementServiceMBeanObjectName();
129:
130: Boolean resultObject = null;
131: Object[] params = new Object[3];
132: params[0] = componentName;
133: params[1] = targetName;
134: params[2] = targetInstanceName;
135:
136: String[] signature = new String[3];
137: signature[0] = "java.lang.String";
138: signature[1] = "java.lang.String";
139: signature[2] = "java.lang.String";
140:
141: resultObject = (Boolean) this .invokeMBeanOperation(mbeanName,
142: "getPerformanceInstrumentationEnabled", params,
143: signature);
144:
145: return resultObject;
146: }
147:
148: /**
149: * Retrieves the performance measurement data for the specified endpoint.
150: * @param componentName
151: * @param endpoint
152: * @param targetName
153: * @param targetInstanceName
154: * @return XML String representing PerformanceData Map
155: * @throws ManagementRemoteException
156: *
157: * @see com.sun.esb.management.api.performance.PerformanceMeasurementService#getPerformanceInstrumentationMeasurement(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
158: */
159: public String getPerformanceInstrumentationMeasurement(
160: String componentName, String endpoint, String targetName,
161: String targetInstanceName) throws ManagementRemoteException {
162: ObjectName mbeanName = this
163: .getPerformanceMeasurementServiceMBeanObjectName();
164:
165: String resultObject = null;
166: Object[] params = new Object[4];
167: params[0] = componentName;
168: params[1] = endpoint;
169: params[2] = targetName;
170: params[3] = targetInstanceName;
171:
172: String[] signature = new String[4];
173: signature[0] = "java.lang.String";
174: signature[1] = "java.lang.String";
175: signature[2] = "java.lang.String";
176: signature[3] = "java.lang.String";
177:
178: resultObject = (String) this .invokeMBeanOperation(mbeanName,
179: "getPerformanceInstrumentationMeasurement", params,
180: signature);
181:
182: return resultObject;
183: }
184:
185: /**
186: * Retrieves the performance statistics categories. Each item in the array is the key to the composite performance data, which also indicates the type (e.g. normalization) of measurement.
187: * @param componentName
188: * @param targetName
189: * @param targetInstanceName
190: * @return array of performance measurement categories
191: * @throws ManagementRemoteException
192: *
193: * @see com.sun.esb.management.api.performance.PerformanceMeasurementService#getPerformanceMeasurementCategories(java.lang.String, java.lang.String, java.lang.String)
194: */
195: public String[] getPerformanceMeasurementCategories(
196: String componentName, String targetName,
197: String targetInstanceName) throws ManagementRemoteException {
198: ObjectName mbeanName = this
199: .getPerformanceMeasurementServiceMBeanObjectName();
200:
201: String[] resultObject = null;
202: Object[] params = new Object[3];
203: params[0] = componentName;
204: params[1] = targetName;
205: params[2] = targetInstanceName;
206:
207: String[] signature = new String[3];
208: signature[0] = "java.lang.String";
209: signature[1] = "java.lang.String";
210: signature[2] = "java.lang.String";
211:
212: resultObject = (String[]) this .invokeMBeanOperation(mbeanName,
213: "getPerformanceMeasurementCategories", params,
214: signature);
215:
216: return resultObject;
217: }
218:
219: /**
220: * Sets the performance measurement enabling flag.
221: * @param componentName
222: * @param flag
223: * @param targetName
224: * @param targetInstanceName
225: * @throws ManagementRemoteException
226: *
227: * @see com.sun.esb.management.api.performance.PerformanceMeasurementService#setPerformanceInstrumentationEnabled(java.lang.String, boolean, java.lang.String, java.lang.String)
228: */
229: public void setPerformanceInstrumentationEnabled(
230: String componentName, boolean flag, String targetName,
231: String targetInstanceName) throws ManagementRemoteException {
232: ObjectName mbeanName = this
233: .getPerformanceMeasurementServiceMBeanObjectName();
234: Object[] params = new Object[4];
235: params[0] = componentName;
236: params[1] = flag;
237: params[2] = targetName;
238: params[3] = targetName;
239:
240: String[] signature = new String[4];
241: signature[0] = "java.lang.String";
242: signature[1] = "boolean";
243: signature[2] = "java.lang.String";
244: signature[3] = "java.lang.String";
245:
246: this .invokeMBeanOperation(mbeanName,
247: "setPerformanceInstrumentationEnabled", params,
248: signature);
249: }
250:
251: /**
252: * This method is used to provide JBIFramework statistics in the
253: * given target.
254: * @param target target name.
255: * @return String table of framework statistics in the given target.
256: *
257: * If the target is a standalone instance the table will have one entry.
258: * If the target is a cluster the table will have an entry for each instance.
259: *
260: * For more information about the type of the entries in table please refer
261: * to <code>JBIStatisticsMBean</code>
262: */
263: public String getFrameworkStatistics(String targetName)
264: throws ManagementRemoteException {
265: ObjectName mbeanName = this
266: .getPerformanceMeasurementServiceMBeanObjectName();
267:
268: String resultObject = null;
269:
270: Object[] params = new Object[1];
271: params[0] = targetName;
272:
273: String[] signature = new String[1];
274: signature[0] = "java.lang.String";
275:
276: resultObject = (String) this .invokeMBeanOperation(mbeanName,
277: "getFrameworkStatistics", params, signature);
278: return resultObject;
279: }
280:
281: /**
282: * This method is used to provide JBIFramework statistics in the
283: * given target.
284: * @param target target name.
285: * @return TabularData table of framework statistics in the given target.
286: *
287: * If the target is a standalone instance the table will have one entry.
288: * If the target is a cluster the table will have an entry for each instance.
289: *
290: * For more information about the type of the entries in table please refer
291: * to <code>JBIStatisticsMBean</code>
292: */
293: public TabularData getFrameworkStatisticsAsTabularData(
294: String targetName) throws ManagementRemoteException {
295: ObjectName mbeanName = this
296: .getPerformanceMeasurementServiceMBeanObjectName();
297:
298: TabularData resultObject = null;
299:
300: Object[] params = new Object[1];
301: params[0] = targetName;
302:
303: String[] signature = new String[1];
304: signature[0] = "java.lang.String";
305:
306: resultObject = (TabularData) this .invokeMBeanOperation(
307: mbeanName, "getFrameworkStatisticsAsTabularData",
308: params, signature);
309: return resultObject;
310: }
311:
312: /**
313: * This method is used to provide statistics for the given component
314: * in the given target
315: * @param targetName target name
316: * @param componentName component name
317: * @return String table of component statistics
318: *
319: * If the target is a standalone instance the table will have one entry.
320: * If the target is a cluster the table will have an entry for each instance.
321: *
322: * For more information about the type of the entries in table please refer
323: * to <code>JBIStatisticsMBean</code>
324: *
325: */
326: public String getComponentStatistics(String componentName,
327: String targetName) throws ManagementRemoteException {
328: ObjectName mbeanName = this
329: .getPerformanceMeasurementServiceMBeanObjectName();
330:
331: String resultObject = null;
332:
333: Object[] params = new Object[2];
334: params[0] = componentName;
335: params[1] = targetName;
336:
337: String[] signature = new String[2];
338: signature[0] = "java.lang.String";
339: signature[1] = "java.lang.String";
340:
341: resultObject = (String) this .invokeMBeanOperation(mbeanName,
342: "getComponentStatistics", params, signature);
343: return resultObject;
344: }
345:
346: /**
347: * This method is used to provide statistics for the given component in the
348: * given target
349: *
350: * @param targetName
351: * target name
352: * @param componentName
353: * component name
354: * @return TabularData table of component statistics
355: *
356: * If the target is a standalone instance the table will have one entry. If
357: * the target is a cluster the table will have an entry for each instance.
358: *
359: * For more information about the type of the entries in table please refer
360: * to <code>JBIStatisticsMBean</code>
361: *
362: */
363: public TabularData getComponentStatisticsAsTabularData(
364: String componentName, String targetName)
365: throws ManagementRemoteException {
366: ObjectName mbeanName = this
367: .getPerformanceMeasurementServiceMBeanObjectName();
368:
369: TabularData resultObject = null;
370:
371: Object[] params = new Object[2];
372: params[0] = componentName;
373: params[1] = targetName;
374:
375: String[] signature = new String[2];
376: signature[0] = "java.lang.String";
377: signature[1] = "java.lang.String";
378:
379: resultObject = (TabularData) this .invokeMBeanOperation(
380: mbeanName, "getComponentStatisticsAsTabularData",
381: params, signature);
382: return resultObject;
383: }
384:
385: /**
386: * This method is used to provide statistic information about the given
387: * endpoint in the given target
388: * @param targetName target name
389: * @param endpointName the endpoint Name
390: * @return String table of endpoint statistics
391: *
392: * If the target is a standalone instance the table will have one entry.
393: * If the target is a cluster the table will have an entry for each instance.
394: *
395: * For more information about the type of the entries in table please refer
396: * to <code>JBIStatisticsMBean</code>
397: */
398: public String getEndpointStatistics(String endpointName,
399: String targetName) throws ManagementRemoteException {
400: ObjectName mbeanName = this
401: .getPerformanceMeasurementServiceMBeanObjectName();
402:
403: String resultObject = null;
404:
405: Object[] params = new Object[2];
406: params[0] = endpointName;
407: params[1] = targetName;
408:
409: String[] signature = new String[2];
410: signature[0] = "java.lang.String";
411: signature[1] = "java.lang.String";
412:
413: resultObject = (String) this .invokeMBeanOperation(mbeanName,
414: "getEndpointStatistics", params, signature);
415: return resultObject;
416: }
417:
418: /**
419: * This method is used to provide statistic information about the given
420: * endpoint in the given target
421: * @param targetName target name
422: * @param endpointName the endpoint Name
423: * @return TabularData table of endpoint statistics
424: *
425: * If the target is a standalone instance the table will have one entry.
426: * If the target is a cluster the table will have an entry for each instance.
427: *
428: * For more information about the type of the entries in table please refer
429: * to <code>JBIStatisticsMBean</code>
430: */
431: public TabularData getEndpointStatisticsAsTabularData(
432: String endpointName, String targetName)
433: throws ManagementRemoteException {
434: ObjectName mbeanName = this
435: .getPerformanceMeasurementServiceMBeanObjectName();
436:
437: TabularData resultObject = null;
438:
439: Object[] params = new Object[2];
440: params[0] = endpointName;
441: params[1] = targetName;
442:
443: String[] signature = new String[2];
444: signature[0] = "java.lang.String";
445: signature[1] = "java.lang.String";
446:
447: resultObject = (TabularData) this .invokeMBeanOperation(
448: mbeanName, "getEndpointStatisticsAsTabularData",
449: params, signature);
450: return resultObject;
451: }
452:
453: /**
454: * This method is used to provide statistics about the message service in the
455: * given target.
456: * @param target target name.
457: * @return String table of NMR statistics in the given target.
458: *
459: * If the target is a standalone instance the table will have one entry.
460: * If the target is a cluster the table will have an entry for each instance.
461: *
462: * For more information about the type of the entries in table please refer
463: * to <code>JBIStatisticsMBean</code>
464: */
465: public String getNMRStatistics(String targetName)
466: throws ManagementRemoteException {
467: ObjectName mbeanName = this
468: .getPerformanceMeasurementServiceMBeanObjectName();
469:
470: String resultObject = null;
471:
472: Object[] params = new Object[1];
473: params[0] = targetName;
474:
475: String[] signature = new String[1];
476: signature[0] = "java.lang.String";
477:
478: resultObject = (String) this .invokeMBeanOperation(mbeanName,
479: "getNMRStatistics", params, signature);
480: return resultObject;
481: }
482:
483: /**
484: * This method is used to provide statistics about the message service in the
485: * given target.
486: * @param target target name.
487: * @return TabularData table of NMR statistics in the given target.
488: *
489: * If the target is a standalone instance the table will have one entry.
490: * If the target is a cluster the table will have an entry for each instance.
491: *
492: * For more information about the type of the entries in table please refer
493: * to <code>JBIStatisticsMBean</code>
494: */
495: public TabularData getNMRStatisticsAsTabularData(String targetName)
496: throws ManagementRemoteException {
497: ObjectName mbeanName = this
498: .getPerformanceMeasurementServiceMBeanObjectName();
499:
500: TabularData resultObject = null;
501:
502: Object[] params = new Object[1];
503: params[0] = targetName;
504:
505: String[] signature = new String[1];
506: signature[0] = "java.lang.String";
507:
508: resultObject = (TabularData) this .invokeMBeanOperation(
509: mbeanName, "getNMRStatisticsAsTabularData", params,
510: signature);
511: return resultObject;
512: }
513:
514: /**
515: * This method is used to provide statistics about a Service Assembly
516: * in the given target.
517: * @param target target name.
518: * @param assemblyName the service assembly name.
519: * @return String table of NMR statistics in the given target.
520: *
521: * If the target is a standalone instance the table will have one entry.
522: * If the target is a cluster the table will have an entry for each instance.
523: *
524: * For more information about the type of the entries in table please refer
525: * to <code>JBIStatisticsMBean</code>
526: */
527: public String getServiceAssemblyStatistics(String assemblyName,
528: String targetName) throws ManagementRemoteException {
529: ObjectName mbeanName = this
530: .getPerformanceMeasurementServiceMBeanObjectName();
531:
532: String resultObject = null;
533:
534: Object[] params = new Object[2];
535: params[0] = assemblyName;
536: params[1] = targetName;
537:
538: String[] signature = new String[2];
539: signature[0] = "java.lang.String";
540: signature[1] = "java.lang.String";
541:
542: resultObject = (String) this .invokeMBeanOperation(mbeanName,
543: "getServiceAssemblyStatistics", params, signature);
544: return resultObject;
545: }
546:
547: /**
548: * This method is used to provide statistics about a Service Assembly
549: * in the given target.
550: * @param target target name.
551: * @param assemblyName the service assembly name.
552: * @return TabularData table of NMR statistics in the given target.
553: *
554: * If the target is a standalone instance the table will have one entry.
555: * If the target is a cluster the table will have an entry for each instance.
556: *
557: * For more information about the type of the entries in table please refer
558: * to <code>JBIStatisticsMBean</code>
559: */
560: public TabularData getServiceAssemblyStatisticsAsTabularData(
561: String componentName, String targetName)
562: throws ManagementRemoteException {
563: ObjectName mbeanName = this
564: .getPerformanceMeasurementServiceMBeanObjectName();
565:
566: TabularData resultObject = null;
567:
568: Object[] params = new Object[2];
569: params[0] = componentName;
570: params[1] = targetName;
571:
572: String[] signature = new String[2];
573: signature[0] = "java.lang.String";
574: signature[1] = "java.lang.String";
575:
576: resultObject = (TabularData) this .invokeMBeanOperation(
577: mbeanName, "getServiceAssemblyStatisticsAsTabularData",
578: params, signature);
579: return resultObject;
580: }
581:
582: /**
583: * This method is used to provide a list of consuming endpoints for a component.
584: * @param componentName component name
585: * @param target target name.
586: * @return TabularData list of consuming endpoints
587: *
588: * If the target is a standalone instance the table will have one entry.
589: * If the target is a cluster the table will have an entry for each instance.
590: *
591: * Each entry in this tabular data is of the following composite type
592: *
593: * String - "InstanceName",
594: * String[] - "Endpoints",
595: */
596: public TabularData getConsumingEndpointsForComponentAsTabularData(
597: String componentName, String targetName)
598: throws ManagementRemoteException {
599: ObjectName mbeanName = this
600: .getPerformanceMeasurementServiceMBeanObjectName();
601:
602: TabularData resultObject = null;
603:
604: Object[] params = new Object[2];
605: params[0] = componentName;
606: params[1] = targetName;
607:
608: String[] signature = new String[2];
609: signature[0] = "java.lang.String";
610: signature[1] = "java.lang.String";
611:
612: resultObject = (TabularData) this .invokeMBeanOperation(
613: mbeanName,
614: "getConsumingEndpointsForComponentAsTabularData",
615: params, signature);
616: return resultObject;
617: }
618:
619: /**
620: * This method is used to provide a list of provisioning endpoints for a component.
621: * @param componentName component name
622: * @param target target name.
623: * @return TabularData list of provisioning endpoints
624: *
625: * If the target is a standalone instance the table will have one entry.
626: * If the target is a cluster the table will have an entry for each instance.
627: *
628: * Each entry in this tabular data is of the following composite type
629: *
630: * String - "InstanceName",
631: * String[] - "Endpoints",
632: */
633: public TabularData getProvidingEndpointsForComponentAsTabularData(
634: String componentName, String targetName)
635: throws ManagementRemoteException {
636: ObjectName mbeanName = this
637: .getPerformanceMeasurementServiceMBeanObjectName();
638:
639: TabularData resultObject = null;
640:
641: Object[] params = new Object[2];
642: params[0] = componentName;
643: params[1] = targetName;
644:
645: String[] signature = new String[2];
646: signature[0] = "java.lang.String";
647: signature[1] = "java.lang.String";
648:
649: resultObject = (TabularData) this .invokeMBeanOperation(
650: mbeanName,
651: "getProvidingEndpointsForComponentAsTabularData",
652: params, signature);
653: return resultObject;
654: }
655:
656: /**
657: * This method is used to enable monitoring of timing
658: * information about message exchanges
659: * @param targetName the target name
660: */
661: public void enableMessageExchangeMonitoring(String targetName)
662: throws ManagementRemoteException {
663: ObjectName mbeanName = this
664: .getPerformanceMeasurementServiceMBeanObjectName();
665:
666: Object[] params = new Object[1];
667: params[0] = targetName;
668:
669: String[] signature = new String[1];
670: signature[0] = "java.lang.String";
671:
672: this .invokeMBeanOperation(mbeanName,
673: "enableMessageExchangeMonitoring", params, signature);
674: }
675:
676: /**
677: * This method is used to disable monitoring of timing
678: * information about message exchanges
679: * @param targetName the target name
680: */
681: public void disableMessageExchangeMonitoring(String targetName)
682: throws ManagementRemoteException {
683: ObjectName mbeanName = this
684: .getPerformanceMeasurementServiceMBeanObjectName();
685:
686: Object[] params = new Object[1];
687: params[0] = targetName;
688:
689: String[] signature = new String[1];
690: signature[0] = "java.lang.String";
691:
692: this .invokeMBeanOperation(mbeanName,
693: "disableMessageExchangeMonitoring", params, signature);
694: }
695:
696: /**
697: * @param args
698: */
699: public static void main(String[] args) {
700: // TODO Auto-generated method stub
701:
702: }
703:
704: }
|