tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1101468 - 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 14:10:56 GMT
Author: antelder
Date: Tue May 10 14:10:55 2011
New Revision: 1101468

URL: http://svn.apache.org/viewvc?rev=1101468&view=rev
Log:
Start adding info about installed contributions to the registry so that distributed Nodes
can find out about contributions

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/Node.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/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java
    tuscany/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
    tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.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=1101468&r1=1101467&r2=1101468&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 14:10:55 2011
@@ -84,4 +84,9 @@ public interface EndpointRegistry {
     void removeRunningComposite(QName name);
     Composite getRunningComposite(QName name);
     List<QName> getRunningCompositeNames();
+    
+    void installContribution(String uri, String url);
+    List<String> getInstalledContributionURIs();
+    String getInstalledContributionURL(String uri);
+    void uninstallContribution(String uri);
 }

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=1101468&r1=1101467&r2=1101468&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 14:10:55 2011
@@ -49,6 +49,7 @@ public class EndpointRegistryImpl extend
 
     private List<Endpoint> endpoints = new ArrayList<Endpoint>();
     private Map<QName, Composite> runningComposites = new HashMap<QName, Composite>();
+    private Map<String, String> installedContributions = new HashMap<String, String>();
     
     protected boolean quietLogging;
 
@@ -161,22 +162,18 @@ public class EndpointRegistryImpl extend
         listeners.clear();
     }
 
-    @Override
     public void addRunningComposite(Composite composite) {
         runningComposites.put(composite.getName(), composite);
     }
 
-    @Override
     public void removeRunningComposite(QName name) {
         runningComposites.remove(name);
     }
 
-    @Override
     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()) {
@@ -185,4 +182,20 @@ public class EndpointRegistryImpl extend
         return compositeNames;
     }
 
+    public void installContribution(String uri, String url) {
+        installedContributions.put(uri, url);
+    }
+
+    public List<String> getInstalledContributionURIs() {
+        return new ArrayList<String>(installedContributions.keySet());
+    }
+
+    public String getInstalledContributionURL(String uri) {
+        return installedContributions.get(uri);
+    }
+
+    public void uninstallContribution(String uri) {
+        installedContributions.remove(uri);
+    }
+
 }

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=1101468&r1=1101467&r2=1101468&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 14:10:55 2011
@@ -837,23 +837,32 @@ public class DeployerImpl implements Dep
         public void stop() {
         }
 
-        @Override
         public void addRunningComposite(Composite composite) {
         }
 
-        @Override
         public void removeRunningComposite(QName name) {
         }
 
-        @Override
         public Composite getRunningComposite(QName name) {
             return null;
         }
 
-        @Override
         public List<QName> getRunningCompositeNames() {
             return null;
         }
 
+        public void installContribution(String uri, String url) {
+        }
+
+        public List<String> getInstalledContributionURIs() {
+            return null;
+        }
+
+        public String getInstalledContributionURL(String uri) {
+            return null;
+        }
+
+        public void uninstallContribution(String uri) {
+        }
     }
 }

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=1101468&r1=1101467&r2=1101468&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 14:10:55 2011
@@ -99,7 +99,9 @@ public class HazelcastEndpointRegistry e
 
     protected Map<Object, Object> endpointWsdls;
     protected Map<String, Endpoint> localEndpoints = new ConcurrentHashMap<String,
Endpoint>();
-    
+
+    protected Map<String, String> installedContributions;
+
     protected AssemblyFactory assemblyFactory;
     protected Object shutdownMutex = new Object();
     protected Properties properties;
@@ -141,6 +143,8 @@ public class HazelcastEndpointRegistry e
             runningComposites = hazelcastInstance.getMap(domainURI + "/CompositeOwners");
             runningCompositeOwners = hazelcastInstance.getMultiMap(domainURI + "/CompositeOwners");
 
+            installedContributions = hazelcastInstance.getMap(domainURI + "/InstalledContributions");
+            
             hazelcastInstance.getCluster().addMembershipListener(this);
 //        }
     }
