diff options
Diffstat (limited to 'sca-java-2.x/trunk')
3 files changed, 73 insertions, 15 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/build.xml b/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/build.xml index 8f47af1544..684aa97ec8 100644 --- a/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/build.xml +++ b/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/build.xml @@ -19,20 +19,22 @@ <project name="itest-nodes-two-jvms-hazelcast" default="run">
<target name="run">
- <parallel failonany="true">
-
- <daemons>
- <java classpath="../../../../distribution/all/target/apache-tuscany-sca-all-2.0-SNAPSHOT.dir/tuscany-sca-2.0-SNAPSHOT/features/tuscany-sca-manifest.jar:./target/classes"
- classname="org.apache.tuscany.sca.impl.Tuscany"
- fork="true"
- failonerror="true">
- <arg value="domain1"/>
- <arg value="nodeService"/>
- </java>
- </daemons>
+ <parallel failonany="true">
+
+ <!-- start a node that will be part of the domain -->
+ <java classpath="../../../../distribution/all/target/apache-tuscany-sca-all-2.0-SNAPSHOT.dir/tuscany-sca-2.0-SNAPSHOT/features/tuscany-sca-manifest.jar:./target/classes"
+ classname="org.apache.tuscany.sca.impl.Tuscany"
+ fork="true"
+ failonerror="true">
+ <arg value="domain1"/>
+ <arg value="nodeService"/>
+ <arg value="8088"/>
+ </java>
- <sequential>
- <sleep seconds="5"/>
+ <sequential>
+ <!-- give the first node a chance to start -->
+ <sleep seconds="5"/>
+ <!-- start a second node that automatically tries to call a service in the first node -->
<java classpath="../../../../distribution/all/target/apache-tuscany-sca-all-2.0-SNAPSHOT.dir/tuscany-sca-2.0-SNAPSHOT/features/tuscany-sca-manifest.jar:./target/classes"
classname="org.apache.tuscany.sca.impl.Tuscany"
fork="true"
@@ -40,6 +42,10 @@ <arg value="domain1"/>
<arg value="nodeClient"/>
</java>
+ <!-- use a HTTP GET to ping the first node to tell it to stop -->
+ <get src="http://localhost:8088"
+ dest="target/deamon.txt"
+ ignoreerrors="true"/>
</sequential>
</parallel>
diff --git a/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/main/java/org/apache/tuscany/sca/impl/Tuscany.java b/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/main/java/org/apache/tuscany/sca/impl/Tuscany.java index 748dc513ef..6915ca73d7 100644 --- a/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/main/java/org/apache/tuscany/sca/impl/Tuscany.java +++ b/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/main/java/org/apache/tuscany/sca/impl/Tuscany.java @@ -21,6 +21,9 @@ package org.apache.tuscany.sca.impl; import java.io.File;
import java.io.FilenameFilter;
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
import java.net.URL;
import org.apache.tuscany.sca.node.Node;
@@ -35,6 +38,11 @@ public class Tuscany { public static void main(String[] args) throws Exception {
String domainName = args[0];
String nodeName = args[1];
+ int deamonPort = -1;
+
+ if (args.length > 2){
+ deamonPort = Integer.parseInt(args[2]);
+ }
// find the domain directory
File currentDirectory = new File(".");
@@ -57,8 +65,38 @@ public class Tuscany { URL nodeConfigURL = nodeDirectory.toURI().resolve("node.xml").toURL();
Node node = nodeFactory.createNode(nodeConfigURL);
+ ShutdownThread shutdown = new ShutdownThread(node);
+ Runtime.getRuntime().addShutdownHook(shutdown);
+
node.start();
+ // for testing we're going to set up a deamon that listens for
+ // a shutdown message on a specified port (well it actually just
+ // waits for a client to connect to the port as that's all we need
+ // for now). If no port is specified then just stop straight away
+
+ if (deamonPort >= 0){
+ // Its a runtime that has to act as a deamon
+ ServerSocket serverSocket = null;
+
+ try {
+ serverSocket = new ServerSocket(deamonPort);
+ } catch (IOException e) {
+ System.out.println("Can't create a ServerSocket on port: " + deamonPort);
+ }
+
+ // all we're doing here is waiting for a connection. If we wanted to implement
+ // a real deamon we should perhaps listen to what's coming in over the resulting socket
+ // and see if a shutdown has been requested
+ Socket clientSocket = null;
+ try {
+ clientSocket = serverSocket.accept();
+ } catch (IOException e) {
+ System.out.println("Accept failed on port: " + deamonPort);
+ }
+ }
+
+ node.stop();
}
/**
@@ -94,4 +132,18 @@ public class Tuscany { return false;
}
}
+
+ private static class ShutdownThread extends Thread {
+ private Node node;
+
+ public ShutdownThread(Node node) {
+ super();
+ this.node = node;
+ }
+
+ @Override
+ public void run() {
+ node.stop();
+ }
+ }
}
\ No newline at end of file diff --git a/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/test/resources/domain-domain1/node-nodeService/node.xml b/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/test/resources/domain-domain1/node-nodeService/node.xml index 64009758d2..5d8620498a 100644 --- a/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/test/resources/domain-domain1/node-nodeService/node.xml +++ b/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/test/resources/domain-domain1/node-nodeService/node.xml @@ -21,8 +21,8 @@ xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
uri="http://sample/nodes/TestNode2"
- domain="default"
- domainRegistry="tuscany:default?listen=127.0.0.1:14820">
+ domain="default"
+ domainRegistry="tuscany:default?listen=127.0.0.1:14820">
<!-- Configure the base URIs for a given binding -->
<!-- Each base URI is for a protocol supported by the binding -->
|