[Mc4j-cvs] mc4j/src/org/mc4j/console/connection StatsIntrospectorAction.java,1.2,1.3 ConnectionNode.
Brought to you by:
ghinkl
From: Greg H. <gh...@us...> - 2006-04-12 19:14:38
|
Update of /cvsroot/mc4j/mc4j/src/org/mc4j/console/connection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20162/src/org/mc4j/console/connection Modified Files: StatsIntrospectorAction.java ConnectionNode.java NumericIntrospectorAction.java Removed Files: WebsphereConnectionNode.java PramatiConnectionNode.java WeblogicConnectionNode.java Oc4jConnectionNode.java Mx4jConnectionNode.java JDMKConnectionNode.java JBossConnectionNode.java JSR160ConnectionNode.java Log Message: Merging EMS into head for the 2.0 release work --- WebsphereConnectionNode.java DELETED --- Index: ConnectionNode.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/connection/ConnectionNode.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** ConnectionNode.java 15 Jan 2005 03:43:54 -0000 1.43 --- ConnectionNode.java 12 Apr 2006 19:13:59 -0000 1.44 *************** *** 20,26 **** import org.mc4j.console.bean.MBeanNode; import org.mc4j.console.connection.create.CreateMBeanAction; - import org.mc4j.console.connection.install.WeblogicConnectionTypeDescriptor; import org.mc4j.console.connection.persistence.ConnectionSetDatabase; - import org.mc4j.console.connection.persistence.ConnectionSettings; import org.mc4j.console.dashboard.global.GlobalDashboardSetNode; import org.mc4j.console.domain.DomainNode; --- 20,24 ---- *************** *** 29,35 **** import org.mc4j.console.query.NewQueryAction; import org.mc4j.console.util.NodeUtil; ! import org.openide.DialogDisplayer; import org.openide.ErrorManager; - import org.openide.NotifyDescriptor; import org.openide.actions.OpenLocalExplorerAction; import org.openide.actions.PropertiesAction; --- 27,40 ---- import org.mc4j.console.query.NewQueryAction; import org.mc4j.console.util.NodeUtil; ! import org.mc4j.console.util.ConnectionInfoAction; ! import org.mc4j.ems.connection.ConnectionFactory; ! import org.mc4j.ems.connection.EmsConnection; ! import org.mc4j.ems.connection.MBeanRegistrationEvent; ! import org.mc4j.ems.connection.MBeanRegistrationListener; ! import org.mc4j.ems.connection.EmsConnectException; ! import org.mc4j.ems.connection.bean.EmsBean; ! import org.mc4j.ems.connection.bean.attribute.EmsAttribute; ! import org.mc4j.ems.connection.settings.ConnectionSettings; import org.openide.ErrorManager; import org.openide.actions.OpenLocalExplorerAction; import org.openide.actions.PropertiesAction; *************** *** 47,53 **** import org.openide.windows.TopComponent; - import javax.management.MBeanServer; - import javax.management.ObjectInstance; - import javax.management.ObjectName; import javax.swing.*; import java.awt.*; --- 52,55 ---- *************** *** 56,62 **** import java.beans.PropertyChangeListener; import java.io.IOException; - import java.lang.reflect.InvocationTargetException; - import java.lang.reflect.UndeclaredThrowableException; - import java.rmi.ConnectException; import java.util.ArrayList; import java.util.Collections; --- 58,61 ---- *************** *** 67,74 **** import java.util.Map; import java.util.Set; - import java.util.SortedSet; import java.util.Timer; - import java.util.TimerTask; - import java.util.TreeSet; /** --- 66,70 ---- *************** *** 78,82 **** * @version $Revision$($Author$ / $Date$) */ ! public abstract class ConnectionNode extends AbstractNode implements IConnectionNode, PropertyChangeListener, Comparable { --- 74,78 ---- * @version $Revision$($Author$ / $Date$) */ ! public class ConnectionNode extends AbstractNode implements IConnectionNode, PropertyChangeListener, Comparable, MBeanRegistrationListener { *************** *** 89,94 **** protected boolean connectionFailure = false; ! /** Holds a map of ObjectNames.getCannonicalName() to MBeanNodes */ ! protected volatile Map mbeans = new HashMap(); protected Node.PropertySet[] settingsPropertySets; --- 85,90 ---- protected boolean connectionFailure = false; ! /** Holds a map of cannonical object names to MBeanNodes */ ! protected volatile Map<String, MBeanNode> mbeans = new HashMap<String, MBeanNode>(); protected Node.PropertySet[] settingsPropertySets; *************** *** 102,107 **** private Set openDashboards = new HashSet(); ! public ConnectionNode() { super(new ConnectionNodeChildren()); // Setup a working pool of up to 5 threads to process remote calls --- 98,108 ---- private Set openDashboards = new HashSet(); ! ! private EmsConnection emsConnection; ! ! ! public ConnectionNode(ConnectionSettings connectionSettings) { super(new ConnectionNodeChildren()); + this.connectionSettings = connectionSettings; // Setup a working pool of up to 5 threads to process remote calls *************** *** 114,120 **** updateIcon(); // Set FeatureDescriptor stuff: - setName("loading"); ! //addPropertyChangeListener(this); } --- 115,126 ---- updateIcon(); // Set FeatureDescriptor stuff: ! setName(connectionSettings.getConnectionName()); ! ! addPropertyChangeListener(this); ! } ! ! public EmsConnection getEmsConnection() { ! return emsConnection; } *************** *** 135,142 **** } - public ConnectionNode(Children children) { - super(children); - - } public int compareTo(Object o) { --- 141,144 ---- *************** *** 153,158 **** - public abstract MBeanServer getMBeanServer(); - // Create the popup menu: protected SystemAction[] createActions() { --- 155,158 ---- *************** *** 189,325 **** protected void loadConnectionNodeChildren(boolean showProgress) throws Exception { ! //String currentText = StatusDisplayer.getDefault().getStatusText(); ProgressDialog progressDialog = null; ! try { ! StatusDisplayer.getDefault().setStatusText("Loading nodes [" + connectionSettings.getConnectionName() + "]"); ! ! MBeanServer server = getMBeanServer(); ! Set objectNames; ! if (connectionSettings.getConnectionType() instanceof WeblogicConnectionTypeDescriptor) { ! Set objectInstances = server.queryMBeans(null,null); ! objectNames = new HashSet(); ! for (Iterator iterator = objectInstances.iterator(); iterator.hasNext();) { ! ObjectInstance objectInstance = (ObjectInstance) iterator.next(); ! objectNames.add(objectInstance.getObjectName()); ! } ! } else { ! objectNames = server.queryNames(null,null); ! } ! StatusDisplayer.getDefault().setStatusText("Loading nodes [" + connectionSettings.getConnectionName() ! + "] 0 of " + objectNames.size()); ! ! if (showProgress) ! progressDialog = new ProgressDialog(objectNames.size()); ! ! ! SortedSet sortedObjectNames = new TreeSet( new MBeanNameComparator()); ! if (objectNames != null) { ! sortedObjectNames.addAll(objectNames); ! } ! ! // Create a secondary set that will be winowed with beans ! // that are still registered. Beans left in this set at the end ! // have been deregistered. ! HashSet oldMBeans = new HashSet(mbeans.keySet()); ! ! int i = 0; ! for (Iterator iter = sortedObjectNames.iterator(); iter.hasNext();) { ! ObjectName objectName = (ObjectName) iter.next(); ! ! synchronized(this) { ! if ((this.mbeans == null) || (!this.mbeans.containsKey(objectName.getCanonicalName()))) { ! //org.openide.windows.IOProvider.getDefault().getStdOut().println("Mount MBean: " + objectInstance.getObjectName().getCanonicalName()); ! addMBean(objectName); ! } else { ! oldMBeans.remove(objectName.getCanonicalName()); ! } ! } ! ! i++; ! if (i % 20 == 0) { ! StatusDisplayer.getDefault().setStatusText("Loading nodes [" + connectionSettings.getConnectionName() ! + "] " + i + " of " + objectNames.size()); ! if (showProgress) ! progressDialog.setValue(i); ! } ! } ! ! Node parent = null; ! // Clean out beans that have been unregistered ! for (Iterator it = oldMBeans.iterator(); it.hasNext();) { ! String mbeansKey = (String) it.next(); ! ! MBeanNode node = (MBeanNode) this.mbeans.get(mbeansKey); ! parent = node.getParentNode(); ! parent.getChildren().remove(new Node[] { node }); ! ! ! mbeans.remove(mbeansKey); ! } ! if(parent != null){ //have we removed any nodes? ! //we need to get to the super parent to clean up the empty domains ! Node superParent = parent; ! while(superParent.getParentNode() != null && !(superParent instanceof ConnectionNode)) { ! superParent = superParent.getParentNode(); ! } ! ! removeEmptyDomainNodes(superParent); ! } ! ! // Reset in case there was a prior failure ! connectionFailure = false; - } catch (Exception e) { - StatusDisplayer.getDefault().setStatusText("Problem contacting server: " + - this.connectionSettings.getConnectionName()); ! Throwable probableConnectException = e; ! ! // the possible ConnectExcpetion is most likely wrapped in an UndeclaredThrowableException ! // depending on the MBeanServerProxy it may be further wrapped in an InvocationTargetException ! if (!(e instanceof ConnectException)){ ! if (e instanceof UndeclaredThrowableException) { ! probableConnectException = ((UndeclaredThrowableException)e).getUndeclaredThrowable(); ! if (probableConnectException instanceof InvocationTargetException) { ! probableConnectException = probableConnectException.getCause(); ! } ! } else { ! probableConnectException = e.getCause(); ! } ! } ! if (probableConnectException instanceof ConnectException) { ! if (connectionFailure) { ! // we know that we have a connection failure -> don't bother the user! ! ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); ! } else { ! // first connection failure -> notify with default severity ! NotifyDescriptor d = ! new NotifyDescriptor.Message("Lost connection to server at \"" + ! this.connectionSettings.getConnectionName() + ! "\". \nPlease disconnect and connect after the server is restarted.", ! NotifyDescriptor.ERROR_MESSAGE); ! DialogDisplayer.getDefault().notify(d); ! // TODO CSC: should we disconnect here?! (and remove the if-then-case!) ! // GH: I wasn't going to disconnect in case its a temporary network issue. ! // The app doesn't really deal well with this right now though. ! } ! connectionFailure = true; ! } else { ! ErrorManager.getDefault().notify(e); ! } ! throw e; ! } finally { ! StatusDisplayer.getDefault().setStatusText(""); ! if (showProgress && progressDialog != null) ! progressDialog.close(); } } ! /** * Recursively removes empty domain nodes. --- 189,228 ---- protected void loadConnectionNodeChildren(boolean showProgress) throws Exception { ! String currentText = StatusDisplayer.getDefault().getStatusText(); ProgressDialog progressDialog = null; ! StatusDisplayer.getDefault().setStatusText("Loading nodes [" + connectionSettings.getConnectionName() + "]"); ! Set<EmsBean> emsBeans = emsConnection.getBeans(); ! StatusDisplayer.getDefault().setStatusText("Loading nodes [" + connectionSettings.getConnectionName() ! + "] 0 of " + emsBeans.size()); ! if (showProgress) ! progressDialog = new ProgressDialog(emsBeans.size()); ! } + public void registrationChanged(MBeanRegistrationEvent event) { + Set<EmsBean> registered = event.getRegistered(); + Set<EmsBean> deregistered = event.getDeregistered(); ! for (EmsBean bean : registered) { ! addMBean(bean); ! } ! Node[] oldNodes = new Node[deregistered.size()]; ! int i = 0; ! for (EmsBean bean : deregistered) { ! MBeanNode currentNode = this.mbeans.remove(bean.getBeanName().getCanonicalName()); ! oldNodes[i++] = currentNode; ! } ! getChildren().remove(oldNodes); ! if (deregistered.size() > 0) { ! // TODO removeEmptyDomainNodes() } } ! ! /** * Recursively removes empty domain nodes. *************** *** 359,375 **** } - /** - * @deprecated - * @param objectInstance - */ - protected void addMBean(ObjectInstance objectInstance) { - synchronized(this) { - this.addMBean(objectInstance.getObjectName()); - } - } ! protected void addMBean(ObjectName objectName) { synchronized(this) { ! String domain = objectName.getDomain(); DomainNode domainNode = (DomainNode) this.mbeanNode.getChildren().findChild(domain); --- 262,270 ---- } ! ! protected void addMBean(EmsBean emsBean) { synchronized(this) { ! String domain = emsBean.getBeanName().getDomain(); DomainNode domainNode = (DomainNode) this.mbeanNode.getChildren().findChild(domain); *************** *** 379,384 **** } ! MBeanNode mbeanNode = new MBeanNode(objectName, this); ! this.mbeans.put(objectName.getCanonicalName(), mbeanNode); if(domainNode.isGroupTypes()) { --- 274,279 ---- } ! MBeanNode mbeanNode = new MBeanNode(this, emsBean); ! this.mbeans.put(emsBean.getBeanName().getCanonicalName(), mbeanNode); if(domainNode.isGroupTypes()) { *************** *** 493,496 **** --- 388,411 ---- public void connect() throws Exception { + ConnectionFactory connectionFactory = new ConnectionFactory(); + + try { + emsConnection = connectionFactory.connect(connectionSettings); + } catch(EmsConnectException e) { + connectionFailure = true; + updateIcon(); + JOptionPane.showMessageDialog(null,"Unable to open connection to server: " + e.getCause().getMessage(), + "Connection Error", JOptionPane.ERROR_MESSAGE); + return; + } + // Store the last 100 values for numeric attributes + connectionSettings.getControlProperties().setProperty(EmsAttribute.CONTROL_ATTRIBUTE_HISTORY_DEPTH,"100"); + + ConnectionInfoAction.addStats(emsConnection); + + this.emsConnection.addRegistrationListener(this); + + + this.connected = true; this.connectionFailure = false; *************** *** 515,519 **** getChildren().add(new Node[] { mbeanNode }); ! loadConnectionNodeChildren(true); // Turn on domain hierarchy grouping by default --- 430,434 ---- getChildren().add(new Node[] { mbeanNode }); ! emsConnection.loadSynchronous(false); // Turn on domain hierarchy grouping by default *************** *** 529,540 **** refreshTimer = new Timer(); ! refreshTimer.schedule( ! new TimerTask() { ! public void run() { ! refresh(); ! } ! }, ! 20000, ! 10000); } --- 444,455 ---- refreshTimer = new Timer(); ! // refreshTimer.schedule( ! // new TimerTask() { ! // public void run() { ! // refresh(); ! // } ! // }, ! // 20000, ! // 10000); } *************** *** 673,677 **** ! public void browseToMBean(final ObjectName objectName) { final MBeanNode node = getMBeanNode(objectName); if (node != null) { --- 588,592 ---- ! public void browseToMBean(final String objectName) { final MBeanNode node = getMBeanNode(objectName); if (node != null) { *************** *** 680,685 **** } ! public MBeanNode getMBeanNode(ObjectName objectName) { ! return (MBeanNode) this.mbeans.get(objectName.getCanonicalName()); } --- 595,600 ---- } ! public MBeanNode getMBeanNode(String objectName) { ! return this.mbeans.get(objectName); } --- JBossConnectionNode.java DELETED --- Index: NumericIntrospectorAction.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/connection/NumericIntrospectorAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NumericIntrospectorAction.java 5 Oct 2004 05:15:59 -0000 1.2 --- NumericIntrospectorAction.java 12 Apr 2006 19:13:59 -0000 1.3 *************** *** 17,21 **** package org.mc4j.console.connection; ! import org.mc4j.console.bean.MBeanNode; import org.openide.nodes.Node; import org.openide.util.HelpCtx; --- 17,22 ---- package org.mc4j.console.connection; ! import org.mc4j.ems.connection.bean.EmsBean; ! import org.mc4j.ems.connection.bean.attribute.EmsAttribute; import org.openide.nodes.Node; import org.openide.util.HelpCtx; *************** *** 24,32 **** import org.openide.windows.OutputWriter; - import javax.management.MBeanAttributeInfo; import java.math.BigDecimal; import java.math.BigInteger; import java.util.HashSet; - import java.util.List; import java.util.Set; --- 25,31 ---- *************** *** 43,64 **** OutputWriter w = IOProvider.getDefault().getIO("Stats Output", true).getOut(); ! List mbeanNodes = node.getMBeanList(); ! for (int i = 0; i < mbeanNodes.size(); i++) { ! MBeanNode beanNode = (MBeanNode) mbeanNodes.get(i); boolean beanOutput = false; ! MBeanAttributeInfo[] infos = beanNode.getMBeanInfo().getAttributes(); ! for (int j = 0; j < infos.length; j++) { ! MBeanAttributeInfo info = infos[j]; - if (STATS_TYPES.contains(info.getType()) && - !info.isWritable()) { if (!beanOutput) { ! w.println(beanNode.getObjectName().getCanonicalName()); beanOutput = true; } ! w.println("\t" + info.getName() + "[" + info.getType() + "]"); } } } --- 42,60 ---- OutputWriter w = IOProvider.getDefault().getIO("Stats Output", true).getOut(); ! for (EmsBean emsBean : node.getEmsConnection().getBeans()) { boolean beanOutput = false; ! for (EmsAttribute attribute : emsBean.getAttributes()) { ! ! if (!attribute.isWritable() && STATS_TYPES.contains(attribute.getType())) { if (!beanOutput) { ! w.println(emsBean.getBeanName().getCanonicalName()); beanOutput = true; } ! w.println("\t" + attribute.getName() + "[" + attribute.getType() + "]"); } + } } --- WeblogicConnectionNode.java DELETED --- --- JDMKConnectionNode.java DELETED --- Index: StatsIntrospectorAction.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/connection/StatsIntrospectorAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StatsIntrospectorAction.java 5 Oct 2004 05:15:59 -0000 1.2 --- StatsIntrospectorAction.java 12 Apr 2006 19:13:59 -0000 1.3 *************** *** 17,22 **** package org.mc4j.console.connection; ! import org.mc4j.console.bean.MBeanNode; ! import org.mc4j.console.bean.attribute.AttributeNode; import org.openide.nodes.Node; import org.openide.util.HelpCtx; --- 17,21 ---- package org.mc4j.console.connection; ! import org.mc4j.ems.connection.bean.EmsBean; import org.openide.nodes.Node; import org.openide.util.HelpCtx; *************** *** 25,29 **** import org.openide.windows.OutputWriter; ! import java.util.List; /** --- 24,28 ---- import org.openide.windows.OutputWriter; ! import java.util.SortedSet; /** *************** *** 39,63 **** OutputWriter w = IOProvider.getDefault().getIO("Stats Output", true).getOut(); ! List mbeanNodes = node.getMBeanList(); ! for (int i = 0; i < mbeanNodes.size(); i++) { ! MBeanNode beanNode = (MBeanNode) mbeanNodes.get(i); ! boolean beanOutput = false; ! ! AttributeNode attrNode = (AttributeNode) beanNode.getAttributeNodeMap().get("Stats"); ! if (attrNode != null) { ! if (!beanOutput) { ! w.println(beanNode.getObjectName().getCanonicalName()); ! beanOutput = true; ! } ! w.println("\t" + beanNode.getName() + "[" + "]"); } - } ! } protected boolean enable(Node[] nodes) { ! return ((nodes.length == 1) && (nodes[0] instanceof ConnectionNode) && (((ConnectionNode)nodes[0]).isConnected())); --- 38,53 ---- OutputWriter w = IOProvider.getDefault().getIO("Stats Output", true).getOut(); ! SortedSet<EmsBean> beans = node.getEmsConnection().getBeans(); ! for (EmsBean bean : beans) { ! if (bean.getAttribute("Stats") != null) { ! w.println("\t" + bean.getBeanName().getCanonicalName()); } } ! } protected boolean enable(Node[] nodes) { ! return ((nodes.length == 1) && (nodes[0] instanceof ConnectionNode) && (((ConnectionNode)nodes[0]).isConnected())); --- Mx4jConnectionNode.java DELETED --- --- JSR160ConnectionNode.java DELETED --- --- PramatiConnectionNode.java DELETED --- --- Oc4jConnectionNode.java DELETED --- |