cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dar...@apache.org
Subject git commit: updated refs/heads/master to c1bae79
Date Sat, 02 Nov 2013 05:39:24 GMT
Updated Branches:
  refs/heads/master 24af28290 -> c1bae7984


Revert "Commit 1460196496d73e0db25c7beb2392cfaf9d591ed7 changed db.properties"

This reverts commit a3cec3802c4c56173c33ccc1e08af059547fe90e.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c1bae798
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c1bae798
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c1bae798

Branch: refs/heads/master
Commit: c1bae7984a29a7f3861d40e77ec896b8d3b53d77
Parents: 24af282
Author: Darren Shepherd <darren.s.shepherd@gmail.com>
Authored: Thu Oct 31 09:20:36 2013 -0700
Committer: Darren Shepherd <darren.s.shepherd@gmail.com>
Committed: Fri Nov 1 22:25:53 2013 -0700

----------------------------------------------------------------------
 .../src/com/cloud/upgrade/DatabaseCreator.java  | 76 +++++++++++---------
 1 file changed, 41 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c1bae798/engine/schema/src/com/cloud/upgrade/DatabaseCreator.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/DatabaseCreator.java b/engine/schema/src/com/cloud/upgrade/DatabaseCreator.java
index 58703ae..e8f2cc5 100755
--- a/engine/schema/src/com/cloud/upgrade/DatabaseCreator.java
+++ b/engine/schema/src/com/cloud/upgrade/DatabaseCreator.java
@@ -19,6 +19,7 @@
 package com.cloud.upgrade;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
@@ -36,7 +37,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
 import com.cloud.utils.PropertiesUtil;
 import com.cloud.utils.component.ComponentContext;
 import com.cloud.utils.component.SystemIntegrityChecker;
-import com.cloud.utils.db.DbProperties;
 import com.cloud.utils.db.ScriptRunner;
 import com.cloud.utils.db.TransactionLegacy;
 
@@ -47,7 +47,7 @@ public class DatabaseCreator {
     protected static void printHelp(String cmd) {
         System.out.println(
                 "\nDatabaseCreator creates the database schema by removing the \n" +
-                        "previous schema, creating the schema, and running \n" +
+                "previous schema, creating the schema, and running \n" +
                 "through the database updaters.");
         System.out.println("Usage: " + cmd + " [options] [db.properties file] [schema.sql
files] [database upgrade class]\nOptions:"
                 + "\n   --database=a,b comma separate databases to initialize, use the db
name in db.properties defined as db.xyz.host, xyz should be passed"
@@ -94,7 +94,13 @@ public class DatabaseCreator {
     }
 
     private static void initDB(String dbPropsFile, String rootPassword, String[] databases,
boolean dryRun) {
-        Properties dbProperties = DbProperties.getDbProperties();
+        Properties dbProperties = new Properties();
+        try {
+            dbProperties.load(new FileInputStream(new File(dbPropsFile)));
+        } catch (IOException e) {
+            System.out.println("IOError: unable to load/read db properties file: " + e);
+            System.exit(1);
+        }
 
         for (String database: databases) {
             String host = dbProperties.getProperty(String.format("db.%s.host", database));
@@ -117,11 +123,11 @@ public class DatabaseCreator {
     }
 
     public static void main(String[] args) {
-
-        ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
-                new String[] {"/com/cloud/upgrade/databaseCreatorContext.xml"});
-        appContext.getBean(ComponentContext.class);
-
+    	
+    	ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
+    	        new String[] {"/com/cloud/upgrade/databaseCreatorContext.xml"});
+    	appContext.getBean(ComponentContext.class);
+    	
         String dbPropsFile = "";
         List<String> sqlFiles = new ArrayList<String>();
         List<String> upgradeClasses = new ArrayList<String>();
@@ -146,12 +152,12 @@ public class DatabaseCreator {
             } else if (arg.endsWith(".sql")) {
                 sqlFiles.add(arg);
             } else if (arg.endsWith(".sql.override")) {
-                if (fileExists(arg)) {
-                    int index = arg.lastIndexOf(".override");
-                    String fileToOverride = arg.substring(0, index);
-                    sqlFiles.remove(fileToOverride);
-                    sqlFiles.add(arg);
-                }
+            	if (fileExists(arg)) {
+            		int index = arg.lastIndexOf(".override");
+            		String fileToOverride = arg.substring(0, index);
+            		sqlFiles.remove(fileToOverride);
+            		sqlFiles.add(arg);
+            	}
             } else if (arg.endsWith(".properties")) {
                 if (!dbPropsFile.endsWith("properties.override") && fileExists(arg))
                     dbPropsFile = arg;
@@ -209,30 +215,30 @@ public class DatabaseCreator {
 
         TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
         try {
-            // Process db upgrade classes
-            for (String upgradeClass: upgradeClasses) {
-                System.out.println("========> Processing upgrade: " + upgradeClass);
-                Class<?> clazz = null;
-                try {
-                    clazz = Class.forName(upgradeClass);
-                    if (!SystemIntegrityChecker.class.isAssignableFrom(clazz)) {
-                        System.err.println("The class must be of SystemIntegrityChecker:
" + clazz.getName());
-                        System.exit(1);
-                    }
-                    SystemIntegrityChecker checker = (SystemIntegrityChecker)clazz.newInstance();
-                    checker.check();
-                } catch (ClassNotFoundException e) {
-                    System.err.println("Unable to find " + upgradeClass + ": " + e.getMessage());
-                    System.exit(1);
-                } catch (InstantiationException e) {
-                    System.err.println("Unable to instantiate " + upgradeClass + ": " + e.getMessage());
-                    System.exit(1);
-                } catch (IllegalAccessException e) {
-                    System.err.println("Unable to access " + upgradeClass + ": " + e.getMessage());
+        // Process db upgrade classes
+        for (String upgradeClass: upgradeClasses) {
+            System.out.println("========> Processing upgrade: " + upgradeClass);
+            Class<?> clazz = null;
+            try {
+                clazz = Class.forName(upgradeClass);
+                if (!SystemIntegrityChecker.class.isAssignableFrom(clazz)) {
+                    System.err.println("The class must be of SystemIntegrityChecker: " +
clazz.getName());
                     System.exit(1);
                 }
-
+                SystemIntegrityChecker checker = (SystemIntegrityChecker)clazz.newInstance();
+                checker.check();
+            } catch (ClassNotFoundException e) {
+                System.err.println("Unable to find " + upgradeClass + ": " + e.getMessage());
+                System.exit(1);
+            } catch (InstantiationException e) {
+                System.err.println("Unable to instantiate " + upgradeClass + ": " + e.getMessage());
+                System.exit(1);
+            } catch (IllegalAccessException e) {
+                System.err.println("Unable to access " + upgradeClass + ": " + e.getMessage());
+                System.exit(1);
             }
+
+         }
         } finally {
             txn.close();
         }


Mime
View raw message