ode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sath...@apache.org
Subject [06/30] ode git commit: retire previous processes
Date Fri, 06 Nov 2015 10:51:01 GMT
retire previous processes


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

Branch: refs/heads/ODE-563
Commit: b4cd9a483bce77070cb21231296ad89c3e8b4593
Parents: 0b19e7e
Author: suba <suba.11@cse.mrt.ac.lk>
Authored: Mon Jun 15 00:19:23 2015 +0530
Committer: suba <suba.11@cse.mrt.ac.lk>
Committed: Mon Jun 15 00:19:23 2015 +0530

----------------------------------------------------------------------
 .../ode/store/ClusterProcessStoreImpl.java      | 37 +++++++++++++++-----
 .../org/apache/ode/store/ProcessStoreImpl.java  |  4 +++
 2 files changed, 33 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ode/blob/b4cd9a48/bpel-store/src/main/java/org/apache/ode/store/ClusterProcessStoreImpl.java
----------------------------------------------------------------------
diff --git a/bpel-store/src/main/java/org/apache/ode/store/ClusterProcessStoreImpl.java b/bpel-store/src/main/java/org/apache/ode/store/ClusterProcessStoreImpl.java
index f364fb7..7f79a8b 100644
--- a/bpel-store/src/main/java/org/apache/ode/store/ClusterProcessStoreImpl.java
+++ b/bpel-store/src/main/java/org/apache/ode/store/ClusterProcessStoreImpl.java
@@ -20,6 +20,8 @@ package org.apache.ode.store;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.iapi.ProcessConf;
+import org.apache.ode.bpel.iapi.ProcessState;
 import org.apache.ode.clustering.hazelcast.HazelcastClusterImpl;
 import org.apache.ode.bpel.iapi.EndpointReferenceContext;
 import org.apache.ode.il.config.OdeConfigProperties;
@@ -27,9 +29,7 @@ import org.apache.ode.il.config.OdeConfigProperties;
 import javax.sql.DataSource;
 import javax.xml.namespace.QName;
 import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Collection;
+import java.util.*;
 
 import com.hazelcast.core.*;
 
@@ -39,6 +39,8 @@ public class ClusterProcessStoreImpl extends ProcessStoreImpl{
     private HazelcastInstance _hazelcastInstance;
     private Member deployInitiator;
     private ITopic<String> clusterMessageTopic;
+    private final ArrayList<ProcessConfImpl> loaded = new ArrayList<ProcessConfImpl>();
+
 
     public ClusterProcessStoreImpl(EndpointReferenceContext eprContext, DataSource ds, String
persistenceType, OdeConfigProperties props, boolean createDatamodel, HazelcastClusterImpl
hazelcastClusterImpl) {
         super(eprContext,ds,persistenceType,props,createDatamodel);
@@ -51,6 +53,10 @@ public class ClusterProcessStoreImpl extends ProcessStoreImpl{
 
     public Collection<QName> deploy(final File deploymentUnitDirectory) {
         Collection<QName> deployed = super.deploy(deploymentUnitDirectory);
+        Map<QName, ProcessConfImpl> _processes = getProcessesMap();
+        for (QName key :_processes.keySet()) {
+            if(!loaded.contains(_processes.get(key))) loaded.add(_processes.get(key));
+        }
         publishProcessStoreDeployedEvent(deploymentUnitDirectory.getName());
         return deployed;
     }
@@ -60,14 +66,29 @@ public class ClusterProcessStoreImpl extends ProcessStoreImpl{
         clusterMessageTopic.publish("Deployed " +duName);
     }
 
+    //have to write code for retire previous versions
     public void publishService(final String duName) {
-        final ArrayList<ProcessConfImpl> loaded = new ArrayList<ProcessConfImpl>();
+        final ArrayList<ProcessConfImpl> confs = new ArrayList<ProcessConfImpl>();
+        String namePart = duName.split("-")[0];
+        ProcessState state = ProcessState.ACTIVE;
+
+        for (Iterator<ProcessConfImpl> iterator = loaded.iterator(); iterator.hasNext();)
{
+            ProcessConfImpl pconf = iterator.next();
+            if (pconf.getPackage().contains(namePart) && pconf.getState().equals(state))
{
+                  pconf.setState(ProcessState.RETIRED);
+                  confs.add(pconf);
+            }
+        }
+
         try {
             exec(new Callable<Object>() {
                 public Object call(ConfStoreConnection conn) {
                     DeploymentUnitDAO dudao = conn.getDeploymentUnit(duName);
                     if (dudao != null) {
-                        loaded.addAll(load(dudao));
+                        List<ProcessConfImpl> load = load(dudao);
+                        loaded.addAll(load);
+                        confs.addAll(load);
+
                     }
                     return null;
                 }
@@ -76,13 +97,14 @@ public class ClusterProcessStoreImpl extends ProcessStoreImpl{
             __log.error("Error loading DU from store: " + duName, ex);
         }
 
-        for (ProcessConfImpl p : loaded) {
+        for (ProcessConfImpl p : confs) {
             try {
                 fireStateChange(p.getProcessId(), p.getState(), p.getDeploymentUnit().getName());
             } catch (Exception except) {
                 __log.error("Error while activating process: pid=" + p.getProcessId() + "
package="+p.getDeploymentUnit().getName(), except);
             }
         }
+        //loadAll();
     }
 
     class ClusterMessageListener implements MessageListener<String> {
@@ -96,9 +118,8 @@ public class ClusterProcessStoreImpl extends ProcessStoreImpl{
                     __log.info("Receive deployment msg to " +_hazelcastInstance.getCluster().getLocalMember()
+" for " +duName);
                     publishService(duName);
                 }
+                else deployInitiator = null;
             }
         }
     }
-
-
 }

http://git-wip-us.apache.org/repos/asf/ode/blob/b4cd9a48/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
----------------------------------------------------------------------
diff --git a/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java b/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
index 1a99ef6..d6f76f3 100644
--- a/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
+++ b/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
@@ -899,4 +899,8 @@ public class ProcessStoreImpl implements ProcessStore {
             }
         }
     }
+
+    protected Map<QName, ProcessConfImpl> getProcessesMap() {
+        return _processes;
+    }
 }


Mime
View raw message