clouds)
* Change the meaning of Process.restart: now restart the process from the start, like MSG_process_restart in C.
* Add Process.setAutoRestart: handling of process restart when failed host comes back.
-
+ * Add Process.getProperty, Host.getProperty, Host.getProperty: allows you to retrieve the properties of the processes/hosts
+
* Introduce a new context factory based on Coroutines (read the doc to know how to use it): simulations are expected to run up to five times faster.
SimGrid-java (3.7.1) stable; urgency=low
*
*/
public native double getSpeed();
-
+ /**
+ * @brief Returns the value of a given host property.
+ */
+ public native String getProperty(String name);
+ /**
+ * @brief Change the value of a given host property.
+ */
+ public native void setProperty(String name, String value);
/** This method tests if a host is avail.
* @return
*/
* Kill time of the process
*/
public double killTime = -1;
-
- public Hashtable<String,String> properties;
-
+
/**
* The name of the process.
*/
this.name = null;
this.bind = 0;
this.args = new Vector<String>();
- this.properties = null;
}
this.args = new Vector<String>();
if (null != args)
this.args.addAll(Arrays.asList(args));
-
- this.properties = new Hashtable<String,String>();
}
/**
* Constructs a new process from a host and his name, the arguments of here method function are
this.args = new Vector<String>();
if (null != args)
this.args.addAll(Arrays.asList(args));
-
- this.properties = new Hashtable<String,String>();
-
+
this.startTime = startTime;
this.killTime = killTime;
}
public int getPPID() {
return ppid;
}
+ /**
+ * @brief Returns the value of a given process property.
+ */
+ public native String getProperty(String name);
+
/**
* Set the kill time of the process
* @param killTime the time when the process is killed
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/str.h"
+#include "msg/msg.h"
#include "jmsg.h"
#include "jmsg_host.h"
#include "jxbt_utilities.h"
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);
+
+ if (!host) {
+ jxbt_throw_notbound(env, "host", jhost);
+ return NULL;
+ }
+ const char *name = (*env)->GetStringUTFChars(env, jname, 0);
+
+ const char *property = MSG_host_get_property_value(host, name);
+ if (!property) {
+ return NULL;
+ }
+
+ jobject jproperty = (*env)->NewStringUTF(env, property);
+
+ (*env)->ReleaseStringUTFChars(env, jname, name);
+
+ return jproperty;
+}
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Host_setProperty(JNIEnv *env, jobject jhost, jobject jname, jobject jvalue) {
+ msg_host_t host = jhost_get_native(env, jhost);
+
+ if (!host) {
+ jxbt_throw_notbound(env, "host", jhost);
+ return;
+ }
+ const char *name = (*env)->GetStringUTFChars(env, jname, 0);
+ const char *value_java = (*env)->GetStringUTFChars(env, jvalue, 0);
+ char *value = strdup(value_java);
+
+ MSG_host_set_property_value(host,name,value,xbt_free);
+
+ (*env)->ReleaseStringUTFChars(env, jvalue, value);
+ (*env)->ReleaseStringUTFChars(env, jname, name);
+
+}
JNIEXPORT jboolean JNICALL
Java_org_simgrid_msg_Host_isAvail(JNIEnv * env, jobject jhost) {
msg_host_t host = jhost_get_native(env, jhost);
JNIEXPORT jint JNICALL
Java_org_simgrid_msg_Host_getLoad(JNIEnv * env,
jobject jhost);
-
+/*
+ * Class org_simgrid_msg_Host
+ * Method getProperty
+ * Signature (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT jobject JNICALL
+Java_org_simgrid_msg_Host_getProperty(JNIEnv *env, jobject jhost, jobject jname);
+/*
+ * Class org_simgrid_msg_Host
+ * Method setProperty
+ * Signature (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Host_setProperty(JNIEnv *env, jobject jhost, jobject jname, jobject jvalue);
/*
* Class org_simgrid_msg_Host
* Method isAvail
jobject jprocess = native_to_java_process(process);
if (!jprocess) {
- jxbt_throw_jni(env, "SIMIX_process_get_jprocess() failed");
+ jxbt_throw_jni(env, "get process failed");
return NULL;
}
return jprocess;
}
+JNIEXPORT jobject JNICALL
+Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname) {
+ msg_process_t process = jprocess_to_native_process(jprocess, env);
+
+ if (!process) {
+ jxbt_throw_notbound(env, "process", jprocess);
+ return NULL;
+ }
+ const char *name = (*env)->GetStringUTFChars(env, jname, 0);
+ const char *property = MSG_process_get_property_value(process, name);
+ if (!property) {
+ return NULL;
+ }
+
+ jobject jproperty = (*env)->NewStringUTF(env, property);
+
+ (*env)->ReleaseStringUTFChars(env, jname, name);
+
+ return jproperty;
+}
JNIEXPORT jobject JNICALL
Java_org_simgrid_msg_Process_currentProcess(JNIEnv * env, jclass cls)
{
*/
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
(JNIEnv *, jclass, jint);
-
+/*
+ * Class org_simgrid_msg_Process
+ * Method waitFor
+ * Signature (D)V
+ */
+JNIEXPORT jobject JNICALL
+Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname);
/*
* Class org_simgrid_msg_Process
* Method currentProcess