Expose atomic counter increment API to Java
This is part of ONOS-1080, ONOS-1081
- implement JNI code
- implement RCClient
- implement HZClient
- implement simple test case
Change-Id: I499ba2a0b648302c4fec8c653631ab28bf52039c
diff --git a/src/main/cpp/edu_stanford_ramcloud_JRamCloud.cc b/src/main/cpp/edu_stanford_ramcloud_JRamCloud.cc
index d895138..f6cfea7 100644
--- a/src/main/cpp/edu_stanford_ramcloud_JRamCloud.cc
+++ b/src/main/cpp/edu_stanford_ramcloud_JRamCloud.cc
@@ -885,3 +885,17 @@
}
return outJNIArray;
}
+
+/*
+ * Class: edu_stanford_ramcloud_JRamCloud
+ * Method: increment
+ * Signature: (J[BJ)J
+ */
+JNIEXPORT jlong JNICALL Java_edu_stanford_ramcloud_JRamCloud_increment (JNIEnv* env, jobject jRamCloud, jlong jTableId, jbyteArray jKey, jlong incrementValue) {
+ RamCloud* ramcloud = getRamCloud(env, jRamCloud);
+ JByteArrayReference key(env, jKey);
+ uint64_t version = VERSION_NONEXISTENT;
+ try {
+ return ramcloud->increment(jTableId, key.pointer, key.length, incrementValue, NULL, &version);
+ } EXCEPTION_CATCHER(VERSION_NONEXISTENT);
+}