From ce208dd59902981b9fac895a6596d0e08b065da6 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 19 May 2011 08:48:21 +0000 Subject: Update to add APIs to get at which composites are running where git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1124606 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sca/runtime/DomainRegistry.java | 2 ++ .../sca/core/assembly/impl/DomainRegistryImpl.java | 13 ++++++++++++- .../tuscany/sca/deployment/impl/DeployerImpl.java | 12 ++++++++++++ .../sca/registry/hazelcast/HazelcastDomainRegistry.java | 17 +++++++++++++++++ .../src/main/java/org/apache/tuscany/sca/Node.java | 7 ++++--- .../main/java/org/apache/tuscany/sca/impl/NodeImpl.java | 10 ++++++++++ .../sca/endpoint/tribes/ReplicatedDomainRegistry.java | 12 ++++++++++++ .../main/java/org/apache/tuscany/sca/shell/Shell.java | 16 ++++++++++++++-- 8 files changed, 83 insertions(+), 6 deletions(-) (limited to 'sca-java-2.x/trunk') diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistry.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistry.java index 817f232f42..08c7a5131f 100644 --- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistry.java +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistry.java @@ -94,4 +94,6 @@ public interface DomainRegistry { Composite getRunningComposite(String contributionURI, String compositeURI); List getMembers(); + String getLocalMember(); + String getRunningMember(String contributionURI, String compositeURI); } diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/DomainRegistryImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/DomainRegistryImpl.java index d0b8b53bf9..c3ffd9091f 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/DomainRegistryImpl.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/DomainRegistryImpl.java @@ -228,8 +228,19 @@ public class DomainRegistryImpl extends BaseDomainRegistry implements DomainRegi } } + private static final String LOCAL_MEMBER_NAME = "LocalOnly"; @Override public List getMembers() { - return Arrays.asList(new String[]{"LocalOnly"}); + return Arrays.asList(new String[]{LOCAL_MEMBER_NAME}); + } + + @Override + public String getLocalMember() { + return LOCAL_MEMBER_NAME; + } + + @Override + public String getRunningMember(String contributionURI, String compositeURI) { + return LOCAL_MEMBER_NAME; } } diff --git a/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java b/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java index 1ccb203efb..40561ade0c 100644 --- a/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java +++ b/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java @@ -882,5 +882,17 @@ public class DeployerImpl implements Deployer { // TODO Auto-generated method stub return null; } + + @Override + public String getLocalMember() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getRunningMember(String contributionURI, String compositeURI) { + // TODO Auto-generated method stub + return null; + } } } diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java index 3ceb3cd10e..bd979aa4a3 100644 --- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java +++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java @@ -660,4 +660,21 @@ public class HazelcastDomainRegistry extends BaseDomainRegistry implements Domai return members; } + @Override + public String getLocalMember() { + return hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString(); + } + + @Override + public String getRunningMember(String contributionURI, String compositeURI) { + for (String m : runningCompositeOwners.keySet()) { + Map> rcs = runningCompositeOwners.get(m); + for (String curi : rcs.keySet()) { + if (rcs.get(curi).contains(compositeURI)) { + return m; + } + } + } + return null; + } } diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java index 279ed709a3..89eeb09c2c 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/Node.java @@ -238,12 +238,13 @@ public interface Node { List getDeployableCompositeURIs(String contributionURI); void validateContribution(String string) throws ContributionReadException, ValidationException; - + + // TODO: should these member getters be replaced with a getDomainRegistry? List getMembers(); + String getLocalMember(); + String getRunningMember(String contributionURI, String compositeURI); // TODO: Add methods to get: - // active members in domain - // which composites are running on which members // start and stop composites on remote members // get/display contribution content // a view-only Node diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java index 7027ee8c53..824b427380 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java @@ -392,4 +392,14 @@ public class NodeImpl implements Node { return domainRegistry.getMembers(); } + @Override + public String getLocalMember() { + return domainRegistry.getLocalMember(); + } + + @Override + public String getRunningMember(String contributionURI, String compositeURI) { + return domainRegistry.getRunningMember(contributionURI, compositeURI); + } + } diff --git a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedDomainRegistry.java b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedDomainRegistry.java index d2b7fb6bd9..246072afc3 100644 --- a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedDomainRegistry.java +++ b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedDomainRegistry.java @@ -481,4 +481,16 @@ public class ReplicatedDomainRegistry extends BaseDomainRegistry implements Doma return null; } + @Override + public String getLocalMember() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getRunningMember(String contributionURI, String compositeURI) { + // TODO Auto-generated method stub + return null; + } + } diff --git a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java index 7302417236..e49ce33c64 100644 --- a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java +++ b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java @@ -473,7 +473,18 @@ public class Shell { // if (cs != null) { for (String curi : node.getStartedCompositeURIs().keySet()) { for (String compositeURI : node.getStartedCompositeURIs().get(curi)) { - out.println(" " + curi + " " + compositeURI); + + String runningMember = node.getRunningMember(curi, compositeURI); + if (node.getLocalMember().equals(runningMember)) { + runningMember = "this"; + } + if ("LocalOnly".equals(runningMember)) { + runningMember = ""; + } else { + runningMember = " (" + runningMember + ")"; + } + + out.println(" " + curi + " " + compositeURI + runningMember); } } // } @@ -484,8 +495,9 @@ public class Shell { } boolean members() { + String localMember = getNode().getLocalMember(); for (String member : getNode().getMembers()) { - out.println(member); + out.println(member + (localMember.equals(member) ? " (this)" : "")); } return true; } -- cgit v1.2.3