geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: rev 57392 - in geronimo/trunk/modules: kernel/src/java/org/apache/geronimo/kernel/config system/src/java/org/apache/geronimo/system/configuration system/src/java/org/apache/geronimo/system/main
Date Wed, 10 Nov 2004 22:14:55 GMT
Author: dain
Date: Wed Nov 10 14:14:54 2004
New Revision: 57392

Modified:
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/PersistentConfigurationList.java
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java
Log:
Changed persistend configuration to only save the configuration list only after the kernel
is fully started.  This fixes the problem of killing the server during the boot process and
having the configuration list overwritten with no data.


Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/PersistentConfigurationList.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/PersistentConfigurationList.java
(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/PersistentConfigurationList.java
Wed Nov 10 14:14:54 2004
@@ -18,9 +18,6 @@
 
 import java.io.IOException;
 import java.util.List;
-import javax.management.ObjectName;
-
-import org.apache.geronimo.kernel.jmx.JMXUtil;
 
 /**
  *
@@ -29,6 +26,10 @@
  * @version $Rev$ $Date$
  */
 public interface PersistentConfigurationList {
+    boolean isKernelFullyStarted();
+
+    void setKernelFullyStarted(boolean kernelFullyStarted);
+
     void save() throws IOException;
 
     List restore() throws IOException;

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java
Wed Nov 10 14:14:54 2004
@@ -52,10 +52,38 @@
  */
 public class FileConfigurationList implements GBeanLifecycle, PersistentConfigurationList
{
     private static final Log log = LogFactory.getLog(PersistentConfigurationList.class);
+
+    /**
+     * The kernel for which we are persisting the configuration list.
+     */
     private final Kernel kernel;
+
+    /**
+     * Used to resolve the location of the configuration file.
+     */
     private final ServerInfo serverInfo;
+
+    /**
+     * The file to which we are saving the configurations.  This is relative to the
+     * server base directory in server info.
+     */
     private final String configFile;
+
+    /**
+     * Is the kernel fully started?  Until the kernel is fully started, we will
+     * not write out a new configuration list.  This stops a crtl^c during start up
+     * from completely overwriting the startup file with no content.
+     */
+    private boolean kernelFullyStarted = false;
+
+    /**
+     * The acutal absolute file where we write the configuration list.
+     */
     private File configList;
+
+    /**
+     * Our hook the kernel calls before shutting down.
+     */
     private Runnable hook;
 
     public FileConfigurationList(Kernel kernel, ServerInfo serverInfo, String configDir)
{
@@ -94,7 +122,20 @@
         configList = null;
     }
 
+    public synchronized boolean isKernelFullyStarted() {
+        return kernelFullyStarted;
+    }
+
+    public synchronized void setKernelFullyStarted(boolean kernelFullyStarted) {
+        this.kernelFullyStarted = kernelFullyStarted;
+    }
+
     public synchronized void save() throws IOException {
+        if (!kernelFullyStarted) {
+            log.info("Configuration list was not saved.  Kernel was never fully started.");
+            return;
+        }
+
         BufferedWriter writer = new BufferedWriter(new FileWriter(configList));
         try {
             List stores = kernel.listConfigurationStores();
@@ -147,6 +188,7 @@
         GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(FileConfigurationList.class);
         infoFactory.addInterface(PersistentConfigurationList.class);
         infoFactory.addAttribute("kernel", Kernel.class, false);
+        infoFactory.addAttribute("kernelFullyStarted", boolean.class, false);
         infoFactory.addReference("ServerInfo", ServerInfo.class);
         infoFactory.addAttribute("configFile", String.class, true);
         infoFactory.setConstructor(new String[]{"kernel", "ServerInfo", "configFile"});

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/Daemon.java	(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java	Wed
Nov 10 14:14:54 2004
@@ -129,7 +129,7 @@
                 for (Iterator i = configLists.iterator(); i.hasNext();) {
                     ObjectName configListName = (ObjectName) i.next();
                     try {
-                        configs = (List) kernel.invoke(configListName, "restore");
+                        configs.addAll((List) kernel.invoke(configListName, "restore"));
                     } catch (IOException e) {
                         System.err.println("Unable to restore last known configurations");
                         e.printStackTrace();
@@ -159,6 +159,13 @@
                 e.printStackTrace();
                 System.exit(3);
                 throw new AssertionError();
+            }
+
+            // Tell every persistent configuration list that the kernel is now fully started
+            Set configLists = kernel.listGBeans(JMXUtil.getObjectName("*:role=PersistentConfigurationList,*"));
+            for (Iterator i = configLists.iterator(); i.hasNext();) {
+                ObjectName configListName = (ObjectName) i.next();
+                kernel.setAttribute(configListName, "kernelFullyStarted", Boolean.TRUE);
             }
 
             log.info("Server startup completed");

Mime
View raw message