Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add AS support in MSG and java bindings
authorPaul Bédaride <paul.bedaride@gmail.com>
Thu, 6 Jun 2013 16:57:26 +0000 (18:57 +0200)
committerPaul Bédaride <paul.bedaride@gmail.com>
Thu, 6 Jun 2013 16:58:07 +0000 (18:58 +0200)
12 files changed:
buildtools/Cmake/DefinePackages.cmake
include/msg/datatypes.h
include/msg/msg.h
src/bindings/java/jmsg.c
src/bindings/java/jmsg.h
src/bindings/java/jmsg_vm.c
src/bindings/java/jmsg_vm.h
src/bindings/java/org/simgrid/msg/Msg.java
src/include/surf/surf.h
src/msg/msg_environment.c
src/surf/surf_private.h
src/surf/surf_routing.c

index 84cb6cc..4e42ec5 100644 (file)
@@ -386,6 +386,8 @@ set(BINDINGS_SRC
 set(JMSG_C_SRC
   src/bindings/java/jmsg.c
   src/bindings/java/jmsg.h
 set(JMSG_C_SRC
   src/bindings/java/jmsg.c
   src/bindings/java/jmsg.h
+  src/bindings/java/jmsg_as.c
+  src/bindings/java/jmsg_as.h
   src/bindings/java/jmsg_comm.c
   src/bindings/java/jmsg_comm.h
   src/bindings/java/jmsg_file.c
   src/bindings/java/jmsg_comm.c
   src/bindings/java/jmsg_comm.h
   src/bindings/java/jmsg_file.c
@@ -411,6 +413,7 @@ set(JMSG_C_SRC
 )
 
 set(JMSG_JAVA_SRC
 )
 
 set(JMSG_JAVA_SRC
+  src/bindings/java/org/simgrid/msg/As.java    
   src/bindings/java/org/simgrid/msg/Comm.java
   src/bindings/java/org/simgrid/msg/File.java
   src/bindings/java/org/simgrid/msg/Host.java
   src/bindings/java/org/simgrid/msg/Comm.java
   src/bindings/java/org/simgrid/msg/File.java
   src/bindings/java/org/simgrid/msg/Host.java
index 78af98e..357748a 100644 (file)
@@ -27,6 +27,8 @@ SG_BEGIN_DECL()
  * want to send your task, but only the name of this mailbox. */
 typedef struct s_smx_rvpoint *msg_mailbox_t;
 
  * want to send your task, but only the name of this mailbox. */
 typedef struct s_smx_rvpoint *msg_mailbox_t;
 
+/* ******************************** Environment ************************************ */
+typedef struct s_as *msg_as_t;
 
 /* ******************************** Host ************************************ */
 
 
 /* ******************************** Host ************************************ */
 
index 8c9c4db..657a357 100644 (file)
@@ -69,6 +69,11 @@ XBT_PUBLIC(void) MSG_set_function(const char *host_id,
 XBT_PUBLIC(double) MSG_get_clock(void);
 XBT_PUBLIC(unsigned long int) MSG_get_sent_msg(void);
 
 XBT_PUBLIC(double) MSG_get_clock(void);
 XBT_PUBLIC(unsigned long int) MSG_get_sent_msg(void);
 
+/************************** Environment ***********************************/
+XBT_PUBLIC(msg_as_t) MSG_environment_get_routing_root(void);
+XBT_PUBLIC(const char *) MSG_environment_as_get_name(msg_as_t as);
+XBT_PUBLIC(xbt_dict_t) MSG_environment_as_get_routing_sons(msg_as_t as);
+XBT_PUBLIC(const char *)MSG_environment_as_get_property_value(msg_as_t as, const char *name);
 
 /************************** File handling ***********************************/
 XBT_PUBLIC(double) MSG_file_read(void* ptr, size_t size, size_t nmemb, msg_file_t stream);
 
 /************************** File handling ***********************************/
 XBT_PUBLIC(double) MSG_file_read(void* ptr, size_t size, size_t nmemb, msg_file_t stream);
index 8a6a626..30f90dc 100644 (file)
@@ -16,6 +16,8 @@
 
 #include "jmsg_process.h"
 
 
 #include "jmsg_process.h"
 
+#include "jmsg_as.h"
+
 #include "jmsg_host.h"
 #include "jmsg_task.h"
 #include "jxbt_utilities.h"
 #include "jmsg_host.h"
 #include "jmsg_task.h"
 #include "jxbt_utilities.h"
@@ -170,6 +172,26 @@ Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls,
 
   (*env)->ReleaseStringUTFChars(env, jplatformFile, platformFile);
 }
 
   (*env)->ReleaseStringUTFChars(env, jplatformFile, platformFile);
 }
+
+JNIEXPORT jobject JNICALL
+Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNIEnv * env, jclass cls)
+{
+  msg_as_t as = MSG_environment_get_routing_root();
+  jobject jas = jas_new_instance(env);
+  if (!jas) {
+    jxbt_throw_jni(env, "java As instantiation failed");
+    return NULL;
+  }
+  jas = jas_ref(env, jas);
+  if (!jas) {
+    jxbt_throw_jni(env, "new global ref allocation failed");
+    return NULL;
+  }
+  jas_bind(jas, as, env);
+
+  return (jobject) jas;
+}
+
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Msg_debug(JNIEnv * env, jclass cls, jstring js)
 {
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Msg_debug(JNIEnv * env, jclass cls, jstring js)
 {
index 73e9ad9..4d9a5d4 100644 (file)
@@ -56,6 +56,8 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_critical(JNIEnv *, jclass,
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls,
                                        jstring jplatformFile);
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls,
                                        jstring jplatformFile);
+JNIEXPORT jobject JNICALL
+Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNIEnv * env, jclass cls);
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Msg_deployApplication(JNIEnv * env, jclass cls,
                                        jstring jdeploymentFile);
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Msg_deployApplication(JNIEnv * env, jclass cls,
                                        jstring jdeploymentFile);
index 8948b57..395b8d2 100644 (file)
@@ -135,7 +135,7 @@ Java_org_simgrid_msg_VM_save(JNIEnv *env, jobject jvm) {
   MSG_vm_save(vm);
 }
 JNIEXPORT void JNICALL
   MSG_vm_save(vm);
 }
 JNIEXPORT void JNICALL
-Java_org_simgrid_msg_VM_retore(JNIEnv *env, jobject jvm) {
+Java_org_simgrid_msg_VM_restore(JNIEnv *env, jobject jvm) {
   msg_vm_t vm = jvm_get_native(env,jvm);
   MSG_vm_restore(vm);
 }
   msg_vm_t vm = jvm_get_native(env,jvm);
   MSG_vm_restore(vm);
 }
index 808fbd7..7bfe807 100644 (file)
@@ -146,4 +146,6 @@ Java_org_simgrid_msg_VM_save(JNIEnv *env, jobject jvm);
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_VM_restore(JNIEnv *env, jobject jvm);
 
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_VM_restore(JNIEnv *env, jobject jvm);
 
+JNIEXPORT jobject JNICALL
+Java_org_simgrid_msg_VM_get_pm(JNIEnv *env, jobject jvm);
 #endif
 #endif
index 2cf133a..5e67165 100644 (file)
@@ -183,6 +183,8 @@ public final class Msg {
         */
        public final static native void createEnvironment(String platformFile);
 
         */
        public final static native void createEnvironment(String platformFile);
 
+       public final static native As environmentGetRoutingRoot();
+
        /**
         * The method to deploy the simulation.
         *
        /**
         * The method to deploy the simulation.
         *
index 74133ae..65694cc 100644 (file)
@@ -713,6 +713,16 @@ XBT_PUBLIC_DATA(s_surf_model_description_t) surf_new_model_description[];
 XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
 XBT_PUBLIC_DATA(xbt_dynar_t) model_list_invoke;
 
 XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
 XBT_PUBLIC_DATA(xbt_dynar_t) model_list_invoke;
 
+/*******************************************/
+/*** SURF Platform *************************/
+/*******************************************/
+typedef struct s_as *AS_t;
+
+XBT_PUBLIC_DATA(AS_t) surf_AS_get_routing_root(void); 
+XBT_PUBLIC_DATA(const char *)surf_AS_get_name(AS_t as);
+XBT_PUBLIC_DATA(xbt_dict_t) surf_AS_get_routing_sons(AS_t as);
+
+
 /*******************************************/
 /*** SURF Globals **************************/
 /*******************************************/
 /*******************************************/
 /*** SURF Globals **************************/
 /*******************************************/
index 497b254..78184f7 100644 (file)
@@ -48,3 +48,22 @@ void MSG_post_create_environment(void) {
       __MSG_host_create(xbt_dict_cursor_get_elm(cursor));
   }
 }
       __MSG_host_create(xbt_dict_cursor_get_elm(cursor));
   }
 }
