}
env->ReleaseStringUTFChars(jname, name);
- if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) { /* native host not associated yet with java host */
+ if (!host->extension(JAVA_HOST_LEVEL)) { /* native host not associated yet with java host */
/* Instantiate a new java host */
jhost = jhost_new_instance(env);
/* the native host data field is set with the global reference to the
* java host returned by this function
*/
- xbt_lib_set(host_lib, host->key, JAVA_HOST_LEVEL, (void *) jhost);
+ host->extension_set(JAVA_HOST_LEVEL, (void *)jhost);
}
/* return the global reference to the java host instance */
- return (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
+ return (jobject) host->extension(JAVA_HOST_LEVEL);
}
JNIEXPORT jobject JNICALL
msg_host_t host = MSG_host_self();
- if (!xbt_lib_get_level(host, JAVA_HOST_LEVEL)) {
+ if (!host->extension(JAVA_HOST_LEVEL)) {
/* the native host not yet associated with the java host instance */
/* instanciate a new java host instance */
env->SetObjectField(jhost, jhost_field_Host_name, jname);
/* Bind & store it */
jhost_bind(jhost, host, env);
- xbt_lib_set(host_lib, host->key, JAVA_HOST_LEVEL, (void *) jhost);
+ host->extension_set(JAVA_HOST_LEVEL, (void *) jhost);
} else {
- jhost = (jobject) xbt_lib_get_level(host, JAVA_HOST_LEVEL);
+ jhost = (jobject) host->extension(JAVA_HOST_LEVEL);
}
return jhost;
return (jdouble) MSG_host_get_core_number(host);
}
-JNIEXPORT jint JNICALL
-Java_org_simgrid_msg_Host_getLoad(JNIEnv * env, jobject jhost) {
- msg_host_t host = jhost_get_native(env, jhost);
-
- if (!host) {
- jxbt_throw_notbound(env, "host", jhost);
- return -1;
- }
-
- return (jint) MSG_get_host_msgload(host);
-}
JNIEXPORT jobject JNICALL
Java_org_simgrid_msg_Host_getProperty(JNIEnv *env, jobject jhost, jobject jname) {
msg_host_t host = jhost_get_native(env, jhost);
for (index = 0; index < count; index++) {
host = xbt_dynar_get_as(table,index,msg_host_t);
- jhost = (jobject) (xbt_lib_get_level(host, JAVA_HOST_LEVEL));
+ jhost = (jobject) host->extension(JAVA_HOST_LEVEL);
if (!jhost) {
jname = env->NewStringUTF(MSG_host_get_name(host));
env->ReleaseStringUTFChars((jstring) jname, name);
}
+
+#include "simgrid/plugins/energy.h"
+JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getConsumedEnergy (JNIEnv *env, jobject jhost) {
+ msg_host_t host = jhost_get_native(env, jhost);
+
+ if (!host) {
+ jxbt_throw_notbound(env, "host", jhost);
+ return 0;
+ }
+
+ return MSG_host_get_consumed_energy(host);
+
+}
+