#include "simgrid/plugins/energy.h"
#include "simgrid/s4u/Host.hpp"
+#include "simgrid/s4u/Storage.hpp"
-#include "jmsg.h"
+#include "jmsg.hpp"
#include "jmsg_host.h"
-#include "jxbt_utilities.h"
#include "jmsg_storage.h"
+#include "jxbt_utilities.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
-SG_BEGIN_DECL()
+extern "C" {
static jmethodID jhost_method_Host_constructor;
static jfieldID jhost_field_Host_bind;
/* get the C string from the java string */
if (jname == nullptr) {
- jxbt_throw_null(env,bprintf("No host can have a null name"));
+ jxbt_throw_null(env, "No host can have a null name");
return nullptr;
}
const char *name = env->GetStringUTFChars(jname, 0);
int index = 0;
jobjectArray jtable;
- xbt_dict_t dict = MSG_host_get_mounted_storage_list(host);
- int count = xbt_dict_length(dict);
+ std::unordered_map<std::string, msg_storage_t> mounted_storages = host->getMountedStorages();
+ int count = mounted_storages.size();
jclass cls = env->FindClass("org/simgrid/msg/Storage");
jtable = env->NewObjectArray((jsize) count, cls, nullptr);
return nullptr;
}
- xbt_dict_cursor_t cursor=nullptr;
- const char* mount_name;
- const char* storage_name;
-
- xbt_dict_foreach(dict,cursor,mount_name,storage_name) {
- jname = env->NewStringUTF(storage_name);
+ for (auto const& elm : mounted_storages) {
+ jname = env->NewStringUTF(elm.second->getCname());
jstorage = Java_org_simgrid_msg_Storage_getByName(env,cls,jname);
env->SetObjectArrayElement(jtable, index, jstorage);
index++;
}
- xbt_dict_free(&dict);
return jtable;
}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCurrentPowerPeak(JNIEnv* env, jobject jhost)
{
msg_host_t host = jhost_get_native(env, jhost);
- return MSG_host_get_current_power_peak(host);
+ return MSG_host_get_speed(host);
}
JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getPowerPeakAt(JNIEnv* env, jobject jhost, jint pstate)
{
msg_host_t host = jhost_get_native(env, jhost);
return MSG_host_get_power_peak_at(host, pstate);
}
-
-SG_END_DECL()
+}