You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2013/01/22 23:18:46 UTC
svn commit: r1437216 - in /airavata/trunk/tools/registry-migrate: pom.xml
src/main/java/org/apache/airavata/registry/migrate/DBMigrator.java
src/main/resources/db-migrate.sh
Author: chathuri
Date: Tue Jan 22 22:18:46 2013
New Revision: 1437216
URL: http://svn.apache.org/viewvc?rev=1437216&view=rev
Log:
adding script to run database migration
Added:
airavata/trunk/tools/registry-migrate/src/main/resources/db-migrate.sh (with props)
Modified:
airavata/trunk/tools/registry-migrate/pom.xml
airavata/trunk/tools/registry-migrate/src/main/java/org/apache/airavata/registry/migrate/DBMigrator.java
Modified: airavata/trunk/tools/registry-migrate/pom.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/tools/registry-migrate/pom.xml?rev=1437216&r1=1437215&r2=1437216&view=diff
==============================================================================
--- airavata/trunk/tools/registry-migrate/pom.xml (original)
+++ airavata/trunk/tools/registry-migrate/pom.xml Tue Jan 22 22:18:46 2013
@@ -59,18 +59,4 @@
<version>1.6.1</version>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
Modified: airavata/trunk/tools/registry-migrate/src/main/java/org/apache/airavata/registry/migrate/DBMigrator.java
URL: http://svn.apache.org/viewvc/airavata/trunk/tools/registry-migrate/src/main/java/org/apache/airavata/registry/migrate/DBMigrator.java?rev=1437216&r1=1437215&r2=1437216&view=diff
==============================================================================
--- airavata/trunk/tools/registry-migrate/src/main/java/org/apache/airavata/registry/migrate/DBMigrator.java (original)
+++ airavata/trunk/tools/registry-migrate/src/main/java/org/apache/airavata/registry/migrate/DBMigrator.java Tue Jan 22 22:18:46 2013
@@ -52,12 +52,12 @@ public class DBMigrator {
//we assume given database is up and running
public static void updateDB (String jdbcUrl, String jdbcUser, String jdbcPwd){
+ InputStream sqlStream = null;
Scanner in = new Scanner(System.in);
if (jdbcPwd == null || jdbcPwd.equals("")){
System.out.println("Enter JDBC password : ");
jdbcPwd = in.next();
}
- File sqlFile = null;
String dbType = getDBType(jdbcUrl);
String jdbcDriver = null;
@@ -65,19 +65,13 @@ public class DBMigrator {
try {
if (dbType.contains("derby")){
jdbcDriver = "org.apache.derby.jdbc.ClientDriver";
- URL url = DBMigrator.class.getClassLoader()
- .getResource(MIGRATE_SQL_DERBY);
- sqlFile = new File(url.toURI());
-
+ sqlStream = DBMigrator.class.getClassLoader().getResourceAsStream(MIGRATE_SQL_DERBY);
} else if (dbType.contains("mysql")){
jdbcDriver = "com.mysql.jdbc.Driver";
- URL url = DBMigrator.class.getClassLoader()
- .getResource(MIGRATE_SQL_MYSQL);
- sqlFile = new File(url.toURI());
+ sqlStream = DBMigrator.class.getClassLoader().getResourceAsStream(MIGRATE_SQL_MYSQL);
}
Class.forName(jdbcDriver).newInstance();
connection = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPwd);
- InputStream sqlStream = new FileInputStream(sqlFile);
if (canUpdated(connection)){
executeSQLScript(connection, sqlStream);
//update configuration table with airavata version
Added: airavata/trunk/tools/registry-migrate/src/main/resources/db-migrate.sh
URL: http://svn.apache.org/viewvc/airavata/trunk/tools/registry-migrate/src/main/resources/db-migrate.sh?rev=1437216&view=auto
==============================================================================
--- airavata/trunk/tools/registry-migrate/src/main/resources/db-migrate.sh (added)
+++ airavata/trunk/tools/registry-migrate/src/main/resources/db-migrate.sh Tue Jan 22 22:18:46 2013
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+. `dirname $0`/setenv.sh
+cd $AIRAVATA_HOME/bin
+
+# update classpath
+REG_MIGRATE_CLASSPATH="$AIRAVATA_HOME/lib"
+for f in $AIRAVATA_HOME/lib/*.jar
+do
+ REG_MIGRATE_CLASSPATH=$REG_MIGRATE_CLASSPATH:$f
+done
+
+$JAVA_HOME/bin/java -server -Xms128M -Xmx128M \
+ $XDEBUG \
+ $TEMP_PROPS \
+ -Djava.endorsed.dirs=$AIRAVATA_HOME/lib/endorsed \
+ -classpath $REG_MIGRATE_CLASSPATH \
+ -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=5000,suspend=y \
+ org.apache.airavata.registry.migrate.DBMigrator $*
Propchange: airavata/trunk/tools/registry-migrate/src/main/resources/db-migrate.sh
------------------------------------------------------------------------------
svn:executable = *