Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a new example for java with bypass of deployment.
authorPierre <pierre@erie.imag.fr>
Fri, 14 Oct 2011 11:26:09 +0000 (13:26 +0200)
committerPierre <pierre@erie.imag.fr>
Fri, 14 Oct 2011 11:26:09 +0000 (13:26 +0200)
.gitignore
CMakeLists.txt
examples/master_slave_bypass/Master.java [new file with mode: 0644]
examples/master_slave_bypass/MsBypass.java [new file with mode: 0644]
examples/master_slave_bypass/Slave.java [new file with mode: 0644]
examples/master_slave_bypass/platform.xml [new file with mode: 0644]

index 11091e1..42403ad 100644 (file)
@@ -1,4 +1,8 @@
 *.class
 simgrid.jar
 libSG_java.so
-
+build/
+*.dylib
+.project
+.cproject
+.classpath
index 8741b2e..ff7ce52 100644 (file)
@@ -127,6 +127,9 @@ set(JAVA_EXAMPLES
        examples/pingPong/Sender.java
        examples/pingPong/Receiver.java
        examples/pingPong/PingPongTest.java
+       examples/master_slave_bypass/Master.java
+       examples/master_slave_bypass/MsBypass.java
+       examples/master_slave_bypass/Slave.java
 )
 
 set(CMAKE_SRC
@@ -144,6 +147,7 @@ set(XML_FILES
     examples/pingPong/pingPongDeployment.xml
     examples/basic/basicDeployment.xml
     examples/basic/deploy.xml
+    examples/master_slave_bypass/platform.xml
 )
 
 set(source_to_pack
@@ -205,11 +209,12 @@ add_custom_target(simgrid_jar ALL
 add_custom_command(
        COMMENT "Build examples for java"
        OUTPUT  ${JAVA_EXAMPLES_CLASS}
-       
+       DEPENDS ${JAVA_EXAMPLES}
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/basic/*.java  
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/pingPong/*.java
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/commTime/*.java
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/*.java                                 
+       COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/*.java
 )
 add_custom_target(simgrid_java_examples ALL
        DEPENDS ${JAVA_EXAMPLES_CLASS}
@@ -243,6 +248,10 @@ java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar
 ADD_TEST(mutualExclusion
 java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar mutualExclusion/centralized/MutexCentral ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/ring3.xml ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/mutex_centralized_deployment.xml
 )
+ADD_TEST(bypass
+java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar master_slave_bypass/MsBypass ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/platform.xml
+)
+
 
 ##########################################
 # Set the  DYLD_LIBRARY_PATH for mac     #
diff --git a/examples/master_slave_bypass/Master.java b/examples/master_slave_bypass/Master.java
new file mode 100644 (file)
index 0000000..67499fa
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Master of a basic master/slave example in Java
+ *
+ * Copyright 2006,2007,2010 The SimGrid Team. All rights reserved. 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. 
+ */
+
+package master_slave_bypass;
+import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Process;
+
+public class Master extends Process {
+       public Master(String hostname, String name) throws HostNotFoundException {
+               super(hostname, name);
+       }
+       public void main(String[] args) throws MsgException {
+               Msg.info("Master Hello!");
+/*     try {
+               Slave process2 = new Slave("alice","process2");
+           }
+       catch (MsgException e){
+                       System.out.println("Mes couilles!!!!!");
+           } */
+       }
+}
diff --git a/examples/master_slave_bypass/MsBypass.java b/examples/master_slave_bypass/MsBypass.java
new file mode 100644 (file)
index 0000000..006c63d
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006,2007,2010. The SimGrid Team. All rights reserved. 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. 
+ */
+
+package master_slave_bypass;
+
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.NativeException;
+
+public class MsBypass {
+   
+   /* This only contains the launcher. If you do nothing more than than you can run 
+    *   java simgrid.msg.Msg
+    * which also contains such a launcher
+    */
+   
+    public static void main(String[] args) throws NativeException {
+       
+    /* initialize the MSG simulation. Must be done before anything else (even logging). */
+    Msg.init(args);
+    Msg.createEnvironment(args[0]);
+
+    /* bypass deploymemt */
+    try {
+    Master process1 = new Master("bob","process1");
+    Slave process2 = new Slave("alice","process2");
+    }
+    catch (MsgException e){
+       System.out.println("Mes couilles!!!!!");
+    }
+    
+       /*  execute the simulation. */
+    Msg.run();
+    }   
+}
diff --git a/examples/master_slave_bypass/Slave.java b/examples/master_slave_bypass/Slave.java
new file mode 100644 (file)
index 0000000..84de81c
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2006,2007,2010. The SimGrid Team. All rights reserved. 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. 
+ */
+package master_slave_bypass;
+import org.simgrid.msg.HostFailureException;
+import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.TimeoutException;
+import org.simgrid.msg.TransferFailureException;
+import org.simgrid.msg.Process;
+
+public class Slave extends Process {
+       public Slave(String hostname, String name) throws HostNotFoundException {
+               super(hostname, name);
+       }
+       public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
+       Msg.info("Slave Hello!");
+       }
+}
\ No newline at end of file
diff --git a/examples/master_slave_bypass/platform.xml b/examples/master_slave_bypass/platform.xml
new file mode 100644 (file)
index 0000000..ea46d06
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+<AS  id="AS0"  routing="Full">
+       <host id="bob" power="137333000"/>
+       <host id="alice" power="98095000"/>
+       
+       <link id="1" bandwidth="100000000" latency="0.001"/>
+       
+       <route  src="bob"
+                       dst="alice"
+                       symmetrical="YES">
+                               <link_ctn id="1"/>
+   </route>
+</AS>
+</platform>
\ No newline at end of file