[rhq] Branch 'rhq-on-as7' - 2 commits - modules/enterprise

mazz mazz at fedoraproject.org
Tue Aug 7 15:59:57 UTC 2012


 modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java |   54 ++++++++--
 1 file changed, 47 insertions(+), 7 deletions(-)

New commits:
commit 54404005e17e4d8dab4577106d75f5bf0632ecba
Author: John Mazzitelli <mazz at redhat.com>
Date:   Tue Aug 7 11:59:52 2012 -0400

    get auto-installer to work with the new installer

diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
index 6a82830..d9bc8f6 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
@@ -27,6 +27,7 @@ import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import javax.servlet.ServletException;
 import javax.servlet.annotation.WebServlet;
 
 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@@ -50,12 +51,46 @@ import org.rhq.enterprise.gui.installer.server.servlet.ServerInstallUtil.Support
  *
  * @author John Mazzitelli
  */
- at WebServlet(value = "/org.rhq.enterprise.gui.installer.Installer/InstallerGWTService")
+ at WebServlet(value = "/org.rhq.enterprise.gui.installer.Installer/InstallerGWTService", loadOnStartup = 1)
 public class InstallerGWTServiceImpl extends RemoteServiceServlet implements InstallerGWTService {
 
     private static final long serialVersionUID = 1L;
 
     @Override
+    public void init() throws ServletException {
+        super.init();
+
+        // our installer is ready - let's see if we are in auto-install mode - if so, begin the install immediately
+        final boolean autoInstallMode;
+        final HashMap<String, String> serverProperties;
+
+        try {
+            serverProperties = getServerProperties();
+            autoInstallMode = ServerInstallUtil.isAutoinstallEnabled(serverProperties);
+        } catch (Throwable t) {
+            log("Cannot determine if in auto-install mode; using manual mode but installer may not work properly.", t);
+            return;
+        }
+
+        if (autoInstallMode) {
+            Runnable asyncAutoInstall = new Runnable() {
+                public void run() {
+                    try {
+                        log("The server is preconfigured - performing auto-install immediately...");
+                        install(serverProperties, null, null);
+                        log("The server has been auto-installed and should be ready shortly.");
+                    } catch (Throwable t) {
+                        log("The server was preconfigured but it failed to auto-install!", t);
+                    }
+                }
+            };
+            new Thread(asyncAutoInstall, "RHQ Server Auto-Install Thread").start();
+        } else {
+            log("In manual-install mode, user must complete the installation via the Installer GUI");
+        }
+    }
+
+    @Override
     public void install(HashMap<String, String> serverProperties, ServerDetails serverDetails,
         String existingSchemaOption) throws Exception {
 
@@ -205,7 +240,7 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
             if (s == null || s.equalsIgnoreCase("auto")) {
                 existingSchemaOptionEnum = ExistingSchemaOption.KEEP;
             } else {
-                existingSchemaOptionEnum = ExistingSchemaOption.valueOf(s);
+                existingSchemaOptionEnum = ExistingSchemaOption.valueOf(s.toUpperCase());
             }
         } else {
             if (existingSchemaOption == null) {
@@ -217,16 +252,21 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
         if (ExistingSchemaOption.SKIP != existingSchemaOptionEnum) {
             if (isDatabaseSchemaExist(dbUrl, dbUsername, clearTextDbPassword)) {
                 if (ExistingSchemaOption.OVERWRITE == existingSchemaOptionEnum) {
+                    log("Database schema exists but installer was told to overwrite it - a new schema will be created now.");
                     ServerInstallUtil.createNewDatabaseSchema(serverProperties, serverDetails, clearTextDbPassword,
                         getLogDir());
                 } else {
+                    log("Database schema exists - it will now be updated.");
                     ServerInstallUtil.upgradeExistingDatabaseSchema(serverProperties, serverDetails,
                         clearTextDbPassword, getLogDir());
                 }
             } else {
+                log("Database schema does not yet exist - it will now be created.");
                 ServerInstallUtil.createNewDatabaseSchema(serverProperties, serverDetails, clearTextDbPassword,
                     getLogDir());
             }
+        } else {
+            log("Ignoring database schema - installer will assume it exists and is already up-to-date.");
         }
 
         // ensure the server info is up to date and stored in the DB


commit 8dd90ca85400c14d36f70541d9a49576fec0066f
Author: John Mazzitelli <mazz at redhat.com>
Date:   Tue Aug 7 10:04:39 2012 -0400

    minor cleanup

diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
index 5396a76..6a82830 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
@@ -199,22 +199,22 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
         // Prepare the db schema.
         // existingSchemaOption is either overwrite, keep or skip.
         // If in auto-install mode, we can be told to overwrite, skip or auto (meaning "keep" if schema exists)
-        ServerInstallUtil.ExistingSchemaOption existingSchemaOptionEnum;
+        ExistingSchemaOption existingSchemaOptionEnum;
         if (autoInstallMode) {
             final String s = serverProperties.get(ServerProperties.PROP_AUTOINSTALL_DATABASE);
             if (s == null || s.equalsIgnoreCase("auto")) {
-                existingSchemaOptionEnum = ServerInstallUtil.ExistingSchemaOption.KEEP;
+                existingSchemaOptionEnum = ExistingSchemaOption.KEEP;
             } else {
-                existingSchemaOptionEnum = ServerInstallUtil.ExistingSchemaOption.valueOf(s);
+                existingSchemaOptionEnum = ExistingSchemaOption.valueOf(s);
             }
         } else {
             if (existingSchemaOption == null) {
                 throw new Exception("Don't know what to do with the database schema");
             }
-            existingSchemaOptionEnum = ServerInstallUtil.ExistingSchemaOption.valueOf(existingSchemaOption);
+            existingSchemaOptionEnum = ExistingSchemaOption.valueOf(existingSchemaOption);
         }
 
-        if (ServerInstallUtil.ExistingSchemaOption.SKIP != existingSchemaOptionEnum) {
+        if (ExistingSchemaOption.SKIP != existingSchemaOptionEnum) {
             if (isDatabaseSchemaExist(dbUrl, dbUsername, clearTextDbPassword)) {
                 if (ExistingSchemaOption.OVERWRITE == existingSchemaOptionEnum) {
                     ServerInstallUtil.createNewDatabaseSchema(serverProperties, serverDetails, clearTextDbPassword,
@@ -398,7 +398,7 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
      * @param serverProperties the server properties
      * @throws Exception
      */
-    public ServerDetails getServerDetailsFromPropertiesOnly(HashMap<String, String> serverProperties) throws Exception {
+    private ServerDetails getServerDetailsFromPropertiesOnly(HashMap<String, String> serverProperties) throws Exception {
 
         String highAvailabilityName = serverProperties.get(ServerProperties.PROP_HIGH_AVAILABILITY_NAME);
         String publicEndpoint = serverProperties.get(ServerProperties.PROP_AUTOINSTALL_PUBLIC_ADDR);




More information about the rhq-commits mailing list