Example #1
0
JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass cls)
{
  /* Run everything */
  XBT_DEBUG("Ready to run MSG_MAIN");
  msg_error_t rv = MSG_main();
  XBT_DEBUG("Done running MSG_MAIN");
  jxbt_check_res("MSG_main()", rv, MSG_OK,
                 xbt_strdup("unexpected error : MSG_main() failed .. please report this bug "));

  XBT_INFO("MSG_main finished; Cleaning up the simulation...");
  /* Cleanup java hosts */
  xbt_dynar_t hosts = MSG_hosts_as_dynar();
  for (unsigned long index = 0; index < xbt_dynar_length(hosts) - 1; index++) {
    msg_host_t msg_host = xbt_dynar_get_as(hosts,index,msg_host_t);
    jobject jhost = (jobject) msg_host->extension(JAVA_HOST_LEVEL);
    if (jhost)
      jhost_unref(env, jhost);

  }
  xbt_dynar_free(&hosts);

  /* Cleanup java storages */
  xbt_dynar_t storages = MSG_storages_as_dynar();
  if(!xbt_dynar_is_empty(storages)){
    for (unsigned long index = 0; index < xbt_dynar_length(storages) - 1; index++) {
      jobject jstorage = (jobject) xbt_lib_get_level(xbt_dynar_get_as(storages,index,msg_storage_t), JAVA_STORAGE_LEVEL);
      if (jstorage)
        jstorage_unref(env, jstorage);
    }
  }
  xbt_dynar_free(&storages);
}
Example #2
0
static void dump_platform_storages(void){
  unsigned int cursor;
  xbt_dynar_t storages = MSG_storages_as_dynar();
  msg_storage_t storage;
  xbt_dynar_foreach(storages, cursor, storage){
    XBT_INFO("Storage %s is attached to %s", MSG_storage_get_name(storage), MSG_storage_get_host(storage));
    MSG_storage_set_property_value(storage, "other usage", xbt_strdup("gpfs"));
  }
Example #3
0
int main(int argc, char **argv)
{
  int res;
  unsigned int cur;
  xbt_dynar_t storages;
  msg_storage_t st;

  MSG_init(&argc, argv);
  MSG_create_environment(argv[1]);
  MSG_function_register("host", host);
  MSG_launch_application(argv[2]);

  storages = MSG_storages_as_dynar();
  xbt_dynar_foreach(storages, cur, st){
    XBT_INFO("Init: %llu MiB used on '%s'",
        MSG_storage_get_used_size(st)/INMEGA,
        MSG_storage_get_name(st));
  }
Example #4
0
JNIEXPORT jobjectArray JNICALL
Java_org_simgrid_msg_Storage_all(JNIEnv * env, jclass cls_arg)
{
  int index;
  jobjectArray jtable;
  jobject jstorage;
  jstring jname;
  msg_storage_t storage;

  xbt_dynar_t table =  MSG_storages_as_dynar();
  int count = xbt_dynar_length(table);

  jclass cls = jxbt_get_class(env, "org/simgrid/msg/Storage");

  if (!cls) {
    return NULL;
  }

  jtable = (*env)->NewObjectArray(env, (jsize) count, cls, NULL);

  if (!jtable) {
    jxbt_throw_jni(env, "Storages table allocation failed");
    return NULL;
  }

  for (index = 0; index < count; index++) {
    storage = xbt_dynar_get_as(table,index,msg_storage_t);
    jstorage = (jobject) (xbt_lib_get_level(storage, JAVA_STORAGE_LEVEL));

    if (!jstorage) {
      jname = (*env)->NewStringUTF(env, MSG_storage_get_name(storage));
      jstorage = Java_org_simgrid_msg_Storage_getByName(env, cls_arg, jname);
    }

    (*env)->SetObjectArrayElement(env, jtable, index, jstorage);
  }
  xbt_dynar_free(&table);
  return jtable;
}