summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4ee5164)
raw | patch | inline | side by side (parent: 4ee5164)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 31 Oct 2010 12:48:05 +0000 (13:48 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 31 Oct 2010 12:48:05 +0000 (13:48 +0100) |
bindings/java/org/collectd/api/CollectdFlushInterface.java | patch | blob | history | |
src/java.c | patch | blob | history | |
src/utils_time.h | patch | blob | history |
diff --git a/bindings/java/org/collectd/api/CollectdFlushInterface.java b/bindings/java/org/collectd/api/CollectdFlushInterface.java
index 3e492ddffd9a7f404579b77ef119087c59fee24d..410c61c60ef21d2d350e29a699fe1c2e5630d42c 100644 (file)
*/
public interface CollectdFlushInterface
{
- public int flush (int timeout, String identifier);
+ public int flush (Number timeout, String identifier);
}
diff --git a/src/java.c b/src/java.c
index 528ec9c475656140b4572bf30361c1c082fbd46b..4d490eb6db2dab69396bfeb647dcff1c43037b8d 100644 (file)
--- a/src/java.c
+++ b/src/java.c
static int cjni_read (user_data_t *user_data);
static int cjni_write (const data_set_t *ds, const value_list_t *vl,
user_data_t *ud);
-static int cjni_flush (int timeout, const char *identifier, user_data_t *ud);
+static int cjni_flush (cdtime_t timeout, const char *identifier, user_data_t *ud);
static void cjni_log (int severity, const char *message, user_data_t *ud);
static int cjni_notification (const notification_t *n, user_data_t *ud);
#undef SET_STRING
/* Set the `time' member. Java stores time in milliseconds. */
- status = ctoj_long (jvm_env, ((jlong) vl->time) * ((jlong) 1000),
+ status = ctoj_long (jvm_env, (jlong) CDTIME_T_TO_MS (vl->time),
c_valuelist, o_valuelist, "setTime");
if (status != 0)
{
@@ -1729,7 +1729,7 @@ static cjni_callback_info_t *cjni_callback_info_create (JNIEnv *jvm_env, /* {{{
case CB_TYPE_FLUSH:
method_name = "flush";
- method_signature = "(ILjava/lang/String;)I";
+ method_signature = "(Ljava/lang/Number;Ljava/lang/String;)I";
break;
case CB_TYPE_SHUTDOWN:
@@ -2551,11 +2551,12 @@ static int cjni_write (const data_set_t *ds, const value_list_t *vl, /* {{{ */
} /* }}} int cjni_write */
/* Call the CB_TYPE_FLUSH callback pointed to by the `user_data_t' pointer. */
-static int cjni_flush (int timeout, const char *identifier, /* {{{ */
+static int cjni_flush (cdtime_t timeout, const char *identifier, /* {{{ */
user_data_t *ud)
{
JNIEnv *jvm_env;
cjni_callback_info_t *cbi;
+ jobject o_timeout;
jobject o_identifier;
int status;
int ret_status;
cbi = (cjni_callback_info_t *) ud->data;
+ o_timeout = ctoj_jdouble_to_number (jvm_env,
+ (jdouble) CDTIME_T_TO_DOUBLE (timeout));
+ if (o_timeout == NULL)
+ {
+ ERROR ("java plugin: cjni_flush: Converting double "
+ "to Number object failed.");
+ return (-1);
+ }
+
o_identifier = NULL;
if (identifier != NULL)
{
o_identifier = (*jvm_env)->NewStringUTF (jvm_env, identifier);
if (o_identifier == NULL)
{
+ (*jvm_env)->DeleteLocalRef (jvm_env, o_timeout);
ERROR ("java plugin: cjni_flush: NewStringUTF failed.");
return (-1);
}
}
ret_status = (*jvm_env)->CallIntMethod (jvm_env,
- cbi->object, cbi->method, (jint) timeout, o_identifier);
+ cbi->object, cbi->method, o_timeout, o_identifier);
(*jvm_env)->DeleteLocalRef (jvm_env, o_identifier);
+ (*jvm_env)->DeleteLocalRef (jvm_env, o_timeout);
status = cjni_thread_detach ();
if (status != 0)
diff --git a/src/utils_time.h b/src/utils_time.h
index 0aa4fce64ef5c8ac9a4b32b3661819c50b9b883c..3c31b3532423bba564958a1b6fb7fd355176af00 100644 (file)
--- a/src/utils_time.h
+++ b/src/utils_time.h
#define CDTIME_T_TO_DOUBLE(t) (((double) (t)) / 1073741824.0)
#define DOUBLE_TO_CDTIME_T(d) ((cdtime_t) ((d) * 1073741824.0))
+#define CDTIME_T_TO_MS(t) ((long) (((double) (t)) / 1073741.824))
+
#define US_TO_CDTIME_T(us) ((cdtime_t) (((double) (us)) * 1073.741824))
#define CDTIME_T_TO_US(t) ((suseconds_t) (((double) (t)) / 1073.741824))
#define NS_TO_CDTIME_T(ns) ((cdtime_t) (((double) (ns)) * 1.073741824))