Author: rkanter
Date: Mon Oct 14 20:18:32 2013
New Revision: 1532058
URL: http://svn.apache.org/r1532058
Log:
OOZIE-1517 Support using MS SQL Server as a metastore (dwann via rkanter)
Added:
oozie/trunk/core/src/main/resources/META-INF/oozie-sqlserver-orm.xml
Modified:
oozie/trunk/core/src/main/resources/META-INF/persistence.xml
oozie/trunk/docs/src/site/twiki/AG_Install.twiki
oozie/trunk/release-log.txt
oozie/trunk/tools/src/main/java/org/apache/oozie/tools/OozieDBCLI.java
Added: oozie/trunk/core/src/main/resources/META-INF/oozie-sqlserver-orm.xml
URL:
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/resources/META-INF/oozie-sqlserver-orm.xml?rev=1532058&view=auto
==============================================================================
--- oozie/trunk/core/src/main/resources/META-INF/oozie-sqlserver-orm.xml (added)
+++ oozie/trunk/core/src/main/resources/META-INF/oozie-sqlserver-orm.xml Mon
Oct 14 20:18:32 2013
@@ -0,0 +1,30 @@
+<?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.
+-->
+<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
+ version="1.0">
+ <entity class="org.apache.oozie.client.rest.JsonSLAEvent">
+ <attributes>
+ <id name="event_id">
+ <generated-value strategy="IDENTITY"/>
+ </id>
+ </attributes>
+ </entity>
+</entity-mappings>
Modified: oozie/trunk/core/src/main/resources/META-INF/persistence.xml
URL:
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/resources/META-INF/persistence.xml?rev=1532058&r1=1532057&r2=1532058&view=diff
==============================================================================
--- oozie/trunk/core/src/main/resources/META-INF/persistence.xml (original)
+++ oozie/trunk/core/src/main/resources/META-INF/persistence.xml Mon Oct 14
20:18:32 2013
@@ -317,4 +317,64 @@
</properties>
</persistence-unit>
+ <persistence-unit name="oozie-sqlserver" transaction-type="RESOURCE_LOCAL">
+
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+
+ <mapping-file>META-INF/oozie-sqlserver-orm.xml</mapping-file>
+ <!--CUSTOM-->
+
+ <class>org.apache.oozie.WorkflowActionBean</class>
+ <class>org.apache.oozie.WorkflowJobBean</class>
+ <class>org.apache.oozie.CoordinatorJobBean</class>
+ <class>org.apache.oozie.CoordinatorActionBean</class>
+ <class>org.apache.oozie.SLAEventBean</class>
+ <class>org.apache.oozie.BundleJobBean</class>
+ <class>org.apache.oozie.BundleActionBean</class>
+ <class>org.apache.oozie.sla.SLARegistrationBean</class>
+ <class>org.apache.oozie.sla.SLASummaryBean</class>
+ <class>org.apache.oozie.client.rest.JsonWorkflowJob</class>
+ <class>org.apache.oozie.client.rest.JsonWorkflowAction</class>
+ <class>org.apache.oozie.client.rest.JsonCoordinatorJob</class>
+ <class>org.apache.oozie.client.rest.JsonCoordinatorAction</class>
+ <class>org.apache.oozie.client.rest.JsonSLAEvent</class>
+ <class>org.apache.oozie.client.rest.JsonBundleJob</class>
+ <class>org.apache.oozie.util.db.ValidateConnectionBean</class>
+
+ <properties>
+ <property name="openjpa.ConnectionDriverName"
value="org.apache.oozie.util.db.InstrumentedBasicDataSource"/>
+
+ <property name="openjpa.ConnectionProperties"
value="**INVALID**"/> <!--Set by StoreService at init time -->
+
+ <property name="openjpa.MetaDataFactory"
+ value="jpa(Types=org.apache.oozie.WorkflowActionBean;
+ org.apache.oozie.WorkflowJobBean;
+ org.apache.oozie.CoordinatorJobBean;
+ org.apache.oozie.CoordinatorActionBean;
+ org.apache.oozie.SLAEventBean;
+ org.apache.oozie.BundleJobBean;
+ org.apache.oozie.BundleActionBean;
+ org.apache.oozie.sla.SLARegistrationBean;
+ org.apache.oozie.sla.SLASummaryBean;
+ org.apache.oozie.client.rest.JsonSLAEvent;
+ org.apache.oozie.client.rest.JsonWorkflowJob;
+ org.apache.oozie.client.rest.JsonWorkflowAction;
+ org.apache.oozie.client.rest.JsonCoordinatorJob;
+ org.apache.oozie.client.rest.JsonCoordinatorAction;
+ org.apache.oozie.client.rest.JsonBundleJob;
+ org.apache.oozie.util.db.ValidateConnectionBean)"></property>
+
+ <property name="openjpa.DetachState"
value="fetch-groups(DetachedStateField=true)"/>
+ <property name="openjpa.LockManager" value="pessimistic"/>
+ <property name="openjpa.ReadLockLevel" value="read"/>
+ <property name="openjpa.WriteLockLevel" value="write"/>
+ <property name="openjpa.jdbc.TransactionIsolation"
value="repeatable-read"/> <!--CUSTOM-->
+ <property name="openjpa.jdbc.DBDictionary"
value="UseGetBytesForBlobs=true"/>
+ <property name="openjpa.jdbc.DBDictionary"
value="UseSetBytesForBlobs=true"/>
+ <property name="openjpa.jdbc.DBDictionary"
value="BlobBufferSize=500000"/>
+ <property name="openjpa.jdbc.DBDictionary" value="batchLimit=50"/>
+ <property name="openjpa.RuntimeUnenhancedClasses"
value="supported"/>
+ <property name="openjpa.Log" value="log4j"/>
+ </properties>
+ </persistence-unit>
+
</persistence>
Modified: oozie/trunk/docs/src/site/twiki/AG_Install.twiki
URL:
http://svn.apache.org/viewvc/oozie/trunk/docs/src/site/twiki/AG_Install.twiki?rev=1532058&r1=1532057&r2=1532058&view=diff
==============================================================================
--- oozie/trunk/docs/src/site/twiki/AG_Install.twiki (original)
+++ oozie/trunk/docs/src/site/twiki/AG_Install.twiki Mon Oct 14 20:18:32 2013
@@ -123,7 +123,7 @@ servlet container (if using Tomcat, copy
---++ Database Configuration
-Oozie works with HSQL, Derby, MySQL, Oracle or PostgreSQL databases.
+Oozie works with HSQL, Derby, MySQL, Oracle, PostgreSQL or SQL Server
databases.
By default, Oozie is configured to use Embedded Derby.
@@ -131,10 +131,10 @@ 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 Derby, MySQL, Oracle or PostgreSQL, the Oozie database schema must be
created using the =ooziedb.sh= command
+If using Derby, MySQL, Oracle, PostgreSQL, or SQL Server, the Oozie database
schema must be created using the =ooziedb.sh= command
line tool.
-If using MySQL or Oracle, the corresponding JDBC driver JAR file mut be copied
to Oozie's =libext/= directory and
+If using MySQL, Oracle, or SQL Server, 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):
@@ -182,7 +182,7 @@ The SQL commands have been written to: o
$
</verbatim>
-NOTE: If using MySQL or Oracle, copy the corresponding JDBC driver JAR file to
the =libext/= directory before running
+NOTE: If using MySQL, Oracle, or SQL Server, copy the corresponding JDBC
driver JAR file to the =libext/= directory before running
the =ooziedb.sh= command line tool.
NOTE: If instead using the '-run' option, the '-sqlfile <FILE>' option is
used, then all the
Modified: oozie/trunk/release-log.txt
URL:
http://svn.apache.org/viewvc/oozie/trunk/release-log.txt?rev=1532058&r1=1532057&r2=1532058&view=diff
==============================================================================
--- oozie/trunk/release-log.txt (original)
+++ oozie/trunk/release-log.txt Mon Oct 14 20:18:32 2013
@@ -1,5 +1,6 @@
-- Oozie 4.1.0 release (trunk - unreleased)
+OOZIE-1517 Support using MS SQL Server as a metastore (dwann via rkanter)
OOZIE-1460 Implement and Document security for HA (rkanter)
OOZIE-1570 Make openjpa connection properties configurable (rohini)
OOZIE-1560 Log messages should have a way of identifying which server they
came from when using HA (rkanter)
Modified: oozie/trunk/tools/src/main/java/org/apache/oozie/tools/OozieDBCLI.java
URL:
http://svn.apache.org/viewvc/oozie/trunk/tools/src/main/java/org/apache/oozie/tools/OozieDBCLI.java?rev=1532058&r1=1532057&r2=1532058&view=diff
==============================================================================
--- oozie/trunk/tools/src/main/java/org/apache/oozie/tools/OozieDBCLI.java
(original)
+++ oozie/trunk/tools/src/main/java/org/apache/oozie/tools/OozieDBCLI.java Mon
Oct 14 20:18:32 2013
@@ -57,7 +57,7 @@ public class OozieDBCLI {
public static final String[] HELP_INFO = {
"",
- "IMPORTANT: If using an Oracle or MySQL Database, before running this",
+ "IMPORTANT: If using an Oracle, MS SQL or MySQL Database, before
running this",
"tool copy the corresponding JDBC driver to the tools libext/
directory"
};
@@ -462,6 +462,15 @@ public class OozieDBCLI {
ddlQueries.add("ALTER TABLE WF_ACTIONS RENAME error_message_temp
TO error_message");
ddlQueries.add("ALTER TABLE COORD_JOBS ALTER COLUMN frequency TYPE
VARCHAR(255)");
}
+ else
+ if (dbVendor.equals("sqlserver")) {
+ ddlQueries.add("ALTER TABLE WF_ACTIONS ALTER COLUMN execution_path
VARCHAR(1024)");
+ ddlQueries.add("ALTER TABLE WF_ACTIONS ADD error_message_temp
VARCHAR(500)");
+ ddlQueries.add("UPDATE WF_ACTIONS SET error_message_temp =
SUBSTRING(error_message,1,500)");
+ ddlQueries.add("ALTER TABLE WF_ACTIONS DROP COLUMN error_message");
+ ddlQueries.add("EXEC sp_rename 'WF_ACTIONS.error_message_temp',
'error_message', 'COLUMN'");
+ ddlQueries.add("ALTER TABLE COORD_JOBS ALTER COLUMN frequency
VARCHAR(255)");
+ }
Connection conn = (run) ? createConnection() : null;
try {
@@ -740,10 +749,20 @@ public class OozieDBCLI {
"insert into OOZIE_SYS (name, data) values ('oozie.version', '" +
BuildInfo.getBuildInfo().getProperty(BuildInfo.BUILD_VERSION) + "')";
+ private final static String CREATE_OOZIE_SYS_INDEX =
+ "create clustered index OOZIE_SYS_PK on OOZIE_SYS (name);";
+
private void createOozieSysTable(String sqlFile, boolean run) throws
Exception {
+ // Some databases do not support tables without a clustered index
+ // so we need to explicitly create a clustered index for OOZIE_SYS
table
+ boolean createIndex = getDBVendor().equals("sqlserver");
+
PrintWriter writer = new PrintWriter(new FileWriter(sqlFile, true));
writer.println();
writer.println(CREATE_OOZIE_SYS);
+ if (createIndex){
+ writer.println(CREATE_OOZIE_SYS_INDEX);
+ }
writer.println(SET_DB_VERSION);
writer.println(SET_OOZIE_VERSION);
writer.close();
@@ -754,6 +773,9 @@ public class OozieDBCLI {
conn.setAutoCommit(true);
Statement st = conn.createStatement();
st.executeUpdate(CREATE_OOZIE_SYS);
+ if (createIndex){
+ st.executeUpdate(CREATE_OOZIE_SYS_INDEX);
+ }
st.executeUpdate(SET_DB_VERSION);
st.executeUpdate(SET_OOZIE_VERSION);
st.close();