Author: tucu
Date: Thu Mar 1 21:36:09 2012
New Revision: 1295913
URL: http://svn.apache.org/viewvc?rev=1295913&view=rev
Log:
OOZIE-631 Oozie DB create/upgrade tool (tucu)
Added:
incubator/oozie/trunk/docs/src/site/twiki/AG_OozieUpgrade.twiki
incubator/oozie/trunk/src/main/assemblies/tools.xml
incubator/oozie/trunk/tools/
incubator/oozie/trunk/tools/pom.xml
incubator/oozie/trunk/tools/src/
incubator/oozie/trunk/tools/src/main/
incubator/oozie/trunk/tools/src/main/bin/
incubator/oozie/trunk/tools/src/main/bin/ooziedb.sh
incubator/oozie/trunk/tools/src/main/java/
incubator/oozie/trunk/tools/src/main/java/org/
incubator/oozie/trunk/tools/src/main/java/org/apache/
incubator/oozie/trunk/tools/src/main/java/org/apache/oozie/
incubator/oozie/trunk/tools/src/main/java/org/apache/oozie/tools/
incubator/oozie/trunk/tools/src/main/java/org/apache/oozie/tools/OozieDBCLI.java
Modified:
incubator/oozie/trunk/core/src/main/conf/oozie-site.xml
incubator/oozie/trunk/docs/src/site/twiki/AG_Install.twiki
incubator/oozie/trunk/docs/src/site/twiki/DG_QuickStart.twiki
incubator/oozie/trunk/docs/src/site/twiki/index.twiki
incubator/oozie/trunk/pom.xml
incubator/oozie/trunk/release-log.txt
incubator/oozie/trunk/src/main/assemblies/distro.xml
Modified: incubator/oozie/trunk/core/src/main/conf/oozie-site.xml
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/conf/oozie-site.xml?rev=1295913&r1=1295912&r2=1295913&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/conf/oozie-site.xml (original)
+++ incubator/oozie/trunk/core/src/main/conf/oozie-site.xml Thu Mar 1 21:36:09
2012
@@ -124,8 +124,8 @@
</property>
<property>
- <name>oozie.service.StoreService.create.db.schema</name>
- <value>true</value>
+ <name>oozie.service.JPAService.create.db.schema</name>
+ <value>false</value>
<description>
Creates Oozie DB.
@@ -135,7 +135,7 @@
</property>
<property>
- <name>oozie.service.StoreService.jdbc.driver</name>
+ <name>oozie.service.JPAService.jdbc.driver</name>
<value>org.apache.derby.jdbc.EmbeddedDriver</value>
<description>
JDBC driver class.
@@ -143,7 +143,7 @@
</property>
<property>
- <name>oozie.service.StoreService.jdbc.url</name>
+ <name>oozie.service.JPAService.jdbc.url</name>
<value>jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true</value>
<description>
JDBC URL.
@@ -151,7 +151,7 @@
</property>
<property>
- <name>oozie.service.StoreService.jdbc.username</name>
+ <name>oozie.service.JPAService.jdbc.username</name>
<value>sa</value>
<description>
DB user name.
@@ -159,21 +159,18 @@
</property>
<property>
- <name>oozie.service.StoreService.jdbc.password</name>
+ <name>oozie.service.JPAService.jdbc.password</name>
<value> </value>
<description>
DB user password.
IMPORTANT: if password is emtpy leave a 1 space string, the
service trims the value,
if empty Configuration assumes it is NULL.
-
- IMPORTANT: if the StoreServicePasswordService is active, it will
reset this value with the value given in
- the console.
</description>
</property>
<property>
- <name>oozie.service.StoreService.pool.max.active.conn</name>
+ <name>oozie.service.JPAService.pool.max.active.conn</name>
<value>10</value>
<description>
Max number of connections.
Modified: incubator/oozie/trunk/docs/src/site/twiki/AG_Install.twiki
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/docs/src/site/twiki/AG_Install.twiki?rev=1295913&r1=1295912&r2=1295913&view=diff
==============================================================================
--- incubator/oozie/trunk/docs/src/site/twiki/AG_Install.twiki (original)
+++ incubator/oozie/trunk/docs/src/site/twiki/AG_Install.twiki Thu Mar 1
21:36:09 2012
@@ -99,7 +99,7 @@ servlet container (if using Tomcat, copy
---++ Database Configuration
-Oozie works with HSQL, Derby, MySQL, Oracle and PostgreSQL databases.
+Oozie works with HSQL, Derby, MySQL, Oracle or PostgreSQL databases.
By default, Oozie is configured to use Embedded Derby.
@@ -107,17 +107,17 @@ Oozie bundles the JDBC drivers for HSQL,
HSQL is normally used for testcases as it is an in-memory database and all
data is lost everytime Oozie is stopped.
-If using MySQL, Oracle or PostgreSQL, the Oozie database schema must be
created. By default, Oozie creates its
-tables automatically.
+If using Derby, MySQL, Oracle or PostgreSQL, the Oozie database schema must be
created using the =ooziedb.sh= command
+line tool.
-The =bin/addtowar.sh= and the =oozie-setup.sh= scripts have an option =-jars=
that can be used to add the Oracle or
-MySQL JDBC driver JARs to the Oozie WAR file.
+If using MySQL or Oracle, the corresponding JDBC driver JAR file mut be copied
to Oozie's =libext/= directory and
+it must be added to Oozie WAR file using the =bin/addtowar.sh= or the
=oozie-setup.sh= scripts using the =-jars= option.
The SQL database used by Oozie is configured using the following configuration
properties (default values shown):
<verbatim>
oozie.db.schema.name=oozie
- oozie.service.JPAService.create.db.schema=true
+ oozie.service.JPAService.create.db.schema=false
oozie.service.JPAService.validate.db.connection=false
oozie.service.JPAService.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
oozie.service.JPAService.jdbc.url=jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true
@@ -126,7 +126,40 @@ The SQL database used by Oozie is config
oozie.service.JPAService.pool.max.active.conn=10
</verbatim>
-If using HSQL, these following configuration properties have to be in
oozie-site.xml:
+*NOTE:* If the =oozie.db.schema.create= property is set to =true= (default
value is =false=) the Oozie tables
+will be created automatically without having to use the =ooziedb= command line
tool. Setting this property to
+ =true= it is recommended only for development.
+
+*NOTE:* If the =oozie.db.schema.create= property is set to true, the
=oozie.service.JPAService.validate.db.connection=
+property value is ignored and Oozie handles it as set to =false=.
+
+Once =oozie-site.xml= has been configured with the database configuration
execute the =ooziedb.sh= command line tool to
+create the database:
+
+<verbatim>
+$ bin/ooziedb.sh create -sqlfile oozie.sql -run
+
+Validate DB Connection.
+DONE
+Check DB schema does not exist
+DONE
+Check OOZIE_SYS table does not exist
+DONE
+Create SQL schema
+DONE
+DONE
+Create OOZIE_SYS table
+DONE
+
+Oozie DB has been created for Oozie version '3.2.0'
+
+$
+</verbatim>
+
+If the '-run' option is not specified, only the SQL file with the command that
would be executed will be created.
+
+If using HSQL there is no need to use the =ooziedb= command line tool as HSQL
is an im-memory database. Use the
+following configuration properties in the oozie-site.xml:
<verbatim>
oozie.db.schema.name=oozie
@@ -139,13 +172,6 @@ If using HSQL, these following configura
oozie.service.JPAService.pool.max.active.conn=10
</verbatim>
-*NOTE:* If the =oozie.db.schema.create= property is set to =true= (default)
the Oozie tables will be created
-automatically if they are not found in the database at Oozie start up time. In
a production system this option should
-be set to =false= once the databaset tables have been created.
-
-*NOTE:* If the =oozie.db.schema.create= property is set to true, the
=oozie.service.JPAService.validate.db.connection=
-property value is ignored and Oozie handles it as set to =false=.
-
---++ Oozie Configuration
By default, Oozie configuration is read from Oozie's =conf/= directory
Added: incubator/oozie/trunk/docs/src/site/twiki/AG_OozieUpgrade.twiki
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/docs/src/site/twiki/AG_OozieUpgrade.twiki?rev=1295913&view=auto
==============================================================================
--- incubator/oozie/trunk/docs/src/site/twiki/AG_OozieUpgrade.twiki (added)
+++ incubator/oozie/trunk/docs/src/site/twiki/AG_OozieUpgrade.twiki Thu Mar 1
21:36:09 2012
@@ -0,0 +1,80 @@
+<noautolink>
+
+[[index][::Go back to Oozie Documentation Index::]]
+
+---+!! Oozie Upgrade
+
+%TOC%
+
+---+ Preparation
+
+Make sure there are not Workflows in RUNNING or SUSPENDED status, otherwise
the database upgrade will fail.
+
+Shutdown Oozie and backup the Oozie database.
+
+Copy the oozie-site.xml from your current setup.
+
+---+ Oozie Server Upgrade
+
+Expand the new Oozie tarball in a new location.
+
+Edit the new oozie-site.xml setting all custom properties values from the old
oozie-site.xml
+
+IMPORTANT: From Oozie 2.x to Oozie 3.x the names of the database configuration
properties have
+changed. Their prefix has changed from =oozie.service.StoreService.*= to
=oozie.service.JPAService.*=.
+Make sure you are using the new prefix.
+
+After upgrading the Oozie server, the =oozie-setup.sh= MUST be rerun before
starting the
+upgraded Oozie server.
+
+Oozie database migration is required when there Oozie database schema changes,
like
+upgrading from Oozie 2.x to Oozie 3.x.
+
+Configure the oozie-site.xml with the correct database configuration
properties as
+explained in the 'Database Configuration' section in [[AG_Install][Oozie
Install]].
+
+Once =oozie-site.xml= has been configured with the database configuration
execute the =ooziedb.sh=
+command line tool to upgrade the database:
+
+<verbatim>
+$ bin/ooziedb.sh upgrade -sqlfile oozie.sql -run
+
+Validate DB Connection.
+DONE
+Check DB schema exists
+DONE
+Check OOZIE_SYS table does not exist
+DONE
+Verify there are not active Workflow Jobs
+DONE
+Create SQL schema
+DONE
+DONE
+Create OOZIE_SYS table
+DONE
+Upgrade COORD_JOBS new columns default values.
+DONE
+Upgrade COORD_JOBS & COORD_ACTIONS status values.
+DONE
+
+IMPORTANT: the following manual changes may have to be done in the Oozie DB
+
+ The 'execution_path' column in the 'WF_ACTIONS' table should be modified to
be a VARCHAR2(1024)
+
+
+Oozie DB has been upgraded to Oozie version '3.2.0'
+
+$
+</verbatim>
+
+The new version of the Oozie server is ready to be started.
+
+---+ Oozie Client Upgrade
+
+While older Oozie clients work with newer Oozie server, to have access to all
the
+functionality of the Oozie server the same version of Oozie client should be
installed
+and used by users.
+
+[[index][::Go back to Oozie Documentation Index::]]
+
+</noautolink>
Modified: incubator/oozie/trunk/docs/src/site/twiki/DG_QuickStart.twiki
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/docs/src/site/twiki/DG_QuickStart.twiki?rev=1295913&r1=1295912&r2=1295913&view=diff
==============================================================================
--- incubator/oozie/trunk/docs/src/site/twiki/DG_QuickStart.twiki (original)
+++ incubator/oozie/trunk/docs/src/site/twiki/DG_QuickStart.twiki Thu Mar 1
21:36:09 2012
@@ -47,7 +47,9 @@ if necessary use =sudo -u OOZIE_USER= wh
Create a *libext/* directory in the directory where Oozie was expanded.
-If using a version of Hadoop bundled in Oozie *hadooplibs/*, copy the
corresponding Hadoop JARs from *hadooplibs/* to the *libext/* directory. If
using a different version of Hadoop, copy the required Hadoop JARs from such
version in the *libext/* directory.
+If using a version of Hadoop bundled in Oozie *hadooplibs/*, copy the
corresponding Hadoop JARs
+from *hadooplibs/* to the *libext/* directory. If using a different version of
Hadoop, copy the
+required Hadoop JARs from such version in the *libext/* directory.
If using the ExtJS library copy the ZIP file to the *libext/* directory.
@@ -57,7 +59,29 @@ Run the =oozie-setup.sh= script to confi
$ bin/oozie-setup.sh
</verbatim>
-To start Oozie as a daemon process run:
+Create the Oozie DB using the 'ooziedb.sh' command line tool:
+
+<verbatim>
+$ bin/ooziedb.sh create -sqlfile oozie.sql -run
+
+Validate DB Connection.
+DONE
+Check DB schema does not exist
+DONE
+Check OOZIE_SYS table does not exist
+DONE
+Create SQL schema
+DONE
+DONE
+Create OOZIE_SYS table
+DONE
+
+Oozie DB has been created for Oozie version '3.2.0'
+
+$
+</verbatim>
+
+Start Oozie as a daemon process run:
<verbatim>
$ bin/oozie-start.sh
Modified: incubator/oozie/trunk/docs/src/site/twiki/index.twiki
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/docs/src/site/twiki/index.twiki?rev=1295913&r1=1295912&r2=1295913&view=diff
==============================================================================
--- incubator/oozie/trunk/docs/src/site/twiki/index.twiki (original)
+++ incubator/oozie/trunk/docs/src/site/twiki/index.twiki Thu Mar 1 21:36:09
2012
@@ -64,6 +64,7 @@ Enough reading already? Follow the steps
* [[AG_Install][Oozie Install]]
* [[AG_Monitoring][Oozie Monitoring]]
* [[DG_CommandLineTool][Command Line Tool]]
+ * [[AG_OozieUpgrade][Oozie Upgrade]]
#LicenseInfo
---++ Licensing Information
Modified: incubator/oozie/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/pom.xml?rev=1295913&r1=1295912&r2=1295913&view=diff
==============================================================================
--- incubator/oozie/trunk/pom.xml (original)
+++ incubator/oozie/trunk/pom.xml Thu Mar 1 21:36:09 2012
@@ -90,6 +90,7 @@
<module>examples</module>
<module>docs</module>
<module>sharelib</module>
+ <module>tools</module>
<module>distro</module>
</modules>
Modified: incubator/oozie/trunk/release-log.txt
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1295913&r1=1295912&r2=1295913&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Thu Mar 1 21:36:09 2012
@@ -1,5 +1,6 @@
-- Oozie 3.2.0 release
+OOZIE-631 Oozie DB create/upgrade tool (tucu)
OOZIE-729 SubmitMRCommand & SubmitMRXCommant testcases fail with Hadoop 0.23
(tucu)
OOZIE-726 Removing switch from default runtime scope to compile scope for
hadooplib.xml assembly due to it pulling in JDK tools.jar with compile scope.
(abayer via tucu)
OOZIE-228 For authorization we should use the ACL model (tucu)
Modified: incubator/oozie/trunk/src/main/assemblies/distro.xml
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/src/main/assemblies/distro.xml?rev=1295913&r1=1295912&r2=1295913&view=diff
==============================================================================
--- incubator/oozie/trunk/src/main/assemblies/distro.xml (original)
+++ incubator/oozie/trunk/src/main/assemblies/distro.xml Thu Mar 1 21:36:09
2012
@@ -67,6 +67,22 @@
<include>*</include>
</includes>
</fileSet>
+ <!-- Tools -->
+ <fileSet>
+
<directory>${basedir}/../tools/target/oozie-tools-${project.version}-tools/oozie-tools-${project.version}/bin</directory>
+ <outputDirectory>/bin</outputDirectory>
+ <includes>
+ <include>*</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ <fileSet>
+
<directory>${basedir}/../tools/target/oozie-tools-${project.version}-tools/oozie-tools-${project.version}/libtools</directory>
+ <outputDirectory>/libtools</outputDirectory>
+ <includes>
+ <include>*</include>
+ </includes>
+ </fileSet>
<!-- Embedded Tomcat -->
<fileSet>
<directory>${basedir}/target/tomcat/oozie-server</directory>
Added: incubator/oozie/trunk/src/main/assemblies/tools.xml
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/src/main/assemblies/tools.xml?rev=1295913&view=auto
==============================================================================
--- incubator/oozie/trunk/src/main/assemblies/tools.xml (added)
+++ incubator/oozie/trunk/src/main/assemblies/tools.xml Thu Mar 1 21:36:09 2012
@@ -0,0 +1,50 @@
+<!--
+ 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.
+-->
+<assembly>
+ <id>tools</id>
+ <formats>
+ <format>dir</format>
+ <!--<format>tar.gz</format>-->
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>${basedir}/src/main/bin</directory>
+
<outputDirectory>oozie-tools-${project.version}/bin</outputDirectory>
+ <includes>
+ <include>*</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <useProjectArtifact>true</useProjectArtifact>
+
<outputDirectory>oozie-tools-${project.version}/libtools</outputDirectory>
+ <unpack>false</unpack>
+ <scope>compile</scope>
+ <excludes>
+ <exclude>*:*:pom:*</exclude>
+ </excludes>
+ <useTransitiveFiltering>true</useTransitiveFiltering>
+ </dependencySet>
+ </dependencySets>
+
+</assembly>
Added: incubator/oozie/trunk/tools/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/tools/pom.xml?rev=1295913&view=auto
==============================================================================
--- incubator/oozie/trunk/tools/pom.xml (added)
+++ incubator/oozie/trunk/tools/pom.xml Thu Mar 1 21:36:09 2012
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.oozie</groupId>
+ <artifactId>oozie-main</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.oozie</groupId>
+ <artifactId>oozie-tools</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ <description>Apache Oozie Tools</description>
+ <name>Apache Oozie Tools</name>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.oozie</groupId>
+ <artifactId>oozie-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.oozie</groupId>
+ <artifactId>oozie-core</artifactId>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-el</groupId>
+ <artifactId>commons-el</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-compiler</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-runtime</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jetty</groupId>
+ <artifactId>org.mortbay.jetty</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-api-2.1</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>servlet-api-2.5</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.oozie</groupId>
+ <artifactId>oozie-hadoop</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+
<descriptor>../src/main/assemblies/tools.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <!-- Include MySQL JDBC driver -->
+ <profile>
+ <id>mysql</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ <property>
+ <name>oozie.test.db</name>
+ <value>mysql</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <!-- Include Oracle JDBC driver
-->
+ <!-- Oracle JDBC driver is not available in any public Maven
repository -->
+ <!-- It must be manually installed in the local Maven cache
-->
+ <profile>
+ <id>oracle</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ <property>
+ <name>oozie.test.db</name>
+ <value>oracle</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc6</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ </profiles>
+</project>
+
Added: incubator/oozie/trunk/tools/src/main/bin/ooziedb.sh
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/tools/src/main/bin/ooziedb.sh?rev=1295913&view=auto
==============================================================================
--- incubator/oozie/trunk/tools/src/main/bin/ooziedb.sh (added)
+++ incubator/oozie/trunk/tools/src/main/bin/ooziedb.sh Thu Mar 1 21:36:09 2012
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# 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.
+#
+
+# resolve links - $0 may be a softlink
+PRG="${0}"
+
+while [ -h "${PRG}" ]; do
+ ls=`ls -ld "${PRG}"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "${PRG}"`/"$link"
+ fi
+done
+
+BASEDIR=`dirname ${PRG}`
+BASEDIR=`cd ${BASEDIR}/..;pwd`
+
+OOZIE_HOME=${BASEDIR}
+OOZIE_CONFIG=${OOZIE_HOME}/conf
+OOZIE_LOG=${OOZIE_HOME}/logs
+OOZIE_DATA=${OOZIE_HOME}/data
+
+if [ -f ${OOZIE_HOME}/bin/oozie-env.sh ]
+then
+ source ${OOZIE_HOME}/bin/oozie-env.sh
+fi
+
+if [ ! -d ${OOZIE_CONFIG} ]
+then
+ echo
+ echo "ERROR: Oozie configuration directory could not be found at
${OOZIE_CONFIG}"
+ echo
+ exit 1
+fi
+
+OOZIEDB_OPTS="-Doozie.home.dir=${OOZIE_HOME}";
+OOZIEDB_OPTS="${OOZIEDB_OPTS} -Doozie.config.dir=${OOZIE_CONFIG}";
+OOZIEDB_OPTS="${OOZIEDB_OPTS} -Doozie.log.dir=${OOZIE_LOG}";
+OOZIEDB_OPTS="${OOZIEDB_OPTS} -Doozie.data.dir=${OOZIE_DATA}";
+
+OOZIECPPATH=""
+for i in "${BASEDIR}/libtools/"*.jar; do
+ OOZIECPPATH="${OOZIECPPATH}:$i"
+done
+for i in "${BASEDIR}/libext/"*.jar; do
+ OOZIECPPATH="${OOZIECPPATH}:$i"
+done
+
+
+if test -z ${JAVA_HOME}
+then
+ JAVA_BIN=java
+else
+ JAVA_BIN=${JAVA_HOME}/bin/java
+fi
+
+while [[ ${1} =~ ^\-D ]]; do
+ JAVA_PROPERTIES="${JAVA_PROPERTIES} ${1}"
+ shift
+done
+
+${JAVA_BIN} ${OOZIEDB_OPTS} ${JAVA_PROPERTIES} -cp ${OOZIECPPATH}
org.apache.oozie.tools.OozieDBCLI "${@}"
Added:
incubator/oozie/trunk/tools/src/main/java/org/apache/oozie/tools/OozieDBCLI.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/tools/src/main/java/org/apache/oozie/tools/OozieDBCLI.java?rev=1295913&view=auto
==============================================================================
---
incubator/oozie/trunk/tools/src/main/java/org/apache/oozie/tools/OozieDBCLI.java
(added)
+++
incubator/oozie/trunk/tools/src/main/java/org/apache/oozie/tools/OozieDBCLI.java
Thu Mar 1 21:36:09 2012
@@ -0,0 +1,557 @@
+/**
+ * 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.
+ */
+package org.apache.oozie.tools;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.oozie.BuildInfo;
+import org.apache.oozie.cli.CLIParser;
+import org.apache.oozie.service.JPAService;
+import org.apache.oozie.service.Services;
+
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Command line tool to create/upgrade Oozie Database
+ */
+public class OozieDBCLI {
+ public static final String HELP_CMD = "help";
+ public static final String VERSION_CMD = "version";
+ public static final String CREATE_CMD = "create";
+ public static final String UPGRADE_CMD = "upgrade";
+ public static final String POST_UPGRADE_CMD = "postupgrade";
+ public static final String SQL_FILE_OPT = "sqlfile";
+ public static final String RUN_OPT = "run";
+
+ public static final String[] HELP_INFO = {
+ "",
+ "IMPORTANT: If using an Oracle or MySQL Database, before running this",
+ "tool copy the corresponding JDBC driver to the tools libext/
directory"
+ };
+
+ private boolean used;
+
+ public static void main(String[] args) {
+ System.exit(new OozieDBCLI().run(args));
+ }
+
+ public OozieDBCLI() {
+ used = false;
+ }
+
+ protected Options createUpgradeOptions() {
+ Option sqlfile = new Option(SQL_FILE_OPT, true, "Generate SQL script
instead creating/upgrading the DB schema");
+ Option run = new Option(RUN_OPT, false, "Confirm the DB schema
creation/upgrade");
+ Options options = new Options();
+ options.addOption(sqlfile);
+ options.addOption(run);
+ return options;
+ }
+
+ public synchronized int run(String[] args) {
+ if (used) {
+ throw new IllegalStateException("CLI instance already used");
+ }
+ used = true;
+
+ CLIParser parser = new CLIParser("ooziedb.sh", HELP_INFO);
+ parser.addCommand(HELP_CMD, "", "display usage", new Options(), false);
+ parser.addCommand(VERSION_CMD, "", "show Oozie DB version
information", new Options(), false);
+ parser.addCommand(CREATE_CMD, "", "create Oozie DB schema",
createUpgradeOptions(), false);
+ parser.addCommand(UPGRADE_CMD, "", "upgrade Oozie DB",
createUpgradeOptions(), false);
+ parser.addCommand(POST_UPGRADE_CMD, "", "post upgrade Oozie DB",
createUpgradeOptions(), false);
+
+ try {
+ System.out.println();
+ CLIParser.Command command = parser.parse(args);
+ if (command.getName().equals(HELP_CMD)) {
+ parser.showHelp();
+ }
+ else if (command.getName().equals(VERSION_CMD)) {
+ showVersion();
+ }
+ else {
+ if (!command.getCommandLine().hasOption(SQL_FILE_OPT)) {
+ throw new Exception("'-sqlfile <FILE>' option must be
specified");
+ }
+ if (command.getName().equals(CREATE_CMD)) {
+ createDB(command.getCommandLine());
+ }
+ if (command.getName().equals(UPGRADE_CMD)) {
+ upgradeDB(command.getCommandLine());
+ }
+ if (command.getName().equals(POST_UPGRADE_CMD)) {
+ postUpgradeDB(command.getCommandLine());
+ }
+ }
+ return 0;
+ }
+ catch (ParseException ex) {
+ System.err.println("Invalid sub-command: " + ex.getMessage());
+ System.err.println();
+ System.err.println(parser.shortHelp());
+ return 1;
+ }
+ catch (Exception ex) {
+ System.err.println();
+ System.err.println("Error: " + ex.getMessage());
+ System.err.println();
+ System.err.println("--------------------------------------");
+ ex.printStackTrace(System.err);
+ System.err.println("--------------------------------------");
+ System.err.println();
+ return 1;
+ }
+ }
+
+ private Map<String, String> getJdbcConf() throws Exception {
+ Services services = new Services();
+ Configuration conf = services.getConf();
+ Map<String, String> jdbcConf = new HashMap<String, String>();
+ jdbcConf.put("driver", conf.get(JPAService.CONF_DRIVER));
+ String url = conf.get(JPAService.CONF_URL);
+ jdbcConf.put("url", url);
+ jdbcConf.put("user", conf.get(JPAService.CONF_USERNAME));
+ jdbcConf.put("password", conf.get(JPAService.CONF_PASSWORD));
+ String dbType = url.substring("jdbc:".length());
+ if (dbType.indexOf(":") <= 0) {
+ throw new RuntimeException("Invalid JDBC URL, missing vendor
'jdbc:[VENDOR]:...'");
+ }
+ dbType = dbType.substring(0, dbType.indexOf(":"));
+ jdbcConf.put("dbtype", dbType);
+ return jdbcConf;
+ }
+
+ private void createDB(CommandLine commandLine) throws Exception {
+ validateConnection();
+ validateDBSchema(false);
+ verifyOozieSysTable(false);
+ String sqlFile = (commandLine.hasOption(SQL_FILE_OPT)) ?
commandLine.getOptionValue(SQL_FILE_OPT) : null;
+ boolean run = commandLine.hasOption(RUN_OPT);
+ createUpgradeDB(sqlFile, run, true);
+ createOozieSysTable(sqlFile, run);
+ System.out.println();
+ if (run) {
+ System.out.println("Oozie DB has been created for Oozie version '"
+
+
BuildInfo.getBuildInfo().getProperty(BuildInfo.BUILD_VERSION) + "'");
+ }
+ else {
+ System.out.println("The SQL commands have NOT been executed, you
must use the '-run' option");
+ }
+ System.out.println();
+ }
+
+ private void upgradeDB(CommandLine commandLine) throws Exception {
+ // placeholder for later versions, to handle upgrades based on the
OOZIE_SYS table.
+ upgradeDBTo32(commandLine);
+ }
+
+ private void upgradeDBTo32(CommandLine commandLine) throws Exception {
+ validateConnection();
+ validateDBSchema(true);
+ verifyOozieSysTable(false);
+ verifyDBState();
+ String sqlFile = (commandLine.hasOption(SQL_FILE_OPT)) ?
commandLine.getOptionValue(SQL_FILE_OPT) : null;
+ boolean run = commandLine.hasOption(RUN_OPT);
+ createUpgradeDB(sqlFile, run, false);
+ createOozieSysTable(sqlFile, run);
+ postUpgradeTasks(sqlFile, run, false);
+ manualStepsNotice();
+ if (run) {
+ System.out.println();
+ System.out.println("Oozie DB has been upgraded to Oozie version '"
+
+
BuildInfo.getBuildInfo().getProperty(BuildInfo.BUILD_VERSION) + "'");
+ }
+ else {
+ System.out.println();
+ System.out.println("The SQL commands have NOT been executed, you
must use the '-run' option");
+ }
+ System.out.println();
+ }
+
+ private void postUpgradeDB(CommandLine commandLine) throws Exception {
+ postUpgradeDBTo32(commandLine);
+ }
+
+ private void postUpgradeDBTo32(CommandLine commandLine) throws Exception {
+ validateConnection();
+ validateDBSchema(true);
+ verifyOozieSysTable(true);
+ verifyOozieDBVersion();
+ verifyDBState();
+ String sqlFile = (commandLine.hasOption(SQL_FILE_OPT)) ?
commandLine.getOptionValue(SQL_FILE_OPT) : null;
+ boolean run = commandLine.hasOption(RUN_OPT);
+ postUpgradeTasks(sqlFile, run, true);
+ manualStepsNotice();
+ if (run) {
+ System.out.println();
+ System.out.println("Post ugprade updates have been executed");
+ }
+ else {
+ System.out.println();
+ System.out.println("Post ugprade updates have NOT been executed,
you must use the '-run' option");
+ }
+ System.out.println();
+ }
+
+ private static final String COORD_JOBS_THROTTLING_DEFAULT =
+ "update COORD_JOBS set mat_throttling = 12";
+
+ private static final String COORD_JOBS_ADD_APP_NAMESPACE =
+ "update COORD_JOBS set app_namespace = 'uri:oozie:coordinator:0.1'";
+
+ private static final String COORD_JOBS_STATUS_1 =
+ "update COORD_JOBS set status = 'RUNNING', PENDING = 1 " +
+ "where id in ( " +
+ "select job_id from COORD_ACTIONS where job_id in ( " +
+ "select id from COORD_JOBS where status = 'SUCCEEDED') and(status !=
'FAILED' and " +
+ "status != 'SUCCEEDED' and status != 'KILLED' and status !=
'TIMEDOUT') )";
+
+ private static final String COORD_JOBS_STATUS_2 =
+ "update COORD_JOBS set status = 'RUNNING' where status = 'PREMATER'";
+
+ private static final String COORD_ACTIONS_STATUS =
+ "update COORD_ACTIONS set status = 'SUSPENDED' " +
+ "where id in( " +
+ "select A.id from COORD_ACTIONS A, WF_JOBS B where A.external_id =
B.id " +
+ "and B.status = 'SUSPENDED' and A.status = 'RUNNING' )";
+
+ private void postUpgradeTasks(String sqlFile, boolean run, boolean force)
throws Exception {
+ PrintWriter writer = new PrintWriter(new FileWriter(sqlFile, true));
+ writer.println();
+ boolean skipUpdates = getJdbcConf().get("url").contains("mysql");
+ Connection conn = (run) ? createConnection() : null;
+ try {
+ System.out.println("Post-upgrade COORD_JOBS new columns default
values");
+ writer.println(COORD_JOBS_THROTTLING_DEFAULT + ";");
+ if (run) {
+ conn.setAutoCommit(true);
+ Statement st = conn.createStatement();
+ st.executeUpdate(COORD_JOBS_THROTTLING_DEFAULT);
+ st.close();
+ }
+ writer.println(COORD_JOBS_ADD_APP_NAMESPACE + ";");
+ if (run) {
+ Statement st = conn.createStatement();
+ st.executeUpdate(COORD_JOBS_ADD_APP_NAMESPACE);
+ st.close();
+ }
+ System.out.println("DONE");
+ if (!skipUpdates || force) {
+ System.out.println("Post-upgrade COORD_JOBS & COORD_ACTIONS
status values");
+ writer.println(COORD_JOBS_STATUS_1 + ";");
+ writer.println(COORD_JOBS_STATUS_2 + ";");
+ writer.println(COORD_ACTIONS_STATUS + ";");
+ if (run) {
+ Statement st = conn.createStatement();
+ st.executeUpdate(COORD_JOBS_STATUS_1);
+ st.close();
+ st = conn.createStatement();
+ st.executeUpdate(COORD_JOBS_STATUS_2);
+ st.close();
+ st = conn.createStatement();
+ st.executeUpdate(COORD_ACTIONS_STATUS);
+ st.close();
+ }
+ System.out.println("DONE");
+ }
+ else {
+ System.out.println("SKIPPING Post-upgrade of COORD_JOBS &
COORD_ACTIONS status values,");
+ System.out.println(" MySQL 5 does not support the
update queries");
+ System.out.println();
+ System.out.println(" Oozie will be able to run jobs
started before the upgrade,");
+ System.out.println(" although those jobs may show
different status names in their actions");
+ }
+ writer.close();
+ }
+ finally {
+ if (run) {
+ conn.close();
+ }
+ }
+ }
+
+ private void manualStepsNotice() {
+ System.out.println();
+ System.out.println("IMPORTANT: the following manual changes must be
done in the Oozie DB");
+ System.out.println();
+ System.out.println(
+ " The 'execution_path' column in the 'WF_ACTIONS' table has to be
modified to be a VARCHAR2(1024)");
+ System.out.println();
+ }
+
+ private Connection createConnection() throws Exception {
+ Map<String, String> conf = getJdbcConf();
+ Class.forName(conf.get("driver")).newInstance();
+ return DriverManager.getConnection(conf.get("url"), conf.get("user"),
conf.get("password"));
+ }
+
+ private void validateConnection() throws Exception {
+ System.out.println("Validate DB Connection");
+ try {
+ createConnection().close();
+ System.out.println("DONE");
+ }
+ catch (Exception ex) {
+ throw new Exception("Could not connect to the database: " +
ex.toString(), ex);
+ }
+ }
+
+ private static final String WORKFLOW_STATUS_QUERY =
+ "select count(*) from WF_JOBS where status IN ('RUNNING',
'SUSPENDED')";
+
+ private void validateDBSchema(boolean exists) throws Exception {
+ System.out.println((exists) ? "Check DB schema exists" : "Check DB
schema does not exist");
+ boolean schemaExists;
+ Connection conn = createConnection();
+ try {
+ Statement st = conn.createStatement();
+ ResultSet rs = st.executeQuery(WORKFLOW_STATUS_QUERY);
+ rs.next();
+ rs.close();
+ st.close();
+ schemaExists = true;
+ }
+ catch (Exception ex) {
+ schemaExists = false;
+ }
+ finally {
+ conn.close();
+ }
+ if (schemaExists != exists) {
+ throw new Exception("DB schema " + ((exists) ? "does not exist" :
"exists"));
+ }
+ System.out.println("DONE");
+ }
+
+ private final static String OOZIE_SYS_EXISTS = "select count(*) from
OOZIE_SYS";
+
+ private void verifyOozieSysTable(boolean exists) throws Exception {
+ System.out.println((exists) ? "Check OOZIE_SYS table exists" : "Check
OOZIE_SYS table does not exist");
+ boolean tableExists;
+ Connection conn = createConnection();
+ try {
+ Statement st = conn.createStatement();
+ ResultSet rs = st.executeQuery(OOZIE_SYS_EXISTS);
+ rs.next();
+ rs.close();
+ st.close();
+ tableExists = true;
+ }
+ catch (Exception ex) {
+ tableExists = false;
+ }
+ finally {
+ conn.close();
+ }
+ if (tableExists != exists) {
+ throw new Exception("OOZIE SYS table " + ((exists) ? "does not
exist" : "exists"));
+ }
+ System.out.println("DONE");
+ }
+
+ private final static String DB_VERSION = "1";
+
+ private final static String GET_OOZIE_DB_VERSION = "select data from
OOZIE_SYS where name = 'db.version'";
+
+ private void verifyOozieDBVersion() throws Exception {
+ System.out.println("Verify Oozie DB version");
+ Connection conn = createConnection();
+ try {
+ Statement st = conn.createStatement();
+ ResultSet rs = st.executeQuery(GET_OOZIE_DB_VERSION);
+ if (rs.next()) {
+ String version = rs.getString(1);
+ if (!DB_VERSION.equals(version.trim())) {
+ throw new Exception("ERROR: Expected Oozie DB version '" +
+ DB_VERSION + "', found '" +
version.trim() + "'");
+ }
+ }
+ else {
+ throw new Exception("ERROR: Could not find Oozie DB
'db.version' in OOZIE_SYS table");
+ }
+ rs.close();
+ st.close();
+ }
+ catch (Exception ex) {
+ throw new Exception("ERROR: Could not query OOZIE_SYS table: " +
ex.toString(), ex);
+ }
+ finally {
+ conn.close();
+ }
+ System.out.println("DONE");
+ }
+
+ private final static String CREATE_OOZIE_SYS =
+ "create table OOZIE_SYS (name varchar(100), data varchar(100))";
+
+ private final static String SET_DB_VERSION =
+ "insert into OOZIE_SYS (name, data) values ('db.version', '" +
DB_VERSION + "')";
+
+ private final static String SET_OOZIE_VERSION =
+ "insert into OOZIE_SYS (name, data) values ('oozie.version', '" +
+ BuildInfo.getBuildInfo().getProperty(BuildInfo.BUILD_VERSION) + "')";
+
+ private void createOozieSysTable(String sqlFile, boolean run) throws
Exception {
+ PrintWriter writer = new PrintWriter(new FileWriter(sqlFile, true));
+ writer.println();
+ writer.println(CREATE_OOZIE_SYS);
+ writer.println(SET_DB_VERSION);
+ writer.println(SET_OOZIE_VERSION);
+ writer.close();
+ System.out.println("Create OOZIE_SYS table");
+ if (run) {
+ Connection conn = createConnection();
+ try {
+ conn.setAutoCommit(true);
+ Statement st = conn.createStatement();
+ st.executeUpdate(CREATE_OOZIE_SYS);
+ st.executeUpdate(SET_DB_VERSION);
+ st.executeUpdate(SET_OOZIE_VERSION);
+ st.close();
+ }
+ catch (Exception ex) {
+ throw new Exception("Could not create OOZIE_SYS table: " +
ex.toString(), ex);
+ }
+ finally {
+ conn.close();
+ }
+ }
+ System.out.println("DONE");
+ }
+
+ private final static String GET_OOZIE_SYS_INFO = "select name, data from
OOZIE_SYS order by name";
+
+ private void showOozieSysInfo() throws Exception {
+ Connection conn = createConnection();
+ try {
+ System.out.println();
+ System.out.println("Oozie DB Version Information");
+ System.out.println("--------------------------------------");
+ Statement st = conn.createStatement();
+ ResultSet rs = st.executeQuery(GET_OOZIE_SYS_INFO);
+ while (rs.next()) {
+ System.out.println(rs.getString(1) + ": " + rs.getString(2));
+ }
+ System.out.println("--------------------------------------");
+ System.out.println();
+ rs.close();
+ st.close();
+ }
+ catch (Exception ex) {
+ throw new Exception("ERROR querying OOZIE_SYS table: " +
ex.toString(), ex);
+ }
+ finally {
+ conn.close();
+ }
+ }
+
+ private void verifyDBState() throws Exception {
+ System.out.println("Verify there are not active Workflow Jobs");
+ Connection conn = createConnection();
+ try {
+ Statement st = conn.createStatement();
+ ResultSet rs = st.executeQuery(WORKFLOW_STATUS_QUERY);
+ rs.next();
+ long activeWorkflows = rs.getLong(1);
+ rs.close();
+ st.close();
+ if (activeWorkflows > 0) {
+ throw new Exception("There are [" + activeWorkflows +
+ "] workflows in RUNNING/SUSPENDED state,
they must complete or be killed");
+ }
+ System.out.println("DONE");
+ }
+ finally {
+ conn.close();
+ }
+ }
+
+ private String[] createMappingToolArguments(String sqlFile) throws
Exception {
+ Map<String, String> conf = getJdbcConf();
+ List<String> args = new ArrayList<String>();
+ args.add("-schemaAction");
+ args.add("add");
+ args.add("-p");
+ args.add("persistence.xml#oozie-" + conf.get("dbtype"));
+ args.add("-connectionDriverName");
+ args.add(conf.get("driver"));
+ args.add("-connectionURL");
+ args.add(conf.get("url"));
+ args.add("-connectionUserName");
+ args.add(conf.get("user"));
+ args.add("-connectionPassword");
+ args.add(conf.get("password"));
+ if (sqlFile != null) {
+ args.add("-sqlFile");
+ args.add(sqlFile);
+ }
+ args.add("org.apache.oozie.client.rest.JsonWorkflowJob");
+ args.add("org.apache.oozie.WorkflowJobBean");
+ args.add("org.apache.oozie.client.rest.JsonWorkflowAction");
+ args.add("org.apache.oozie.WorkflowActionBean");
+ args.add("org.apache.oozie.client.rest.JsonCoordinatorJob");
+ args.add("org.apache.oozie.CoordinatorJobBean");
+ args.add("org.apache.oozie.client.rest.JsonCoordinatorAction");
+ args.add("org.apache.oozie.CoordinatorActionBean");
+ args.add("org.apache.oozie.client.rest.JsonSLAEvent");
+ args.add("org.apache.oozie.client.rest.JsonBundleJob");
+ args.add("org.apache.oozie.BundleJobBean");
+ args.add("org.apache.oozie.BundleActionBean");
+ return args.toArray(new String[args.size()]);
+ }
+
+ private void createUpgradeDB(String sqlFile, boolean run, boolean create)
throws Exception {
+ System.out.println((create) ? "Create SQL schema" : "Upgrade SQL
schema");
+ String[] args = createMappingToolArguments(sqlFile);
+ org.apache.openjpa.jdbc.meta.MappingTool.main(args);
+ if (run) {
+ args = createMappingToolArguments(null);
+ org.apache.openjpa.jdbc.meta.MappingTool.main(args);
+ }
+ System.out.println("DONE");
+ }
+
+ private void showVersion() throws Exception {
+ System.out.println("Oozie DB tool version: "
+ +
BuildInfo.getBuildInfo().getProperty(BuildInfo.BUILD_VERSION));
+ System.out.println();
+ validateConnection();
+ validateDBSchema(true);
+ try {
+ verifyOozieSysTable(true);
+ }
+ catch (Exception ex) {
+ throw new Exception("ERROR: It seems this Oozie DB was never
upgraded with the 'ooziedb' tool");
+ }
+ showOozieSysInfo();
+ }
+
+}