A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
more legacy MSG functions
[simgrid.git]
/
src
/
bindings
/
java
/
jmsg_host.cpp
diff --git
a/src/bindings/java/jmsg_host.cpp
b/src/bindings/java/jmsg_host.cpp
index
2676d37
..
7076f7a
100644
(file)
--- a/
src/bindings/java/jmsg_host.cpp
+++ b/
src/bindings/java/jmsg_host.cpp
@@
-1,22
+1,21
@@
/* Functions related to the java host instances. */
/* Functions related to the java host instances. */
-/* Copyright (c) 2007-201
7
. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-201
8
. 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. */
#include "simgrid/plugins/energy.h"
#include "simgrid/s4u/Host.hpp"
/* 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. */
#include "simgrid/plugins/energy.h"
#include "simgrid/s4u/Host.hpp"
+#include "simgrid/s4u/Storage.hpp"
-#include "jmsg.h"
+#include "jmsg.h
pp
"
#include "jmsg_host.h"
#include "jmsg_host.h"
-#include "jxbt_utilities.h"
#include "jmsg_storage.h"
#include "jmsg_storage.h"
+#include "jxbt_utilities.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
-SG_BEGIN_DECL()
-
static jmethodID jhost_method_Host_constructor;
static jfieldID jhost_field_Host_bind;
static jfieldID jhost_field_Host_name;
static jmethodID jhost_method_Host_constructor;
static jfieldID jhost_field_Host_bind;
static jfieldID jhost_field_Host_name;
@@
-55,7
+54,7
@@
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jcla
/* get the C string from the java string */
if (jname == nullptr) {
/* 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);
return nullptr;
}
const char *name = env->GetStringUTFChars(jname, 0);
@@
-122,7
+121,7
@@
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jc
return nullptr;
}
/* Sets the host name */
return nullptr;
}
/* Sets the host name */
- jobject jname = env->NewStringUTF(host->cname());
+ jobject jname = env->NewStringUTF(host->
get_
cname());
env->SetObjectField(jhost, jhost_field_Host_name, jname);
/* Bind & store it */
jhost_bind(jhost, host, env);
env->SetObjectField(jhost, jhost_field_Host_name, jname);
/* Bind & store it */
jhost_bind(jhost, host, env);
@@
-141,7
+140,7
@@
JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_on(JNIEnv *env, jobject jhost)
JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_off(JNIEnv *env, jobject jhost) {
msg_host_t host = jhost_get_native(env, jhost);
JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_off(JNIEnv *env, jobject jhost) {
msg_host_t host = jhost_get_native(env, jhost);
- MSG_host_off(host);
+ MSG_host_off(host);
}
JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getCount(JNIEnv * env, jclass cls) {
}
JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getCount(JNIEnv * env, jclass cls) {
@@
-237,8
+236,8
@@
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getMountedStorage(JNIEn
int index = 0;
jobjectArray jtable;
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);
jclass cls = env->FindClass("org/simgrid/msg/Storage");
jtable = env->NewObjectArray((jsize) count, cls, nullptr);
@@
-248,17
+247,12
@@
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getMountedStorage(JNIEn
return 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->get_cname());
jstorage = Java_org_simgrid_msg_Storage_getByName(env,cls,jname);
env->SetObjectArrayElement(jtable, index, jstorage);
index++;
}
jstorage = Java_org_simgrid_msg_Storage_getByName(env,cls,jname);
env->SetObjectArrayElement(jtable, index, jstorage);
index++;
}
- xbt_dict_free(&dict);
return jtable;
}
return jtable;
}
@@
-319,7
+313,7
@@
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclas
jobject jhost = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
if (not jhost) {
jobject jhost = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
if (not jhost) {
- jstring jname = env->NewStringUTF(host->cname());
+ jstring jname = env->NewStringUTF(host->
get_
cname());
jhost = Java_org_simgrid_msg_Host_getByName(env, cls_arg, jname);
}
jhost = Java_org_simgrid_msg_Host_getByName(env, cls_arg, jname);
}
@@
-332,7
+326,7
@@
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclas
JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_setAsyncMailbox(JNIEnv * env, jclass cls_arg, jobject jname)
{
const char *name = env->GetStringUTFChars((jstring) jname, 0);
JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_setAsyncMailbox(JNIEnv * env, jclass cls_arg, jobject jname)
{
const char *name = env->GetStringUTFChars((jstring) jname, 0);
-
MSG_mailbox_set_async
(name);
+
sg_mailbox_set_receiver
(name);
env->ReleaseStringUTFChars((jstring) jname, name);
}
env->ReleaseStringUTFChars((jstring) jname, name);
}
@@
-371,12
+365,10
@@
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)
{
msg_host_t host = jhost_get_native(env, jhost);
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);
}
}
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()