Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Storage-kill: last crumbs
[simgrid.git] / src / bindings / java / jmsg_host.cpp
index 75c2ad4..68bc9a0 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to the java host instances.                            */
 
-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2021. 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. */
@@ -9,12 +9,10 @@
 #include "simgrid/plugins/energy.h"
 #include "simgrid/plugins/load.h"
 #include "simgrid/s4u/Host.hpp"
-#include "simgrid/s4u/Storage.hpp"
 
 #include "JavaContext.hpp"
 #include "jmsg.hpp"
 #include "jmsg_host.h"
-#include "jmsg_storage.h"
 #include "jxbt_utilities.hpp"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
@@ -93,7 +91,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv* env, jclas
     jhost_bind(jhost, host, env);
 
     /* the native host data field is set with the global reference to the java host returned by this function */
-    host->extension_set(JAVA_HOST_LEVEL, (void *)jhost);
+    host->extension_set(JAVA_HOST_LEVEL, jhost);
   }
 
   /* return the global reference to the java host instance */
@@ -128,7 +126,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jc
     env->SetObjectField(jhost, jhost_field_Host_name, jname);
     /* Bind & store it */
     jhost_bind(jhost, host, env);
-    host->extension_set(JAVA_HOST_LEVEL, (void *) jhost);
+    host->extension_set(JAVA_HOST_LEVEL, jhost);
   } else {
     jhost = (jobject) host->extension(JAVA_HOST_LEVEL);
   }
@@ -159,7 +157,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getSpeed(JNIEnv * env, jobje
     return -1;
   }
 
-  return (jdouble)sg_host_speed(host);
+  return (jdouble)sg_host_get_speed(host);
 }
 
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCoreNumber(JNIEnv * env, jobject jhost) {
@@ -224,74 +222,6 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Host_isOn(JNIEnv * env, jobject
   return (jboolean)sg_host_is_on(host);
 }
 
-JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getMountedStorage(JNIEnv * env, jobject jhost)
-{
-  msg_host_t host = jhost_get_native(env, jhost);
-  jobject jstorage;
-  jstring jname;
-
-  if (not host) {
-    jxbt_throw_notbound(env, "host", jhost);
-    return nullptr;
-  }
-
-  int index = 0;
-  jobjectArray jtable;
-  std::unordered_map<std::string, sg_storage_t> mounted_storages = host->get_mounted_storages();
-  int count  = mounted_storages.size();
-  jclass cls = env->FindClass("org/simgrid/msg/Storage");
-
-  jtable = env->NewObjectArray((jsize) count, cls, nullptr);
-
-  if (not jtable) {
-    jxbt_throw_jni(env, "Storages table allocation failed");
-    return nullptr;
-  }
-
-  for (auto const& elm : mounted_storages) {
-    jname    = env->NewStringUTF(elm.second->get_cname());
-    jstorage = Java_org_simgrid_msg_Storage_getByName(env,cls,jname);
-    env->SetObjectArrayElement(jtable, index, jstorage);
-    index++;
-  }
-  return jtable;
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getAttachedStorage(JNIEnv * env, jobject jhost)
-{
-  const_sg_host_t host = jhost_get_native(env, jhost);
-
-  if (not host) {
-    jxbt_throw_notbound(env, "host", jhost);
-    return nullptr;
-  }
-  jobjectArray jtable;
-
-  xbt_dynar_t dyn = sg_host_get_attached_storage_list(host);
-  jclass cls      = jxbt_get_class(env, "java/lang/String");
-  jtable          = env->NewObjectArray(static_cast<jsize>(xbt_dynar_length(dyn)), cls, nullptr);
-  unsigned int index;
-  const char* storage_name;
-  jstring jstorage_name;
-  xbt_dynar_foreach (dyn, index, storage_name) {
-    jstorage_name = env->NewStringUTF(storage_name);
-    env->SetObjectArrayElement(jtable, index, jstorage_name);
-  }
-  xbt_dynar_free_container(&dyn);
-  return jtable;
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getStorageContent(JNIEnv * env, jobject jhost)
-{
-  msg_host_t host = jhost_get_native(env, jhost);
-
-  if (not host) {
-    jxbt_throw_notbound(env, "host", jhost);
-    return nullptr;
-  }
-  return (jobjectArray)sg_host_get_storage_content(host);
-}
-
 JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclass cls_arg)
 {
   sg_host_t* table = sg_host_list();
@@ -309,7 +239,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclas
   }
 
   for (int index = 0; index < count; index++) {
-    jobject jhost = static_cast<jobject>(table[index]->extension(JAVA_HOST_LEVEL));
+    auto jhost = static_cast<jobject>(table[index]->extension(JAVA_HOST_LEVEL));
 
     if (not jhost) {
       jstring jname = env->NewStringUTF(table[index]->get_cname());
@@ -364,7 +294,7 @@ JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getPstatesCount(JNIEnv* env, jo
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentPowerPeak(JNIEnv* env, jobject jhost)
 {
   const_sg_host_t host = jhost_get_native(env, jhost);
-  return sg_host_speed(host);
+  return sg_host_get_speed(host);
 }
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getPowerPeakAt(JNIEnv* env, jobject jhost, jint pstate)
 {
@@ -375,7 +305,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getPowerPeakAt(JNIEnv* env,
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getLoad(JNIEnv* env, jobject jhost)
 {
   const_sg_host_t host = jhost_get_native(env, jhost);
-  return sg_host_load(host);
+  return sg_host_get_load(host);
 }
 
 JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentLoad (JNIEnv *env, jobject jhost)