jclass class_Host = env->FindClass("org/simgrid/msg/Host");
jhost_method_Host_constructor = env->GetMethodID(class_Host, "<init>", "()V");
jhost_field_Host_bind = jxbt_get_jfield(env,class_Host, "bind", "J");
jclass class_Host = env->FindClass("org/simgrid/msg/Host");
jhost_method_Host_constructor = env->GetMethodID(class_Host, "<init>", "()V");
jhost_field_Host_bind = jxbt_get_jfield(env,class_Host, "bind", "J");
-JNIEXPORT jobject JNICALL
-Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls,
- jstring jname) {
+
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls, jstring jname) {
msg_host_t host; /* native host */
jobject jhost; /* global reference to the java host instance returned */
/* get the C string from the java string */
if (jname == NULL) {
msg_host_t host; /* native host */
jobject jhost; /* global reference to the java host instance returned */
/* get the C string from the java string */
if (jname == NULL) {
}
const char *name = env->GetStringUTFChars(jname, 0);
/* get the host by name (the hosts are created during the grid resolution) */
}
const char *name = env->GetStringUTFChars(jname, 0);
/* get the host by name (the hosts are created during the grid resolution) */
/* bind the java host and the native host */
jhost_bind(jhost, host, env);
/* bind the java host and the native host */
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->set_facet(JAVA_HOST_LEVEL, (void *)jhost);
+ /* 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);
/* the native host not yet associated with the java host instance */
/* instanciate a new java host instance */
/* 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);
env->SetObjectField(jhost, jhost_field_Host_name, jname);
/* Bind & store it */
jhost_bind(jhost, host, env);
-JNIEXPORT jobject JNICALL
-Java_org_simgrid_msg_Host_getProperty(JNIEnv *env, jobject jhost, jobject jname) {
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getProperty(JNIEnv *env, jobject jhost, jobject jname) {
MSG_host_set_property_value(host, name, value, xbt_free_f);
MSG_host_set_property_value(host, name, value, xbt_free_f);
-JNIEXPORT jobjectArray JNICALL
-Java_org_simgrid_msg_Host_getMountedStorage(JNIEnv * env, jobject jhost){
-
+JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getMountedStorage(JNIEnv * env, jobject jhost)
+{
- jobjectArray jtable;
- xbt_dict_t dict = MSG_host_get_mounted_storage_list(host);
- int count = xbt_dict_length(dict);
- jclass cls = env->FindClass("org/simgrid/msg/Storage");
+ jobjectArray jtable;
+ xbt_dict_t dict = MSG_host_get_mounted_storage_list(host);
+ int count = xbt_dict_length(dict);
+ jclass cls = env->FindClass("org/simgrid/msg/Storage");
- xbt_dict_cursor_t cursor=NULL;
- const char *mount_name, *storage_name;
+ xbt_dict_cursor_t cursor=NULL;
+ const char *mount_name, *storage_name;
- xbt_dict_foreach(dict,cursor,mount_name,storage_name) {
- jname = env->NewStringUTF(storage_name);
- jstorage = Java_org_simgrid_msg_Storage_getByName(env,cls,jname);
- env->SetObjectArrayElement(jtable, index, jstorage);
+ xbt_dict_foreach(dict,cursor,mount_name,storage_name) {
+ jname = env->NewStringUTF(storage_name);
+ jstorage = Java_org_simgrid_msg_Storage_getByName(env,cls,jname);
+ env->SetObjectArrayElement(jtable, index, jstorage);
-JNIEXPORT jobjectArray JNICALL
-Java_org_simgrid_msg_Host_getAttachedStorage(JNIEnv * env, jobject jhost){
+JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getAttachedStorage(JNIEnv * env, jobject jhost)
+{
-JNIEXPORT jobjectArray JNICALL
-Java_org_simgrid_msg_Host_getStorageContent(JNIEnv * env, jobject jhost){
+JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getStorageContent(JNIEnv * env, jobject jhost)
+{
for (index = 0; index < count; index++) {
host = xbt_dynar_get_as(table,index,msg_host_t);
for (index = 0; index < count; index++) {
host = xbt_dynar_get_as(table,index,msg_host_t);
const char *name = env->GetStringUTFChars((jstring) jname, 0);
MSG_mailbox_set_async(name);
env->ReleaseStringUTFChars((jstring) jname, name);
const char *name = env->GetStringUTFChars((jstring) jname, 0);
MSG_mailbox_set_async(name);
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;
+ }