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: * @(#)JbiListStatisticsTask.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.ant;
0030:
0031: import org.apache.tools.ant.BuildException;
0032: import java.io.File;
0033: import java.io.StringWriter;
0034: import java.io.PrintWriter;
0035: import java.util.Iterator;
0036: import java.util.List;
0037: import java.util.Set;
0038: import java.util.ArrayList;
0039: import java.util.Vector;
0040: import java.util.Enumeration;
0041: import java.util.Collection;
0042: import java.util.Date;
0043: import javax.management.openmbean.TabularData;
0044: import javax.management.openmbean.CompositeData;
0045: import javax.management.openmbean.CompositeType;
0046: import javax.management.openmbean.OpenType;
0047: import javax.management.openmbean.SimpleType;
0048: import javax.management.openmbean.TabularType;
0049: import javax.management.openmbean.ArrayType;
0050: import java.lang.Integer;
0051: import java.lang.Long;
0052: import java.lang.IllegalArgumentException;
0053: import com.sun.jbi.ui.common.JBIComponentInfo;
0054: import com.sun.jbi.ui.common.JBIStatisticsItemNames;
0055: import com.sun.jbi.ui.common.ServiceAssemblyInfo;
0056: import com.sun.jbi.ui.ant.util.TimeUtil;
0057:
0058: enum StatisticsType {
0059: FRAMEWORK("framework"), COMPONENT("component"), SERVICEASSEMBLY(
0060: "serviceassembly"), ENDPOINT("endpoint"), NMR("nmr"), ALL(
0061: "all");
0062:
0063: /** The String alue */
0064: private String mString;
0065:
0066: StatisticsType(String strValue) {
0067: mString = strValue;
0068: }
0069:
0070: public String toString() {
0071: return mString.toUpperCase();
0072: }
0073:
0074: public static StatisticsType valueOfString(String valStr) {
0075: return StatisticsType.valueOf(valStr.toUpperCase());
0076: }
0077: };
0078:
0079: /** This class is an ant task for stopping the service
0080: * engine or binding component.
0081: *
0082: * @author Sun Microsystems, Inc.
0083: */
0084: public class JbiListStatisticsTask extends JbiTargetTask {
0085: /**
0086: * success msg key
0087: */
0088: private static final String SUCCESS_STATUS_KEY = "jbi.ui.ant.list.statistics.successful";
0089: /**
0090: * failure msg key
0091: */
0092: private static final String FAILED_STATUS_KEY = "jbi.ui.ant.list.statistics.failed";
0093: /**
0094: * component state
0095: */
0096: private static final String COMPONENT_STARTED_STATE = "Started";
0097:
0098: /**
0099: * keys for providing endpoints
0100: */
0101: private static final String PROVIDER_ENDPOINT_TYPE_NAME = "ProviderEndpointStats";
0102:
0103: /**
0104: * keys for consuming endpoints
0105: */
0106: private static final String COMSUMER_ENDPOINT_TYPE_NAME = "ConsumerEndpointStats";
0107:
0108: /** Holds value of property statistics type. */
0109: private String mStatisticsType;
0110:
0111: /** Holds value of property mComponentName. */
0112: private List mComponentList;
0113:
0114: /** Holds value of property mServiceAssemblyList. */
0115: private List mServiceAssemblyList;
0116:
0117: /** Holds value of property mEndpointList. */
0118: private List mEndpointList;
0119:
0120: /** Getter for property statistics type.
0121: * @return value of property statistics type.
0122: *
0123: */
0124: public String getType() {
0125: return this .mStatisticsType;
0126: }
0127:
0128: /**
0129: * Setter for property statistics type.
0130: * @param statisticsType the type of statistics data.
0131: */
0132: public void setType(String statisticsType) {
0133: this .mStatisticsType = statisticsType;
0134: }
0135:
0136: /**
0137: * returns component element list
0138: * @return component List
0139: */
0140: public List getComponentList() {
0141: if (this .mComponentList == null) {
0142: this .mComponentList = new ArrayList();
0143: }
0144: return this .mComponentList;
0145: }
0146:
0147: /**
0148: * factory method for creating the nested element <component>
0149: * @return Component Object
0150: */
0151: public Component createComponent() {
0152: Component component = new Component();
0153: this .getComponentList().add(component);
0154: return component;
0155: }
0156:
0157: /**
0158: * returns serviceassembly element list
0159: * @return List
0160: */
0161: public List getServiceAssemblyList() {
0162: if (this .mServiceAssemblyList == null) {
0163: this .mServiceAssemblyList = new ArrayList();
0164: }
0165: return this .mServiceAssemblyList;
0166: }
0167:
0168: /**
0169: * factory method for creating the nested element <serviceassembly>
0170: * @return ServiceAssembly Object
0171: */
0172: public ServiceAssembly createServiceAssembly() {
0173: ServiceAssembly sa = new ServiceAssembly();
0174: this .getServiceAssemblyList().add(sa);
0175: return sa;
0176: }
0177:
0178: /**
0179: * returns endpoint element list
0180: * @return component List
0181: */
0182: public List getEndpointList() {
0183: if (this .mEndpointList == null) {
0184: this .mEndpointList = new ArrayList();
0185: }
0186: return this .mEndpointList;
0187: }
0188:
0189: /**
0190: * factory method for creating the nested element <endpoint>
0191: * @return Endpoint Object
0192: */
0193: public Endpoint createEndpoint() {
0194: Endpoint endpoint = new Endpoint();
0195: this .getEndpointList().add(endpoint);
0196: return endpoint;
0197: }
0198:
0199: /** executes the stop componentnt task. Ant Task framework calls this method to
0200: * excute the task.
0201: * @throws BuildException if error or exception occurs.
0202: */
0203: public void executeTask() throws BuildException {
0204:
0205: String target = getValidTarget();
0206: String theTypeStr = getType();
0207: try {
0208: StringWriter stringWriter = new StringWriter();
0209: PrintWriter msgWriter = new PrintWriter(stringWriter);
0210:
0211: StatisticsType theType = null;
0212: try {
0213: theType = StatisticsType.valueOfString(theTypeStr);
0214: } catch (IllegalArgumentException exp) {
0215: String errMsg = null;
0216: if ((theTypeStr == null)
0217: || (theTypeStr.compareTo("") == 0)) {
0218: errMsg = createFailedFormattedJbiAdminResult(
0219: "jbi.ui.ant.list.statistics.error.empty.type",
0220: null);
0221: } else {
0222: errMsg = createFailedFormattedJbiAdminResult(
0223: "jbi.ui.ant.list.statistics.error.wrong.type",
0224: new String[] { theTypeStr });
0225: }
0226:
0227: throw new Exception(errMsg);
0228: } catch (NullPointerException exp) {
0229: String errMsg = createFailedFormattedJbiAdminResult(
0230: "jbi.ui.ant.list.statistics.error.empty.type",
0231: new String[] { theTypeStr });
0232: throw new Exception(errMsg);
0233: }
0234:
0235: TabularData result = null;
0236:
0237: switch (theType) {
0238: case FRAMEWORK:
0239: logDebug("Statistics for framework, the target is "
0240: + target);
0241: result = this .getJBIAdminCommands().getFrameworkStats(
0242: target);
0243: logDebug("Statistics for framework, the target is "
0244: + target);
0245: printStatsForFramework(result, target, msgWriter);
0246: break;
0247: case COMPONENT:
0248: logDebug("Statistics for components, the target is "
0249: + target);
0250: getStatsForComponentsAndPrintStats(getComponentList(),
0251: target, msgWriter, stringWriter);
0252: break;
0253: case SERVICEASSEMBLY:
0254: logDebug("Statistics for service assemblies, the target is "
0255: + target);
0256: getStatsForServiceAssemblies(getServiceAssemblyList(),
0257: target, msgWriter, stringWriter);
0258: break;
0259: case ENDPOINT:
0260: logDebug("Statistics for endpoints, the target is "
0261: + target);
0262: getStatsForEndpointsAndPrintStats(getEndpointList(),
0263: target, msgWriter, stringWriter);
0264: break;
0265: case NMR:
0266: logDebug("Statistics for NMR, the target is " + target);
0267: result = this .getJBIAdminCommands().getNMRStats(target);
0268: logDebug("Statistics for NMR, the result is " + result);
0269: printStatsForNMR(result, target, msgWriter);
0270: break;
0271: case ALL:
0272: logDebug("Statistics for NMR, the target is " + target);
0273: result = this .getJBIAdminCommands().getNMRStats(target);
0274: logDebug("Statistics for NMR, the result is " + result);
0275: printStatsForNMR(result, target, msgWriter);
0276:
0277: logDebug("Statistics for framework, the target is "
0278: + target);
0279: result = this .getJBIAdminCommands().getFrameworkStats(
0280: target);
0281: logDebug("Statistics for framework, the target is "
0282: + target);
0283: printStatsForFramework(result, target, msgWriter);
0284: stringWriter.flush();
0285:
0286: logDebug("Statistics for components, the target is "
0287: + target);
0288: getStatsForComponentsAndPrintStats(getComponentList(),
0289: target, msgWriter, stringWriter);
0290:
0291: logDebug("Statistics for service assemblies, the target is "
0292: + target);
0293: getStatsForServiceAssemblies(getServiceAssemblyList(),
0294: target, msgWriter, stringWriter);
0295:
0296: logDebug("Statistics for endpoints, the target is "
0297: + target);
0298: getStatsForEndpointsAndPrintStats(getEndpointList(),
0299: target, msgWriter, stringWriter);
0300: stringWriter.flush();
0301: break;
0302: default:
0303: String errMsg = null;
0304: if ((theTypeStr == null)
0305: || (theTypeStr.compareTo("") == 0)) {
0306: errMsg = createFailedFormattedJbiAdminResult(
0307: "jbi.ui.ant.list.statistics.error.empty.type",
0308: new String[] { theTypeStr });
0309: } else {
0310: errMsg = createFailedFormattedJbiAdminResult(
0311: "jbi.ui.ant.list.statistics.error.wrong.type",
0312: null);
0313: }
0314:
0315: throw new Exception(errMsg);
0316: }
0317:
0318: msgWriter.close();
0319: printMessage(stringWriter.getBuffer().toString());
0320: stringWriter.close();
0321:
0322: } catch (Exception ex) {
0323: throw new BuildException(ex);
0324: }
0325: }
0326:
0327: /**
0328: * Print statistics data for framework
0329: * @param result the Tabular data containing stats data
0330: * @param target
0331: * @param msgWriter the PrintWriter
0332: */
0333: private void printStatsForFramework(TabularData result,
0334: String target, PrintWriter msgWriter) {
0335: String header = getI18NBundle().getMessage(
0336: "jbi.ui.ant.print.jbi.stats.framework.info.header",
0337: new String[] { target });
0338: String headerSeparator = getI18NBundle().getMessage(
0339: "jbi.ui.ant.print.jbi.stats.info.header.separator");
0340: String pageSeparator = getI18NBundle().getMessage(
0341: "jbi.ui.ant.print.jbi.stats.info.separator");
0342:
0343: String emptyResult = getI18NBundle().getMessage(
0344: "jbi.ui.ant.print.jbi.stats.framework.info.empty");
0345:
0346: msgWriter.println(headerSeparator);
0347: msgWriter.println(header);
0348: msgWriter.println(headerSeparator);
0349:
0350: if ((result == null) || (result.size() == 0)) {
0351: msgWriter.println(emptyResult);
0352: msgWriter.println(pageSeparator);
0353: return;
0354: }
0355:
0356: for (Iterator dataIter = result.values().iterator(); dataIter
0357: .hasNext();) {
0358: CompositeData compData = (CompositeData) dataIter.next();
0359: String instanceName = (String) compData
0360: .get(JBIStatisticsItemNames.INSTANCE_NAME);
0361: Long startupTime = (Long) compData
0362: .get(JBIStatisticsItemNames.FRAMEWORK_STARTUP_TIME);
0363: Long upTime = (Long) compData
0364: .get(JBIStatisticsItemNames.FRAMEWORK_UPTIME);
0365:
0366: startupTime = (startupTime != null) ? startupTime
0367: : (new Long(0));
0368: upTime = (upTime != null) ? upTime : (new Long(0));
0369:
0370: String instanceNameLine = getI18NBundle()
0371: .getMessage(
0372: "jbi.ui.ant.print.jbi.stats.framework.instance.name",
0373: new String[] { instanceName });
0374: String formatString = getI18NBundle().getMessage(
0375: "jbi.ui.ant.print.jbi.stats.framework.up.time");
0376: TimeUtil timeUtil = new TimeUtil(upTime.longValue());
0377: String upTimeLine = getI18NBundle().getMessage(
0378: "jbi.ui.ant.print.jbi.stats.framework.up.time",
0379: new String[] { upTime.toString() });
0380: String startupTimeLine = getI18NBundle()
0381: .getMessage(
0382: "jbi.ui.ant.print.jbi.stats.framework.startup.time",
0383: new String[] { startupTime.toString() });
0384:
0385: msgWriter.println(instanceNameLine);
0386: msgWriter.println(pageSeparator);
0387: msgWriter.format(formatString + "\n", timeUtil.getDays(),
0388: timeUtil.getHours(), timeUtil.getMins(), timeUtil
0389: .getSecs());
0390: msgWriter.println(startupTimeLine);
0391:
0392: msgWriter.println("");
0393: }
0394: }
0395:
0396: /**
0397: * Print statistics data for components
0398: * @param results the vector data containing tabular stats data
0399: * @param target
0400: * @param msgWriter the PrintWriter
0401: */
0402: private void printStatsForComponent(String compName,
0403: TabularData result, String target, PrintWriter msgWriter,
0404: String pageSeparator) {
0405: if (compName != null) {
0406: msgWriter.println(getI18NBundle().getMessage(
0407: "jbi.ui.ant.print.jbi.stats.component.name",
0408: new String[] { compName }));
0409: msgWriter.println(pageSeparator);
0410: } else {
0411: return;
0412: }
0413:
0414: if ((result == null) || (result.values() == null)
0415: || (result.values().size() == 0)) {
0416: String emptyResult = getI18NBundle()
0417: .getMessage(
0418: "jbi.ui.ant.print.jbi.stats.component.info.nostats");
0419:
0420: msgWriter.println(emptyResult);
0421: msgWriter.println("");
0422: msgWriter.println("");
0423:
0424: return;
0425: }
0426:
0427: Collection collect = result.values();
0428: Iterator dataIter = collect.iterator();
0429: for (; dataIter.hasNext();) {
0430: CompositeData compData = (CompositeData) dataIter.next();
0431: CompositeType compType = compData.getCompositeType();
0432: Set compItemSet = compType.keySet();
0433: String instanceName = "";
0434:
0435: if (compItemSet
0436: .contains(JBIStatisticsItemNames.COMPONENT_UPTIME)) {
0437: Long componentUpTime = (Long) compData
0438: .get(JBIStatisticsItemNames.COMPONENT_UPTIME);
0439: String formatString = getI18NBundle().getMessage(
0440: "jbi.ui.ant.print.jbi.stats.component.up.time");
0441: TimeUtil timeUtil = new TimeUtil(componentUpTime
0442: .longValue());
0443: msgWriter.format(formatString + "\n", timeUtil
0444: .getDays(), timeUtil.getHours(), timeUtil
0445: .getMins(), timeUtil.getSecs());
0446: }
0447:
0448: if (compItemSet
0449: .contains(JBIStatisticsItemNames.NUMBER_OF_ACTIVATED_ENDPOINTS)) {
0450: Long numActivatedEndpoints = (Long) compData
0451: .get(JBIStatisticsItemNames.NUMBER_OF_ACTIVATED_ENDPOINTS);
0452: msgWriter
0453: .println(getI18NBundle()
0454: .getMessage(
0455: "jbi.ui.ant.print.jbi.stats.common.num.activated.endpoints",
0456: new String[] { (numActivatedEndpoints != null) ? numActivatedEndpoints
0457: .toString()
0458: : "" }));
0459: }
0460:
0461: if (compItemSet
0462: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_REQUESTS)) {
0463: Long numReceivedRequests = (Long) compData
0464: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_REQUESTS);
0465: msgWriter
0466: .println(getI18NBundle()
0467: .getMessage(
0468: "jbi.ui.ant.print.jbi.stats.common.num.received.requests",
0469: new String[] { (numReceivedRequests != null) ? numReceivedRequests
0470: .toString()
0471: : "" }));
0472: }
0473:
0474: if (compItemSet
0475: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_REQUESTS)) {
0476: Long numSentRequests = (Long) compData
0477: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_REQUESTS);
0478: msgWriter
0479: .println(getI18NBundle()
0480: .getMessage(
0481: "jbi.ui.ant.print.jbi.stats.common.num.sent.requests",
0482: new String[] { (numSentRequests != null) ? numSentRequests
0483: .toString()
0484: : "" }));
0485: }
0486:
0487: if (compItemSet
0488: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_REPLIES)) {
0489: Long numReceivedReplies = (Long) compData
0490: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_REPLIES);
0491: msgWriter
0492: .println(getI18NBundle()
0493: .getMessage(
0494: "jbi.ui.ant.print.jbi.stats.common.num.received.replies",
0495: new String[] { (numReceivedReplies != null) ? numReceivedReplies
0496: .toString()
0497: : "" }));
0498: }
0499:
0500: if (compItemSet
0501: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_REPLIES)) {
0502: Long numSentReplies = (Long) compData
0503: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_REPLIES);
0504: msgWriter
0505: .println(getI18NBundle()
0506: .getMessage(
0507: "jbi.ui.ant.print.jbi.stats.common.num.sent.replies",
0508: new String[] { (numSentReplies != null) ? numSentReplies
0509: .toString()
0510: : "" }));
0511: }
0512:
0513: if (compItemSet
0514: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_DONES)) {
0515: Long numReceivedDONEs = (Long) compData
0516: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_DONES);
0517: msgWriter
0518: .println(getI18NBundle()
0519: .getMessage(
0520: "jbi.ui.ant.print.jbi.stats.common.num.received.dones",
0521: new String[] { (numReceivedDONEs != null) ? numReceivedDONEs
0522: .toString()
0523: : "" }));
0524: }
0525:
0526: if (compItemSet
0527: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_DONES)) {
0528: Long numSentDONEs = (Long) compData
0529: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_DONES);
0530: msgWriter
0531: .println(getI18NBundle()
0532: .getMessage(
0533: "jbi.ui.ant.print.jbi.stats.common.num.sent.dones",
0534: new String[] { (numSentDONEs != null) ? numSentDONEs
0535: .toString()
0536: : "" }));
0537: }
0538:
0539: if (compItemSet
0540: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_FAULTS)) {
0541: Long numReceivedFaults = (Long) compData
0542: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_FAULTS);
0543: msgWriter
0544: .println(getI18NBundle()
0545: .getMessage(
0546: "jbi.ui.ant.print.jbi.stats.common.num.received.faults",
0547: new String[] { (numReceivedFaults != null) ? numReceivedFaults
0548: .toString()
0549: : "" }));
0550: }
0551:
0552: if (compItemSet
0553: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_FAULTS)) {
0554: Long numSentFaults = (Long) compData
0555: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_FAULTS);
0556: msgWriter
0557: .println(getI18NBundle()
0558: .getMessage(
0559: "jbi.ui.ant.print.jbi.stats.common.num.sent.faults",
0560: new String[] { (numSentFaults != null) ? numSentFaults
0561: .toString()
0562: : "" }));
0563: }
0564:
0565: if (compItemSet
0566: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_ERRORS)) {
0567: Long numReceivedErrors = (Long) compData
0568: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_ERRORS);
0569: msgWriter
0570: .println(getI18NBundle()
0571: .getMessage(
0572: "jbi.ui.ant.print.jbi.stats.common.num.received.errors",
0573: new String[] { (numReceivedErrors != null) ? numReceivedErrors
0574: .toString()
0575: : "" }));
0576: }
0577:
0578: if (compItemSet
0579: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_ERRORS)) {
0580: Long numSentErrors = (Long) compData
0581: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_ERRORS);
0582: msgWriter
0583: .println(getI18NBundle()
0584: .getMessage(
0585: "jbi.ui.ant.print.jbi.stats.common.num.sent.errors",
0586: new String[] { (numSentErrors != null) ? numSentErrors
0587: .toString()
0588: : "" }));
0589: }
0590:
0591: if (compItemSet
0592: .contains(JBIStatisticsItemNames.NUMBER_OF_COMPLETED_EXCHANGES)) {
0593: Long numCompletedExchanges = (Long) compData
0594: .get(JBIStatisticsItemNames.NUMBER_OF_COMPLETED_EXCHANGES);
0595: msgWriter
0596: .println(getI18NBundle()
0597: .getMessage(
0598: "jbi.ui.ant.print.jbi.stats.common.num.completed.exchanges",
0599: new String[] { (numCompletedExchanges != null) ? numCompletedExchanges
0600: .toString()
0601: : "" }));
0602: }
0603:
0604: if (compItemSet
0605: .contains(JBIStatisticsItemNames.NUMBER_OF_ACTIVE_EXCHANGES)) {
0606: Long numActiveExchanges = (Long) compData
0607: .get(JBIStatisticsItemNames.NUMBER_OF_ACTIVE_EXCHANGES);
0608: msgWriter
0609: .println(getI18NBundle()
0610: .getMessage(
0611: "jbi.ui.ant.print.jbi.stats.common.num.active.exchanges",
0612: new String[] { (numActiveExchanges != null) ? numActiveExchanges
0613: .toString()
0614: : "" }));
0615: }
0616:
0617: if (compItemSet
0618: .contains(JBIStatisticsItemNames.NUMBER_OF_ERROR_EXCHANGES)) {
0619: Long numErrorExchanges = (Long) compData
0620: .get(JBIStatisticsItemNames.NUMBER_OF_ERROR_EXCHANGES);
0621: msgWriter
0622: .println(getI18NBundle()
0623: .getMessage(
0624: "jbi.ui.ant.print.jbi.stats.common.num.error.exchanges",
0625: new String[] { (numErrorExchanges != null) ? numErrorExchanges
0626: .toString()
0627: : "" }));
0628: }
0629:
0630: msgWriter
0631: .println("\n"
0632: + getI18NBundle()
0633: .getMessage(
0634: "jbi.ui.ant.print.jbi.stats.common.message.exchanges.statistics",
0635: null) + "\n");
0636:
0637: String valueNotAvailable = getI18NBundle()
0638: .getMessage(
0639: "jbi.ui.ant.print.jbi.stats.common.message.value.not.available",
0640: null);
0641:
0642: if (compItemSet
0643: .contains(JBIStatisticsItemNames.MESSAGE_EXCHANGE_RESPONSE_TIME)) {
0644: Long mepResponseTime = (Long) compData
0645: .get(JBIStatisticsItemNames.MESSAGE_EXCHANGE_RESPONSE_TIME);
0646: msgWriter
0647: .println(getI18NBundle()
0648: .getMessage(
0649: "jbi.ui.ant.print.jbi.stats.common.mep.response.time",
0650: new String[] { mepResponseTime == null ? valueNotAvailable
0651: : mepResponseTime
0652: .toString() }));
0653: }
0654:
0655: if (compItemSet
0656: .contains(JBIStatisticsItemNames.MESSAGE_EXCHANGE_COMPONENT_TIME)) {
0657: Long mepComponentTime = (Long) compData
0658: .get(JBIStatisticsItemNames.MESSAGE_EXCHANGE_COMPONENT_TIME);
0659: msgWriter
0660: .println(getI18NBundle()
0661: .getMessage(
0662: "jbi.ui.ant.print.jbi.stats.common.mep.component.time",
0663: new String[] {
0664: instanceName,
0665: mepComponentTime == null ? valueNotAvailable
0666: : mepComponentTime
0667: .toString() }));
0668: }
0669:
0670: if (compItemSet
0671: .contains(JBIStatisticsItemNames.MESSAGE_EXCHANGE_DELIVERY_CHANNEL_TIME)) {
0672: Long mepDeliveryChannelTime = (Long) compData
0673: .get(JBIStatisticsItemNames.MESSAGE_EXCHANGE_DELIVERY_CHANNEL_TIME);
0674: msgWriter
0675: .println(getI18NBundle()
0676: .getMessage(
0677: "jbi.ui.ant.print.jbi.stats.common.mep.delivery.channel.time",
0678: new String[] { mepDeliveryChannelTime == null ? valueNotAvailable
0679: : mepDeliveryChannelTime
0680: .toString() }));
0681: }
0682:
0683: if (compItemSet
0684: .contains(JBIStatisticsItemNames.MESSAGE_EXCHANGE_NMR_TIME)) {
0685: Long mepMessageServiceTime = (Long) compData
0686: .get(JBIStatisticsItemNames.MESSAGE_EXCHANGE_NMR_TIME);
0687: msgWriter
0688: .println(getI18NBundle()
0689: .getMessage(
0690: "jbi.ui.ant.print.jbi.stats.common.mep.message.service.time",
0691: new String[] { mepMessageServiceTime == null ? valueNotAvailable
0692: : mepMessageServiceTime
0693: .toString() }));
0694: }
0695:
0696: if (compItemSet
0697: .contains(JBIStatisticsItemNames.COMPONENT_EXTENSION_STATS)) {
0698: msgWriter
0699: .println("\n"
0700: + getI18NBundle()
0701: .getMessage(
0702: "jbi.ui.ant.print.jbi.stats.common.provided.statistics",
0703: null) + "\n");
0704: CompositeData componentExtensionStats = (CompositeData) compData
0705: .get(JBIStatisticsItemNames.COMPONENT_EXTENSION_STATS);
0706: if (componentExtensionStats != null) {
0707: printCompositeDataRecursively(
0708: componentExtensionStats, msgWriter, "\t");
0709: }
0710: }
0711: msgWriter.println("");
0712: }
0713:
0714: msgWriter.println("");
0715: }
0716:
0717: /**
0718: * Print statistics data for service assemblies
0719: * @param results the vector data containing tabular stats data
0720: * @param target
0721: * @param msgWriter the PrintWriter
0722: */
0723: private void printStatsForServiceAssembly(TabularData result,
0724: String target, PrintWriter msgWriter, String pageSeparator) {
0725: String valueNotAvailable = getI18NBundle()
0726: .getMessage(
0727: "jbi.ui.ant.print.jbi.stats.common.message.value.not.available",
0728: null);
0729:
0730: Collection collect = result.values();
0731: Iterator dataIter = collect.iterator();
0732: for (; dataIter.hasNext();) {
0733: CompositeData saCompData = (CompositeData) dataIter.next();
0734: CompositeType saCompType = saCompData.getCompositeType();
0735: Set saCompItemSet = saCompType.keySet();
0736:
0737: if (saCompItemSet
0738: .contains(JBIStatisticsItemNames.SERVICE_ASSEMBLY_NAME)) {
0739: String saName = (String) saCompData
0740: .get(JBIStatisticsItemNames.SERVICE_ASSEMBLY_NAME);
0741: msgWriter.println(getI18NBundle().getMessage(
0742: "jbi.ui.ant.print.jbi.stats.sa.name",
0743: new String[] { saName }));
0744: msgWriter.println(pageSeparator);
0745: }
0746:
0747: if (saCompItemSet
0748: .contains(JBIStatisticsItemNames.SERVICE_ASSEMBLY_LAST_STARTUP_TIME)) {
0749: Date saLastStartupTime = (Date) saCompData
0750: .get(JBIStatisticsItemNames.SERVICE_ASSEMBLY_LAST_STARTUP_TIME);
0751: msgWriter
0752: .println(getI18NBundle()
0753: .getMessage(
0754: "jbi.ui.ant.print.jbi.stats.sa.last.startup.time",
0755: new String[] { (saLastStartupTime != null) ? saLastStartupTime
0756: .toString()
0757: : "" }));
0758: }
0759:
0760: if (saCompItemSet
0761: .contains(JBIStatisticsItemNames.SERVICE_ASSEMBLY_SHUTDOWN_TIME)) {
0762: Long saShutdownTime = (Long) saCompData
0763: .get(JBIStatisticsItemNames.SERVICE_ASSEMBLY_SHUTDOWN_TIME);
0764: msgWriter
0765: .println(getI18NBundle()
0766: .getMessage(
0767: "jbi.ui.ant.print.jbi.stats.sa.shutdown.time",
0768: new String[] { saShutdownTime == null ? valueNotAvailable
0769: : saShutdownTime
0770: .toString() }));
0771: }
0772:
0773: if (saCompItemSet
0774: .contains(JBIStatisticsItemNames.SERVICE_ASSEMBLY_STARTUP_TIME)) {
0775: Long saStartupTime = (Long) saCompData
0776: .get(JBIStatisticsItemNames.SERVICE_ASSEMBLY_STARTUP_TIME);
0777: msgWriter
0778: .println(getI18NBundle()
0779: .getMessage(
0780: "jbi.ui.ant.print.jbi.stats.sa.startup.time",
0781: new String[] { saStartupTime == null ? valueNotAvailable
0782: : saStartupTime
0783: .toString() }));
0784: }
0785:
0786: if (saCompItemSet
0787: .contains(JBIStatisticsItemNames.SERVICE_ASSEMBLY_STOP_TIME)) {
0788: Long saStopTime = (Long) saCompData
0789: .get(JBIStatisticsItemNames.SERVICE_ASSEMBLY_STOP_TIME);
0790: msgWriter
0791: .println(getI18NBundle()
0792: .getMessage(
0793: "jbi.ui.ant.print.jbi.stats.sa.stop.time",
0794: new String[] { saStopTime == null ? valueNotAvailable
0795: : saStopTime.toString() }));
0796: }
0797:
0798: msgWriter.println("");
0799: String tab = "\t";
0800:
0801: if (saCompItemSet
0802: .contains(JBIStatisticsItemNames.SERVICE_ASSEMBLY_SU_STATISTICS)) {
0803: CompositeData[] suStatistics = (CompositeData[]) saCompData
0804: .get(JBIStatisticsItemNames.SERVICE_ASSEMBLY_SU_STATISTICS);
0805:
0806: for (int i = 0; i < suStatistics.length; ++i) {
0807: CompositeData suCompData = suStatistics[i];
0808: CompositeType suCompType = suCompData
0809: .getCompositeType();
0810: Set suCompItemSet = suCompType.keySet();
0811:
0812: if (suCompItemSet
0813: .contains(JBIStatisticsItemNames.SERVICE_UNIT_NAME)) {
0814: String suName = (String) suCompData
0815: .get(JBIStatisticsItemNames.SERVICE_UNIT_NAME);
0816: msgWriter.println(getI18NBundle().getMessage(
0817: "jbi.ui.ant.print.jbi.stats.su.name",
0818: new String[] { suName }));
0819: }
0820:
0821: if (suCompItemSet
0822: .contains(JBIStatisticsItemNames.SERVICE_UNIT_SHUTDOWN_TIME)) {
0823: Long suShutdownTime = (Long) suCompData
0824: .get(JBIStatisticsItemNames.SERVICE_UNIT_SHUTDOWN_TIME);
0825: msgWriter
0826: .println(tab
0827: + getI18NBundle()
0828: .getMessage(
0829: "jbi.ui.ant.print.jbi.stats.su.shutdown.time",
0830: new String[] { suShutdownTime == null ? valueNotAvailable
0831: : suShutdownTime
0832: .toString() }));
0833: }
0834:
0835: if (suCompItemSet
0836: .contains(JBIStatisticsItemNames.SERVICE_UNIT_STARTUP_TIME)) {
0837: Long suStartupTime = (Long) suCompData
0838: .get(JBIStatisticsItemNames.SERVICE_UNIT_STARTUP_TIME);
0839: msgWriter
0840: .println(tab
0841: + getI18NBundle()
0842: .getMessage(
0843: "jbi.ui.ant.print.jbi.stats.su.startup.time",
0844: new String[] { suStartupTime == null ? valueNotAvailable
0845: : suStartupTime
0846: .toString() }));
0847: }
0848:
0849: if (suCompItemSet
0850: .contains(JBIStatisticsItemNames.SERVICE_UNIT_STOP_TIME)) {
0851: Long suStopTime = (Long) suCompData
0852: .get(JBIStatisticsItemNames.SERVICE_UNIT_STOP_TIME);
0853: msgWriter
0854: .println(tab
0855: + getI18NBundle()
0856: .getMessage(
0857: "jbi.ui.ant.print.jbi.stats.su.stop.time",
0858: new String[] { suStopTime == null ? valueNotAvailable
0859: : suStopTime
0860: .toString() }));
0861: }
0862:
0863: msgWriter.println("");
0864: }
0865:
0866: msgWriter.println("");
0867: }
0868: msgWriter.println("");
0869: }
0870: }
0871:
0872: /**
0873: * Print statistics data for endpoints
0874: * @param results the vector data containing tabular stats data
0875: * @param target
0876: * @param msgWriter the PrintWriter
0877: */
0878: private void printStatsForEndpoint(String endpointName,
0879: TabularData result, String target, PrintWriter msgWriter,
0880: String pageSeparator) {
0881: for (Iterator dataIter = result.values().iterator(); dataIter
0882: .hasNext();) {
0883: CompositeData endpointCompData = (CompositeData) dataIter
0884: .next();
0885: CompositeType compType = endpointCompData
0886: .getCompositeType();
0887: Set compItemSet = compType.keySet();
0888: String compTypeName = endpointCompData.getCompositeType()
0889: .getTypeName();
0890: if (("" + compTypeName)
0891: .compareTo(PROVIDER_ENDPOINT_TYPE_NAME) == 0) {
0892: msgWriter
0893: .println(getI18NBundle()
0894: .getMessage(
0895: "jbi.ui.ant.print.jbi.stats.endpoint.provider.name",
0896: new String[] { endpointName }));
0897: msgWriter.println(pageSeparator);
0898:
0899: if (compItemSet
0900: .contains(JBIStatisticsItemNames.PROVIDER_ENDPOINT_ACTIVATION_TIME)) {
0901: Date activationTime = (Date) endpointCompData
0902: .get(JBIStatisticsItemNames.PROVIDER_ENDPOINT_ACTIVATION_TIME);
0903: msgWriter
0904: .println(getI18NBundle()
0905: .getMessage(
0906: "jbi.ui.ant.print.jbi.stats.endpoint.activation.time",
0907: new String[] { activationTime
0908: .toString() }));
0909: }
0910: if (compItemSet
0911: .contains(JBIStatisticsItemNames.PROVIDER_ENDPOINT_UPTIME)) {
0912: Long upTime = (Long) endpointCompData
0913: .get(JBIStatisticsItemNames.PROVIDER_ENDPOINT_UPTIME);
0914: String formatString = getI18NBundle()
0915: .getMessage(
0916: "jbi.ui.ant.print.jbi.stats.endpoint.up.time");
0917: TimeUtil timeUtil = new TimeUtil(upTime.longValue());
0918: msgWriter.format(formatString + "\n", timeUtil
0919: .getDays(), timeUtil.getHours(), timeUtil
0920: .getMins(), timeUtil.getSecs());
0921: }
0922: if (compItemSet
0923: .contains(JBIStatisticsItemNames.NUMBER_OF_ACTIVE_EXCHANGES)) {
0924: Long numActiveExchanges = (Long) endpointCompData
0925: .get(JBIStatisticsItemNames.NUMBER_OF_ACTIVE_EXCHANGES);
0926: msgWriter
0927: .println(getI18NBundle()
0928: .getMessage(
0929: "jbi.ui.ant.print.jbi.stats.common.num.active.exchanges",
0930: new String[] { numActiveExchanges
0931: .toString() }));
0932: }
0933: if (compItemSet
0934: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_REQUESTS)) {
0935: Long numReceivedRequests = (Long) endpointCompData
0936: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_REQUESTS);
0937: msgWriter
0938: .println(getI18NBundle()
0939: .getMessage(
0940: "jbi.ui.ant.print.jbi.stats.common.num.received.requests",
0941: new String[] { numReceivedRequests
0942: .toString() }));
0943: }
0944: if (compItemSet
0945: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_REPLIES)) {
0946: Long numSentReplies = (Long) endpointCompData
0947: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_REPLIES);
0948: msgWriter
0949: .println(getI18NBundle()
0950: .getMessage(
0951: "jbi.ui.ant.print.jbi.stats.common.num.sent.replies",
0952: new String[] { numSentReplies
0953: .toString() }));
0954: }
0955: if (compItemSet
0956: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_DONES)) {
0957: Long numReceivedDONEs = (Long) endpointCompData
0958: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_DONES);
0959: msgWriter
0960: .println(getI18NBundle()
0961: .getMessage(
0962: "jbi.ui.ant.print.jbi.stats.common.num.received.dones",
0963: new String[] { numReceivedDONEs
0964: .toString() }));
0965: }
0966: if (compItemSet
0967: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_DONES)) {
0968: Long numSentDONEs = (Long) endpointCompData
0969: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_DONES);
0970: msgWriter
0971: .println(getI18NBundle()
0972: .getMessage(
0973: "jbi.ui.ant.print.jbi.stats.common.num.sent.dones",
0974: new String[] { numSentDONEs
0975: .toString() }));
0976: }
0977: if (compItemSet
0978: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_FAULTS)) {
0979: Long numReceivedFaults = (Long) endpointCompData
0980: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_FAULTS);
0981: msgWriter
0982: .println(getI18NBundle()
0983: .getMessage(
0984: "jbi.ui.ant.print.jbi.stats.common.num.received.faults",
0985: new String[] { numReceivedFaults
0986: .toString() }));
0987: }
0988: if (compItemSet
0989: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_FAULTS)) {
0990: Long numSentFaults = (Long) endpointCompData
0991: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_FAULTS);
0992: msgWriter
0993: .println(getI18NBundle()
0994: .getMessage(
0995: "jbi.ui.ant.print.jbi.stats.common.num.sent.faults",
0996: new String[] { numSentFaults
0997: .toString() }));
0998: }
0999: if (compItemSet
1000: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_ERRORS)) {
1001: Long numReceivedErrors = (Long) endpointCompData
1002: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_ERRORS);
1003: msgWriter
1004: .println(getI18NBundle()
1005: .getMessage(
1006: "jbi.ui.ant.print.jbi.stats.common.num.received.errors",
1007: new String[] { numReceivedErrors
1008: .toString() }));
1009: }
1010: if (compItemSet
1011: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_ERRORS)) {
1012: Long numSentErrors = (Long) endpointCompData
1013: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_ERRORS);
1014: msgWriter
1015: .println(getI18NBundle()
1016: .getMessage(
1017: "jbi.ui.ant.print.jbi.stats.common.num.sent.errors",
1018: new String[] { numSentErrors
1019: .toString() }));
1020: }
1021:
1022: String valueNotAvailable = getI18NBundle()
1023: .getMessage(
1024: "jbi.ui.ant.print.jbi.stats.common.message.value.not.available",
1025: null);
1026:
1027: msgWriter
1028: .println("\n"
1029: + getI18NBundle()
1030: .getMessage(
1031: "jbi.ui.ant.print.jbi.stats.common.message.exchanges.statistics",
1032: null) + "\n");
1033:
1034: if (compItemSet
1035: .contains(JBIStatisticsItemNames.MESSAGE_EXCHANGE_RESPONSE_TIME)) {
1036: Long mepResponseTime = (Long) endpointCompData
1037: .get(JBIStatisticsItemNames.MESSAGE_EXCHANGE_RESPONSE_TIME);
1038: msgWriter
1039: .println(getI18NBundle()
1040: .getMessage(
1041: "jbi.ui.ant.print.jbi.stats.common.mep.response.time",
1042: new String[] { mepResponseTime == null ? valueNotAvailable
1043: : mepResponseTime
1044: .toString() }));
1045: }
1046: if (compItemSet
1047: .contains(JBIStatisticsItemNames.MESSAGE_EXCHANGE_COMPONENT_TIME)) {
1048: String componentName = (String) endpointCompData
1049: .get(JBIStatisticsItemNames.ENDPOINT_COMPONENT_NAME);
1050: Long mepComponentTime = (Long) endpointCompData
1051: .get(JBIStatisticsItemNames.MESSAGE_EXCHANGE_COMPONENT_TIME);
1052: msgWriter
1053: .println(getI18NBundle()
1054: .getMessage(
1055: "jbi.ui.ant.print.jbi.stats.common.mep.component.time",
1056: new String[] {
1057: componentName + "",
1058: mepComponentTime == null ? valueNotAvailable
1059: : mepComponentTime
1060: .toString() }));
1061: }
1062: if (compItemSet
1063: .contains(JBIStatisticsItemNames.MESSAGE_EXCHANGE_DELIVERY_CHANNEL_TIME)) {
1064: Long mepDeliveryChannelTime = (Long) endpointCompData
1065: .get(JBIStatisticsItemNames.MESSAGE_EXCHANGE_DELIVERY_CHANNEL_TIME);
1066: msgWriter
1067: .println(getI18NBundle()
1068: .getMessage(
1069: "jbi.ui.ant.print.jbi.stats.common.mep.delivery.channel.time",
1070: new String[] { mepDeliveryChannelTime == null ? valueNotAvailable
1071: : mepDeliveryChannelTime
1072: .toString() }));
1073: }
1074: if (compItemSet
1075: .contains(JBIStatisticsItemNames.MESSAGE_EXCHANGE_NMR_TIME)) {
1076: Long mepMessageServiceTime = (Long) endpointCompData
1077: .get(JBIStatisticsItemNames.MESSAGE_EXCHANGE_NMR_TIME);
1078: msgWriter
1079: .println(getI18NBundle()
1080: .getMessage(
1081: "jbi.ui.ant.print.jbi.stats.common.mep.message.service.time",
1082: new String[] { mepMessageServiceTime == null ? valueNotAvailable
1083: : mepMessageServiceTime
1084: .toString() }));
1085: }
1086:
1087: if (compItemSet
1088: .contains(JBIStatisticsItemNames.OJC_PERFORMANCE_STATS)) {
1089: msgWriter
1090: .println("\n"
1091: + getI18NBundle()
1092: .getMessage(
1093: "jbi.ui.ant.print.jbi.stats.common.perf.instr.dataline",
1094: null) + "\n");
1095:
1096: TabularData pfTbData = (TabularData) endpointCompData
1097: .get(JBIStatisticsItemNames.OJC_PERFORMANCE_STATS);
1098: for (Iterator pfTbIter = pfTbData.values()
1099: .iterator(); pfTbIter.hasNext();) {
1100: CompositeData pfCompData = (CompositeData) pfTbIter
1101: .next();
1102: printCompositeDataRecursively(pfCompData,
1103: msgWriter, "");
1104: msgWriter.println("");
1105: }
1106: }
1107: } else if (("" + compTypeName)
1108: .compareTo(COMSUMER_ENDPOINT_TYPE_NAME) == 0) {
1109: msgWriter
1110: .println(getI18NBundle()
1111: .getMessage(
1112: "jbi.ui.ant.print.jbi.stats.endpoint.consumer.name",
1113: new String[] { endpointName }));
1114: msgWriter.println(pageSeparator);
1115:
1116: if (compItemSet
1117: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_REQUESTS)) {
1118: Long numSentRequests = (Long) endpointCompData
1119: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_REQUESTS);
1120: msgWriter
1121: .println(getI18NBundle()
1122: .getMessage(
1123: "jbi.ui.ant.print.jbi.stats.common.num.sent.requests",
1124: new String[] { numSentRequests
1125: .toString() }));
1126: }
1127: if (compItemSet
1128: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_REPLIES)) {
1129: Long numReceivedRequests = (Long) endpointCompData
1130: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_REPLIES);
1131: msgWriter
1132: .println(getI18NBundle()
1133: .getMessage(
1134: "jbi.ui.ant.print.jbi.stats.common.num.received.replies",
1135: new String[] { numReceivedRequests
1136: .toString() }));
1137: }
1138: if (compItemSet
1139: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_DONES)) {
1140: Long numReceivedDONEs = (Long) endpointCompData
1141: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_DONES);
1142: msgWriter
1143: .println(getI18NBundle()
1144: .getMessage(
1145: "jbi.ui.ant.print.jbi.stats.common.num.received.dones",
1146: new String[] { numReceivedDONEs
1147: .toString() }));
1148: }
1149: if (compItemSet
1150: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_DONES)) {
1151: Long numSentDONEs = (Long) endpointCompData
1152: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_DONES);
1153: msgWriter
1154: .println(getI18NBundle()
1155: .getMessage(
1156: "jbi.ui.ant.print.jbi.stats.common.num.sent.dones",
1157: new String[] { numSentDONEs
1158: .toString() }));
1159: }
1160: if (compItemSet
1161: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_FAULTS)) {
1162: Long numReceivedFaults = (Long) endpointCompData
1163: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_FAULTS);
1164: msgWriter
1165: .println(getI18NBundle()
1166: .getMessage(
1167: "jbi.ui.ant.print.jbi.stats.common.num.received.faults",
1168: new String[] { numReceivedFaults
1169: .toString() }));
1170: }
1171: if (compItemSet
1172: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_FAULTS)) {
1173: Long numSentFaults = (Long) endpointCompData
1174: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_FAULTS);
1175: msgWriter
1176: .println(getI18NBundle()
1177: .getMessage(
1178: "jbi.ui.ant.print.jbi.stats.common.num.sent.faults",
1179: new String[] { numSentFaults
1180: .toString() }));
1181: }
1182: if (compItemSet
1183: .contains(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_ERRORS)) {
1184: Long numReceivedErrors = (Long) endpointCompData
1185: .get(JBIStatisticsItemNames.NUMBER_OF_RECEIVED_ERRORS);
1186: msgWriter
1187: .println(getI18NBundle()
1188: .getMessage(
1189: "jbi.ui.ant.print.jbi.stats.common.num.received.errors",
1190: new String[] { numReceivedErrors
1191: .toString() }));
1192: }
1193: if (compItemSet
1194: .contains(JBIStatisticsItemNames.NUMBER_OF_SENT_ERRORS)) {
1195: Long numSentErrors = (Long) endpointCompData
1196: .get(JBIStatisticsItemNames.NUMBER_OF_SENT_ERRORS);
1197: msgWriter
1198: .println(getI18NBundle()
1199: .getMessage(
1200: "jbi.ui.ant.print.jbi.stats.common.num.sent.errors",
1201: new String[] { numSentErrors
1202: .toString() }));
1203: }
1204:
1205: String valueNotAvailable = getI18NBundle()
1206: .getMessage(
1207: "jbi.ui.ant.print.jbi.stats.common.message.value.not.available",
1208: null);
1209:
1210: msgWriter
1211: .println("\n"
1212: + getI18NBundle()
1213: .getMessage(
1214: "jbi.ui.ant.print.jbi.stats.common.message.exchanges.statistics",
1215: null) + "\n");
1216:
1217: if (compItemSet
1218: .contains(JBIStatisticsItemNames.MESSAGE_EXCHANGE_RESPONSE_TIME)) {
1219: Long mepResponseTime = (Long) endpointCompData
1220: .get(JBIStatisticsItemNames.MESSAGE_EXCHANGE_RESPONSE_TIME);
1221: msgWriter
1222: .println(getI18NBundle()
1223: .getMessage(
1224: "jbi.ui.ant.print.jbi.stats.common.mep.response.time",
1225: new String[] { mepResponseTime == null ? valueNotAvailable
1226: : mepResponseTime
1227: .toString() }));
1228: }
1229: if (compItemSet
1230: .contains(JBIStatisticsItemNames.MESSAGE_EXCHANGE_COMPONENT_TIME)) {
1231: Long mepComponentTime = (Long) endpointCompData
1232: .get(JBIStatisticsItemNames.MESSAGE_EXCHANGE_COMPONENT_TIME);
1233: msgWriter
1234: .println(getI18NBundle()
1235: .getMessage(
1236: "jbi.ui.ant.print.jbi.stats.common.mep.component.time.noname",
1237: new String[] { mepComponentTime == null ? valueNotAvailable
1238: : mepComponentTime
1239: .toString() }));
1240: }
1241: if (compItemSet
1242: .contains(JBIStatisticsItemNames.MESSAGE_EXCHANGE_DELIVERY_CHANNEL_TIME)) {
1243: Long mepDeliveryChannelTime = (Long) endpointCompData
1244: .get(JBIStatisticsItemNames.MESSAGE_EXCHANGE_DELIVERY_CHANNEL_TIME);
1245: msgWriter
1246: .println(getI18NBundle()
1247: .getMessage(
1248: "jbi.ui.ant.print.jbi.stats.common.mep.delivery.channel.time",
1249: new String[] { mepDeliveryChannelTime == null ? valueNotAvailable
1250: : mepDeliveryChannelTime
1251: .toString() }));
1252: }
1253: if (compItemSet
1254: .contains(JBIStatisticsItemNames.CONSUMING_ENDPOINT_STATUS_TIME)) {
1255: Long mepMessageServiceTime = (Long) endpointCompData
1256: .get(JBIStatisticsItemNames.CONSUMING_ENDPOINT_STATUS_TIME);
1257: msgWriter
1258: .println(getI18NBundle()
1259: .getMessage(
1260: "jbi.ui.ant.print.jbi.stats.common.mep.message.service.time",
1261: new String[] { mepMessageServiceTime == null ? valueNotAvailable
1262: : mepMessageServiceTime
1263: .toString() }));
1264: }
1265:
1266: msgWriter
1267: .println("\n"
1268: + getI18NBundle()
1269: .getMessage(
1270: "jbi.ui.ant.print.jbi.stats.common.perf.instr.dataline",
1271: null) + "\n");
1272:
1273: if (compItemSet
1274: .contains(JBIStatisticsItemNames.OJC_PERFORMANCE_STATS)) {
1275: TabularData pfTbData = (TabularData) endpointCompData
1276: .get(JBIStatisticsItemNames.OJC_PERFORMANCE_STATS);
1277: for (Iterator pfTbIter = pfTbData.values()
1278: .iterator(); pfTbIter.hasNext();) {
1279: CompositeData pfCompData = (CompositeData) pfTbIter
1280: .next();
1281: printCompositeDataRecursively(pfCompData,
1282: msgWriter, "");
1283: msgWriter.println("");
1284: }
1285: }
1286: }
1287: msgWriter.println("");
1288: }
1289: msgWriter.println("");
1290: }
1291:
1292: /**
1293: * Print statistics data for components
1294: * @param result the tabular data containing NMR stats data
1295: * @param target
1296: * @param msgWriter the PrintWriter
1297: */
1298: private void printStatsForNMR(TabularData result, String target,
1299: PrintWriter msgWriter) {
1300: String header = getI18NBundle().getMessage(
1301: "jbi.ui.ant.print.jbi.stats.nmr.info.header",
1302: new String[] { target });
1303: String headerSeparator = getI18NBundle().getMessage(
1304: "jbi.ui.ant.print.jbi.stats.info.header.separator");
1305: String pageSeparator = getI18NBundle().getMessage(
1306: "jbi.ui.ant.print.jbi.stats.info.separator");
1307:
1308: String emptyResult = getI18NBundle().getMessage(
1309: "jbi.ui.ant.print.jbi.stats.nmr.info.empty");
1310:
1311: msgWriter.println(headerSeparator);
1312: msgWriter.println(header);
1313: msgWriter.println(headerSeparator);
1314:
1315: if ((result == null) || (result.size() == 0)) {
1316: msgWriter.println(emptyResult);
1317: msgWriter.println(pageSeparator);
1318: return;
1319: }
1320:
1321: for (Iterator dataIter = result.values().iterator(); dataIter
1322: .hasNext();) {
1323: CompositeData compData = (CompositeData) dataIter.next();
1324: String instanceName = (String) compData
1325: .get(JBIStatisticsItemNames.INSTANCE_NAME);
1326: String[] listActiveChannels = (String[]) compData
1327: .get(JBIStatisticsItemNames.NMR_STATS_ACTIVE_CHANNELS);
1328: String[] listActiveEndpoints = (String[]) compData
1329: .get(JBIStatisticsItemNames.NMR_STATS_ACTIVE_ENDPOINTS);
1330:
1331: String instanceNameLine = getI18NBundle().getMessage(
1332: "jbi.ui.ant.print.jbi.stats.nmr.instance.name",
1333: new String[] { instanceName });
1334:
1335: msgWriter.println(instanceNameLine);
1336: msgWriter.println(pageSeparator);
1337:
1338: if (listActiveChannels != null) {
1339: String activeChannelNumberLine = getI18NBundle()
1340: .getMessage(
1341: "jbi.ui.ant.print.jbi.stats.nmr.active.channel.number",
1342: new String[] { Integer
1343: .toString(listActiveChannels.length) });
1344:
1345: msgWriter.println(activeChannelNumberLine);
1346: for (int i = 0; i < listActiveChannels.length; ++i) {
1347: msgWriter.println(listActiveChannels[i]);
1348: }
1349:
1350: }
1351:
1352: msgWriter.println("");
1353:
1354: if (listActiveEndpoints != null) {
1355: String activeEndpointNumberLine = getI18NBundle()
1356: .getMessage(
1357: "jbi.ui.ant.print.jbi.stats.nmr.active.endpoint.number",
1358: new String[] { Integer
1359: .toString(listActiveEndpoints.length) });
1360: msgWriter.println(activeEndpointNumberLine);
1361: for (int i = 0; i < listActiveEndpoints.length; ++i) {
1362: msgWriter.println(listActiveEndpoints[i]);
1363: }
1364: }
1365:
1366: msgWriter.println("");
1367: msgWriter.println("");
1368: }
1369: }
1370:
1371: /**
1372: * Query the stats data for components
1373: * @param theList the list which contains component element
1374: * @param target
1375: * @return the vector which contains comoonent stats data in tabular objects
1376: */
1377: private void getStatsForComponentsAndPrintStats(List theList,
1378: String target, PrintWriter msgWriter,
1379: StringWriter stringWriter) {
1380:
1381: ArrayList componentList = new ArrayList(theList);
1382:
1383: // Check the list, remove the entry with empty name value
1384: Iterator compIter = theList.iterator();
1385: while (compIter.hasNext()) {
1386: Component comp = (Component) compIter.next();
1387: if (comp != null) {
1388: String compName = comp.getName();
1389: if ((compName != null)
1390: && (compName.trim().compareTo("") == 0)) {
1391: componentList.remove(comp);
1392: }
1393: }
1394: }
1395:
1396: try {
1397: if (componentList.size() == 0) {
1398: compIter = null;
1399: JBIComponentInfo compInfo = null;
1400:
1401: List bcList = JBIComponentInfo.readFromXmlText(this
1402: .getJBIAdminCommands().listBindingComponents(
1403: COMPONENT_STARTED_STATE, null, null,
1404: target));
1405: compIter = bcList.iterator();
1406: while (compIter.hasNext()) {
1407: compInfo = (JBIComponentInfo) compIter.next();
1408: Component component = new Component();
1409: component.setName(compInfo.getName());
1410: componentList.add(component);
1411: }
1412:
1413: List seList = JBIComponentInfo.readFromXmlText(this
1414: .getJBIAdminCommands().listServiceEngines(
1415: COMPONENT_STARTED_STATE, null, null,
1416: target));
1417: compIter = bcList.iterator();
1418: compIter = seList.iterator();
1419: while (compIter.hasNext()) {
1420: compInfo = (JBIComponentInfo) compIter.next();
1421: Component component = new Component();
1422: component.setName(compInfo.getName());
1423: componentList.add(component);
1424: }
1425: }
1426:
1427: // Start to print ...
1428: String header = getI18NBundle().getMessage(
1429: "jbi.ui.ant.print.jbi.stats.component.info.header",
1430: new String[] { target });
1431: String headerSeparator = getI18NBundle().getMessage(
1432: "jbi.ui.ant.print.jbi.stats.info.header.separator");
1433: String pageSeparator = getI18NBundle().getMessage(
1434: "jbi.ui.ant.print.jbi.stats.info.separator");
1435:
1436: String emptyResult = getI18NBundle().getMessage(
1437: "jbi.ui.ant.print.jbi.stats.component.info.empty");
1438:
1439: msgWriter.println(headerSeparator);
1440: msgWriter.println(header);
1441: msgWriter.println(headerSeparator);
1442:
1443: int results = 0;
1444: Iterator it = componentList.iterator();
1445: while (it.hasNext()) {
1446: String compName = (String) ((Component) it.next())
1447: .getName();
1448: logDebug("The component name is: " + compName);
1449: TabularData result = this .getJBIAdminCommands()
1450: .getComponentStats(compName, target);
1451: printStatsForComponent(compName, result, target,
1452: msgWriter, pageSeparator);
1453: stringWriter.flush();
1454:
1455: ++results;
1456: }
1457:
1458: if (results == 0) {
1459: msgWriter.println(emptyResult);
1460: msgWriter.println(pageSeparator);
1461: }
1462: } catch (Exception ex) {
1463: processTaskException(ex);
1464: }
1465: }
1466:
1467: /**
1468: * Query the stats data for service assemblies
1469: * @param theList the list which contains service assembly elements
1470: * @param target
1471: * @return the vector which contains service assembly stats data in tabular objects
1472: */
1473: private void getStatsForServiceAssemblies(List theList,
1474: String target, PrintWriter msgWriter,
1475: StringWriter stringWriter) {
1476: ArrayList saNameList = new ArrayList(theList);
1477:
1478: // Check the list, remove the entry with empty name value
1479: Iterator saNameIter = theList.iterator();
1480: while (saNameIter.hasNext()) {
1481: ServiceAssembly sa = (ServiceAssembly) saNameIter.next();
1482: if (sa != null) {
1483: String saName = sa.getName();
1484: if ((saName != null)
1485: && (saName.trim().compareTo("") == 0)) {
1486: saNameList.remove(sa);
1487: }
1488: }
1489: }
1490:
1491: try {
1492: if (saNameList.size() == 0) {
1493: List saList = ServiceAssemblyInfo
1494: .readFromXmlTextWithProlog(this
1495: .getJBIAdminCommands()
1496: .listServiceAssemblies(target));
1497:
1498: ServiceAssemblyInfo saInfo = null;
1499: Iterator saIter = saList.iterator();
1500: logDebug("Start to list sa names");
1501: while (saIter.hasNext()) {
1502: saInfo = (ServiceAssemblyInfo) saIter.next();
1503: ServiceAssembly sa = new ServiceAssembly();
1504: sa.setName(saInfo.getName());
1505: saNameList.add(sa);
1506: logDebug("The sa name is: " + saInfo.getName());
1507: }
1508: }
1509:
1510: // Start to print ...
1511: String header = getI18NBundle().getMessage(
1512: "jbi.ui.ant.print.jbi.stats.sa.info.header",
1513: new String[] { target });
1514: String headerSeparator = getI18NBundle().getMessage(
1515: "jbi.ui.ant.print.jbi.stats.info.header.separator");
1516: String pageSeparator = getI18NBundle().getMessage(
1517: "jbi.ui.ant.print.jbi.stats.info.separator");
1518:
1519: String emptyResult = getI18NBundle().getMessage(
1520: "jbi.ui.ant.print.jbi.stats.sa.info.empty");
1521:
1522: msgWriter.println(headerSeparator);
1523: msgWriter.println(header);
1524: msgWriter.println(headerSeparator);
1525:
1526: int results = 0;
1527: Iterator it = saNameList.iterator();
1528: while (it.hasNext()) {
1529: String saName = ((ServiceAssembly) it.next()).getName();
1530: TabularData result = (TabularData) this
1531: .getJBIAdminCommands().getServiceAssemblyStats(
1532: saName, target);
1533: if (result != null) {
1534: printStatsForServiceAssembly(result, target,
1535: msgWriter, pageSeparator);
1536: stringWriter.flush();
1537: ++results;
1538: }
1539: }
1540:
1541: if (results == 0) {
1542: msgWriter.println(emptyResult);
1543: msgWriter.println(pageSeparator);
1544: }
1545: } catch (Exception ex) {
1546: processTaskException(ex);
1547: }
1548: }
1549:
1550: /**
1551: * Query the stats data for endpoints
1552: * @param theList the list which contains endpoint element
1553: * @param target
1554: * @return the vector which contains comoonent stats data in tabular objects
1555: */
1556: private void getStatsForEndpointsAndPrintStats(List theList,
1557: String target, PrintWriter msgWriter,
1558: StringWriter stringWriter) {
1559: ArrayList endpointNameList = new ArrayList(theList);
1560:
1561: // Check the list, remove the entry with empty name value
1562: Iterator endpointNameIter = theList.iterator();
1563: while (endpointNameIter.hasNext()) {
1564: Endpoint endpoint = (Endpoint) endpointNameIter.next();
1565: if (endpoint != null) {
1566: String endpointName = endpoint.getName();
1567: if ((endpointName != null)
1568: && (endpointName.trim().compareTo("") == 0)) {
1569: endpointNameList.remove(endpoint);
1570: }
1571: }
1572: }
1573:
1574: try {
1575: if (endpointNameList.size() == 0) {
1576: TabularData tbData = this .getJBIAdminCommands()
1577: .getNMRStats(target);
1578:
1579: for (Iterator dataIter = tbData.values().iterator(); dataIter
1580: .hasNext();) {
1581: CompositeData compData = (CompositeData) dataIter
1582: .next();
1583: String[] listActiveEndpoints = (String[]) compData
1584: .get(JBIStatisticsItemNames.NMR_STATS_ACTIVE_ENDPOINTS);
1585:
1586: for (int i = 0; i < listActiveEndpoints.length; ++i) {
1587: Endpoint endpoint = new Endpoint();
1588: endpoint
1589: .setName((String) listActiveEndpoints[i]);
1590: endpointNameList.add(endpoint);
1591: }
1592: }
1593: }
1594:
1595: // Start to print ...
1596: String header = getI18NBundle().getMessage(
1597: "jbi.ui.ant.print.jbi.stats.endpoint.info.header",
1598: new String[] { target });
1599: String headerSeparator = getI18NBundle().getMessage(
1600: "jbi.ui.ant.print.jbi.stats.info.header.separator");
1601: String pageSeparator = getI18NBundle().getMessage(
1602: "jbi.ui.ant.print.jbi.stats.info.separator");
1603:
1604: String emptyResult = getI18NBundle().getMessage(
1605: "jbi.ui.ant.print.jbi.stats.endpoint.info.empty");
1606:
1607: msgWriter.println(headerSeparator);
1608: msgWriter.println(header);
1609: msgWriter.println(headerSeparator);
1610:
1611: int results = 0;
1612:
1613: Iterator it = endpointNameList.iterator();
1614: while (it.hasNext()) {
1615: String endpointName = ((Endpoint) it.next()).getName();
1616: logDebug("Statistics for endpoint, the endpoint is "
1617: + endpointName);
1618: logDebug("Statistics for endpoint, the target is "
1619: + target);
1620: TabularData result = (TabularData) this
1621: .getJBIAdminCommands().getEndpointStats(
1622: endpointName, target);
1623: if (result != null) {
1624: printStatsForEndpoint(endpointName, result, target,
1625: msgWriter, pageSeparator);
1626: stringWriter.flush();
1627: ++results;
1628: }
1629: }
1630:
1631: if (results == 0) {
1632: msgWriter.println(emptyResult);
1633: msgWriter.println(pageSeparator);
1634: }
1635:
1636: } catch (Exception ex) {
1637: processTaskException(ex);
1638: }
1639: }
1640:
1641: /**
1642: * returns i18n key. tasks implement this method.
1643: * @return i18n key for the success status
1644: */
1645: protected String getTaskFailedStatusI18NKey() {
1646: return FAILED_STATUS_KEY;
1647: }
1648:
1649: /**
1650: * returns i18n key. tasks implement this method.
1651: * @return i18n key for the failed status
1652: */
1653: protected String getTaskSuccessStatusI18NKey() {
1654: return SUCCESS_STATUS_KEY;
1655: }
1656:
1657: /**
1658: * Ant helper class
1659: */
1660: public class Component {
1661: protected String mName;
1662:
1663: public Component() {
1664: mName = "";
1665: }
1666:
1667: public String getName() {
1668: return mName;
1669: }
1670:
1671: public void setName(String theName) {
1672: mName = theName;
1673: }
1674: }
1675:
1676: /**
1677: * Ant helper class
1678: */
1679: public class ServiceAssembly {
1680: protected String mName;
1681:
1682: public ServiceAssembly() {
1683: mName = "";
1684: }
1685:
1686: public String getName() {
1687: return mName;
1688: }
1689:
1690: public void setName(String theName) {
1691: mName = theName;
1692: }
1693: }
1694:
1695: /**
1696: * Ant helper class
1697: */
1698: public class Endpoint {
1699: protected String mName;
1700:
1701: public Endpoint() {
1702: mName = "";
1703: }
1704:
1705: public String getName() {
1706: return mName;
1707: }
1708:
1709: public void setName(String theName) {
1710: mName = theName;
1711: }
1712: }
1713: }
|