tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1101369 - in /tuscany/sca-java-2.x/trunk/modules: core-spi/src/main/java/org/apache/tuscany/sca/runtime/ core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/ domain-...
Date Tue, 10 May 2011 08:59:42 GMT
Author: antelder
Date: Tue May 10 08:59:41 2011
New Revision: 1101369

URL: http://svn.apache.org/viewvc?rev=1101369&view=rev
Log:
Update the registry to support getting the QName and Composite, and use that in teh hazelcast
registry to manage the running composites

Modified:
    tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
    tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
    tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
    tuscany/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java

Modified: tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java?rev=1101369&r1=1101368&r2=1101369&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
Tue May 10 08:59:41 2011
@@ -82,5 +82,6 @@ public interface EndpointRegistry {
 
     void addRunningComposite(Composite composite);
     void removeRunningComposite(QName name);
-    List<Composite> getRunningComposites();
+    Composite getRunningComposite(QName name);
+    List<QName> getRunningCompositeNames();
 }

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java?rev=1101369&r1=1101368&r2=1101369&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
Tue May 10 08:59:41 2011
@@ -172,8 +172,17 @@ public class EndpointRegistryImpl extend
     }
 
     @Override
-    public List<Composite> getRunningComposites() {
-        return new ArrayList<Composite>(runningComposites.values());
+    public Composite getRunningComposite(QName name) {
+        return runningComposites.get(name);
+    }
+
+    @Override
+    public List<QName> getRunningCompositeNames() {
+        List<QName> compositeNames = new ArrayList<QName>();
+        for (Composite composite : runningComposites.values()) {
+            compositeNames.add(composite.getName());
+        }
+        return compositeNames;
     }
 
 }

Modified: tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java?rev=1101369&r1=1101368&r2=1101369&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
Tue May 10 08:59:41 2011
@@ -846,7 +846,12 @@ public class DeployerImpl implements Dep
         }
 
         @Override
-        public List<Composite> getRunningComposites() {
+        public Composite getRunningComposite(QName name) {
+            return null;
+        }
+
+        @Override
+        public List<QName> getRunningCompositeNames() {
             return null;
         }
 

Modified: tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java?rev=1101369&r1=1101368&r2=1101369&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
Tue May 10 08:59:41 2011
@@ -25,7 +25,6 @@ import java.io.StringReader;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -82,12 +81,16 @@ public class HazelcastEndpointRegistry e
     private final static Logger logger = Logger.getLogger(HazelcastEndpointRegistry.class.getName());
 
     private HazelcastInstance hazelcastInstance;
+
     protected Map<Object, Object> endpointMap;
-    protected Map<Object, Object> endpointWsdls;
-    protected Map<QName, Composite> runningComposites;
-    protected Map<String, Endpoint> localEndpoints = new ConcurrentHashMap<String,
Endpoint>();
     protected MultiMap<String, String> endpointOwners;
 
+    protected Map<QName, String> runningComposites;
+    protected MultiMap<String, QName> runningCompositeOwners;
+
+    protected Map<Object, Object> endpointWsdls;
+    protected Map<String, Endpoint> localEndpoints = new ConcurrentHashMap<String,
Endpoint>();
+    
     protected AssemblyFactory assemblyFactory;
     protected Object shutdownMutex = new Object();
     protected Properties properties;
@@ -126,9 +129,8 @@ public class HazelcastEndpointRegistry e
             endpointOwners = hazelcastInstance.getMultiMap(domainURI + "/EndpointOwners");
             endpointWsdls = hazelcastInstance.getMap(domainURI + "/EndpointWsdls");
 
-            // TODO: get going in-JVM first then fix this which needs to serialize/deserialize
the composite
-            // runningComposites = hazelcastInstance.getMap(domainURI + "/composites");
-            runningComposites = new HashMap<QName, Composite>();
+            runningComposites = hazelcastInstance.getMap(domainURI + "/CompositeOwners");
+            runningCompositeOwners = hazelcastInstance.getMultiMap(domainURI + "/CompositeOwners");
 
             hazelcastInstance.getCluster().addMembershipListener(this);
 //        }
@@ -142,6 +144,8 @@ public class HazelcastEndpointRegistry e
                 endpointMap = null;
                 endpointOwners = null;
                 endpointWsdls = null;
+                runningComposites = null;
+                runningCompositeOwners = null;
             }
         }
     }
@@ -434,6 +438,12 @@ public class HazelcastEndpointRegistry e
                                 endpointWsdls.remove(k);
                             }
                         }
+                        if (runningCompositeOwners.containsKey(memberAddr)) {
+                            Collection<QName> keys = runningCompositeOwners.remove(memberAddr);
+                            for (QName k : keys) {
+                                runningComposites.remove(k);
+                            }
+                        }
                     } finally {
                         lock.unlock();
                     }
@@ -465,18 +475,46 @@ public class HazelcastEndpointRegistry e
         }
         return null;
     }
+
     @Override
     public void addRunningComposite(Composite composite) {
-        runningComposites.put(composite.getName(), composite);
+        String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
+        String compositeXML = ""; // TODO: serialize composite
+        Transaction txn = hazelcastInstance.getTransaction();
+        txn.begin();
+        try {
+            runningComposites.put(composite.getName(), compositeXML);
+            runningCompositeOwners.put(localMemberAddr, composite.getName());
+            txn.commit();
+        } catch (Throwable e) {
+            txn.rollback();
+            throw new ServiceRuntimeException(e);
+        }
     }
 
     @Override
     public void removeRunningComposite(QName name) {
-        runningComposites.remove(name);
+        String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
+        Transaction txn = hazelcastInstance.getTransaction();
+        txn.begin();
+        try {
+            runningComposites.remove(name);
+            runningCompositeOwners.remove(localMemberAddr, name);
+            txn.commit();
+        } catch (Throwable e) {
+            txn.rollback();
+            throw new ServiceRuntimeException(e);
+        }
+    }
+
+    @Override
+    public Composite getRunningComposite(QName name) {
+        String compositeXML = runningComposites.get(name);
+        return null; // TODO: unserialize composite xml
     }
 
     @Override
-    public List<Composite> getRunningComposites() {
-        return new ArrayList<Composite>(runningComposites.values());
+    public List<QName> getRunningCompositeNames() {
+        return new ArrayList<QName>(runningCompositeOwners.values());
     }
 }

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java?rev=1101369&r1=1101368&r2=1101369&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
Tue May 10 08:59:41 2011
@@ -222,8 +222,8 @@ public class NodeImpl implements Node {
         domainComposite.setAutowire(false);
         domainComposite.setLocal(false);
         List<Composite> domainIncludes = domainComposite.getIncludes();
-        for (Composite composite : endpointRegistry.getRunningComposites()) {
-            domainIncludes.add(composite);
+        for (QName compositeName : endpointRegistry.getRunningCompositeNames()) {
+            domainIncludes.add(endpointRegistry.getRunningComposite(compositeName));
         }
         return domainComposite;
     }

Modified: tuscany/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java?rev=1101369&r1=1101368&r2=1101369&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
Tue May 10 08:59:41 2011
@@ -433,7 +433,13 @@ public class ReplicatedEndpointRegistry 
     }
 
     @Override
-    public List<Composite> getRunningComposites() {
+    public Composite getRunningComposite(QName name) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public List<QName> getRunningCompositeNames() {
         // TODO Auto-generated method stub
         return null;
     }



Mime
View raw message