Moving integration tests from Derby to H2 in order to make them runnable again since they were throwing OOMs (ported from master)
Project: http://git-wip-us.apache.org/repos/asf/ode/repo Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/e1a7881b Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/e1a7881b Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/e1a7881b Branch: refs/heads/ode-1.3.6.x Commit: e1a7881b7b33cf52122c551bfc1b22d1a6b9f005 Parents: 6234715 Author: Tammo van Lessen <[email protected]> Authored: Fri Aug 23 18:50:58 2013 +0200 Committer: Tammo van Lessen <[email protected]> Committed: Fri Aug 23 18:50:58 2013 +0200 ---------------------------------------------------------------------- Rakefile | 33 ++++++++---- .../org/apache/ode/axis2/ODEConfigDirAware.java | 4 +- .../correlation/CorrelationJoinHibTest.java | 2 +- .../correlation/CorrelationJoinLazyHibTest.java | 2 +- .../correlation/CorrelationJoinLazyTest.java | 2 +- .../axis2/correlation/CorrelationJoinTest.java | 2 +- .../correlation/CorrelationMultiHibTest.java | 2 +- .../axis2/correlation/CorrelationMultiTest.java | 2 +- .../WEB-INF/conf.hib-h2/ode-axis2.properties | 26 +++++++++ .../WEB-INF/conf.jpa-h2/ode-axis2.properties | 21 ++++++++ .../webapp/WEB-INF/conf/ode-axis2.properties | 7 ++- .../org/apache/ode/bpel/iapi/Scheduler.java | 2 + .../java/org/apache/ode/il/MockScheduler.java | 3 ++ .../apache/ode/bpel/engine/BpelServerImpl.java | 6 +++ .../bpel/engine/replayer/ReplayerScheduler.java | 3 ++ .../apache/ode/bpel/runtime/MockBpelServer.java | 1 + .../store/hib/DbConfStoreConnectionFactory.java | 1 + dao-hibernate-db/src/main/sql/ode.h2.properties | 51 ++++++++++++++++++ .../src/main/sql/simplesched-h2.sql | 31 +++++++++++ .../bpel/BpelDAOConnectionFactoryImpl.java | 2 + .../src/main/descriptors/persistence.h2.xml | 55 ++++++++++++++++++++ .../src/main/scripts/simplesched-h2.sql | 31 +++++++++++ jbi/src/test/resources/smx-base.xml | 2 +- .../ode/scheduler/simple/DatabaseDelegate.java | 2 + .../ode/scheduler/simple/JdbcDelegate.java | 34 +++++++++--- .../ode/scheduler/simple/SimpleScheduler.java | 4 ++ tasks/h2.rake | 43 +++++++++++++++ 27 files changed, 346 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/Rakefile ---------------------------------------------------------------------- diff --git a/Rakefile b/Rakefile index 6978b81..b770041 100644 --- a/Rakefile +++ b/Rakefile @@ -67,6 +67,7 @@ Release.tag_name = lambda { |version| "APACHE_ODE_#{version.upcase}" } if Releas desc "Apache ODE" define "ode" do + project.version = VERSION_NUMBER project.group = "org.apache.ode" @@ -100,7 +101,7 @@ define "ode" do JAVAX.connector, JAVAX.jms, JAVAX.persistence, JAVAX.transaction, JAVAX.stream, JIBX, GERONIMO.connector, GERONIMO.kernel, GERONIMO.transaction, LOG4J, OPENJPA, SAXON, TRANQL, WOODSTOX, WSDL4J, WS_COMMONS, XALAN, XERCES, XMLBEANS, SPRING, - AXIS2_MODULES.libs + AXIS2_MODULES.libs, H2::REQUIRES package(:war).with(:libs=>libs).path("WEB-INF").tap do |web_inf| web_inf.merge project("dao-jpa-ojpa-derby").package(:zip) @@ -127,7 +128,7 @@ define "ode" do end test.using :testng, :forkmode=>'perTest', :properties=>{ "log4j.debug" => true, "log4j.configuration"=>"test-log4j.properties", "test.ports" => ENV['TEST_PORTS'] } - test.with projects("tools"), libs, AXIS2_TEST, AXIOM, HIBERNATE, JAVAX.servlet, Buildr::Jetty::REQUIRES, DOM4J, SLF4J, LOG4J + test.with [projects("tools"), libs, AXIS2_TEST, Buildr::Jetty::REQUIRES, HIBERNATE, JAVAX.servlet, DOM4J, SLF4J, LOG4J].uniq webapp_dir = "#{test.compile.target}/webapp" test.setup task(:prepare_webapp) do |task| cp_r _("src/main/webapp"), test.compile.target.to_s @@ -336,17 +337,22 @@ define "ode" do store_sql = export[ properties_for[:derby], bpel_store, _("target/store.sql") ] common_sql = _("src/main/sql/common.sql") derby_sql = concat(_("target/derby.sql")=>[ predefined_for[:derby], common_sql, runtime_sql, store_sql ]) - derby_db = Derby.create(_("target/derby/hibdb")=>derby_sql) + derby_db = Derby.create(_("target/derby-hibdb")=>derby_sql) build derby_db %w{ mysql firebird hsql postgres sqlserver oracle }.each do |db| - partial = export[ properties_for[db], dao_hibernate, _("target/partial.#{db}.sql") ] - build concat(_("target/#{db}.sql")=>[ common_sql, predefined_for[db], partial ]) + partial_runtime = export[ properties_for[db], dao_hibernate, _("target/partial.runtime.#{db}.sql") ] + partial_store = export[ properties_for[db], bpel_store, _("target/partial.store.#{db}.sql") ] + build concat(_("target/#{db}.sql")=>[ common_sql, predefined_for[db], partial_store, partial_runtime]) end + h2_sql = _("target/hsql.sql") + h2_db = H2.create("ode-hib-h2", _("target/h2-hibdb")=>h2_sql) + build h2_db + NativeDB.create_dbs self, _("."), :hib - package(:zip).include(derby_db) + package(:zip).include(derby_db).include(h2_db) end desc "ODE OpenJPA DAO Implementation" @@ -360,7 +366,7 @@ define "ode" do desc "ODE OpenJPA Derby Database" define "dao-jpa-ojpa-derby" do - %w{ derby mysql oracle postgres }.each do |db| + %w{ derby mysql oracle postgres h2 }.each do |db| db_xml = _("src/main/descriptors/persistence.#{db}.xml") scheduler_sql = _("src/main/scripts/simplesched-#{db}.sql") common_sql = _("src/main/scripts/common.sql") @@ -372,7 +378,8 @@ define "ode" do sql = concat(_("target/#{db}.sql")=>[_("src/main/scripts/license-header.sql"), common_sql, partial_sql, scheduler_sql]) build sql end - derby_db = Derby.create(_("target/derby/jpadb")=>_("target/derby.sql")) + derby_db = Derby.create(_("target/derby-jpadb")=>_("target/derby.sql")) + h2_db = H2.create("ode-jpa-h2", _("target/h2-jpadb")=>_("target/h2.sql")) test.with projects("bpel-api", "bpel-dao", "bpel-obj", "bpel-epr", "dao-jpa", "utils"), BACKPORT, COMMONS.collections, COMMONS.lang, COMMONS.logging, GERONIMO.transaction, @@ -380,10 +387,11 @@ define "ode" do JAVAX.transaction, LOG4J, OPENJPA, XERCES, WSDL4J build derby_db + build h2_db NativeDB.create_dbs self, _("."), :jpa - package(:zip).include(derby_db) + package(:zip).include(derby_db).include(h2_db) end desc "ODE JAva Concurrent OBjects" @@ -623,6 +631,13 @@ define "ode" do # sign artifacts gpg_sign_before_upload + + + task :aligndeps do + pp transitive(['org.apache.axis2:axis2-webapp:jar:1.5.6', 'org.apache.rampart:rampart-project:jar:1.5.2']).group_by {|s| "#{s.group}:#{s.id}:#{s.classifier}:#{s.type}" }.map {|i,v| v.sort_by(&:version).first.to_spec}.sort + end + + end define "apache-ode" do http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/axis2-war/src/test/java/org/apache/ode/axis2/ODEConfigDirAware.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/ODEConfigDirAware.java b/axis2-war/src/test/java/org/apache/ode/axis2/ODEConfigDirAware.java index 0dfdf00..585adfc 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/ODEConfigDirAware.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/ODEConfigDirAware.java @@ -20,8 +20,8 @@ package org.apache.ode.axis2; public interface ODEConfigDirAware { - final String HIB_DERBY_CONF_DIR = ODEConfigDirAware.class.getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-derby"; - final String JPA_DERBY_CONF_DIR = ODEConfigDirAware.class.getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-derby"; + final String HIB_DERBY_CONF_DIR = ODEConfigDirAware.class.getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-h2"; + final String JPA_DERBY_CONF_DIR = ODEConfigDirAware.class.getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-h2"; String getODEConfigDir(); } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinHibTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinHibTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinHibTest.java index 5692360..e588b77 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinHibTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinHibTest.java @@ -22,6 +22,6 @@ package org.apache.ode.axis2.correlation; public class CorrelationJoinHibTest extends CorrelationJoinTest { @Override public String getODEConfigDir() { - return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-derby"; + return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-h2"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyHibTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyHibTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyHibTest.java index d3f0fe2..d15290c 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyHibTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyHibTest.java @@ -22,6 +22,6 @@ package org.apache.ode.axis2.correlation; public class CorrelationJoinLazyHibTest extends CorrelationJoinLazyTest { @Override public String getODEConfigDir() { - return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-derby"; + return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-h2"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyTest.java index 66b0fb5..5fba9b6 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyTest.java @@ -79,6 +79,6 @@ public class CorrelationJoinLazyTest extends Axis2TestBase implements ODEConfigD } public String getODEConfigDir() { - return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-derby"; + return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-h2"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinTest.java index 38ef792..f2289bd 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinTest.java @@ -78,6 +78,6 @@ public class CorrelationJoinTest extends Axis2TestBase implements ODEConfigDirAw } public String getODEConfigDir() { - return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-derby"; + return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-h2"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiHibTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiHibTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiHibTest.java index de41a06..95655aa 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiHibTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiHibTest.java @@ -22,6 +22,6 @@ package org.apache.ode.axis2.correlation; public class CorrelationMultiHibTest extends CorrelationMultiTest { @Override public String getODEConfigDir() { - return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-derby"; + return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-h2"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiTest.java index c3b0ce9..2855a40 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiTest.java @@ -60,6 +60,6 @@ public class CorrelationMultiTest extends Axis2TestBase implements ODEConfigDirA } public String getODEConfigDir() { - return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-derby"; + return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-h2"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/axis2-war/src/test/webapp/WEB-INF/conf.hib-h2/ode-axis2.properties ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/webapp/WEB-INF/conf.hib-h2/ode-axis2.properties b/axis2-war/src/test/webapp/WEB-INF/conf.hib-h2/ode-axis2.properties new file mode 100644 index 0000000..c081fb7 --- /dev/null +++ b/axis2-war/src/test/webapp/WEB-INF/conf.hib-h2/ode-axis2.properties @@ -0,0 +1,26 @@ +# +# 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. +# + +ode-axis2.dao.factory=org.apache.ode.axis2.instancecleanup.HibDaoConnectionFactoryImpl +ode-axis2.db.mode=INTERNAL +ode-axis2.db.int.jdbcurl=jdbc:h2:file:axis2-war/target/test/classes/webapp/WEB-INF/h2-hibdb/ode-hib-h2;DB_CLOSE_ON_EXIT=false;user=sa;TRACE_LEVEL_FILE=3 +ode-axis2.db.int.driver=org.h2.Driver +ode-axis2.cluster.localRoute.targets=http://doesntexist:8080/ode/processes/ +ode-axis2.cluster.localRoute.base=http://localhost:8888/ode/processes/ +ode-axis2.event.listeners=org.apache.ode.bpel.common.evt.DebugBpelEventListener +ode.acquireTransactionLocks=true +hibernate.dialect=org.hibernate.dialect.H2Dialect \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/axis2-war/src/test/webapp/WEB-INF/conf.jpa-h2/ode-axis2.properties ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/webapp/WEB-INF/conf.jpa-h2/ode-axis2.properties b/axis2-war/src/test/webapp/WEB-INF/conf.jpa-h2/ode-axis2.properties new file mode 100644 index 0000000..dbb191d --- /dev/null +++ b/axis2-war/src/test/webapp/WEB-INF/conf.jpa-h2/ode-axis2.properties @@ -0,0 +1,21 @@ +# +# 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. +# + +ode-axis2.dao.factory=org.apache.ode.axis2.instancecleanup.JpaDaoConnectionFactoryImpl +ode-axis2.db.mode=INTERNAL +ode-axis2.db.int.jdbcurl=jdbc:h2:file:axis2-war/target/test/classes/webapp/WEB-INF/h2-jpadb/ode-jpa-h2;DB_CLOSE_ON_EXIT=false;user=sa;TRACE_LEVEL_FILE=3 +ode-axis2.db.int.driver=org.h2.Driver http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/axis2-war/src/test/webapp/WEB-INF/conf/ode-axis2.properties ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/webapp/WEB-INF/conf/ode-axis2.properties b/axis2-war/src/test/webapp/WEB-INF/conf/ode-axis2.properties index 6e8afcf..c081fb7 100644 --- a/axis2-war/src/test/webapp/WEB-INF/conf/ode-axis2.properties +++ b/axis2-war/src/test/webapp/WEB-INF/conf/ode-axis2.properties @@ -16,8 +16,11 @@ # ode-axis2.dao.factory=org.apache.ode.axis2.instancecleanup.HibDaoConnectionFactoryImpl -ode-axis2.db.emb.name=hibdb -ode-axis2.db.mode=EMBEDDED +ode-axis2.db.mode=INTERNAL +ode-axis2.db.int.jdbcurl=jdbc:h2:file:axis2-war/target/test/classes/webapp/WEB-INF/h2-hibdb/ode-hib-h2;DB_CLOSE_ON_EXIT=false;user=sa;TRACE_LEVEL_FILE=3 +ode-axis2.db.int.driver=org.h2.Driver ode-axis2.cluster.localRoute.targets=http://doesntexist:8080/ode/processes/ ode-axis2.cluster.localRoute.base=http://localhost:8888/ode/processes/ ode-axis2.event.listeners=org.apache.ode.bpel.common.evt.DebugBpelEventListener +ode.acquireTransactionLocks=true +hibernate.dialect=org.hibernate.dialect.H2Dialect \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java ---------------------------------------------------------------------- diff --git a/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java b/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java index c900c89..52a6a31 100644 --- a/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java +++ b/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java @@ -143,6 +143,8 @@ public interface Scheduler { void stop(); void shutdown(); + + void acquireTransactionLocks(); public interface Synchronizer { /** http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java ---------------------------------------------------------------------- diff --git a/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java b/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java index 272378f..89487d9 100644 --- a/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java +++ b/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java @@ -212,6 +212,9 @@ public class MockScheduler implements Scheduler { public void shutdown() { } + + public void acquireTransactionLocks() { + } public void registerSynchronizer(final Synchronizer synch) throws ContextException { if (_txm != null) { http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java ---------------------------------------------------------------------- diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java index 70fdd28..c8d0bdf 100644 --- a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java +++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java @@ -571,6 +571,12 @@ public class BpelServerImpl implements BpelServer, Scheduler.JobProcessor { _engine.setInstanceThrottledMaximumCount(instanceThrottledMaximumCount); } + public void acquireTransactionLocks() { + if (Boolean.parseBoolean(_configProperties.getProperty("ode.acquireTransactionLocks", "false"))) { + _contexts.scheduler.acquireTransactionLocks(); + } + } + /** * A polled runnable instance that implements this interface will be set * with the contexts before the run() method is called. http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerScheduler.java ---------------------------------------------------------------------- diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerScheduler.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerScheduler.java index ca58f2b..b09b44a 100644 --- a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerScheduler.java +++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/replayer/ReplayerScheduler.java @@ -96,6 +96,9 @@ public class ReplayerScheduler implements Scheduler { public void shutdown() { } + + public void acquireTransactionLocks() { + } public void startReplaying(Replayer replayer) throws Exception { this.replayer = replayer; http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java ---------------------------------------------------------------------- diff --git a/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java b/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java index b689e4c..79fe78e 100644 --- a/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java +++ b/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java @@ -404,6 +404,7 @@ class MockBpelServer { public void start() { _scheduler.start(); } public void stop() { _scheduler.stop(); } public void shutdown() { _scheduler.shutdown(); } + public void acquireTransactionLocks() { _scheduler.acquireTransactionLocks(); } public void registerSynchronizer(Synchronizer synch) throws ContextException { _scheduler.registerSynchronizer(synch); http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java ---------------------------------------------------------------------- diff --git a/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java b/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java index b11e15d..624f5ee 100644 --- a/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java +++ b/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java @@ -76,6 +76,7 @@ public class DbConfStoreConnectionFactory implements ConfStoreConnectionFactory // Informix Dynamic Server // Oracle 8 and Oracle >8 HIBERNATE_DIALECTS.put("Apache Derby", new DialectFactory.VersionInsensitiveMapper(DEFAULT_HIBERNATE_DIALECT)); + HIBERNATE_DIALECTS.put("H2", new DialectFactory.VersionInsensitiveMapper("org.hibernate.dialect.H2Dialect")); } private TransactionManager _txMgr; http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/dao-hibernate-db/src/main/sql/ode.h2.properties ---------------------------------------------------------------------- diff --git a/dao-hibernate-db/src/main/sql/ode.h2.properties b/dao-hibernate-db/src/main/sql/ode.h2.properties new file mode 100644 index 0000000..df11164 --- /dev/null +++ b/dao-hibernate-db/src/main/sql/ode.h2.properties @@ -0,0 +1,51 @@ +# +# 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. +# + +# +# Misc. Hibernate DAO Configuration +# Settings in this file override the defaults. +# + +# The type of database we are connecting to, uncomment the +# correct one: + +#hibernate.dialect=org.hibernate.dialect.DerbyDialect +hibernate.dialect=org.hibernate.dialect.H2Dialect +#hibernate.dialect=org.hibernate.dialect.HSQLDialect +#hibernate.dialect=org.hibernate.dialect.OracleDialect +#hibernate.dialect=org.hibernate.dialect.Oracle9Dialect +#hibernate.dialect=org.hibernate.dialect.SQLServerDialect +#hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +#hibernate.dialect=org.hibernate.dialect.SybaseDialect + +#Enable SQL-level debug logging (uncomment for logging) +#hibernate.show_sql=true + +# Enable schema auto-generation. +hibernate.hbm2ddl.auto = update + +# Hibernate / JTA Session Management Conifguration +hibernate.current_session_context_class=jta +hibernate.transaction.manager_lookup_class=org.apache.ode.daohib.HibernateTransactionManagerLookup + + +# see Query Language Changes http://www.hibernate.org/250.html: here to prevent +# problems related to ANTLR class loading. Can be commented out on platforms +# where new ANTLRs are present +#hibernate.query.factory_class=org.hibernate.hql.classic.ClassicQueryTranslatorFactory http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/dao-hibernate-db/src/main/sql/simplesched-h2.sql ---------------------------------------------------------------------- diff --git a/dao-hibernate-db/src/main/sql/simplesched-h2.sql b/dao-hibernate-db/src/main/sql/simplesched-h2.sql new file mode 100644 index 0000000..2ee1bc9 --- /dev/null +++ b/dao-hibernate-db/src/main/sql/simplesched-h2.sql @@ -0,0 +1,31 @@ +-- Apache ODE - SimpleScheduler Database Schema +-- +-- MySQL scripts by Maciej Szefler. +-- +-- +DROP TABLE IF EXISTS ODE_JOB; + +CREATE TABLE ODE_JOB ( + jobid CHAR(64) NOT NULL DEFAULT '', + ts BIGINT NOT NULL DEFAULT 0, + nodeid char(64) NULL, + scheduled int NOT NULL DEFAULT 0, + transacted int NOT NULL DEFAULT 0, + + instanceId BIGINT, + mexId varchar(255), + processId varchar(255), + type varchar(255), + channel varchar(255), + correlatorId varchar(255), + correlationKeySet varchar(255), + retryCount int, + inMem int, + detailsExt blob(4096), + + PRIMARY KEY(jobid) +); + +create index IDX_ODE_JOB_TS on ODE_JOB(ts); +create index IDX_ODE_JOB_NODEID on ODE_JOB(nodeid); + http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java ---------------------------------------------------------------------- diff --git a/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java b/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java index 56558ed..099b849 100644 --- a/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java +++ b/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java @@ -162,6 +162,8 @@ public class BpelDAOConnectionFactoryImpl implements BpelDAOConnectionFactoryJDB "org.hibernate.dialect.DerbyDialect")); HIBERNATE_DIALECTS.put("INGRES", new DialectFactory.VersionInsensitiveMapper( "org.hibernate.dialect.IngresDialect")); + HIBERNATE_DIALECTS.put("H2", new DialectFactory.VersionInsensitiveMapper( + "org.hibernate.dialect.H2Dialect")); } public void shutdown() { http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/dao-jpa-ojpa-derby/src/main/descriptors/persistence.h2.xml ---------------------------------------------------------------------- diff --git a/dao-jpa-ojpa-derby/src/main/descriptors/persistence.h2.xml b/dao-jpa-ojpa-derby/src/main/descriptors/persistence.h2.xml new file mode 100644 index 0000000..c73aba4 --- /dev/null +++ b/dao-jpa-ojpa-derby/src/main/descriptors/persistence.h2.xml @@ -0,0 +1,55 @@ +<?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. + --> +<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"> + <persistence-unit name="ode-unit-test-embedded"> + <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> + <class>org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl</class> + <class>org.apache.ode.dao.jpa.CorrelationSetDAOImpl</class> + <class>org.apache.ode.dao.jpa.CorrelatorDAOImpl</class> + <class>org.apache.ode.dao.jpa.EventDAOImpl</class> + <class>org.apache.ode.dao.jpa.FaultDAOImpl</class> + <class>org.apache.ode.dao.jpa.MessageDAOImpl</class> + <class>org.apache.ode.dao.jpa.MessageExchangeDAOImpl</class> + <class>org.apache.ode.dao.jpa.MessageRouteDAOImpl</class> + <class>org.apache.ode.dao.jpa.PartnerLinkDAOImpl</class> + <class>org.apache.ode.dao.jpa.ProcessDAOImpl</class> + <class>org.apache.ode.dao.jpa.ProcessInstanceDAOImpl</class> + <class>org.apache.ode.dao.jpa.ScopeDAOImpl</class> + <class>org.apache.ode.dao.jpa.XmlDataDAOImpl</class> + + <class>org.apache.ode.store.jpa.ProcessConfDaoImpl</class> + <class>org.apache.ode.store.jpa.ProcessConfPropertyDaoImpl</class> + <class>org.apache.ode.store.jpa.DeploymentUnitDaoImpl</class> + <class>org.apache.ode.store.jpa.VersionTrackerDAOImpl</class> + + <properties> + <!-- Properties for an embedded Derby connection --> + <property name="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource"/> + <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.H2Dictionary"/> + <!-- To validate DBSchema and create DDL at runtime - use this property. Currently the DDL is created at build time --> + <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/> + + <property name="openjpa.ConnectionProperties" + value="DriverClassName=org.apache.derby.jdbc.EmbeddedDriver,Url=jdbc:derby:target/database/openjpa-test-database;create=true,MaxActive=100,MaxWait=10000,TestOnBorrow=true"/> + + </properties> + </persistence-unit> +</persistence> + http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/dao-jpa-ojpa-derby/src/main/scripts/simplesched-h2.sql ---------------------------------------------------------------------- diff --git a/dao-jpa-ojpa-derby/src/main/scripts/simplesched-h2.sql b/dao-jpa-ojpa-derby/src/main/scripts/simplesched-h2.sql new file mode 100644 index 0000000..2ee1bc9 --- /dev/null +++ b/dao-jpa-ojpa-derby/src/main/scripts/simplesched-h2.sql @@ -0,0 +1,31 @@ +-- Apache ODE - SimpleScheduler Database Schema +-- +-- MySQL scripts by Maciej Szefler. +-- +-- +DROP TABLE IF EXISTS ODE_JOB; + +CREATE TABLE ODE_JOB ( + jobid CHAR(64) NOT NULL DEFAULT '', + ts BIGINT NOT NULL DEFAULT 0, + nodeid char(64) NULL, + scheduled int NOT NULL DEFAULT 0, + transacted int NOT NULL DEFAULT 0, + + instanceId BIGINT, + mexId varchar(255), + processId varchar(255), + type varchar(255), + channel varchar(255), + correlatorId varchar(255), + correlationKeySet varchar(255), + retryCount int, + inMem int, + detailsExt blob(4096), + + PRIMARY KEY(jobid) +); + +create index IDX_ODE_JOB_TS on ODE_JOB(ts); +create index IDX_ODE_JOB_NODEID on ODE_JOB(nodeid); + http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/jbi/src/test/resources/smx-base.xml ---------------------------------------------------------------------- diff --git a/jbi/src/test/resources/smx-base.xml b/jbi/src/test/resources/smx-base.xml index 56eb7c8..6e0ce72 100644 --- a/jbi/src/test/resources/smx-base.xml +++ b/jbi/src/test/resources/smx-base.xml @@ -54,7 +54,7 @@ /> <bean id="odeMCF" class="org.tranql.connector.derby.EmbeddedLocalMCF"> - <property name="databaseName" value="target/test/smx/ode/hibdb"/> + <property name="databaseName" value="target/test/smx/ode/derby-hibdb"/> <property name="createDatabase" value="false"/> <property name="userName" value = "sa"/> <property name="password" value = ""/> http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/DatabaseDelegate.java ---------------------------------------------------------------------- diff --git a/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/DatabaseDelegate.java b/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/DatabaseDelegate.java index a0b893b..d578c03 100644 --- a/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/DatabaseDelegate.java +++ b/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/DatabaseDelegate.java @@ -103,4 +103,6 @@ public interface DatabaseDelegate { * @throws DatabaseException */ int updateReassign(String oldnode, String newnode) throws DatabaseException; + + public void acquireTransactionLocks(); } http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/JdbcDelegate.java ---------------------------------------------------------------------- diff --git a/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/JdbcDelegate.java b/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/JdbcDelegate.java index 7e9e89c..6672e8d 100644 --- a/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/JdbcDelegate.java +++ b/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/JdbcDelegate.java @@ -22,27 +22,24 @@ package org.apache.ode.scheduler.simple; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.Serializable; +import java.math.BigDecimal; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Statement; import java.sql.Types; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.math.BigDecimal; import javax.sql.DataSource; -import javax.xml.namespace.QName; - -import org.apache.ode.bpel.iapi.Scheduler; -import org.apache.ode.bpel.iapi.Scheduler.JobDetails; -import org.apache.ode.utils.DbIsolation; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.ode.bpel.iapi.Scheduler; +import org.apache.ode.bpel.iapi.Scheduler.JobDetails; import org.apache.ode.utils.DbIsolation; import org.apache.ode.utils.StreamUtils; @@ -456,6 +453,8 @@ public class JdbcDelegate implements DatabaseDelegate { d = Dialect.FIREBIRD; } else if (dbProductName.indexOf("HSQL") >= 0) { d = Dialect.HSQL; + } else if (dbProductName.indexOf("H2") >= 0) { + d = Dialect.H2; } else if (dbProductName.indexOf("Microsoft SQL") >= 0) { d = Dialect.SQLSERVER; } else if (dbProductName.indexOf("MySQL") >= 0) { @@ -476,8 +475,27 @@ public class JdbcDelegate implements DatabaseDelegate { return d; } + public void acquireTransactionLocks() { + Statement s = null; + Connection c = null; + try { + c = getConnection(); + s = c.createStatement(); + s.execute("update ODE_JOB set jobid = '' where 1 = 0"); + } catch (Exception e) { + throw new RuntimeException("", e); + } finally { + try { + if (s != null) s.close(); + if (c != null) c.close(); + } catch (Exception e) { + throw new RuntimeException("", e); + } + } + } + enum Dialect { - DB2, DERBY, FIREBIRD, HSQL, MYSQL, ORACLE, SQLSERVER, SYBASE, SYBASE12, UNKNOWN + DB2, DERBY, FIREBIRD, HSQL, MYSQL, ORACLE, SQLSERVER, SYBASE, SYBASE12, H2, UNKNOWN } } http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java ---------------------------------------------------------------------- diff --git a/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java b/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java index 49bbff6..7438f9f 100644 --- a/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java +++ b/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java @@ -829,6 +829,10 @@ public class SimpleScheduler implements Scheduler, TaskRunner { // _db.insertJob(jobRetry, _nodeId, false); // return delay; // } + + public void acquireTransactionLocks() { + _db.acquireTransactionLocks(); + } private abstract class SchedulerTask extends Task implements Runnable { SchedulerTask(long schedDate) { http://git-wip-us.apache.org/repos/asf/ode/blob/e1a7881b/tasks/h2.rake ---------------------------------------------------------------------- diff --git a/tasks/h2.rake b/tasks/h2.rake new file mode 100644 index 0000000..af5344b --- /dev/null +++ b/tasks/h2.rake @@ -0,0 +1,43 @@ +# +# 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. +# + +module H2 + + REQUIRES = "com.h2database:h2:jar:1.3.173" + + #Java.classpath << REQUIRES + + class << self + + # Returns a task that will create a new H2 database. The task name is the path to + # the H2 database. The prerequisites are all the SQL files for inclusion in the database. + # + # For example: + # H2.create "mydb"=>h2.sql + def create(dbname, args) + db, prereqs = args.keys.first, args.values.first + targetDir=File.expand_path(db) + file(targetDir=>prereqs) do |task| + rm_rf task.name if File.exist?(task.name) + Java::Commands.java "org.h2.tools.RunScript", "-url", "jdbc:h2:file:"+Util.normalize_path("#{targetDir}/#{dbname}")+";DB_CLOSE_ON_EXIT=false;user=sa", "-showResults", "-script", prereqs, :classpath => REQUIRES + # Copy the SQL files into the database directory. + Buildr.filter(prereqs).into(task.name).run + touch task.name, :verbose=>false + end + end + end +end
