Repository: ode
Updated Branches:
  refs/heads/ode-1.3.x d5f4fe1d0 -> 4ca976421


ODE-1020: Fixed deactivation of process services for retiring processes.


Project: http://git-wip-us.apache.org/repos/asf/ode/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/4ca97642
Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/4ca97642
Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/4ca97642

Branch: refs/heads/ode-1.3.x
Commit: 4ca9764215004c0badb23262faf5c07b84b42975
Parents: d5f4fe1
Author: sathwik <[email protected]>
Authored: Wed Oct 22 12:04:02 2014 +0530
Committer: sathwik <[email protected]>
Committed: Wed Oct 22 12:04:02 2014 +0530

----------------------------------------------------------------------
 .../apache/ode/bpel/engine/BpelEngineImpl.java  | 37 +++++++++++++++-----
 .../org/apache/ode/bpel/engine/BpelProcess.java | 28 ++++++---------
 2 files changed, 39 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ode/blob/4ca97642/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
----------------------------------------------------------------------
diff --git 
a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java 
b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
index 19584c5..b24c643 100644
--- a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
+++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
@@ -279,19 +279,38 @@ public class BpelEngineImpl implements BpelEngine {
             if (__log.isDebugEnabled())
                 __log.debug("Deactivating process " + p.getPID());
 
-            Iterator<List<BpelProcess>> serviceIter = 
_serviceMap.values().iterator();
-            while (serviceIter.hasNext()) {
-                Iterator<BpelProcess> entryProcesses = 
serviceIter.next().iterator();
-                while (entryProcesses.hasNext()) {
-                    BpelProcess entryProcess = entryProcesses.next();
-                    if (entryProcess.getPID().equals(process)) {
-                        entryProcesses.remove();
+            boolean deactivate = true;
+            Iterator<Endpoint> endpointItr = p.getServiceNames().iterator();
+
+            ProcessState state = null;
+
+            while(endpointItr.hasNext()){
+                Endpoint endPoint = endpointItr.next();
+                List<BpelProcess> processList = 
_serviceMap.get(endPoint.serviceName);
+
+                Iterator<BpelProcess> processListItr = processList.iterator();
+
+                while(processListItr.hasNext()){
+                    BpelProcess entryProcess = processListItr.next();
+                    state = entryProcess.getConf().getState();
+                    // Don't deactivate process services if there is another 
process in Active/Retired state and
+                    // associated with the same service name
+                    if( (ProcessState.ACTIVE.equals(state) || 
ProcessState.RETIRED.equals(state)) &&
+                            !(entryProcess.getPID().equals(p.getPID()))) {
+
+                        deactivate = false;
+                    } else {
+                        if(entryProcess.getPID().equals(process)) {
+                            processListItr.remove();
+                        }
                     }
                 }
             }
 
-            // unregister the services provided by the process
-            p.deactivate();            
+            if(deactivate){
+                // unregister the services provided by the process
+                p.deactivate();
+            }
             // release the resources held by this process
             p.dehydrate();
             // update the process footprints list

http://git-wip-us.apache.org/repos/asf/ode/blob/4ca97642/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
----------------------------------------------------------------------
diff --git 
a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java 
b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
index 3976b85..bbe4cab 100644
--- a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
+++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
@@ -596,27 +596,21 @@ public class BpelProcess {
     }
 
     void deactivate() {
-        // the BindingContext contains only the endpoints for the latest 
process version
-        if 
(org.apache.ode.bpel.iapi.ProcessState.ACTIVE.equals(_pconf.getState())) {
-            // Deactivate all the my-role endpoints.
-            for (Endpoint endpoint : _myEprs.keySet()) {
-                // Deactivate the EPR only if there are no more references
-                // to this endpoint from any (active) BPEL process.
-                if (isShareable(endpoint)) {
-                    if(__log.isDebugEnabled()) __log.debug("deactivating 
shared endpoint " + endpoint+ " for pid "+ _pid);
-                    if (!_sharedEps.decrementReferenceCount(endpoint)) {
-                        
_engine._contexts.bindingContext.deactivateMyRoleEndpoint(endpoint);
-                        _sharedEps.removeEndpoint(endpoint);
-                    }
-                } else {
-                    if(__log.isDebugEnabled()) __log.debug("deactivating 
non-shared endpoint " + endpoint + " for pid "+ _pid);
+        for (Endpoint endpoint : _myEprs.keySet()) {
+            // Deactivate the EPR only if there are no more references
+            // to this endpoint from any (active) BPEL process.
+            if (isShareable(endpoint)) {
+                if(__log.isDebugEnabled()) __log.debug("deactivating shared 
endpoint " + endpoint+ " for pid "+ _pid);
+                if (!_sharedEps.decrementReferenceCount(endpoint)) {
                     
_engine._contexts.bindingContext.deactivateMyRoleEndpoint(endpoint);
+                    _sharedEps.removeEndpoint(endpoint);
                 }
+            } else {
+                if(__log.isDebugEnabled()) __log.debug("deactivating 
non-shared endpoint " + endpoint + " for pid "+ _pid);
+                
_engine._contexts.bindingContext.deactivateMyRoleEndpoint(endpoint);
             }
-            // TODO Deactivate all the partner-role channels
-        } else {
-            if(__log.isDebugEnabled()) __log.debug("pid "+_pid+" is not 
ACTIVE, no endpoints to deactivate");
         }
+        // TODO Deactivate all the partner-role channels
     }
 
     private boolean isShareable(Endpoint endpoint) {

Reply via email to