Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java Fri Apr 3 18:06:37 2009 @@ -21,7 +21,6 @@ import java.io.InputStream; import java.net.URI; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -33,6 +32,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.ode.agents.memory.SizingAgent; import org.apache.ode.bpel.common.FaultException; import org.apache.ode.bpel.common.ProcessState; import org.apache.ode.bpel.dao.BpelDAOConnection; @@ -50,6 +50,7 @@ import org.apache.ode.bpel.iapi.PartnerRoleChannel; import org.apache.ode.bpel.iapi.ProcessConf; import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY; +import org.apache.ode.bpel.intercept.InstanceCountThrottler; import org.apache.ode.bpel.intercept.InterceptorInvoker; import org.apache.ode.bpel.intercept.MessageExchangeInterceptor; import org.apache.ode.bpel.o.OElementVarType; @@ -61,7 +62,6 @@ import org.apache.ode.bpel.runtime.ExpressionLanguageRuntimeRegistry; import org.apache.ode.bpel.runtime.PROCESS; import org.apache.ode.bpel.runtime.PropertyAliasEvaluationContext; -import org.apache.ode.bpel.runtime.InvalidProcessException; import org.apache.ode.bpel.runtime.channels.FaultData; import org.apache.ode.jacob.soup.ReplacementMap; import org.apache.ode.utils.ObjectPrinter; @@ -123,11 +123,20 @@ private ExternalVariableManager _evm; + public static final QName PROP_PATH = new QName("PATH"); + public static final QName PROP_SVG = new QName("SVG"); + public static final QName PROP_LAZY_HYDRATE = new QName("process.hydration.lazy"); + public static final QName PROP_MAX_INSTANCES = new QName("process.instance.throttled.maximum.count"); + + // The ratio of in-memory vs serialized size of compiled bpel object. + private static final int PROCESS_MEMORY_TO_SERIALIZED_SIZE_RATIO = 5; + public BpelProcess(ProcessConf conf) { _pid = conf.getProcessId(); _pconf = conf; _hydrationLatch = new HydrationLatch(); } + /** * Retrives the base URI to use for local resource resolution. @@ -358,8 +367,8 @@ * message exchange * @return <code>true</code> if execution should continue, <code>false</code> otherwise */ - boolean processInterceptors(MyRoleMessageExchangeImpl mex, InterceptorInvoker invoker) { - InterceptorContextImpl ictx = new InterceptorContextImpl(_engine._contexts.dao.getConnection(), getProcessDAO(), _pconf); + public boolean processInterceptors(MyRoleMessageExchangeImpl mex, InterceptorInvoker invoker) { + InterceptorContextImpl ictx = new InterceptorContextImpl(_engine._contexts.dao.getConnection(), getProcessDAO(), _pconf, _engine, this); for (MessageExchangeInterceptor i : _mexInterceptors) if (!mex.processInterceptor(i, mex, ictx, invoker)) @@ -390,26 +399,7 @@ __log.debug("InvokeInternal event for mexid " + we.getMexId()); } MyRoleMessageExchangeImpl mex = (MyRoleMessageExchangeImpl) _engine.getMessageExchange(we.getMexId()); - try { - invokeProcess(mex); - } catch (InvalidProcessException e) { - // we're invoking a target process, trying to see if we can retarget the message - // to the current version (only applies when it's a new process creation) - if (e.getCauseCode() == InvalidProcessException.RETIRED_CAUSE_CODE) { - boolean found = false; - for (BpelProcess process : getEngine()._activeProcesses.values()) { - if (process.getConf().getState().equals(org.apache.ode.bpel.iapi.ProcessState.ACTIVE) - && process.getConf().getType().equals(getConf().getType())) { - we.setProcessId(process._pid); - mex._process = process; - found = true; - process.handleWorkEvent(jobData); - break; - } - } - if (!found) throw e; - } else throw e; - } + invokeProcess(mex); } else { // Instance level events ProcessInstanceDAO procInstance = getProcessDAO().getInstance(we.getIID()); @@ -550,6 +540,9 @@ _sharedEps = _engine.getSharedEndpoints(); _debugger = createDebuggerSupport(); + if (getInstanceMaximumCount() < Integer.MAX_VALUE) + registerMessageExchangeInterceptor(new InstanceCountThrottler()); + __log.debug("Activating " + _pid); // Activate all the my-role endpoints. for (Map.Entry<String, Endpoint> entry : _pconf.getProvideEndpoints().entrySet()) { @@ -560,7 +553,7 @@ initialEPR = _sharedEps.getEndpointReference(endpoint); if (initialEPR == null) { // Create an EPR by physically activating the endpoint - initialEPR = _engine._contexts.bindingContext.activateMyRoleEndpoint(_pid, entry.getValue()); + initialEPR = _engine._contexts.bindingContext.activateMyRoleEndpoint(_pid, endpoint); _sharedEps.addEndpoint(endpoint, initialEPR); __log.debug("Activated " + _pid + " myrole " + entry.getKey() + ": EPR is " + initialEPR); } @@ -568,7 +561,7 @@ _sharedEps.incrementReferenceCount(endpoint); } else { // Create an EPR by physically activating the endpoint - initialEPR = _engine._contexts.bindingContext.activateMyRoleEndpoint(_pid, entry.getValue()); + initialEPR = _engine._contexts.bindingContext.activateMyRoleEndpoint(_pid, endpoint); __log.debug("Activated " + _pid + " myrole " + entry.getKey() + ": EPR is " + initialEPR); } _myEprs.put(endpoint, initialEPR); @@ -637,7 +630,7 @@ } } - protected QName getPID() { + public QName getPID() { return _pid; } @@ -891,7 +884,7 @@ __log.error(errmsg); throw new BpelEngineException(errmsg, e); } - + if (_partnerRoles == null) { _partnerRoles = new HashMap<OPartnerLink, PartnerLinkPartnerRoleImpl>(); } @@ -937,6 +930,7 @@ + prole._initialEPR); } } + _engine.setProcessSize(_pid, true); _hydratedOnce = true; } @@ -975,12 +969,17 @@ } catch (Exception ex) { String errmsg = "DbError"; __log.error(errmsg, ex); + ex.printStackTrace(); throw new BpelEngineException(errmsg, ex); } } } } + + public int getInstanceInUseCount() { + return hintIsHydrated() ? _hydrationLatch.getDepth(1) : 0; + } private void registerExprLang(OProcess oprocess) { for (OExpressionLanguage elang : oprocess.expressionLanguages) { @@ -1039,8 +1038,59 @@ } private boolean hasActiveInstances(ProcessDAO processDAO) { - Collection<ProcessInstanceDAO> activeInstances = processDAO.getActiveInstances(); - return (activeInstances != null && activeInstances.size() > 0); + // Select count of instances instead of all active instances + // Collection<ProcessInstanceDAO> activeInstances = processDAO.getActiveInstances(); + // return (activeInstances != null && activeInstances.size() > 0); + return processDAO.getNumInstances() > 0; + } + + public void registerMessageExchangeInterceptor(MessageExchangeInterceptor interceptor) { + _mexInterceptors.add(interceptor); + } + + public void unregisterMessageExchangeInterceptor(MessageExchangeInterceptor interceptor) { + _mexInterceptors.remove(interceptor); + } + + public long sizeOf() { + // try to get actual size from sizing agent, if enabled + long footprint = SizingAgent.deepSizeOf(this); + // if unsuccessful, estimate size (this is a inaccurate guess) + if (footprint == 0) { + footprint = getEstimatedHydratedSize(); + } + // add the sizes of all the services this process provides + for (EndpointReference myEpr : _myEprs.values()) { + footprint += _engine._contexts.bindingContext.calculateSizeofService(myEpr); + } + // return the total footprint + return footprint; + } + + public String getProcessProperty(QName property, String defaultValue) { + Text text = (Text) getProcessProperty(property); + if (text == null) { + return defaultValue; + } + String value = text.getWholeText(); + return (value == null) ? defaultValue : value; + } + + public boolean isHydrationLazy() { + return Boolean.valueOf(getProcessProperty(PROP_LAZY_HYDRATE, "true")); + } + + public boolean isHydrationLazySet() { + return getProcessProperty(PROP_LAZY_HYDRATE) != null; + } + + public int getInstanceMaximumCount() { + return Integer.valueOf(getProcessProperty(PROP_MAX_INSTANCES, Integer.toString(_engine.getInstanceThrottledMaximumCount()))); + } + + public long getEstimatedHydratedSize() { + return _pconf.getCBPFileSize() * + PROCESS_MEMORY_TO_SERIALIZED_SIZE_RATIO; } public long getTimeout(OPartnerLink partnerLink) {
Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java Fri Apr 3 18:06:37 2009 @@ -24,6 +24,7 @@ import java.util.*; import javax.wsdl.Operation; +import javax.wsdl.OperationType; import javax.xml.namespace.QName; import org.apache.commons.logging.Log; Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java Fri Apr 3 18:06:37 2009 @@ -88,9 +88,10 @@ private State _state = State.SHUTDOWN; private Contexts _contexts = new Contexts(); + private Properties _configProperties; private DehydrationPolicy _dehydrationPolicy; private boolean _hydrationLazy; - private Properties _configProperties; + private int _hydrationLazyMinimumSize; BpelEngineImpl _engine; protected BpelDatabase _db; @@ -289,8 +290,10 @@ _engine.registerProcess(process); _registeredProcesses.add(process); - if (!_hydrationLazy) { + if (!isLazyHydratable(process)) { process.hydrate(); + } else { + _engine.setProcessSize(process.getPID(), false); } __log.info(__msgs.msgProcessRegistered(conf.getProcessId())); @@ -298,6 +301,16 @@ _mngmtLock.writeLock().unlock(); } } + + private boolean isLazyHydratable(BpelProcess process) { + if (process.isHydrationLazySet()) { + return process.isHydrationLazy(); + } + if (!_hydrationLazy) { + return false; + } + return process.getEstimatedHydratedSize() < _hydrationLazyMinimumSize; + } // enable extensibility protected BpelProcess createBpelProcess(ProcessConf conf) { @@ -343,7 +356,7 @@ */ public void registerMessageExchangeInterceptor(MessageExchangeInterceptor interceptor) { // NOTE: do not synchronize, globalInterceptors is copy-on-write. - _contexts.globalIntereceptors.add(interceptor); + _contexts.globalInterceptors.add(interceptor); } /** @@ -352,7 +365,7 @@ */ public void unregisterMessageExchangeInterceptor(MessageExchangeInterceptor interceptor) { // NOTE: do not synchronize, globalInterceptors is copy-on-write. - _contexts.globalIntereceptors.remove(interceptor); + _contexts.globalInterceptors.remove(interceptor); } /** @@ -480,4 +493,22 @@ this._hydrationLazy = hydrationLazy; } + public void setProcessThrottledMaximumSize( + long hydrationThrottledMaximumSize) { + _engine.setProcessThrottledMaximumSize(hydrationThrottledMaximumSize); + } + + public void setProcessThrottledMaximumCount( + int hydrationThrottledMaximumCount) { + _engine.setProcessThrottledMaximumCount(hydrationThrottledMaximumCount); + } + + public void setHydrationLazyMinimumSize(int hydrationLazyMinimumSize) { + this._hydrationLazyMinimumSize = hydrationLazyMinimumSize; + } + + public void setInstanceThrottledMaximumCount( + int instanceThrottledMaximumCount) { + _engine.setInstanceThrottledMaximumCount(instanceThrottledMaximumCount); + } } Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java Fri Apr 3 18:06:37 2009 @@ -52,7 +52,7 @@ BpelDAOConnectionFactory inMemDao; /** Global Message-Exchange interceptors. Must be copy-on-write!!! */ - final List<MessageExchangeInterceptor >globalIntereceptors = new CopyOnWriteArrayList<MessageExchangeInterceptor>(); + final List<MessageExchangeInterceptor >globalInterceptors = new CopyOnWriteArrayList<MessageExchangeInterceptor>(); /** Global event listeners. Must be copy-on-write!!! */ final List<BpelEventListener> eventListeners = new CopyOnWriteArrayList<BpelEventListener>(); Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java Fri Apr 3 18:06:37 2009 @@ -20,6 +20,7 @@ import org.apache.ode.bpel.dao.BpelDAOConnection; import org.apache.ode.bpel.dao.ProcessDAO; +import org.apache.ode.bpel.iapi.BpelEngine; import org.apache.ode.bpel.iapi.ProcessConf; import org.apache.ode.bpel.intercept.MessageExchangeInterceptor.InterceptorContext; @@ -33,11 +34,15 @@ private ProcessDAO _processDao; private BpelDAOConnection _connection; private ProcessConf _pconf; + private BpelEngine _bpelEngine; + private BpelProcess _bpelProcess; - public InterceptorContextImpl(BpelDAOConnection connection, ProcessDAO processDAO, ProcessConf pconf) { + public InterceptorContextImpl(BpelDAOConnection connection, ProcessDAO processDAO, ProcessConf pconf, BpelEngine bpelEngine, BpelProcess bpelProcess) { _connection = connection; _processDao = processDAO; _pconf = pconf; + _bpelEngine = bpelEngine; + _bpelProcess = bpelProcess; } public BpelDAOConnection getConnection() { @@ -51,5 +56,13 @@ public ProcessConf getProcessConf() { return _pconf; } + + public BpelEngine getBpelEngine() { + return _bpelEngine; + } + + public BpelProcess getBpelProcess() { + return _bpelProcess; + } } Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MessageExchangeImpl.java Fri Apr 3 18:06:37 2009 @@ -155,6 +155,8 @@ setStatus(Status.FAULT); getDAO().setFault(faultType); getDAO().setResponse(((MessageImpl)outputFaultMessage)._dao); + + responseReceived(); } void setFaultExplanation(String explanation) { Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java Fri Apr 3 18:06:37 2009 @@ -19,6 +19,7 @@ package org.apache.ode.bpel.engine; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.ArrayList; @@ -79,7 +80,7 @@ */ private boolean processInterceptors(MyRoleMessageExchangeImpl mex, InterceptorInvoker invoker) { InterceptorContextImpl ictx = new InterceptorContextImpl(_engine._contexts.dao.getConnection(), - mex._dao.getProcess(), null); + mex._dao.getProcess(), null, _engine, _process); for (MessageExchangeInterceptor i : _engine.getGlobalInterceptors()) if (!processInterceptor(i, mex, ictx, invoker)) @@ -184,7 +185,9 @@ public void release(boolean instanceSucceeded) { if(__log.isDebugEnabled()) __log.debug("Releasing mex " + getMessageExchangeId()); - _dao.release(_process.isCleanupCategoryEnabled(instanceSucceeded, CLEANUP_CATEGORY.MESSAGES)); + if (_process != null) { + _dao.release(_process.isCleanupCategoryEnabled(instanceSucceeded, CLEANUP_CATEGORY.MESSAGES)); + } _dao = null; } Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/NStateLatch.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/NStateLatch.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/NStateLatch.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/NStateLatch.java Fri Apr 3 18:06:37 2009 @@ -119,4 +119,8 @@ _lock.unlock(); } } + + public int getDepth(int state) { + return (_state == state ? _depth : 0); + } } Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java Fri Apr 3 18:06:37 2009 @@ -184,7 +184,7 @@ if (!_process.processInterceptors(mex, InterceptorInvoker.__onNewInstanceInvoked)) { __log.debug("Not creating a new instance for mex " + mex + "; interceptor prevented!"); - return; + throw new InvalidProcessException("Cannot instantiate process '" + _process.getPID() + "' any more.", InvalidProcessException.TOO_MANY_INSTANCES_CAUSE_CODE); } ProcessInstanceDAO newInstance = processDAO.createInstance(routing.correlator); Added: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/InstanceCountThrottler.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/InstanceCountThrottler.java?rev=761744&view=auto ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/InstanceCountThrottler.java (added) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/InstanceCountThrottler.java Fri Apr 3 18:06:37 2009 @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ode.bpel.intercept; + +import org.apache.ode.bpel.iapi.MyRoleMessageExchange; +import org.w3c.dom.Node; +import org.w3c.dom.Text; + +import javax.xml.namespace.QName; +import java.util.Map; + +/** + * An example of a simple interceptor providing a "throttling" capability - that is an + * ability to limit the number of instances created for a given process. + * + * @author Maciej Szefler + */ +public class InstanceCountThrottler extends NoOpInterceptor { + + @Override + public void onNewInstanceInvoked(MyRoleMessageExchange mex, + InterceptorContext ic) throws FailMessageExchangeException { + if (ic.getProcessDAO().getNumInstances() >= ic.getBpelProcess().getInstanceMaximumCount()) + throw new FailMessageExchangeException("Too many instances."); + } +} Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/InterceptorInvoker.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/InterceptorInvoker.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/InterceptorInvoker.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/InterceptorInvoker.java Fri Apr 3 18:06:37 2009 @@ -50,6 +50,14 @@ } }; + /** Invoke {...@link MessageExchangeInterceptor#onBpelServerInvoked(MyRoleMessageExchange, InterceptorContext)} */ + public static final InterceptorInvoker __onJobScheduled = new InterceptorInvoker("onJobScheduled") { + public void invoke(MessageExchangeInterceptor i, MessageExchange mex, InterceptorContext ictx) + throws FailMessageExchangeException, FaultMessageExchangeException { + i.onJobScheduled((MyRoleMessageExchange) mex, ictx); + } + }; + /** Invoke {...@link MessageExchangeInterceptor#onPartnerInvoked(PartnerRoleMessageExchange, InterceptorContext)} */ public static final InterceptorInvoker __onPartnerInvoked = new InterceptorInvoker("onPartnerInvoked") { public void invoke(MessageExchangeInterceptor i, MessageExchange mex, InterceptorContext ictx) Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java Fri Apr 3 18:06:37 2009 @@ -20,6 +20,8 @@ import org.apache.ode.bpel.dao.BpelDAOConnection; import org.apache.ode.bpel.dao.ProcessDAO; +import org.apache.ode.bpel.engine.BpelProcess; +import org.apache.ode.bpel.iapi.BpelEngine; import org.apache.ode.bpel.iapi.MyRoleMessageExchange; import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange; import org.apache.ode.bpel.iapi.ProcessConf; @@ -34,6 +36,16 @@ public interface MessageExchangeInterceptor { /** + * Called when the message is scheduled, before any attempt to + * invoke the BPEL server is made. + * + * @param mex + * message exchange + */ + void onJobScheduled(MyRoleMessageExchange mex, InterceptorContext ic) + throws FailMessageExchangeException, FaultMessageExchangeException; + + /** * Called when the BPEL server is invoked, before any attempt to route the * message exchange to a process. * @@ -82,6 +94,10 @@ ProcessDAO getProcessDAO(); ProcessConf getProcessConf(); + + BpelEngine getBpelEngine(); + + BpelProcess getBpelProcess(); } } Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/NoOpInterceptor.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/NoOpInterceptor.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/NoOpInterceptor.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/NoOpInterceptor.java Fri Apr 3 18:06:37 2009 @@ -31,6 +31,11 @@ */ public class NoOpInterceptor implements MessageExchangeInterceptor { + public void onJobScheduled(MyRoleMessageExchange mex, + InterceptorContext ic) throws FailMessageExchangeException, + FaultMessageExchangeException { + } + public void onBpelServerInvoked(MyRoleMessageExchange mex, InterceptorContext ic) throws FailMessageExchangeException, FaultMessageExchangeException { Added: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ProcessCountThrottler.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ProcessCountThrottler.java?rev=761744&view=auto ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ProcessCountThrottler.java (added) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ProcessCountThrottler.java Fri Apr 3 18:06:37 2009 @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ode.bpel.intercept; + +import org.apache.ode.bpel.iapi.MyRoleMessageExchange; +import org.apache.ode.bpel.runtime.InvalidProcessException; + +/** + * An example of a simple interceptor providing a "throttling" capability - that is an + * ability to limit the size of processes created in a server. + */ +public class ProcessCountThrottler extends NoOpInterceptor { + + @Override + public void onJobScheduled(MyRoleMessageExchange mex, + InterceptorContext ic) throws FailMessageExchangeException, + FaultMessageExchangeException { + while (ic.getBpelEngine().getHydratedProcessCount(ic.getBpelProcess().getPID()) > ic.getBpelEngine().getProcessThrottledMaximumCount()) { + if (!ic.getBpelEngine().dehydrateLastUnusedProcess()) { + mex.setProperty("causeCode", String.valueOf(InvalidProcessException.TOO_MANY_PROCESSES_CAUSE_CODE)); + throw new FailMessageExchangeException("The number of processes in-use is more than the upper limit (" + ic.getBpelEngine().getProcessThrottledMaximumCount() + ")"); + } + } + } +} Added: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ProcessSizeThrottler.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ProcessSizeThrottler.java?rev=761744&view=auto ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ProcessSizeThrottler.java (added) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ProcessSizeThrottler.java Fri Apr 3 18:06:37 2009 @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ode.bpel.intercept; + +import org.apache.ode.bpel.iapi.MyRoleMessageExchange; +import org.apache.ode.bpel.runtime.InvalidProcessException; + +/** + * An example of a simple interceptor providing a "throttling" capability - that is an + * ability to limit the size of processes created in a server. + */ +public class ProcessSizeThrottler extends NoOpInterceptor { + + @Override + public void onJobScheduled(MyRoleMessageExchange mex, + InterceptorContext ic) throws FailMessageExchangeException, + FaultMessageExchangeException { + while (ic.getBpelEngine().getHydratedProcessSize(ic.getBpelProcess().getPID()) > ic.getBpelEngine().getProcessThrottledMaximumSize()) { + if (!ic.getBpelEngine().dehydrateLastUnusedProcess()) { + mex.setProperty("causeCode", String.valueOf(InvalidProcessException.TOO_HUGE_PROCESSES_CAUSE_CODE)); + throw new FailMessageExchangeException("The size of all running processes is more than the upper limit (" + ic.getBpelEngine().getProcessThrottledMaximumSize() + ")"); + } + } + } +} Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/InvalidProcessException.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/InvalidProcessException.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/InvalidProcessException.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/InvalidProcessException.java Fri Apr 3 18:06:37 2009 @@ -31,6 +31,12 @@ public final static int RETIRED_CAUSE_CODE = 1; + public final static int TOO_MANY_INSTANCES_CAUSE_CODE = 2; + + public final static int TOO_MANY_PROCESSES_CAUSE_CODE = 3; + + public final static int TOO_HUGE_PROCESSES_CAUSE_CODE = 4; + private final int causeCode; public InvalidProcessException(String msg, Throwable cause) { Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java Fri Apr 3 18:06:37 2009 @@ -263,6 +263,10 @@ public void close() { }; }; } + + public long calculateSizeofService(EndpointReference epr) { + return 0; + } }; return _bindContext; } Modified: ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-store/src/main/java/org/apache/ode/store/ProcessConfImpl.java Fri Apr 3 18:06:37 2009 @@ -227,6 +227,13 @@ } } + public long getCBPFileSize() { + CBPInfo cbpInfo = _du.getCBPInfo(getType()); + if (cbpInfo == null) + throw new ContextException("CBP record not found for type " + getType()); + return cbpInfo.cbp.length(); + } + public String getBpelDocument() { CBPInfo cbpInfo = _du.getCBPInfo(getType()); if (cbpInfo == null) Modified: ode/branches/APACHE_ODE_1.X/bpel-test/src/main/java/org/apache/ode/test/BindingContextImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/main/java/org/apache/ode/test/BindingContextImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-test/src/main/java/org/apache/ode/test/BindingContextImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-test/src/main/java/org/apache/ode/test/BindingContextImpl.java Fri Apr 3 18:06:37 2009 @@ -73,4 +73,8 @@ return new PartnerRoleChannelImpl(); } + public long calculateSizeofService(EndpointReference epr) { + return 0; + } + } Modified: ode/branches/APACHE_ODE_1.X/bpel-test/src/main/java/org/apache/ode/test/MessageExchangeContextImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/main/java/org/apache/ode/test/MessageExchangeContextImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-test/src/main/java/org/apache/ode/test/MessageExchangeContextImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-test/src/main/java/org/apache/ode/test/MessageExchangeContextImpl.java Fri Apr 3 18:06:37 2009 @@ -38,20 +38,21 @@ package org.apache.ode.test; +import java.io.IOException; + +import javax.xml.namespace.QName; + import org.apache.ode.bpel.iapi.BpelEngineException; import org.apache.ode.bpel.iapi.ContextException; import org.apache.ode.bpel.iapi.Message; -import org.apache.ode.bpel.iapi.MessageExchange.Status; import org.apache.ode.bpel.iapi.MessageExchangeContext; import org.apache.ode.bpel.iapi.MyRoleMessageExchange; import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange; +import org.apache.ode.bpel.iapi.MessageExchange.Status; import org.apache.ode.utils.DOMUtils; import org.w3c.dom.Element; import org.xml.sax.SAXException; -import javax.xml.namespace.QName; -import java.io.IOException; - /** * This is a simple MessageExchangeContext implementation * that only supports a set of "well known" portTypes used Modified: ode/branches/APACHE_ODE_1.X/bpel-test/src/test/java/org/apache/ode/test/BasicActivities20Test.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/test/java/org/apache/ode/test/BasicActivities20Test.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-test/src/test/java/org/apache/ode/test/BasicActivities20Test.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-test/src/test/java/org/apache/ode/test/BasicActivities20Test.java Fri Apr 3 18:06:37 2009 @@ -18,16 +18,16 @@ */ package org.apache.ode.test; -import org.apache.ode.bpel.iapi.ContextException; -import org.apache.ode.bpel.iapi.MessageExchange; -import org.junit.Ignore; -import org.junit.Test; - -import javax.xml.namespace.QName; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; +import javax.xml.namespace.QName; + +import org.apache.ode.bpel.iapi.ContextException; +import org.apache.ode.bpel.iapi.MessageExchange; +import org.junit.Test; + public class BasicActivities20Test extends BPELTestAbstract { @Test public void testHelloWorld2() throws Throwable { Modified: ode/branches/APACHE_ODE_1.X/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java (original) +++ ode/branches/APACHE_ODE_1.X/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java Fri Apr 3 18:06:37 2009 @@ -18,7 +18,6 @@ */ package org.apache.ode.test; -import org.junit.Ignore; import org.junit.Test; public class StructuredActivities20Test extends BPELTestAbstract { Modified: ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ActivityRecoveryDAOImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ActivityRecoveryDAOImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ActivityRecoveryDAOImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ActivityRecoveryDAOImpl.java Fri Apr 3 18:06:37 2009 @@ -75,6 +75,7 @@ private Long _instanceId; // _instances is unused because this is a one-way relationship at the database level + @SuppressWarnings("unused") @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="INSTANCE_ID") private ProcessInstanceDAOImpl _instance; Modified: ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java Fri Apr 3 18:06:37 2009 @@ -54,8 +54,6 @@ @Basic @Column(name="PROCESS_ID") private String _processId; - @Transient - private int _numInstances; @Basic @Column(name="PROCESS_TYPE") private String _processType; @Basic @Column(name="GUID") @@ -94,7 +92,6 @@ CorrelatorDAO instantiatingCorrelator) { ProcessInstanceDAOImpl inst = new ProcessInstanceDAOImpl((CorrelatorDAOImpl)instantiatingCorrelator, this); getEM().persist(inst); - _numInstances++; return inst; } @@ -102,7 +99,6 @@ CorrelatorDAO instantiatingCorrelator, MessageExchangeDAO mex) { ProcessInstanceDAOImpl inst = new ProcessInstanceDAOImpl((CorrelatorDAOImpl)instantiatingCorrelator, this); getEM().persist(inst); - _numInstances++; return inst; } @@ -183,7 +179,8 @@ } public int getNumInstances() { - return _numInstances; + Long instanceCount = (Long) getSingleResult(getEM().createNamedQuery(ProcessInstanceDAOImpl.COUNT_INSTANCE_IDS_BY_PROCESS).setParameter("process", this)); + return (instanceCount == null ? 0 : instanceCount.intValue()); } public long getVersion() { Modified: ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java Fri Apr 3 18:06:37 2009 @@ -65,6 +65,7 @@ @NamedQueries({ @NamedQuery(name=ProcessInstanceDAOImpl.DELETE_INSTANCES_BY_PROCESS, query="delete from ProcessInstanceDAOImpl as i where i._process = :process"), @NamedQuery(name=ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS, query="select i._instanceId from ProcessInstanceDAOImpl as i where i._process = :process"), + @NamedQuery(name=ProcessInstanceDAOImpl.COUNT_INSTANCE_IDS_BY_PROCESS, query="select count(i._instanceId) from ProcessInstanceDAOImpl as i where i._process = :process"), @NamedQuery(name=ProcessInstanceDAOImpl.SELECT_FAULT_IDS_BY_PROCESS, query="select i._faultId from ProcessInstanceDAOImpl as i where i._process = :process and i._faultId is not null"), @NamedQuery(name=ProcessInstanceDAOImpl.COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID, query="select count(i._instanceId), max(i._lastRecovery) from ProcessInstanceDAOImpl as i where i._process._processId = :processId and i._state in(:states) and exists(select r from ActivityRecoveryDAOImpl r where i = r._instance)") @@ -73,7 +74,8 @@ private static final Log __log = LogFactory.getLog(ProcessInstanceDAOImpl.class); public final static String DELETE_INSTANCES_BY_PROCESS = "DELETE_INSTANCES_BY_PROCESS"; - public final static String SELECT_INSTANCE_IDS_BY_PROCESS = "SELECT_INSTANCE_IDS_BY_PROCESS"; + public final static String SELECT_INSTANCE_IDS_BY_PROCESS = "SELECT_INSTANCE_IDS_BY_PROCESS"; public final static String COUNT_INSTANCE_IDS_BY_PROCESS = "COUNT_INSTANCE_IDS_BY_PROCESS"; + public final static String SELECT_FAULT_IDS_BY_PROCESS = "SELECT_FAULT_IDS_BY_PROCESS"; public final static String COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID = "COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID"; Modified: ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/BindingContextImpl.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/BindingContextImpl.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/BindingContextImpl.java (original) +++ ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/BindingContextImpl.java Fri Apr 3 18:06:37 2009 @@ -18,13 +18,20 @@ */ package org.apache.ode.jbi; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.ode.bpel.iapi.*; +import java.util.HashMap; +import java.util.Map; import javax.wsdl.PortType; import javax.xml.namespace.QName; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.ode.bpel.iapi.BindingContext; +import org.apache.ode.bpel.iapi.ContextException; +import org.apache.ode.bpel.iapi.Endpoint; +import org.apache.ode.bpel.iapi.EndpointReference; +import org.apache.ode.bpel.iapi.PartnerRoleChannel; + /** * JBI Implementation of ODE's {...@link org.apache.ode.bpel.iapi.BindingContext} * interface. @@ -36,7 +43,7 @@ private static final Log __log = LogFactory.getLog(BindingContextImpl.class); private final OdeContext _ode; - + BindingContextImpl(OdeContext ode) { _ode = ode; } @@ -92,4 +99,9 @@ } } + + + public long calculateSizeofService(EndpointReference epr) { + return _ode.calculateSizeOfService(epr); + } } Modified: ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java?rev=761744&r1=761743&r2=761744&view=diff ============================================================================== --- ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java (original) +++ ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java Fri Apr 3 18:06:37 2009 @@ -39,10 +39,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.ode.agents.memory.SizingAgent; import org.apache.ode.bpel.dao.BpelDAOConnectionFactory; import org.apache.ode.bpel.engine.BpelServerImpl; import org.apache.ode.bpel.engine.ProcessAndInstanceManagementImpl; import org.apache.ode.bpel.iapi.Endpoint; +import org.apache.ode.bpel.iapi.EndpointReference; import org.apache.ode.bpel.iapi.ProcessConf; import org.apache.ode.bpel.o.OPartnerLink; import org.apache.ode.bpel.o.OProcess; @@ -115,6 +117,8 @@ /** Mapping of Endpoint to OdeService */ private Map<Endpoint, OdeService> _activeOdeServices = new ConcurrentHashMap<Endpoint, OdeService>(); + private Map<OdeService, EndpointReference> _serviceEprMap = new HashMap<OdeService, EndpointReference>(); + /** * Gets the delivery channel. @@ -214,6 +218,7 @@ MyEndpointReference myepr = new MyEndpointReference(service); service.activate(); _activeOdeServices.put(endpoint, service); + _serviceEprMap.put(service, myepr); return myepr; } @@ -222,6 +227,7 @@ OdeService svc = _activeOdeServices.remove(endpoint); if (svc != null) { + _serviceEprMap.remove(svc); svc.deactivate(); } } @@ -303,4 +309,16 @@ } } } + + public long calculateSizeOfService(EndpointReference epr) { + if (epr != null) { + for (OdeService odeService : _serviceEprMap.keySet()) { + EndpointReference serviceEpr = _serviceEprMap.get(odeService); + if (serviceEpr != null && epr.equals(serviceEpr)) { + return SizingAgent.deepSizeOf(odeService); + } + } + } + return 0; + } }