+
+msg_as_t MSG_environment_get_routing_root() {
+  return surf_AS_get_routing_root();
+}
+
+const char *MSG_environment_as_get_name(msg_as_t as) {
+  return surf_AS_get_name(as);
+}
+
+xbt_dict_t MSG_environment_as_get_routing_sons(msg_as_t as) {
+  xbt_dict_t res = surf_AS_get_routing_sons(as);
+  return res;
+}
+
+const char *MSG_environment_as_get_property_value(msg_as_t as, const char *name)
+{
+  xbt_dict_t dict = xbt_lib_get_or_null(as_router_lib, MSG_environment_as_get_name(as), ROUTING_PROP_ASR_LEVEL);
+  return xbt_dict_get_or_null(dict, name);
+}
index 076a05c..2fb09bf 100644 (file)
@@ -104,7 +104,6 @@ int net_get_link_latency_limited(surf_action_t action);
  */
 int __surf_is_absolute_file_path(const char *file_path);
 
  */
 int __surf_is_absolute_file_path(const char *file_path);
 
-typedef struct s_as *AS_t;
 typedef struct s_routing_edge {
   AS_t rc_component;
   e_surf_network_element_type_t rc_type;
 typedef struct s_routing_edge {
   AS_t rc_component;
   e_surf_network_element_type_t rc_type;
index 5901fbd..c4a0fa3 100644 (file)
@@ -1229,3 +1229,17 @@ void routing_exit(void) {
   finalize_rec(routing_platf->root);
   xbt_free(routing_platf);
 }
   finalize_rec(routing_platf->root);
   xbt_free(routing_platf);
 }
+
+AS_t surf_AS_get_routing_root() {
+  return routing_platf->root;  
+}
+
+const char *surf_AS_get_name(AS_t as) {
+  return as->name;
+}
+
+xbt_dict_t surf_AS_get_routing_sons(AS_t as) {
+  return as->routing_sons;
+}
+
+