geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r219992 - in /geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main: Daemon.java ProgressBarStartupMonitor.java SilentStartupMonitor.java
Date Thu, 21 Jul 2005 03:58:55 GMT
Author: ammulder
Date: Wed Jul 20 20:58:51 2005
New Revision: 219992

URL: http://svn.apache.org/viewcvs?rev=219992&view=rev
Log:
Show a list of GBeans that weren't started
 - If one of them happens to have a "port" property, show that too

Modified:
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/SilentStartupMonitor.java

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java?rev=219992&r1=219991&r2=219992&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java Wed
Jul 20 20:58:51 2005
@@ -109,7 +109,7 @@
         if(!started) {
             started = true;
 
-            // This MUST be done before the first log is acquired
+            // This MUST be done before the first log is acquired (WHICH THE STARTUP MONITOR
5 LINES LATER DOES!)
             GeronimoLogging.initialize(verboseArg == null ? GeronimoLogging.WARN : verboseArg
== ARGUMENT_VERBOSE ? GeronimoLogging.INFO : GeronimoLogging.DEBUG);
             log = LogFactory.getLog(Daemon.class.getName());
 
@@ -262,19 +262,6 @@
             for (Iterator i = configLists.iterator(); i.hasNext();) {
                 ObjectName configListName = (ObjectName) i.next();
                 kernel.setAttribute(configListName, "kernelFullyStarted", Boolean.TRUE);
-            }
-
-            Set allGBeans = kernel.listGBeans(JMXUtil.getObjectName("*:*"));
-            for (Iterator iterator = allGBeans.iterator(); iterator.hasNext();) {
-                ObjectName objectName = (ObjectName) iterator.next();
-                try {
-                    int state = kernel.getGBeanState(objectName);
-                    if (state != State.RUNNING_INDEX) {
-                        log.info("GBean " + objectName + " is not running. Current state:
" + State.fromInt(state).getName());
-                    }
-                } catch (GBeanNotFoundException e) {
-                    log.info("Alleged GBean " + objectName + " is not a GBean");
-                }
             }
 
             // Startup sequence is finished

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java?rev=219992&r1=219991&r2=219992&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java
Wed Jul 20 20:58:51 2005
@@ -15,8 +15,12 @@
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.NoSuchAttributeException;
+import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * A startup monitor that shows progress using line feeds
@@ -24,6 +28,7 @@
  * @version $Revision: 1.0$
  */
 public class ProgressBarStartupMonitor implements StartupMonitor {
+    private final static Log log = LogFactory.getLog(ProgressBarStartupMonitor.class.getName());
     private final static char STATUS_NOT_READY=' ';
     private final static char STATUS_LOADING='-';
     private final static char STATUS_LOADED='>';
@@ -139,25 +144,50 @@
     private void wrapUp() {
         repaint();
         out.println();
+
+        List apps = new ArrayList();  // type = String (message)
+        List ports = new ArrayList(); // type = AddressHolder
+        Map failed = new HashMap();   // key = ObjectName, value = String (message)
+        String serverInfo = null;
         try {
-            Set gbeans = kernel.listGBeans(new ObjectName("*:*"));
+            Set gbeans = kernel.listGBeans(ObjectName.getInstance("*:*"));
             Map beanInfos = new HashMap(); // key = GBeanInfo, value = List (of attribute
names)
-            List ports = new ArrayList(); // type = AddressHolder
-            ObjectName serverInfo = null;
-            boolean firstApp = true;
             for (Iterator it = gbeans.iterator(); it.hasNext();) {
                 ObjectName name = (ObjectName) it.next();
                 if(isApplicationModule(name)) {
-                    if(firstApp) {
-                        firstApp = false;
-                        out.println("  Started Application Modules:");
+                    apps.add("    "+decodeModule(name.getKeyProperty("j2eeType"))+": "+name.getKeyProperty("name"));
+                }
+
+                int stateValue = kernel.getGBeanState(name);
+                if (stateValue != State.RUNNING_INDEX) {
+                    GBeanData data = kernel.getGBeanData(name);
+                    State state = State.fromInt(stateValue);
+                    StringBuffer buf = new StringBuffer();
+                    buf.append("(").append(state.getName());
+                    // Since it's not unusual for a failure to be caused by a port binding
failure
+                    //    we'll see if there's a likely looking port attribute in the config
data
+                    //    for the GBean.  It's a long shot, but hey.
+                    if(data != null && data.getAttributes() != null) {
+                        Map map = data.getAttributes();
+                        for (Iterator it2 = map.keySet().iterator(); it2.hasNext();) {
+                            String att = (String) it2.next();
+                            if(att.equals("port") || att.indexOf("Port") > -1) {
+                                buf.append(",").append(att).append("=").append(map.get(att));
+                            }
+                        }
                     }
-                    out.println("    "+decodeModule(name.getKeyProperty("j2eeType"))+": "+name.getKeyProperty("name"));
+                    buf.append(")");
+                    failed.put(name, buf.toString());
+                    continue;
                 }
+
+                // Check if this is ServerInfo
                 GBeanInfo info = kernel.getGBeanInfo(name);
                 if(info.getClassName().equals("org.apache.geronimo.system.serverinfo.ServerInfo"))
{
-                    serverInfo = name;
+                    serverInfo = (String) kernel.getAttribute(name, "version");
                 }
+
+                // Look for any SocketAddress properties
                 List list = (List) beanInfos.get(info);
                 if(list == null) {
                     list = new ArrayList(3);
@@ -189,46 +219,6 @@
                     }
                 }
             }
-            Collections.sort(ports);
-            if(ports.size() > 0) {
-                System.out.println("  Listening on Ports:");
-                int max = 0;
-                for (int i = 0; i < ports.size(); i++) {
-                    AddressHolder holder = (AddressHolder) ports.get(i);
-                    max = Math.max(max, holder.getAddress().getAddress().getHostAddress().length());
-                }
-                for (int i = 0; i < ports.size(); i++) {
-                    AddressHolder holder = (AddressHolder) ports.get(i);
-                    StringBuffer buf = new StringBuffer();
-                    buf.append("   ");
-                    if(holder.getAddress().getPort() < 10) {
-                        buf.append(' ');
-                    }
-                    if(holder.getAddress().getPort() < 100) {
-                        buf.append(' ');
-                    }
-                    if(holder.getAddress().getPort() < 1000) {
-                        buf.append(' ');
-                    }
-                    if(holder.getAddress().getPort() < 10000) {
-                        buf.append(' ');
-                    }
-                    buf.append(holder.getAddress().getPort()).append(' ');
-                    buf.append(holder.getAddress().getAddress().getHostAddress());
-                    for(int j=holder.getAddress().getAddress().getHostAddress().length();
j<=max; j++) {
-                        buf.append(' ');
-                    }
-                    buf.append(holder.getName());
-                    out.println(buf.toString());
-                }
-            }
-            StringBuffer msg = new StringBuffer();
-            msg.append("Geronimo Application Server started");
-            if(serverInfo != null) {
-                msg.append(" (version ").append(kernel.getAttribute(serverInfo, "version")+")");
-            }
-            out.println(msg.toString());
-            out.flush();
         } catch (MalformedObjectNameException e) {
             e.printStackTrace();
         } catch (GBeanNotFoundException e) {
@@ -238,6 +228,70 @@
         } catch (Exception e) { // required by Kernel.getAttribute
             e.printStackTrace();
         }
+
+        // Helpful output: list of applications started
+        if(apps.size() > 0) {
+            out.println("  Started Application Modules:");
+            for (int i = 0; i < apps.size(); i++) {
+                out.println((String)apps.get(i));
+            }
+        }
+        // Helpful output: list of ports we listen on
+        if(ports.size() > 0) {
+            Collections.sort(ports);
+            System.out.println("  Listening on Ports:");
+            int max = 0;
+            for (int i = 0; i < ports.size(); i++) {
+                AddressHolder holder = (AddressHolder) ports.get(i);
+                max = Math.max(max, holder.getAddress().getAddress().getHostAddress().length());
+            }
+            for (int i = 0; i < ports.size(); i++) {
+                AddressHolder holder = (AddressHolder) ports.get(i);
+                StringBuffer buf = new StringBuffer();
+                buf.append("   ");
+                if(holder.getAddress().getPort() < 10) {
+                    buf.append(' ');
+                }
+                if(holder.getAddress().getPort() < 100) {
+                    buf.append(' ');
+                }
+                if(holder.getAddress().getPort() < 1000) {
+                    buf.append(' ');
+                }
+                if(holder.getAddress().getPort() < 10000) {
+                    buf.append(' ');
+                }
+                buf.append(holder.getAddress().getPort()).append(' ');
+                buf.append(holder.getAddress().getAddress().getHostAddress());
+                for(int j=holder.getAddress().getAddress().getHostAddress().length(); j<=max;
j++) {
+                    buf.append(' ');
+                }
+                buf.append(holder.getName());
+                out.println(buf.toString());
+            }
+        }
+        // Helpful output: list of GBeans that did not start
+        if(failed.size() > 0) {
+            out.println("  WARNING: Some GBeans were not started successfully:");
+            for (Iterator it = failed.keySet().iterator(); it.hasNext();) {
+                ObjectName name = (ObjectName) it.next();
+                String state = (String) failed.get(name);
+                if(name.getKeyProperty("name") != null) {
+                    log.debug("Unable to start "+name+" "+state);
+                    out.println("    "+name.getKeyProperty("name")+" "+state);
+                } else {
+                    out.println("    "+name+" "+state);
+                }
+            }
+        }
+
+        StringBuffer msg = new StringBuffer();
+        msg.append("Geronimo Application Server started");
+        if(serverInfo != null) {
+            msg.append(" (version ").append(serverInfo).append(")");
+        }
+        out.println(msg.toString());
+        out.flush();
     }
 
     public synchronized void loadFailed(String configuration, Exception problem) {

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/SilentStartupMonitor.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/SilentStartupMonitor.java?rev=219992&r1=219991&r2=219992&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/SilentStartupMonitor.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/SilentStartupMonitor.java
Wed Jul 20 20:58:51 2005
@@ -1,16 +1,31 @@
 package org.apache.geronimo.system.main;
 
 import java.net.URI;
+import java.util.Set;
+import java.util.Iterator;
+
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.management.State;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+
+import javax.management.ObjectName;
+import javax.management.MalformedObjectNameException;
 
 /**
  * @version $Revision: 1.0$
  */
 public class SilentStartupMonitor implements StartupMonitor {
+    private final static Log log = LogFactory.getLog(SilentStartupMonitor.class.getName());
+
+    private Kernel kernel;
+
     public void systemStarting(long startTime) {
     }
 
     public void systemStarted(Kernel kernel) {
+        this.kernel = kernel;
     }
 
     public void foundConfigurations(URI[] configurations) {
@@ -29,6 +44,18 @@
     }
 
     public void startupFinished() {
+        try {
+            Set gbeans = kernel.listGBeans(ObjectName.getInstance("*:*"));
+            for (Iterator it = gbeans.iterator(); it.hasNext();) {
+                ObjectName name = (ObjectName) it.next();
+                int state = kernel.getGBeanState(name);
+                if (state != State.RUNNING_INDEX) {
+                    log.warn("Unable to start "+name+" ("+State.fromInt(state).getName()+")");
+                }
+            }
+        } catch (MalformedObjectNameException e) {
+        } catch (GBeanNotFoundException e) {
+        }
         System.out.println("Geronimo startup complete");
     }
 



Mime
View raw message