Author: mszefler Date: Wed Jan 24 17:28:36 2007 New Revision: 499638 URL: http://svn.apache.org/viewvc?view=rev&rev=499638 Log: Scheduler tweaks for job retry. Hacked pom.xml to use pxe.intalio.org primarily Moved example modules into distro modules.
Added: incubator/ode/trunk/distro-axis2/src/examples/ - copied from r499624, incubator/ode/trunk/axis2-examples/src/examples/ incubator/ode/trunk/distro-jbi/src/examples/ - copied from r499624, incubator/ode/trunk/jbi-examples/src/examples/ Removed: incubator/ode/trunk/axis2-examples/ incubator/ode/trunk/jbi-examples/src/examples/ Modified: incubator/ode/trunk/axis2-war/pom.xml incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEngine.java incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java incubator/ode/trunk/bpel-runtime/pom.xml incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/JobImpl.java incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java incubator/ode/trunk/bpel-store/pom.xml incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/DeploymentUnitTest.java incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseDAOTest.java incubator/ode/trunk/dao-jpa-ojpa-derby/pom.xml incubator/ode/trunk/distro-axis2/build.xml incubator/ode/trunk/distro-axis2/pom.xml incubator/ode/trunk/distro-axis2/src/main/assembly/assembly.xml incubator/ode/trunk/distro-jbi/build.xml incubator/ode/trunk/distro-jbi/pom.xml incubator/ode/trunk/distro-jbi/src/main/assembly/assembly.xml incubator/ode/trunk/jacob/pom.xml incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java incubator/ode/trunk/pom.xml Modified: incubator/ode/trunk/axis2-war/pom.xml URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2-war/pom.xml?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/axis2-war/pom.xml (original) +++ incubator/ode/trunk/axis2-war/pom.xml Wed Jan 24 17:28:36 2007 @@ -36,7 +36,8 @@ <plugins> <plugin> <artifactId>maven-war-plugin</artifactId> - <executions> + <version>2.0.2</version> + <executions> <execution> <goals> <goal>war</goal> Modified: incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEngine.java URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEngine.java?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEngine.java (original) +++ incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEngine.java Wed Jan 24 17:28:36 2007 @@ -34,7 +34,7 @@ * exception of any kind, then the current transaction <em>must</em> be rolled * back. */ -public interface BpelEngine { +public interface BpelEngine extends Scheduler.JobProcessor { /** * Create a "my role" message exchange for invoking a BPEL process. @@ -60,16 +60,4 @@ MessageExchange getMessageExchangeByClientKey(String clientKey); - /** - * Call-back to the engine used by the [EMAIL PROTECTED] Scheduler} implementation for - * executing scheduled jobs. - * - * @param jobId - * job identifier returned by the [EMAIL PROTECTED] Scheduler}.scheduleXXX - * methods. - * @param jobDetail - * job details as passed in to the [EMAIL PROTECTED] Scheduler}.scheduleXXX - * methods - */ - void onScheduledJob(String jobId, Map<String, Object> jobDetail); } Modified: incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java (original) +++ incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java Wed Jan 24 17:28:36 2007 @@ -19,6 +19,7 @@ package org.apache.ode.bpel.iapi; +import java.io.Serializable; import java.util.Date; import java.util.Map; import java.util.concurrent.Callable; @@ -28,6 +29,8 @@ */ public interface Scheduler { + void setJobProcessor(JobProcessor processor) throws ContextException; + /** * Schedule a persisted job. Persisted jobs MUST survive system failure. * They also must not be scheduled unless the transaction associated with @@ -110,4 +113,50 @@ void beforeCompletion(); } + + /** + * Interface implemented by the object responsible for job execution. + * @author mszefler + */ + public interface JobProcessor { + void onScheduledJob(JobInfo jobInfo) throws JobProcessorException; + } + + /** + * Wrapper containing information about a scheduled job. + * @author mszefler + */ + public static class JobInfo implements Serializable { + private static final long serialVersionUID = 1L; + public final String jobName; + public final int retryCount; + public final Map<String,Object> jobDetail; + + public JobInfo(String jobName, Map<String,Object>jobDetail, int retryCount) { + this.jobName = jobName; + this.jobDetail = jobDetail; + this.retryCount = retryCount; + } + } + + /** + * Exception thrown by the [EMAIL PROTECTED] JobProcessor} to indicate failure in job + * processing. + * @author mszefler + */ + public class JobProcessorException extends Exception { + private static final long serialVersionUID = 1L; + public final boolean retry; + + public JobProcessorException(boolean retry) { + this.retry = retry; + } + + public JobProcessorException(Throwable cause, boolean retry) { + super(cause); + this.retry = retry; + } + } + + } Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java (original) +++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/DefaultResourceFinder.java Wed Jan 24 17:28:36 2007 @@ -71,7 +71,13 @@ return null; } - return new FileInputStream(new File(suURI.getPath(),relative.getPath())); + File f = new File(suURI.getPath(),relative.getPath()); + if (!f.exists()) { + __log.debug("fileNotFound: " + f); + return null; + } + + return new FileInputStream(f); } } Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java (original) +++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java Wed Jan 24 17:28:36 2007 @@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; @@ -106,7 +107,13 @@ } try { - src.setByteStream(_wsdlFinder.openResource(location)); + InputStream str = _wsdlFinder.openResource(location); + if (str != null) + src.setByteStream(str); + else { + __log.debug("resolveEntity: resource not found: " + location); + throw new IOException("Resource not found: " + location); + } } catch (IOException ioex) { __log.debug("resolveEntity: IOException opening " + location,ioex); @@ -117,6 +124,9 @@ __log.debug("resolveEntity: failIfNotFound NOT set, returning NULL"); return null; + } catch (Exception ex) { + __log.debug("resolveEntity: unexpected error: " + location); + throw new IOException("Unexpected error loading resource: " + location); } return src; Modified: incubator/ode/trunk/bpel-runtime/pom.xml URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/pom.xml?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/bpel-runtime/pom.xml (original) +++ incubator/ode/trunk/bpel-runtime/pom.xml Wed Jan 24 17:28:36 2007 @@ -180,6 +180,7 @@ <plugin> <groupId>org.apache.myfaces.tobago</groupId> <artifactId>maven-apt-plugin</artifactId> + <version>1.0.7</version> <executions> <execution> <phase>generate-sources</phase> Modified: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java (original) +++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java Wed Jan 24 17:28:36 2007 @@ -19,10 +19,12 @@ package org.apache.ode.bpel.engine; +import java.io.File; +import java.io.FileOutputStream; +import java.io.ObjectOutputStream; import java.util.Date; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Random; import javax.wsdl.Operation; @@ -37,21 +39,24 @@ import org.apache.ode.bpel.evt.BpelEvent; import org.apache.ode.bpel.iapi.BpelEngine; import org.apache.ode.bpel.iapi.BpelEngineException; +import org.apache.ode.bpel.iapi.ContextException; import org.apache.ode.bpel.iapi.Endpoint; import org.apache.ode.bpel.iapi.Message; import org.apache.ode.bpel.iapi.MessageExchange; import org.apache.ode.bpel.iapi.MyRoleMessageExchange; +import org.apache.ode.bpel.iapi.Scheduler; import org.apache.ode.bpel.iapi.MessageExchange.MessageExchangePattern; import org.apache.ode.bpel.iapi.MessageExchange.Status; import org.apache.ode.bpel.iapi.MyRoleMessageExchange.CorrelationStatus; +import org.apache.ode.bpel.iapi.Scheduler.JobInfo; import org.apache.ode.bpel.intercept.MessageExchangeInterceptor; import org.apache.ode.bpel.o.OPartnerLink; import org.apache.ode.bpel.o.OProcess; import org.apache.ode.utils.msg.MessageBundle; /** - * Implementation of the [EMAIL PROTECTED] BpelEngine} interface: provides the server - * methods that should be invoked in the context of a transaction. + * Implementation of the [EMAIL PROTECTED] BpelEngine} interface: provides the server methods that should be invoked in the context of a + * transaction. * * @author mszefler * @@ -82,6 +87,9 @@ private static final Messages __msgs = MessageBundle.getMessages(Messages.class); + /** Maximum number of tries for async jobs. */ + private static final int MAX_RETRIES = 3; + /** Active processes, keyed by process id. */ final HashMap<QName, BpelProcess> _activeProcesses = new HashMap<QName, BpelProcess>(); @@ -101,8 +109,7 @@ MessageExchangeDAO dao; if (target == null || target.isInMemory()) { - dao = _contexts.inMemDao.getConnection().createMessageExchange( - MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE); + dao = _contexts.inMemDao.getConnection().createMessageExchange(MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE); } else { dao = _contexts.dao.getConnection().createMessageExchange(MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE); } @@ -199,16 +206,14 @@ } /** - * Route to a process using the service id. Note, that we do not need the - * endpoint name here, we are assuming that two processes would not be - * registered under the same service qname but different endpoint. + * Route to a process using the service id. Note, that we do not need the endpoint name here, we are assuming that two processes + * would not be registered under the same service qname but different endpoint. * * @param service * target service id * @param request * request message - * @return process corresponding to the targetted service, or - * <code>null</code> if service identifier is not recognized. + * @return process corresponding to the targetted service, or <code>null</code> if service identifier is not recognized. */ BpelProcess route(QName service, Message request) { // TODO: use the message to route to the correct service if more than @@ -230,49 +235,79 @@ if (process == null) return null; - + return process._oprocess; } - public void onScheduledJob(String jobId, Map<String, Object> jobDetail) { - WorkEvent we = new WorkEvent(jobDetail); + public void onScheduledJob(Scheduler.JobInfo jobInfo) throws Scheduler.JobProcessorException { + // NOTE: wrap this method real tight in a try/catch block, we need to handle all types of + // failure here, the scheduler is not going to know how to handle our errors. + try { + WorkEvent we = new WorkEvent(jobInfo.jobDetail); + ProcessInstanceDAO instance; + if (we.isInMem()) + instance = _contexts.inMemDao.getConnection().getInstance(we.getIID()); + else + instance = _contexts.dao.getConnection().getInstance(we.getIID()); + + if (instance == null) { + __log.error(__msgs.msgScheduledJobReferencesUnknownInstance(we.getIID())); + // nothing we can do, this instance is not in the database, it will + // always + // fail. + return; + } - ProcessInstanceDAO instance; - if (we.isInMem()) - instance = _contexts.inMemDao.getConnection().getInstance(we.getIID()); - else - instance = _contexts.dao.getConnection().getInstance(we.getIID()); - - if (instance == null) { - __log.error(__msgs.msgScheduledJobReferencesUnknownInstance(we.getIID())); - // nothing we can do, this instance is not in the database, it will - // always - // fail. - return; - } + ProcessDAO processDao = instance.getProcess(); + BpelProcess process = _activeProcesses.get(processDao.getProcessId()); + if (process == null) { + // If the process is not active, it means that we should not be + // doing + // any work on its behalf, therefore we will reschedule the events + // for some time in the future (1 minute). + Date future = new Date(System.currentTimeMillis() + (60 * 1000)); + __log.info(__msgs.msgReschedulingJobForInactiveProcess(processDao.getProcessId(), jobInfo.jobName, future)); + _contexts.scheduler.schedulePersistedJob(jobInfo.jobDetail, future); + } + + assert process != null; + process.handleWorkEvent(jobInfo.jobDetail); + debuggingDelay(); + } catch (BpelEngineException bee) { + throw new Scheduler.JobProcessorException(bee,checkRetry(jobInfo,bee)); + } catch (ContextException ce) { + throw new Scheduler.JobProcessorException(ce,checkRetry(jobInfo,ce)); + } catch (RuntimeException rte) { + throw new Scheduler.JobProcessorException(rte,checkRetry(jobInfo,rte)); + } catch (Throwable t) { + throw new Scheduler.JobProcessorException(false); - ProcessDAO processDao = instance.getProcess(); - BpelProcess process = _activeProcesses.get(processDao.getProcessId()); - if (process == null) { - // If the process is not active, it means that we should not be - // doing - // any work on its behalf, therefore we will reschedule the events - // for some time in the future (1 minute). - Date future = new Date(System.currentTimeMillis() + (60 * 1000)); - __log.info(__msgs.msgReschedulingJobForInactiveProcess(processDao.getProcessId(), jobId, future)); - _contexts.scheduler.schedulePersistedJob(jobDetail, future); } + } + + private boolean checkRetry(JobInfo jobInfo, Throwable t) { + // TODO, better handling of failed jobs (put them in the DB perhaps?) + if (jobInfo.retryCount < MAX_RETRIES) + return true; - assert process != null; - process.handleWorkEvent(jobDetail); - debuggingDelay(); + __log.error("Job could not be completed after " + MAX_RETRIES + "! ",t); + + try { + File f = File.createTempFile("ode-bad-job", ".ser", new File("")); + ObjectOutputStream fos = new ObjectOutputStream(new FileOutputStream(f)); + fos.writeObject(jobInfo); + fos.close(); + } catch (Exception ex) { + __log.error("Could not save bad job; it will be lost!",ex); + } + + // No more retries. + return false; } /** - * Block the thread for random amount of time. Used for testing for races - * and the like. The delay generated is exponentially distributed with the - * mean obtained from the <code>ODE_DEBUG_TX_DELAY</code> environment - * variable. + * Block the thread for random amount of time. Used for testing for races and the like. The delay generated is exponentially + * distributed with the mean obtained from the <code>ODE_DEBUG_TX_DELAY</code> environment variable. */ private void debuggingDelay() { // Do a delay for debugging purposes. @@ -280,9 +315,9 @@ try { double u = _random.nextDouble(); // Uniform long delay = (long) (-Math.log(u) * _delayMean); // Exponential - // distribution - // with mean - // _delayMean + // distribution + // with mean + // _delayMean __log.warn("Debugging delay has been activated; delaying transaction for " + delay + "ms."); Thread.sleep(delay); } catch (InterruptedException e) { Modified: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java (original) +++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java Wed Jan 24 17:28:36 2007 @@ -27,6 +27,8 @@ import org.apache.ode.bpel.explang.ConfigurationException; import org.apache.ode.bpel.iapi.*; import org.apache.ode.bpel.iapi.BpelEventListener; +import org.apache.ode.bpel.iapi.Scheduler.JobInfo; +import org.apache.ode.bpel.iapi.Scheduler.JobProcessorException; import org.apache.ode.bpel.iapi.Scheduler.Synchronizer; import org.apache.ode.bpel.intercept.MessageExchangeInterceptor; import org.apache.ode.bpel.o.OExpressionLanguage; @@ -57,7 +59,7 @@ * @author Maciej Szefler <mszefler at gmail dot com> * @author mriou <mriou at apache dot org> */ -public class BpelServerImpl implements BpelServer { +public class BpelServerImpl implements BpelServer, Scheduler.JobProcessor { private static final Log __log = LogFactory.getLog(BpelServerImpl.class); @@ -486,6 +488,10 @@ throw new BpelEngineException(errmsg, ex); } + } + + public void onScheduledJob(JobInfo jobInfo) throws JobProcessorException { + getEngine().onScheduledJob(jobInfo); } // Modified: incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java (original) +++ incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java Wed Jan 24 17:28:36 2007 @@ -286,10 +286,10 @@ QuartzSchedulerImpl _quartz; long _nextSchedule; - SchedulerWrapper(BpelServer server, TransactionManager txManager, DataSource dataSource) { + SchedulerWrapper(BpelServerImpl server, TransactionManager txManager, DataSource dataSource) { ExecutorService executorService = Executors.newCachedThreadPool(); _quartz = new QuartzSchedulerImpl(); - _quartz.setBpelServer(server); + _quartz.setJobProcessor(server); _quartz.setExecutorService(executorService, 20); _quartz.setTransactionManager(txManager); _quartz.setDataSource(dataSource); @@ -325,6 +325,11 @@ public void registerSynchronizer(Synchronizer synch) throws ContextException { _quartz.registerSynchronizer(synch); + } + + public void setJobProcessor(JobProcessor processor) throws ContextException { + _quartz.setJobProcessor(processor); + } } Modified: incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/JobImpl.java URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/JobImpl.java?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/JobImpl.java (original) +++ incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/JobImpl.java Wed Jan 24 17:28:36 2007 @@ -28,8 +28,8 @@ */ public class JobImpl implements Job { - public void execute(JobExecutionContext jobcontext) throws JobExecutionException { - QuartzSchedulerImpl.execute(jobcontext); - } + public void execute(JobExecutionContext jobcontext) throws JobExecutionException { + QuartzSchedulerImpl.execute(jobcontext); + } } Modified: incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java (original) +++ incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java Wed Jan 24 17:28:36 2007 @@ -35,6 +35,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.ode.bpel.iapi.BpelEngineException; import org.apache.ode.bpel.iapi.BpelServer; import org.apache.ode.bpel.iapi.ContextException; import org.apache.ode.bpel.iapi.Scheduler; @@ -42,6 +43,7 @@ import org.quartz.JobDataMap; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; import org.quartz.SchedulerException; import org.quartz.SimpleTrigger; import org.quartz.Trigger; @@ -59,7 +61,7 @@ * Quartz-based scheduler. * * @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m - * + * */ public class QuartzSchedulerImpl implements Scheduler { @@ -68,7 +70,7 @@ private static final Map<String, QuartzSchedulerImpl> __instanceMap = Collections .synchronizedMap(new HashMap<String, QuartzSchedulerImpl>()); - protected BpelServer _server; + protected JobProcessor _processor; private org.quartz.Scheduler _quartz; @@ -88,8 +90,8 @@ _id = "ODE"; } - public void setBpelServer(BpelServer server) { - _server = server; + public void setJobProcessor(JobProcessor processor) { + _processor = processor; } public void setExecutorService(ExecutorService es, int threads) { @@ -106,25 +108,23 @@ } public void init() throws ContextException { - if (_server == null) - throw new NullPointerException("BpelServer not set!"); + if (_processor == null) + throw new NullPointerException("JobProcessor not set!"); if (_executorSvc == null) - throw new NullPointerException("ExeuctorService not set!"); + throw new NullPointerException("ExecutorService not set!"); if (_managedDS == null) - throw new NullPointerException("Managed DataSource name not set!"); + throw new NullPointerException("DataSource name not set!"); if (_txm == null) throw new NullPointerException("TransactionManager not set!"); - DBConnectionManager.getInstance() - .addConnectionProvider("managed", new DataSourceConnectionProvider(_managedDS)); + DBConnectionManager.getInstance().addConnectionProvider("managed", new DataSourceConnectionProvider(_managedDS)); JobStoreJTA jobStore = new JobStoreJTA(_txm); jobStore.setDataSource("managed"); checkSqlServer(); - + try { - _quartz = createScheduler(_id, _id, new QuartzThreadPoolExecutorServiceImpl(_executorSvc, - _threads), jobStore); + _quartz = createScheduler(_id, _id, new QuartzThreadPoolExecutorServiceImpl(_executorSvc, _threads), jobStore); _quartz.getSchedulerInstanceId(); __instanceMap.put(_id, this); } catch (Exception ex) { @@ -150,7 +150,7 @@ ; } } - + } public void start() { @@ -200,8 +200,7 @@ jobDetail.setDurability(false); jobDetail.setVolatility(volatil); jobDetail.setRequestsRecovery(true); - Trigger trigger = new SimpleTrigger(jobDetail.getName() + ".trigger", org.quartz.Scheduler.DEFAULT_GROUP, when, - null, 0, 0L); + Trigger trigger = new SimpleTrigger(jobDetail.getName() + ".trigger", org.quartz.Scheduler.DEFAULT_GROUP, when, null, 0, 0L); trigger.setVolatility(volatil); try { @@ -214,8 +213,7 @@ return jobDetail.getName(); } - public String scheduleVolatileJob(boolean transacted, Map<String, Object> detail, Date when) - throws ContextException { + public String scheduleVolatileJob(boolean transacted, Map<String, Object> detail, Date when) throws ContextException { return schedule(detail, when, true, !transacted); } @@ -265,7 +263,7 @@ } public <T> T execIsolatedTransaction(final Callable<T> transaction) throws Exception, ContextException { - Future<T> res = _executorSvc.submit(new Callable<T>() { + Future<T> res = _executorSvc.submit(new Callable<T>() { public T call() throws Exception { return execTransaction(transaction); } @@ -273,7 +271,6 @@ return res.get(); } - protected void rollback() throws Exception { try { _txm.rollback(); @@ -302,19 +299,31 @@ } @SuppressWarnings("unchecked") - private void doExecute(JobExecutionContext jobcontext) { - _server.getEngine().onScheduledJob(jobcontext.getJobDetail().getName(), - jobcontext.getJobDetail().getJobDataMap()); + private void doExecute(JobExecutionContext jobcontext) throws JobExecutionException { + JobInfo ji = new JobInfo(jobcontext.getJobDetail().getName(), + jobcontext.getJobDetail().getJobDataMap(), + jobcontext.getRefireCount()); + try { + _processor.onScheduledJob(ji); + } catch (JobProcessorException jpe) { + throw new JobExecutionException(jpe, jpe.retry); + } catch (RuntimeException ex) { + __log.error("Scheduled transaction failed unexpectedly: transaction will not be retried!.", ex); + throw new JobExecutionException(ex, true); + } catch (Throwable t) { + __log.fatal("Scheduled transaction failed unexpectedly: transaction will not be retried!.", t); + throw new JobExecutionException(false); + } } - public static void execute(JobExecutionContext jobcontext) { + public static void execute(JobExecutionContext jobcontext) throws JobExecutionException { String schedulerGuid = jobcontext.getJobDetail().getJobDataMap().getString("__scheduler"); __instanceMap.get(schedulerGuid).doExecute(jobcontext); } /** - * Create a QUARTZ scheduler using JTA Job Shell. Unfortunately there is no - * "easy" way to do this using the standard scheduler factory. + * Create a QUARTZ scheduler using JTA Job Shell. Unfortunately there is no "easy" way to do this using the standard scheduler + * factory. * * @param schedulerName * @param schedulerInstanceId @@ -326,8 +335,8 @@ * @param dbFailureRetryInterval * @throws SchedulerException */ - private org.quartz.Scheduler createScheduler(String schedulerName, String schedulerInstanceId, - ThreadPool threadPool, JobStoreJTA jobStore) throws SchedulerException { + private org.quartz.Scheduler createScheduler(String schedulerName, String schedulerInstanceId, ThreadPool threadPool, + JobStoreJTA jobStore) throws SchedulerException { jobStore.setInstanceName(schedulerName); jobStore.setInstanceId(schedulerInstanceId); @@ -360,7 +369,6 @@ return scheduler; } - public void registerSynchronizer(final Synchronizer synch) throws ContextException { try { _txm.getTransaction().registerSynchronization(new Synchronization() { @@ -372,7 +380,7 @@ public void afterCompletion(int status) { synch.afterCompletion(status == Status.STATUS_COMMITTED); } - + }); } catch (Exception e) { throw new ContextException("Unable to register synchronizer.", e); Modified: incubator/ode/trunk/bpel-store/pom.xml URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/pom.xml?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/bpel-store/pom.xml (original) +++ incubator/ode/trunk/bpel-store/pom.xml Wed Jan 24 17:28:36 2007 @@ -79,7 +79,6 @@ <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> - <version>2.0.2</version> <scope>compile</scope> </dependency> <dependency> Modified: incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/DeploymentUnitTest.java URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/DeploymentUnitTest.java?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/DeploymentUnitTest.java (original) +++ incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/DeploymentUnitTest.java Wed Jan 24 17:28:36 2007 @@ -18,13 +18,14 @@ * Test some complicated xsd/wsdl loading. */ public void setUp() throws Exception { - File dir = new File(getClass().getResource("/complexImport/deploy.xml").getPath()).getParentFile(); +// File dir = new File(getClass().getResource("/complexImport/deploy.xml").getPath()).getParentFile(); + File dir = new File("/tmp/relative-include/build/"); du = new DeploymentUnitDir(dir); } public void testRegistry() { DocumentRegistry dr = du.getDocRegistry(); - assertNotNull(dr.getDefinitionForPortType(new QName("http://ode/bpel/unit-test.wsdl","HelloPortType"))); + //assertNotNull(dr.getDefinitionForPortType(new QName("http://ode/bpel/unit-test.wsdl","HelloPortType"))); } public void testCompile() { Modified: incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseDAOTest.java URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseDAOTest.java?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseDAOTest.java (original) +++ incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseDAOTest.java Wed Jan 24 17:28:36 2007 @@ -19,15 +19,11 @@ package org.apache.ode.daohib.bpel; -import java.io.FileInputStream; -import java.util.Properties; - import javax.sql.DataSource; import junit.framework.TestCase; import org.apache.ode.bpel.dao.BpelDAOConnection; -import org.apache.ode.daohib.SessionManager; import org.objectweb.jotm.Jotm; /** @@ -43,15 +39,15 @@ private DataSource ds; protected void initTM() throws Exception { - Properties hibProps = new Properties(); - hibProps.load(new FileInputStream("../dao-hibernate/src/hibernate/derby.properties")); - + jotm = new Jotm(true, false); ds = getDataSource(); - SessionManager sessMgr = new SessionManager(hibProps, ds, jotm.getTransactionManager()); jotm.getTransactionManager().begin(); - BpelDAOConnectionFactoryImpl factoryImpl = new BpelDAOConnectionFactoryImpl(); + BpelDAOConnectionFactoryImpl factoryImpl = new BpelDAOConnectionFactoryImpl(); + factoryImpl.setTransactionManager(jotm.getTransactionManager()); + factoryImpl.setDataSource(ds); + daoConn = factoryImpl.getConnection(); } Modified: incubator/ode/trunk/dao-jpa-ojpa-derby/pom.xml URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-jpa-ojpa-derby/pom.xml?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/dao-jpa-ojpa-derby/pom.xml (original) +++ incubator/ode/trunk/dao-jpa-ojpa-derby/pom.xml Wed Jan 24 17:28:36 2007 @@ -87,13 +87,6 @@ <version>${derbyVersion}</version> <scope>compile</scope> </dependency> - <dependency> - <groupId>commons-dbcp</groupId> - <artifactId>commons-dbcp</artifactId> - <version>1.2.1</version> - <scope>compile</scope> - </dependency> - </dependencies> <build> @@ -129,6 +122,15 @@ </goals> </execution> </executions> + <dependencies> + + <dependency> + <groupId>commons-dbcp</groupId> + <artifactId>commons-dbcp</artifactId> + <version>1.2.1</version> + </dependency> + + </dependencies> </plugin> <plugin> Modified: incubator/ode/trunk/distro-axis2/build.xml URL: http://svn.apache.org/viewvc/incubator/ode/trunk/distro-axis2/build.xml?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/distro-axis2/build.xml (original) +++ incubator/ode/trunk/distro-axis2/build.xml Wed Jan 24 17:28:36 2007 @@ -15,6 +15,7 @@ <target name="stage" depends="init" description="stage a distribution"> <mkdir dir="${stage}" /> <antcall target="_stage_license" /> + <antcall target="_stage_examples" /> </target> <target name="_stage_license"> @@ -27,4 +28,10 @@ </copy> </target> + <target name="_stage_examples"> + <mkdir dir="${stage}/examples" /> + <copy todir="${stage}/examples" overwrite="true"> + <fileset dir="src/examples"/> + </copy> + </target> </project> Modified: incubator/ode/trunk/distro-axis2/pom.xml URL: http://svn.apache.org/viewvc/incubator/ode/trunk/distro-axis2/pom.xml?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/distro-axis2/pom.xml (original) +++ incubator/ode/trunk/distro-axis2/pom.xml Wed Jan 24 17:28:36 2007 @@ -49,13 +49,6 @@ <classifier>tar</classifier> <version>${project.version}</version> </dependency> - <dependency> - <groupId>org.apache.ode</groupId> - <artifactId>ode-axis2-examples</artifactId> - <type>tar</type> - <classifier>tar</classifier> - <version>${project.version}</version> - </dependency> <dependency> <groupId>commons-codec</groupId> Modified: incubator/ode/trunk/distro-axis2/src/main/assembly/assembly.xml URL: http://svn.apache.org/viewvc/incubator/ode/trunk/distro-axis2/src/main/assembly/assembly.xml?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/distro-axis2/src/main/assembly/assembly.xml (original) +++ incubator/ode/trunk/distro-axis2/src/main/assembly/assembly.xml Wed Jan 24 17:28:36 2007 @@ -38,7 +38,6 @@ <scope>runtime</scope> <outputDirectory/> <includes> - <include>org.apache.ode:ode-axis2-examples</include> <include>org.apache.ode:ode-tools-bin</include> </includes> <unpack>true</unpack> Modified: incubator/ode/trunk/distro-jbi/build.xml URL: http://svn.apache.org/viewvc/incubator/ode/trunk/distro-jbi/build.xml?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/distro-jbi/build.xml (original) +++ incubator/ode/trunk/distro-jbi/build.xml Wed Jan 24 17:28:36 2007 @@ -15,6 +15,7 @@ <target name="stage" depends="init" description="stage a distribution"> <mkdir dir="${stage}" /> <antcall target="_stage_license" /> + <antcall target="_stage_examples" /> </target> <target name="_stage_license"> @@ -24,6 +25,12 @@ <include name="NOTICE"/> <include name="DISCLAIMER"/> </fileset> + </copy> + </target> + <target name="_stage_examples"> + <mkdir dir="${stage}/examples" /> + <copy todir="${stage}/examples" overwrite="true"> + <fileset dir="src/examples"/> </copy> </target> Modified: incubator/ode/trunk/distro-jbi/pom.xml URL: http://svn.apache.org/viewvc/incubator/ode/trunk/distro-jbi/pom.xml?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/distro-jbi/pom.xml (original) +++ incubator/ode/trunk/distro-jbi/pom.xml Wed Jan 24 17:28:36 2007 @@ -49,13 +49,6 @@ <classifier>tar</classifier> <version>${project.version}</version> </dependency> - <dependency> - <groupId>org.apache.ode</groupId> - <artifactId>ode-jbi-examples</artifactId> - <type>tar</type> - <classifier>tar</classifier> - <version>${project.version}</version> - </dependency> <dependency> <groupId>commons-codec</groupId> Modified: incubator/ode/trunk/distro-jbi/src/main/assembly/assembly.xml URL: http://svn.apache.org/viewvc/incubator/ode/trunk/distro-jbi/src/main/assembly/assembly.xml?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/distro-jbi/src/main/assembly/assembly.xml (original) +++ incubator/ode/trunk/distro-jbi/src/main/assembly/assembly.xml Wed Jan 24 17:28:36 2007 @@ -38,7 +38,6 @@ <scope>runtime</scope> <outputDirectory/> <includes> - <include>org.apache.ode:ode-jbi-examples</include> <include>org.apache.ode:ode-tools-bin</include> </includes> <unpack>true</unpack> Modified: incubator/ode/trunk/jacob/pom.xml URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jacob/pom.xml?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/jacob/pom.xml (original) +++ incubator/ode/trunk/jacob/pom.xml Wed Jan 24 17:28:36 2007 @@ -52,7 +52,7 @@ <plugin> <groupId>org.apache.myfaces.tobago</groupId> <artifactId>maven-apt-plugin</artifactId> - <version>1.0.8</version> + <version>1.0.7</version> <executions> <execution> <phase>generate-sources</phase> Modified: incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java (original) +++ incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java Wed Jan 24 17:28:36 2007 @@ -232,7 +232,7 @@ _ode._mexContext = new MessageExchangeContextImpl(_ode); _ode._executorService = Executors.newCachedThreadPool(); _ode._scheduler = new QuartzSchedulerImpl(); - _ode._scheduler.setBpelServer(_ode._server); + _ode._scheduler.setJobProcessor(_ode._server); _ode._scheduler.setExecutorService(_ode._executorService, 20); _ode._scheduler.setTransactionManager((TransactionManager) _ode .getContext().getTransactionManager()); Modified: incubator/ode/trunk/pom.xml URL: http://svn.apache.org/viewvc/incubator/ode/trunk/pom.xml?view=diff&rev=499638&r1=499637&r2=499638 ============================================================================== --- incubator/ode/trunk/pom.xml (original) +++ incubator/ode/trunk/pom.xml Wed Jan 24 17:28:36 2007 @@ -106,11 +106,9 @@ | --> <modules> - <module>jbi-examples</module> <module>tools-bin</module> <module>axis2</module> <module>axis2-war</module> - <module>axis2-examples</module> <module>utils</module> <module>minerva</module> @@ -266,7 +264,7 @@ --> <repositories> <repository> - <id>intalio</id> + <id>central</id> <name>ODE Maven2 repository</name> <url>http://pxe.intalio.org/public/maven2</url> <snapshots> @@ -274,6 +272,18 @@ <updatePolicy>never</updatePolicy> </snapshots> </repository> + <repository> + <id>central-maven</id> + <name>Maven Repository Switchboard</name> + <url>http://repo1.maven.org/maven2</url> + <snapshots> + <enabled>false</enabled> + <updatePolicy>never</updatePolicy> + </snapshots> + </repository> + +<!-- Rely only on Intalio repository, prevents maven madness. + <repository> <id>apache-incubator</id> <name>Apache Incubator Repository</name> @@ -284,15 +294,6 @@ </snapshots> </repository> <repository> - <id>central</id> - <name>Maven Repository Switchboard</name> - <url>http://repo1.maven.org/maven2</url> - <snapshots> - <enabled>false</enabled> - <updatePolicy>never</updatePolicy> - </snapshots> - </repository> - <repository> <id>ibiblio</id> <name>ibiblio</name> <url>http://www.ibiblio.org/maven2</url> @@ -328,19 +329,23 @@ <updatePolicy>never</updatePolicy> </snapshots> </repository> +--> </repositories> <pluginRepositories> <pluginRepository> - <id>intalio</id> + <id>central</id> <name>Intalio Maven2 repository</name> <url>http://pxe.intalio.org/public/maven2</url> </pluginRepository> <pluginRepository> - <id>central</id> + <id>central-maven</id> <name>Maven Repository Switchboard</name> <url>http://repo1.maven.org/maven2</url> </pluginRepository> + +<!-- Safe sex.... + <pluginRepository> <id>codehaus</id> <name>Maven Central Plugins Development Repository</name> @@ -361,6 +366,9 @@ <name>Apache Snapshot Repository</name> <url>http://people.apache.org/repo/m2-snapshot-repository</url> </pluginRepository> +--> + + </pluginRepositories> @@ -479,11 +487,6 @@ <artifactId>ode-jbi-install</artifactId> <version>${project.version}</version> <type>zip</type> - </dependency> - <dependency> - <groupId>org.apache.ode</groupId> - <artifactId>ode-jbi-examples</artifactId> - <version>${project.version}</version> </dependency> <dependency> <groupId>org.apache.ode</groupId>