@@ -485,7 +489,6 @@ public class HazelcastEndpointRegistry e
         return null;
     }
 
-    @Override
     public void addRunningComposite(Composite composite) {
         String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
         String compositeXML = writeComposite(composite);
@@ -501,7 +504,6 @@ public class HazelcastEndpointRegistry e
         }
     }
 
-    @Override
     public void removeRunningComposite(QName name) {
         String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString();
         Transaction txn = hazelcastInstance.getTransaction();
@@ -516,13 +518,11 @@ public class HazelcastEndpointRegistry e
         }
     }
 
-    @Override
     public Composite getRunningComposite(QName name) {
         String compositeXML = runningComposites.get(name);
         return readComposite(compositeXML);
     }
 
-    @Override
     public List<QName> getRunningCompositeNames() {
         return new ArrayList<QName>(runningCompositeOwners.values());
     }
@@ -557,4 +557,20 @@ public class HazelcastEndpointRegistry e
             throw new RuntimeException(e);
         }
     }
+
+    public void installContribution(String uri, String url) {
+        installedContributions.put(uri, url);
+    }
+
+    public List<String> getInstalledContributionURIs() {
+        return new ArrayList<String>(installedContributions.keySet());
+    }
+
+    public String getInstalledContributionURL(String uri) {
+        return installedContributions.get(uri);
+    }
+
+    public void uninstallContribution(String uri) {
+        installedContributions.remove(uri);
+    }
 }

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java?rev=1101468&r1=1101467&r2=1101468&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java
Tue May 10 14:10:55 2011
@@ -162,8 +162,9 @@ public interface Node {
      * @param compositeURI
      * @throws ActivationException 
      * @throws ValidationException 
+     * @throws ContributionReadException 
      */
-    void start(String contributionURI, String compositeURI) throws ActivationException, ValidationException;
+    void start(String contributionURI, String compositeURI) throws ActivationException, ValidationException,
ContributionReadException;
     
     /**
      * 4687 10.7.2 remove From Domain-Level Composite

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=1101468&r1=1101467&r2=1101468&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 14:10:55 2011
@@ -85,7 +85,7 @@ public class NodeImpl implements Node {
     private EndpointRegistry endpointRegistry;
     private ExtensionPointRegistry extensionPointRegistry;
     private TuscanyRuntime tuscanyRuntime;
-    private Map<String, InstalledContribution> installedContributions = new HashMap<String,
InstalledContribution>();
+    private Map<String, InstalledContribution> locallyInstalledContributions = new
HashMap<String, InstalledContribution>();
     
     private static Map<String, Node> allNodes = new HashMap<String, Node>();
     
@@ -107,6 +107,15 @@ public class NodeImpl implements Node {
         if (uri == null) {
             uri = getDefaultContributionURI(contributionURL);
         }
+        endpointRegistry.installContribution(uri, contributionURL);
+        if (startDeployables) {
+            // TODO: sort out metadata and dependents in distributed
+            localInstall(uri, contributionURL, metaDataURL, dependentContributionURIs, startDeployables);
+        }
+        return uri;
+    }
+
+    private void localInstall(String uri, String contributionURL, String metaDataURL, List<String>
dependentContributionURIs, boolean startDeployables) throws ContributionReadException, ValidationException,
ActivationException {
         Monitor monitor = deployer.createMonitor();
         Contribution contribution = deployer.loadContribution(IOHelper.createURI(uri), IOHelper.getLocationAsURL(contributionURL),
monitor);
         monitor.analyzeProblems();
@@ -114,7 +123,6 @@ public class NodeImpl implements Node {
             mergeContributionMetaData(metaDataURL, contribution);
         }
         installContribution(contribution, dependentContributionURIs, startDeployables);
-        return uri;
     }
 
     private void mergeContributionMetaData(String metaDataURL, Contribution contribution)
throws ValidationException {
@@ -133,7 +141,7 @@ public class NodeImpl implements Node {
     
     public String installContribution(Contribution contribution, List<String> dependentContributionURIs,
boolean startDeployables) throws ContributionReadException, ActivationException, ValidationException
{
         InstalledContribution ic = new InstalledContribution(contribution.getURI(), contribution.getLocation(),
contribution, dependentContributionURIs);
-        installedContributions.put(contribution.getURI(), ic);
+        locallyInstalledContributions.put(contribution.getURI(), ic);
         if (startDeployables) {
             for (Composite c : ic.getDefaultDeployables()) {
                 startComposite(c, ic);
@@ -159,14 +167,14 @@ public class NodeImpl implements Node {
         if (ic.getDependentContributionURIs() != null) {
             // if the install specified dependent uris use just those contributions
             for (String uri : ic.getDependentContributionURIs()) {
-                InstalledContribution dependee = installedContributions.get(uri);
+                InstalledContribution dependee = locallyInstalledContributions.get(uri);
                 if (dependee != null) {
                     dependentContributions.add(dependee.getContribution());
                 }
             }
         } else {
             // otherwise use all available contributions for dependents
-            for (InstalledContribution ics : installedContributions.values()) {
+            for (InstalledContribution ics : locallyInstalledContributions.values()) {
                 dependentContributions.add(ics.getContribution());
             }
         }
@@ -181,7 +189,7 @@ public class NodeImpl implements Node {
     }
 
     public String start(String contributionURI, Composite composite) throws ActivationException,
ValidationException {
-        InstalledContribution ic = installedContributions.get(contributionURI);
+        InstalledContribution ic = locallyInstalledContributions.get(contributionURI);
         if (ic == null) {
             throw new IllegalArgumentException("contribution not installed: " + contributionURI);
         }
@@ -190,10 +198,15 @@ public class NodeImpl implements Node {
         return compositeArtifcatURI;
     }
 
-    public void start(String contributionURI, String compositeURI) throws ActivationException,
ValidationException {
-        InstalledContribution ic = installedContributions.get(contributionURI);
+    public void start(String contributionURI, String compositeURI) throws ActivationException,
ValidationException, ContributionReadException {
+        InstalledContribution ic = locallyInstalledContributions.get(contributionURI);
         if (ic == null) {
-            throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
+            String url = endpointRegistry.getInstalledContributionURL(contributionURI);
+            if (url == null) {
+                throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
+            }
+            localInstall(contributionURI, url, null, null, false);
+            ic = locallyInstalledContributions.get(contributionURI);
         }
         if (!ic.restart(compositeURI)) {
             for (Artifact a : ic.getContribution().getArtifacts()) {
@@ -208,7 +221,7 @@ public class NodeImpl implements Node {
 
     @Override
     public void stop(String contributionURI, String compositeURI) throws ActivationException
{
-        InstalledContribution ic = installedContributions.get(contributionURI);
+        InstalledContribution ic = locallyInstalledContributions.get(contributionURI);
         if (ic == null) {
             throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
         }
@@ -251,14 +264,17 @@ public class NodeImpl implements Node {
     }
 
     public List<String> removeContribution(String contributionURI) throws ActivationException
{
+        endpointRegistry.uninstallContribution(contributionURI);
+
+        // TODO: should this next bit happen?
         List<String> removedContributionURIs = new ArrayList<String>();
-        InstalledContribution ic = installedContributions.get(contributionURI);
+        InstalledContribution ic = locallyInstalledContributions.get(contributionURI);
         if (ic != null) {
             removedContributionURIs.add(ic.getURI());
             for (String dependent : getDependentContributions(contributionURI)) {
                 removedContributionURIs.addAll(removeContribution(dependent));
             }
-            installedContributions.remove(contributionURI);
+            locallyInstalledContributions.remove(contributionURI);
             for (String compositeURI : ic.getStartedCompositeURIs()) {
                 ic.stop(compositeURI);
             }
@@ -285,7 +301,7 @@ public class NodeImpl implements Node {
     }
 
     public void stop() {
-        ArrayList<String> ics = new ArrayList<String>(installedContributions.keySet());
+        ArrayList<String> ics = new ArrayList<String>(locallyInstalledContributions.keySet());
         for (String uri : ics) {
             try {
                 removeContribution(uri);
@@ -430,7 +446,7 @@ public class NodeImpl implements Node {
     }
 
     public List<String> getStartedCompositeURIs(String contributionURI) {
-        InstalledContribution ic = installedContributions.get(contributionURI);
+        InstalledContribution ic = locallyInstalledContributions.get(contributionURI);
         if (ic == null) {
             throw new IllegalArgumentException("no contribution found for: " + contributionURI);
         }
@@ -438,19 +454,19 @@ public class NodeImpl implements Node {
     }
 
     public List<String> getInstalledContributionURIs() {
-        return new ArrayList<String>(installedContributions.keySet());
+        return new ArrayList<String>(locallyInstalledContributions.keySet());
     }
 
     public Contribution getInstalledContribution(String uri) {
-        if (installedContributions.containsKey(uri)) {
-            return installedContributions.get(uri).getContribution();
+        if (locallyInstalledContributions.containsKey(uri)) {
+            return locallyInstalledContributions.get(uri).getContribution();
         }
         throw new IllegalArgumentException("no contribution found for: " + uri);
     }
 
     protected String getContributionUriForArtifact(String artifactURI) {
         String contributionURI = null;
-        for (String uri : installedContributions.keySet()) {
+        for (String uri : locallyInstalledContributions.keySet()) {
             if (artifactURI.startsWith(uri)) {
                 contributionURI = uri;
                 break;
@@ -469,12 +485,12 @@ public class NodeImpl implements Node {
     }
     
     public Set<String> getDependentContributions(String contributionURI) {
-        InstalledContribution ic = installedContributions.get(contributionURI);
+        InstalledContribution ic = locallyInstalledContributions.get(contributionURI);
         if (ic == null) {
             throw new IllegalArgumentException("Contribution not installed: " + contributionURI);
         }
         Set<String> dependentContributionURIs = new HashSet<String>();
-        for (InstalledContribution icx : installedContributions.values()) {
+        for (InstalledContribution icx : locallyInstalledContributions.values()) {
             if (ic != icx) {
                 List<Contribution> dependencies = icx.getContribution().getDependencies();
                 if (dependencies != null && dependencies.contains(ic.getContribution()))
{

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java?rev=1101468&r1=1101467&r2=1101468&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/PerfTest.java
Tue May 10 14:10:55 2011
@@ -56,7 +56,7 @@ public class PerfTest {
         validate(node);
     }
 
-    private void validate(Node node) throws ActivationException, ValidationException, NoSuchServiceException
{
+    private void validate(Node node) throws ActivationException, ValidationException, NoSuchServiceException,
ContributionReadException {
         node.start("sample-helloworld", "helloworld.composite");
         
         Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent");

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=1101468&r1=1101467&r2=1101468&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 14:10:55 2011
@@ -444,4 +444,28 @@ public class ReplicatedEndpointRegistry 
         return null;
     }
 
+    @Override
+    public void installContribution(String uri, String url) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public List<String> getInstalledContributionURIs() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public String getInstalledContributionURL(String uri) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void uninstallContribution(String uri) {
+        // TODO Auto-generated method stub
+        
+    }
+
 }

Modified: tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java?rev=1101468&r1=1101467&r2=1101468&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
Tue May 10 14:10:55 2011
@@ -383,7 +383,7 @@ public class Shell {
         return false;
     }
 
-    boolean start(String curi, String compositeURI) throws ActivationException, ValidationException
{
+    boolean start(String curi, String compositeURI) throws ActivationException, ValidationException,
ContributionReadException {
         Contribution c = getNode().getInstalledContribution(curi);
         for (Artifact a : c.getArtifacts()) {
             if (compositeURI.equals(a.getURI())) {



Mime
View raw message