0001: /*
0002: * ChainBuilder ESB
0003: * Visual Enterprise Integration
0004: *
0005: * Copyright (C) 2006 Bostech Corporation
0006: *
0007: * This program is free software; you can redistribute it and/or modify it
0008: * under the terms of the GNU General Public License as published by the
0009: * Free Software Foundation; either version 2 of the License, or (at your option)
0010: * any later version.
0011: *
0012: * This program is distributed in the hope that it will be useful,
0013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
0014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0015: * for more details.
0016: *
0017: * You should have received a copy of the GNU General Public License along with
0018: * this program; if not, write to the Free Software Foundation, Inc.,
0019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0020: *
0021: *
0022: * $Id: JmxOperationImpl.java 3985 2006-12-20 19:48:34Z tvolle $
0023: */
0024: package com.bostechcorp.cbesb.console.server;
0025:
0026: import java.util.ArrayList;
0027: import java.util.HashMap;
0028: import java.util.List;
0029:
0030: import com.bostechcorp.cbesb.common.i18n.CoreMessageConstants;
0031: import com.bostechcorp.cbesb.common.i18n.Messages;
0032: import com.bostechcorp.cbesb.common.util.runtimedb.EndpointSettingDB;
0033: import com.bostechcorp.cbesb.common.util.runtimedb.EndpointStatisticsDB;
0034: import com.bostechcorp.cbesb.common.util.runtimedb.vo.EndpointStatVO;
0035: import com.bostechcorp.cbesb.console.client.ConsoleVersion;
0036: import com.bostechcorp.cbesb.console.common.BaseRPCResultInfo;
0037: import com.bostechcorp.cbesb.console.common.JmxAssemblyInfo;
0038: import com.bostechcorp.cbesb.console.common.JmxComponentInfo;
0039: import com.bostechcorp.cbesb.console.common.JmxEndpointInfo;
0040: import com.bostechcorp.cbesb.console.common.ServerSideException;
0041: import com.bostechcorp.cbesb.console.jmxclient.JmxClient;
0042: import com.bostechcorp.cbesb.console.pub.JmxAssemblyExtObj;
0043: import com.bostechcorp.cbesb.console.pub.JmxAssemblyObj;
0044: import com.bostechcorp.cbesb.console.pub.JmxComponentObj;
0045: import com.bostechcorp.cbesb.console.pub.JmxEndpointObj;
0046: import com.bostechcorp.cbesb.console.rpc.JmxOperation;
0047:
0048: public class JmxOperationImpl extends JmxServiceServlet implements
0049: JmxOperation {
0050:
0051: private static final long serialVersionUID = -84691175475079607L;
0052:
0053: public final String DELIMITER = "#";
0054:
0055: public final String[] SEPRIORITYLIST = new String[] {
0056: "ChainBuilderESB-SE-Installer",
0057: "ChainBuilderESB-SE-Scheduler" };
0058:
0059: public JmxComponentInfo getCurrentComponentList() {
0060: JmxComponentInfo result = null;
0061: try {
0062: result = new JmxComponentInfo();
0063: result
0064: .setCallType(JmxComponentInfo.GET_CURRENT_COMPONENT_LIST);
0065:
0066: getClientFromSession().getCurrentComponentList(result);
0067: result.setRefreshRate(ConsoleSettingUtil
0068: .getComponentRefreshRate(super .getCurrentUserId()));
0069: } catch (Throwable t) {
0070: result
0071: .setException(
0072: (Messages
0073: .get(CoreMessageConstants.FAILED_GET_COMPONENT_LIST)),
0074: (Exception) t);
0075: }
0076: return result;
0077: }
0078:
0079: public JmxComponentInfo getInstallComponentList() {
0080: JmxComponentInfo result = null;
0081: try {
0082: result = new JmxComponentInfo();
0083: result
0084: .setCallType(JmxComponentInfo.GET_INSTALL_COMPONENT_LIST);
0085:
0086: getClientFromSession().getInstallCompontentList(result);
0087: result.setRefreshRate(ConsoleSettingUtil
0088: .getComponentRefreshRate(super .getCurrentUserId()));
0089:
0090: } catch (Throwable t) {
0091: result
0092: .setException(
0093: (Messages
0094: .get(CoreMessageConstants.FAILED_GET_COMPONENT_LIST)),
0095: (Exception) t);
0096: }
0097: return result;
0098: }
0099:
0100: public JmxComponentInfo shutdownComponent(String componentName) {
0101: JmxComponentInfo result = null;
0102: try {
0103: result = new JmxComponentInfo();
0104: // result.setCallType(JmxComponentInfo.SHUTDOWN_COMPONENT);
0105:
0106: getClientFromSession().shutdownComponent(componentName);
0107: result = getCurrentComponentList();
0108: } catch (Throwable t) {
0109: result
0110: .setException(
0111: (Messages
0112: .get(CoreMessageConstants.FAILED_SHUTDOWN_COMPONENT))
0113: + ":" + componentName,
0114: (Exception) t);
0115: }
0116: return result;
0117: }
0118:
0119: public JmxComponentInfo startComponent(String componentName) {
0120: JmxComponentInfo result = null;
0121: try {
0122: result = new JmxComponentInfo();
0123: // result.setCallType(JmxComponentInfo.START_COMPONENT);
0124:
0125: getClientFromSession().startComponent(componentName);
0126: result = getCurrentComponentList();
0127: } catch (Throwable t) {
0128: result.setException((Messages
0129: .get(CoreMessageConstants.FAILED_START_COMPONENT))
0130: + ":" + componentName, (Exception) t);
0131: }
0132: return result;
0133: }
0134:
0135: public JmxComponentInfo startAllComponent() {
0136: JmxComponentInfo result = null;
0137: try {
0138: result = new JmxComponentInfo();
0139: // result.setCallType(JmxComponentInfo.START_COMPONENT);
0140:
0141: List priorityList = getStartPriorityList();
0142: for (int i = 0; i < priorityList.size(); i++) {
0143: String componentName = (String) priorityList.get(i);
0144: getClientFromSession().startComponent(componentName);
0145: }
0146: result = getCurrentComponentList();
0147: } catch (Throwable t) {
0148: result
0149: .setException(
0150: (Messages
0151: .get(CoreMessageConstants.FAILED_STARTAll_COMPONENT)),
0152: (Exception) t);
0153: }
0154: return result;
0155: }
0156:
0157: public JmxComponentInfo shutdownAllComponent() {
0158: JmxComponentInfo result = null;
0159: try {
0160: result = new JmxComponentInfo();
0161: // result.setCallType(JmxComponentInfo.SHUTDOWN_COMPONENT);
0162:
0163: List priorityList = getStartPriorityList();
0164: for (int i = priorityList.size() - 1; i >= 0; i--) {
0165: String componentName = (String) priorityList.get(i);
0166: getClientFromSession().shutdownComponent(componentName);
0167: }
0168: result = getCurrentComponentList();
0169: } catch (Throwable t) {
0170: result
0171: .setException(
0172: (Messages
0173: .get(CoreMessageConstants.FAILED_SHUTDOWNALL_COMPONENT)),
0174: (Exception) t);
0175: }
0176: return result;
0177: }
0178:
0179: public JmxComponentInfo stopComponent(String componentName) {
0180: JmxComponentInfo result = null;
0181:
0182: try {
0183: result = new JmxComponentInfo();
0184: result.setCallType(JmxComponentInfo.START_COMPONENT);
0185: getClientFromSession().stopComponent(componentName);
0186: } catch (Exception e) {
0187: result.setException((Messages
0188: .get(CoreMessageConstants.FAILED_STOP_COMPONENT))
0189: + ":" + componentName, (Exception) e);
0190: }
0191:
0192: return result;
0193: }
0194:
0195: // -------------------------------------------------------------------------
0196: public JmxAssemblyInfo deployServiceAssembly(String assemblyZipUrl) {
0197: JmxAssemblyInfo result = null;
0198: try {
0199: result = new JmxAssemblyInfo();
0200: // result.setCallType(JmxAssemblyInfo.DEPLOY_SERVICEASSEMBLY);
0201: getClientFromSession()
0202: .deployServiceAssembly(assemblyZipUrl);
0203: result = getDeployServiceAssemblyList();
0204: } catch (Throwable t) {
0205: result
0206: .setException(
0207: (Messages
0208: .get(CoreMessageConstants.FAILED_DEPLOY_SERVICE_ASSEMBLY))
0209: + ":" + assemblyZipUrl,
0210: (Exception) t);
0211: }
0212: return result;
0213: }
0214:
0215: public JmxAssemblyInfo getCurrentServiceAssemblyList() {
0216: JmxAssemblyInfo result = null;
0217: try {
0218: result = new JmxAssemblyInfo();
0219: result
0220: .setCallType(JmxAssemblyInfo.GET_CURRENT_SERVICEASSEMBLY_LIST);
0221: getClientFromSession()
0222: .getCurrentServiceAssemblyList(result);
0223: result.setRefreshRate(ConsoleSettingUtil
0224: .getSaRefreshRate(super .getCurrentUserId()));
0225: } catch (Throwable t) {
0226: result
0227: .setException(
0228: (Messages
0229: .get(CoreMessageConstants.FAILED_GET_CURRENT_ASSEMBLY_LIST)),
0230: (Exception) t);
0231: }
0232: return result;
0233: }
0234:
0235: /**
0236: * get AssemblyList and AssemblyObj at one time for endpoint status view
0237: * @param saName
0238: * @return
0239: */
0240: public JmxAssemblyExtObj getSAListForEndpointStatus(String saName) {
0241: JmxAssemblyExtObj result = null;
0242: try {
0243: result = new JmxAssemblyExtObj();
0244: JmxClient jmxclient = getClientFromSession();
0245: // jmxclient.stopPollingNotification();
0246: result.setSaList(jmxclient.getSANames());
0247: if (result.getSaList().length > 0) {
0248: if (saName == null || saName.equals(""))
0249: saName = result.getSaList()[0];
0250: else {
0251: if (!includeInArray(result.getSaList(), saName)) {
0252: saName = result.getSaList()[0];
0253: }
0254: }
0255: JmxAssemblyObj assemblyObj = this
0256: .getAssemblyObjAndValues(saName);
0257: if (assemblyObj.isError()) {
0258: result.setException(assemblyObj.getExceptionText(),
0259: assemblyObj.getExceptionTrace());
0260: return result;
0261: }
0262: result.setSaObj(assemblyObj);
0263: }
0264:
0265: } catch (Throwable t) {
0266: result
0267: .setException(
0268: (Messages
0269: .get(CoreMessageConstants.FAILED_GET_ENDPOINT_LIST)),
0270: (Exception) t);
0271: }
0272: return result;
0273: }
0274:
0275: private boolean includeInArray(String[] array, String value) {
0276: for (int i = 0; i < array.length; i++) {
0277: if (array[i].equals(value))
0278: return true;
0279: }
0280: return false;
0281: }
0282:
0283: /**
0284: * get AssemblyList and AssemblyObj at noe time for endpoint statistic view
0285: * @param saName
0286: * @return
0287: */
0288: public JmxAssemblyExtObj getSAListForEndpointStat(String saName) {
0289: JmxAssemblyExtObj result = null;
0290: try {
0291: result = new JmxAssemblyExtObj();
0292: JmxClient jmxclient = getClientFromSession();
0293: // jmxclient.stopPollingNotification();
0294: String[] saList = jmxclient.getSANames();
0295: result.setSaList(saList);
0296: if (result.getSaList().length > 0) {
0297: if (saName == null || saName.equals(""))
0298: saName = result.getSaList()[0];
0299: else {
0300: if (!includeInArray(result.getSaList(), saName)) {
0301: saName = result.getSaList()[0];
0302: }
0303: }
0304: result.setSaObj(this .getSaStatObj(saName));
0305: }
0306:
0307: } catch (Throwable t) {
0308: result
0309: .setException(
0310: (Messages
0311: .get(CoreMessageConstants.FAILED_GET_STATISTIC_INFO)),
0312: (Exception) t);
0313: }
0314: return result;
0315: }
0316:
0317: public JmxAssemblyInfo getDeployServiceAssemblyList() {
0318: JmxAssemblyInfo result = null;
0319: try {
0320: result = new JmxAssemblyInfo();
0321: result
0322: .setCallType(JmxAssemblyInfo.GET_DEPLOY_SERVICEASSEMBLY_LIST);
0323: getClientFromSession().getDeployServiceAssemblyList(result);
0324: result.setRefreshRate(ConsoleSettingUtil
0325: .getSaRefreshRate(super .getCurrentUserId()));
0326:
0327: } catch (Throwable t) {
0328: result
0329: .setException(
0330: (Messages
0331: .get(CoreMessageConstants.FAILED_GET_DEPLOY_ASSEMBLY_LIST)),
0332: (Exception) t);
0333: }
0334: return result;
0335: }
0336:
0337: public JmxAssemblyInfo shutdownServiceAssembly(String assemblyName) {
0338: JmxAssemblyInfo result = null;
0339: try {
0340: result = new JmxAssemblyInfo();
0341: // result.setCallType(JmxAssemblyInfo.SHOTDOWN_SERVICEASSEMBLY);
0342: getClientFromSession()
0343: .shutdownServiceAssembly(assemblyName);
0344: result = getCurrentServiceAssemblyList();
0345: } catch (Throwable t) {
0346: result
0347: .setException(
0348: (Messages
0349: .get(CoreMessageConstants.FAILED_SHUTDOWN_ASSEMBLY))
0350: + ":" + assemblyName, (Exception) t);
0351: }
0352: return result;
0353: }
0354:
0355: public JmxAssemblyInfo startServiceAssembly(String assemblyName) {
0356: JmxAssemblyInfo result = null;
0357: try {
0358: result = new JmxAssemblyInfo();
0359: getClientFromSession().startServiceAssembly(assemblyName);
0360: result = getCurrentServiceAssemblyList();
0361: } catch (Throwable t) {
0362: result.setException((Messages
0363: .get(CoreMessageConstants.FAILED_START_ASSEMBLY))
0364: + ":" + assemblyName, (Exception) t);
0365: }
0366: return result;
0367: }
0368:
0369: public JmxAssemblyInfo stopServiceAssembly(String assemblyName) {
0370: JmxAssemblyInfo result = null;
0371: try {
0372: result = new JmxAssemblyInfo();
0373: result.setCallType(JmxAssemblyInfo.STOP_SERVICEASSEMBLY);
0374: getClientFromSession().stopServiceAssembly(assemblyName);
0375: } catch (Throwable t) {
0376: result.setException((Messages
0377: .get(CoreMessageConstants.FAILED_STOP_ASSEMBLY))
0378: + ":" + assemblyName, (Exception) t);
0379: }
0380: return result;
0381: }
0382:
0383: public JmxAssemblyInfo undeployServiceAssembly(String assemblyName) {
0384: JmxAssemblyInfo result = null;
0385: try {
0386: result = new JmxAssemblyInfo();
0387: // result.setCallType(JmxAssemblyInfo.UNDEPLOY_SERVICEASSEMBLY);
0388: getClientFromSession()
0389: .undeployServiceAssembly(assemblyName);
0390: result = getDeployServiceAssemblyList();
0391: } catch (Throwable t) {
0392: result
0393: .setException(
0394: (Messages
0395: .get(CoreMessageConstants.FAILED_UNDEPLOY_ASSEMBLY))
0396: + ":" + assemblyName, (Exception) t);
0397: }
0398: return result;
0399: }
0400:
0401: public JmxComponentInfo installComponent(String componentName,
0402: String jarName) {
0403: JmxComponentInfo result = null;
0404: try {
0405: result = new JmxComponentInfo();
0406: // result.setCallType(JmxComponentInfo.INSTALL_COMPONENT);
0407:
0408: getClientFromSession().installComponent(componentName,
0409: jarName);
0410: result = getInstallComponentList();
0411: } catch (Throwable t) {
0412: result
0413: .setException(
0414: (Messages
0415: .get(CoreMessageConstants.FAILED_INSTALL_COMPONENT))
0416: + ":" + componentName,
0417: (Exception) t);
0418: }
0419: return result;
0420: }
0421:
0422: public JmxComponentInfo uninstallComponent(String componentName) {
0423: JmxComponentInfo result = null;
0424: try {
0425: result = new JmxComponentInfo();
0426: // result.setCallType(JmxComponentInfo.UNINSTALL_COMPONENT);
0427: getClientFromSession().uninstallComponent(componentName);
0428: result = getInstallComponentList();
0429: } catch (Throwable t) {
0430: result
0431: .setException(
0432: (Messages
0433: .get(CoreMessageConstants.FAILED_UNINSTALL_COMPONENT))
0434: + ":" + componentName,
0435: (Exception) t);
0436: }
0437: return result;
0438: }
0439:
0440: public JmxComponentInfo installAllComponents() {
0441: JmxComponentInfo result = null;
0442: try {
0443: result = new JmxComponentInfo();
0444: // result.setCallType(JmxComponentInfo.INSTALL_COMPONENT);
0445: List installlist = getInstallPriorityList();
0446:
0447: List lbs = getInstallSharedLibs();
0448: for (int i = 0; i < lbs.size(); i++) {
0449: String component = (String) lbs.get(i);
0450: String[] names = component.split(DELIMITER);
0451: String componentName = names[0];
0452: String jarName = names[1];
0453: getClientFromSession().installSharedLibrary(
0454: componentName, jarName);
0455: }
0456:
0457: for (int i = 0; i < installlist.size(); i++) {
0458: String component = (String) installlist.get(i);
0459:
0460: String[] names = component.split(DELIMITER);
0461: String componentName = names[0];
0462: String jarName = names[1];
0463: getClientFromSession().installComponent(componentName,
0464: jarName);
0465: }
0466: result = getInstallComponentList();
0467: } catch (Throwable t) {
0468: result
0469: .setException(
0470: (Messages
0471: .get(CoreMessageConstants.FAILED_INSTALLALL_COMPONENT)),
0472: (Exception) t);
0473: }
0474: return result;
0475: }
0476:
0477: public JmxComponentInfo uninstallAllComponents() {
0478: JmxComponentInfo result = null;
0479: try {
0480: result = new JmxComponentInfo();
0481: // result.setCallType(JmxComponentInfo.UNINSTALL_COMPONENT);
0482: List uninstalllist = getUninstallPriorityList();
0483:
0484: List lbs = getUninstallSharedLibs();
0485:
0486: for (int i = uninstalllist.size() - 1; i >= 0; i--) {
0487: String componentName = (String) uninstalllist.get(i);
0488: getClientFromSession()
0489: .uninstallComponent(componentName);
0490: }
0491:
0492: for (int i = 0; i < lbs.size(); i++) {
0493: String componentName = (String) lbs.get(i);
0494: getClientFromSession().uninstallSharedLibrary(
0495: componentName);
0496: }
0497: result = getInstallComponentList();
0498: } catch (Throwable t) {
0499: result
0500: .setException(
0501: (Messages
0502: .get(CoreMessageConstants.FAILED_UNINSTALLALL_COMPONENT)),
0503: (Exception) t);
0504: }
0505: return result;
0506: }
0507:
0508: public JmxComponentInfo uninstallSharedLibrary(String libName) {
0509: JmxComponentInfo result = null;
0510: try {
0511: result = new JmxComponentInfo();
0512: result
0513: .setCallType(JmxComponentInfo.UNINSTALL_SHAREDLIBRARY);
0514:
0515: getClientFromSession().uninstallSharedLibrary(libName);
0516: result = getInstallComponentList();
0517: } catch (Throwable t) {
0518: result
0519: .setException(
0520: (Messages
0521: .get(CoreMessageConstants.FAILED_UNINSTALL_SHARED_LIBRARY))
0522: + ":" + libName, (Exception) t);
0523: }
0524: return result;
0525: }
0526:
0527: public JmxComponentInfo installSharedLibrary(String libName,
0528: String jarName) {
0529: JmxComponentInfo result = null;
0530:
0531: try {
0532: result = new JmxComponentInfo();
0533: result.setCallType(JmxComponentInfo.INSTALL_SHAREDLIBRARY);
0534:
0535: getClientFromSession().installSharedLibrary(libName,
0536: jarName);
0537: result = getInstallComponentList();
0538: } catch (Throwable t) {
0539: result
0540: .setException(
0541: (Messages
0542: .get(CoreMessageConstants.FAILED_INSTALLALL_SHARED_LIBRARY))
0543: + ":" + libName, (Exception) t);
0544: }
0545: return result;
0546: }
0547:
0548: public void installUserComponent(String fileName) {
0549: }
0550:
0551: public JmxComponentInfo getDependences(String componentName) {
0552: JmxComponentInfo result = null;
0553:
0554: try {
0555: result = new JmxComponentInfo();
0556: result
0557: .setCallType(JmxComponentInfo.GET_COMPONENT_DEPENDENCE);
0558:
0559: getClientFromSession()
0560: .getDependences(componentName, result);
0561: }
0562:
0563: catch (Throwable t) {
0564: result
0565: .setException(
0566: (Messages
0567: .get(CoreMessageConstants.FAILED_GET_ASSEMBLY_FOR_COMPONENT))
0568: + ":" + componentName,
0569: (Exception) t);
0570: }
0571: return result;
0572: }
0573:
0574: // -----------------------------------------------------------------------------
0575:
0576: /**
0577: * It is for endpoint status view that show all assemblies
0578: */
0579: public JmxEndpointInfo getSaList() {
0580: JmxEndpointInfo result = null;
0581: try {
0582: result = new JmxEndpointInfo();
0583: result.setCallType(JmxEndpointInfo.GET_SA_LIST);
0584: // getClientFromSession().stopPollingNotification();
0585:
0586: getClientFromSession().getSaList(result);
0587: }
0588:
0589: catch (Throwable t) {
0590: result
0591: .setException(
0592: (Messages
0593: .get(CoreMessageConstants.FAILED_GET_ENDPOINT_INFO)),
0594: (Exception) t);
0595: }
0596: return result;
0597: }
0598:
0599: /**
0600: * get the endpoint statistics info for all SAs.
0601: */
0602: public JmxEndpointInfo getSaStatList() {
0603: JmxEndpointInfo endpointInfo = null;
0604: try {
0605: endpointInfo = new JmxEndpointInfo();
0606: endpointInfo.setCallType(JmxEndpointInfo.GET_SA_STAT_LIST);
0607: // getClientFromSession().stopPollingNotification();
0608:
0609: getClientFromSession().getSaList(endpointInfo);
0610: List<EndpointStatVO> list = EndpointStatisticsDB.query();
0611: HashMap<String, EndpointStatVO> map = new HashMap<String, EndpointStatVO>();
0612: for (EndpointStatVO statVO : list) {
0613: map.put(statVO.getEndpointName(), statVO);
0614: }
0615: for (int i = 0; i < endpointInfo.getSaList().length; i++) {
0616: JmxAssemblyObj sa = endpointInfo.getSaList()[i];
0617: for (int j = 0; j < sa.getComponentList().length; j++) {
0618: JmxComponentObj component = sa.getComponentList()[j];
0619: for (int m = 0; m < component.getEndpointList().length; m++) {
0620: JmxEndpointObj endpoint = component
0621: .getEndpointList()[m];
0622: if (map.containsKey(endpoint.getName())) {
0623: EndpointStatVO statVO = map.get(endpoint
0624: .getName());
0625: endpoint.setLatency(statVO.getLatency());
0626: endpoint.setMessagesCount(statVO
0627: .getMessagesCount());
0628: endpoint.setMessagesPerSecond(statVO
0629: .getMessagesPerSecond());
0630: }
0631: }
0632: }
0633: }
0634: }
0635:
0636: catch (Throwable t) {
0637: endpointInfo
0638: .setException(
0639: (Messages
0640: .get(CoreMessageConstants.FAILED_GET_STATISTIC_INFO)),
0641: (Exception) t);
0642: }
0643: return endpointInfo;
0644: }
0645:
0646: /**
0647: * get the endpoint statistics info for one SA.
0648: */
0649: public JmxAssemblyObj getSaStatObj(String saName) {
0650: JmxAssemblyObj sa = null;
0651: try {
0652: sa = new JmxAssemblyObj();
0653: sa.setName(saName);
0654: sa.setCallType(JmxAssemblyObj.REFRESH_GET_ASSEMLY_OBJ);
0655: // getClientFromSession().stopPollingNotification();
0656: getClientFromSession().getAssemblyObj(sa);
0657: List<EndpointStatVO> list = EndpointStatisticsDB
0658: .queryBySA(saName);
0659: HashMap<String, EndpointStatVO> map = new HashMap<String, EndpointStatVO>();
0660: for (EndpointStatVO statVO : list) {
0661: map.put(statVO.getEndpointName(), statVO);
0662: }
0663: for (int j = 0; j < sa.getComponentList().length; j++) {
0664: JmxComponentObj component = sa.getComponentList()[j];
0665: for (int m = 0; m < component.getEndpointList().length; m++) {
0666: JmxEndpointObj endpoint = component
0667: .getEndpointList()[m];
0668: if (map.containsKey(endpoint.getName())) {
0669: EndpointStatVO statVO = map.get(endpoint
0670: .getName());
0671: endpoint.setLatency(statVO.getLatency());
0672: endpoint.setMessagesCount(statVO
0673: .getMessagesCount());
0674: endpoint.setMessagesPerSecond(statVO
0675: .getMessagesPerSecond());
0676: }
0677: }
0678: }
0679:
0680: }
0681:
0682: catch (Throwable t) {
0683: sa
0684: .setException(
0685: (Messages
0686: .get(CoreMessageConstants.FAILED_GET_STATISTIC_INFO_FOR_ASSEMBLY))
0687: + ":" + saName, (Exception) t);
0688: }
0689: return sa;
0690: }
0691:
0692: /**
0693: *
0694: */
0695: public JmxComponentObj getComponentObj(String saName,
0696: String componentName) {
0697: JmxComponentObj result = null;
0698: try {
0699: result = new JmxComponentObj(componentName);
0700: result.setCallType(JmxEndpointInfo.GET_COMPONENT_ENDPOINTS);
0701: result = getClientFromSession().getComponentObjAndValues(
0702: saName, componentName);
0703: }
0704:
0705: catch (Throwable t) {
0706: result
0707: .setException(
0708: (Messages
0709: .get(CoreMessageConstants.FAILED_GET_COMPONENT_INFO_FOR_ASSEMBLY))
0710: + ":" + componentName,
0711: (Exception) t);
0712: }
0713: return result;
0714: }
0715:
0716: public JmxComponentObj startEndpoint(String saName,
0717: String componentName, String endpointName) {
0718: JmxComponentObj result = null;
0719: try {
0720: result = new JmxComponentObj(componentName);
0721: result.setCallType(JmxEndpointInfo.START_ENDPOINT);
0722: JmxClient jmxclient = getClientFromSession();
0723: // jmxclient.stopPollingNotification();
0724: jmxclient.startEndpoint(componentName, endpointName);
0725: result = jmxclient.getComponentObjAndValues(saName,
0726: componentName);
0727: }
0728:
0729: catch (Throwable t) {
0730: result.setException((Messages
0731: .get(CoreMessageConstants.FAILED_START_ENDPOINT))
0732: + ":" + endpointName, (Exception) t);
0733: }
0734: return result;
0735: }
0736:
0737: public JmxComponentObj stopEndpoint(String saName,
0738: String componentName, String endpointName) {
0739: JmxComponentObj result = null;
0740: try {
0741: result = new JmxComponentObj(componentName);
0742: result.setCallType(JmxEndpointInfo.STOP_ENDPOINT);
0743: JmxClient jmxclient = getClientFromSession();
0744: // jmxclient.stopPollingNotification();
0745: jmxclient.stopEndpoint(componentName, endpointName);
0746: result = jmxclient.getComponentObjAndValues(saName,
0747: componentName);
0748:
0749: }
0750:
0751: catch (Throwable t) {
0752: result.setException((Messages
0753: .get(CoreMessageConstants.FAILED_STOP_ENDPOINT))
0754: + ":" + endpointName, (Exception) t);
0755: }
0756: return result;
0757: }
0758:
0759: public JmxComponentObj cycleEndpoint(String saName,
0760: String componentName, String endpointName) {
0761: JmxComponentObj result = null;
0762: try {
0763: result = new JmxComponentObj(componentName);
0764: result.setCallType(JmxEndpointInfo.CYCLE_ENDPOINT);
0765: JmxClient jmxclient = getClientFromSession();
0766: // jmxclient.stopPollingNotification();
0767:
0768: jmxclient.stopEndpoint(componentName, endpointName);
0769: jmxclient.startEndpoint(componentName, endpointName);
0770: result = jmxclient.getComponentObjAndValues(saName,
0771: componentName);
0772:
0773: } catch (Throwable t) {
0774: result.setException((Messages
0775: .get(CoreMessageConstants.FAILED_CYCLE_ENDPOINT))
0776: + ":" + endpointName, (Exception) t);
0777: }
0778: return result;
0779: }
0780:
0781: public JmxEndpointInfo getPropertyObjects(String saName,
0782: String componentName, String endpointName, String suName,
0783: String role) {
0784: JmxEndpointInfo result = new JmxEndpointInfo();
0785:
0786: try {
0787: result.setCallType(JmxEndpointInfo.GET_PROPERTY_OBJECTS);
0788: JmxEndpointObj endpointObj = new JmxEndpointObj();
0789: endpointObj.setComponentName(componentName);
0790: endpointObj.setName(endpointName);
0791: endpointObj.setSuName(suName);
0792: endpointObj.setRole(role);
0793: endpointObj.setSaName(saName);
0794: getClientFromSession().getPropertyObjects(componentName,
0795: endpointName, endpointObj);
0796: result.setCurEndpointObj(endpointObj);
0797: }
0798:
0799: catch (Throwable t) {
0800: result
0801: .setException(
0802: (Messages
0803: .get(CoreMessageConstants.FAILED_GET_PROPERTIES_FOR_ENDPOINT))
0804: + ":" + endpointName, (Exception) t);
0805: }
0806: return result;
0807: }
0808:
0809: public JmxEndpointInfo setPropertyObjects(String saName,
0810: String suName, String componentName, String endpointName,
0811: String type, String[][] propertyObjects) {
0812: JmxEndpointInfo result = null;
0813:
0814: try {
0815: result = new JmxEndpointInfo();
0816: result.setCallType(JmxEndpointInfo.SET_PROPERTY_OBJECTS);
0817: JmxClient jmxclient = getClientFromSession();
0818: // jmxclient.stopPollingNotification();
0819:
0820: jmxclient.setPropertyObjects(componentName, endpointName,
0821: propertyObjects, result);
0822:
0823: EndpointSettingDB.saveEndpointSettings(saName, suName,
0824: endpointName, type, propertyObjects);
0825: }
0826:
0827: catch (Throwable t) {
0828: result
0829: .setException(
0830: (Messages
0831: .get(CoreMessageConstants.FAILED_SET_PROPERTIES_FOR_ENDPOINT))
0832: + ":" + endpointName, (Exception) t);
0833: }
0834: return result;
0835: }
0836:
0837: public BaseRPCResultInfo deletePropertyObjects(String saName,
0838: String suName, String endpointName, String type) {
0839: BaseRPCResultInfo result = null;
0840:
0841: try {
0842: result = new BaseRPCResultInfo();
0843: result.setCallType(JmxEndpointInfo.DELETE_PROPERTY_OBJECTS);
0844: result.setSource(saName);
0845:
0846: EndpointSettingDB.deleteEndpointSettings(saName, suName,
0847: endpointName, type);
0848: }
0849:
0850: catch (Throwable t) {
0851: result
0852: .setException(
0853: (Messages
0854: .get(CoreMessageConstants.FAILED_DELETE_PROPERTIES_FOR_ENDPOINT))
0855: + ":" + endpointName, (Exception) t);
0856: }
0857: return result;
0858: }
0859:
0860: public List getStartPriorityList() {
0861: List list = new ArrayList();
0862: String[] bcs = this .getCurrentComponentList()
0863: .getBindingComponents();
0864: String[] ses = this .getCurrentComponentList()
0865: .getServiceEngines();
0866:
0867: List serviceEngList = new ArrayList();
0868: List bindingComList = new ArrayList();
0869:
0870: // put all the binding components in one list, lowest priority to start.
0871: for (int i = 0; i < bcs.length; i++) {
0872: bindingComList.add(bcs[i]);
0873: }
0874:
0875: int index = 0;
0876: for (int i = 0; i < ses.length; i++) {
0877: serviceEngList.add(ses[i]);
0878: }
0879:
0880: for (int i = 0; i < SEPRIORITYLIST.length; i++) {
0881: if (serviceEngList.contains(SEPRIORITYLIST[i])) {
0882: // remove the one at the current position.
0883: serviceEngList.remove(SEPRIORITYLIST[i]);
0884: // add this one at the specific position.
0885: serviceEngList.add(index, SEPRIORITYLIST[i]);
0886: index++;
0887: }
0888: }
0889:
0890: list.addAll(serviceEngList);
0891: list.addAll(bindingComList);
0892:
0893: return list;
0894: }
0895:
0896: // Get all the components to be installed in the priority order.
0897: public List getInstallPriorityList() {
0898: List list = new ArrayList();
0899: String[] bcs = this .getInstallComponentList()
0900: .getBindingComponents();
0901: String[] ses = this .getInstallComponentList()
0902: .getServiceEngines();
0903:
0904: List serviceEngList = new ArrayList();
0905: List bindingComList = new ArrayList();
0906:
0907: List serviceEngList_Name = new ArrayList();
0908:
0909: // put all the uninstalled binding components in one list, lowest
0910: // priority to start.
0911: for (int i = 0; i < bcs.length; i++) {
0912: bindingComList.add(bcs[i]);
0913: }
0914:
0915: int index = 0;
0916: for (int i = 0; i < ses.length; i++) {
0917: serviceEngList.add(ses[i]);
0918: }
0919:
0920: for (int i = 0; i < ses.length; i++) {
0921: String comName = ses[i].split(DELIMITER)[0];
0922: serviceEngList_Name.add(comName);
0923: }
0924:
0925: for (int i = 0; i < SEPRIORITYLIST.length; i++) {
0926: if (serviceEngList_Name.contains(SEPRIORITYLIST[i])) {
0927: int ind = serviceEngList_Name
0928: .indexOf(SEPRIORITYLIST[i]);
0929: String comName_jarName = (String) serviceEngList
0930: .get(ind);
0931: // remove the one at the current position.
0932: serviceEngList_Name.remove(SEPRIORITYLIST[i]);
0933: serviceEngList.remove(comName_jarName);
0934: // add this one at the specific position.
0935: serviceEngList_Name.add(index, SEPRIORITYLIST[i]);
0936: serviceEngList.add(index, comName_jarName);
0937: index++;
0938: }
0939: }
0940:
0941: list.addAll(serviceEngList);
0942: list.addAll(bindingComList);
0943:
0944: return list;
0945: }
0946:
0947: private List getInstallSharedLibs() {
0948: List sharedLibList = new ArrayList();
0949: String[] sls = this .getInstallComponentList()
0950: .getSharedLibraries();
0951:
0952: for (int i = 0; i < sls.length; i++) {
0953: sharedLibList.add(sls[i]);
0954: }
0955: return sharedLibList;
0956: }
0957:
0958: private List getUninstallSharedLibs() {
0959: List uninstallSLList = new ArrayList();
0960: String[] sls = this .getInstallComponentList().getUninstallSL();
0961: for (int i = 0; i < sls.length; i++) {
0962: uninstallSLList.add(sls[i]);
0963: }
0964: return uninstallSLList;
0965: }
0966:
0967: // Get all the components to be uninstalled in the priority order.
0968: private List getUninstallPriorityList() {
0969: List list = new ArrayList();
0970: String[] bcs = this .getInstallComponentList().getUninstallBC();
0971: String[] ses = this .getInstallComponentList().getUninstallSE();
0972:
0973: List uninstallBCList = new ArrayList();
0974: List uninstallSEList = new ArrayList();
0975:
0976: // put all the installed shared libraries into one list, highest
0977: // priority to
0978: // start.
0979:
0980: // put all the installed binding components in one list, lowest priority
0981: // to start.
0982: for (int i = 0; i < bcs.length; i++) {
0983: uninstallBCList.add(bcs[i]);
0984: }
0985:
0986: int index = 0;
0987: for (int i = 0; i < ses.length; i++) {
0988: uninstallSEList.add(ses[i]);
0989: }
0990:
0991: for (int i = 0; i < SEPRIORITYLIST.length; i++) {
0992: if (uninstallSEList.contains(SEPRIORITYLIST[i])) {
0993: // remove the one at the current position.
0994: uninstallSEList.remove(SEPRIORITYLIST[i]);
0995: // add this one at the specific position.
0996: uninstallSEList.add(index, SEPRIORITYLIST[i]);
0997: index++;
0998: }
0999: }
1000:
1001: list.addAll(uninstallSEList);
1002: list.addAll(uninstallBCList);
1003:
1004: return list;
1005:
1006: }
1007:
1008: /* (non-Javadoc)
1009: * @see com.bostechcorp.cbesb.console.rpc.JmxOperation#pollingCurrentComponentList()
1010: */
1011: public JmxComponentInfo pollingCurrentComponentList() {
1012: return getCurrentComponentList();
1013: }
1014:
1015: /* (non-Javadoc)
1016: * @see com.bostechcorp.cbesb.console.rpc.JmxOperation#pollingCurrentServiceAssemblyList()
1017: */
1018: public JmxAssemblyInfo pollingCurrentServiceAssemblyList() {
1019:
1020: return getCurrentServiceAssemblyList();
1021: }
1022:
1023: /* (non-Javadoc)
1024: * @see com.bostechcorp.cbesb.console.rpc.JmxOperation#pollingDeployServiceAssemblyList()
1025: */
1026: public JmxAssemblyInfo pollingDeployServiceAssemblyList() {
1027:
1028: return getDeployServiceAssemblyList();
1029: }
1030:
1031: /* (non-Javadoc)
1032: * @see com.bostechcorp.cbesb.console.rpc.JmxOperation#pollingInstallComponentList()
1033: */
1034: public JmxComponentInfo pollingInstallComponentList() {
1035:
1036: return getInstallComponentList();
1037: }
1038:
1039: public String[] getEndpointNameArray() throws ServerSideException {
1040: try {
1041: return getClientFromSession().getEndpointNameArray();
1042: } catch (Exception ex) {
1043: throw new ServerSideException(
1044: (Messages
1045: .get(CoreMessageConstants.FAILED_GET_ENDPOINT_NAME_LIST)),
1046: ex);
1047:
1048: }
1049:
1050: }
1051:
1052: public ConsoleVersion getVersionInfo(String name) {
1053: ConsoleVersion consoleVersion = new ConsoleVersion();
1054: try {
1055: getClientFromSession().getVersionInfo(name, consoleVersion);
1056: } catch (Exception e) {
1057: consoleVersion
1058: .setException(
1059: (Messages
1060: .get(CoreMessageConstants.FAILED_GET_VERSION_INFO_FOR_COMPONENT))
1061: + ":" + name, e);
1062: }
1063: return consoleVersion;
1064: }
1065:
1066: public ConsoleVersion getCCSLVersionInfo(String name) {
1067: ConsoleVersion consoleVersion = new ConsoleVersion();
1068: try {
1069: getClientFromSession().getCCSLVersionInfo(name,
1070: consoleVersion);
1071: } catch (Exception e) {
1072: consoleVersion
1073: .setException(
1074: (Messages
1075: .get(CoreMessageConstants.FAILED_GET_CCSL_VERSION_INFO_FOR_COMPONENT))
1076: + ":" + name, e);
1077: }
1078: return consoleVersion;
1079:
1080: }
1081:
1082: /**
1083: * It is for endpoint status, only show one assembly
1084: */
1085: public JmxAssemblyObj getAssemblyObjAndValues(String saName) {
1086: JmxAssemblyObj result = null;
1087: try {
1088: result = new JmxAssemblyObj();
1089: result.setName(saName);
1090: result.setCallType(JmxAssemblyObj.REFRESH_GET_ASSEMLY_OBJ);
1091: JmxClient jmxclient = getClientFromSession();
1092: // jmxclient.stopPollingNotification();
1093: jmxclient.getAssemblyObjAndValues(result);
1094: }
1095:
1096: catch (Throwable t) {
1097: result
1098: .setException(
1099: (Messages
1100: .get(CoreMessageConstants.FAILED_GET_EDNPOINT_INFO_FOR_ASSEMBLY))
1101: + ":" + saName, (Exception) t);
1102: }
1103: return result;
1104:
1105: }
1106:
1107: public BaseRPCResultInfo deleteEndpointStatistics(String saName) {
1108: BaseRPCResultInfo result = null;
1109: try {
1110: result = new BaseRPCResultInfo();
1111: getClientFromSession().resetEndpointStatistics(saName);
1112:
1113: }
1114:
1115: catch (Throwable t) {
1116: result
1117: .setException(
1118: (Messages
1119: .get(CoreMessageConstants.FAILED_DELETE_ENDPOINT_STATISTICS_INFO_FOR_ASSEMBLY))
1120: + ":" + saName, (Exception) t);
1121: }
1122: return result;
1123: }
1124:
1125: public BaseRPCResultInfo deleteAllEndpointStatistics() {
1126: BaseRPCResultInfo result = null;
1127: try {
1128: result = new BaseRPCResultInfo();
1129: getClientFromSession().resetEndpointStatistics("all");
1130:
1131: }
1132:
1133: catch (Throwable t) {
1134: result
1135: .setException(
1136: (Messages
1137: .get(CoreMessageConstants.FAILED_DELETE_ALLENDPOINT_STATISTICS_INFO)),
1138: (Exception) t);
1139: }
1140: return result;
1141: }
1142:
1143: public void stopPollingNotification() throws ServerSideException {
1144: JmxClient jmxclient = getClientFromSession();
1145: jmxclient.stopPollingNotification();
1146:
1147: }
1148:
1149: public JmxAssemblyInfo shutdownAllServiceAssembly() {
1150: JmxAssemblyInfo result = null;
1151: try {
1152: result = new JmxAssemblyInfo();
1153: // result.setCallType(JmxComponentInfo.START_COMPONENT);
1154:
1155: List assemblyList = getServiceAssemblyList();
1156: for (int i = 0; i < assemblyList.size(); i++) {
1157: String assemblyName = (String) assemblyList.get(i);
1158: getClientFromSession().shutdownServiceAssembly(
1159: assemblyName);
1160: }
1161: result = getCurrentServiceAssemblyList();
1162: } catch (Throwable t) {
1163: result
1164: .setException(
1165: (Messages
1166: .get(CoreMessageConstants.FAILED_SHUTDOWNALL_ASSEMBLY)),
1167: (Exception) t);
1168: }
1169: return result;
1170: }
1171:
1172: public JmxAssemblyInfo startAllServiceAssembly() {
1173: JmxAssemblyInfo result = null;
1174: try {
1175: result = new JmxAssemblyInfo();
1176: // result.setCallType(JmxComponentInfo.START_COMPONENT);
1177:
1178: List assemblyList = getServiceAssemblyList();
1179: for (int i = 0; i < assemblyList.size(); i++) {
1180: String assemblyName = (String) assemblyList.get(i);
1181: getClientFromSession().startServiceAssembly(
1182: assemblyName);
1183: }
1184: result = getCurrentServiceAssemblyList();
1185: } catch (Throwable t) {
1186: result
1187: .setException(
1188: (Messages
1189: .get(CoreMessageConstants.FAILED_STARTAll_ASSEMBLY)),
1190: (Exception) t);
1191: }
1192: return result;
1193: }
1194:
1195: private List getServiceAssemblyList() {
1196: List list = new ArrayList();
1197: String[] sas = this .getCurrentServiceAssemblyList()
1198: .getServiceAssemblys();
1199: // put all the binding components in one list, lowest priority to start.
1200: for (int i = 0; i < sas.length; i++) {
1201: list.add(sas[i]);
1202: }
1203: return list;
1204: }
1205: }
|