Parcourir la source

[partial-ns] Add sync options in WriteOptions.

Haohui Mai il y a 10 ans
Parent
commit
af9ff74e8b

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfsdb/src/main/java/org/apache/hadoop/hdfs/hdfsdb/NativeObject.java

@@ -19,7 +19,7 @@ package org.apache.hadoop.hdfs.hdfsdb;
 
 abstract class NativeObject implements AutoCloseable {
   static {
-    System.loadLibrary("hdfs-jni");
+    System.loadLibrary("hdfsdb-jni");
   }
   protected long nativeHandle;
   protected long nativeHandle() { return nativeHandle; }

+ 6 - 0
hadoop-hdfs-project/hadoop-hdfsdb/src/main/java/org/apache/hadoop/hdfs/hdfsdb/WriteOptions.java

@@ -22,6 +22,11 @@ public class WriteOptions extends NativeObject {
     super(construct());
   }
 
+  public WriteOptions sync(boolean value) {
+    sync(nativeHandle, value);
+    return this;
+  }
+
   @Override
   public void close() {
     if (nativeHandle != 0) {
@@ -32,4 +37,5 @@ public class WriteOptions extends NativeObject {
 
   private static native long construct();
   private static native void destruct(long handle);
+  private static native void sync(long handle, boolean value);
 }

+ 5 - 0
hadoop-hdfs-project/hadoop-hdfsdb/src/main/native/jni/bindings.cc

@@ -224,6 +224,11 @@ jlong JNICALL Java_org_apache_hadoop_hdfs_hdfsdb_WriteOptions_construct(JNIEnv *
   return uintptr(new leveldb::WriteOptions());
 }
 
+void JNICALL Java_org_apache_hadoop_hdfs_hdfsdb_WriteOptions_sync(JNIEnv *, jclass, jlong handle, jboolean value) {
+  leveldb::WriteOptions *options = reinterpret_cast<leveldb::WriteOptions*>(handle);
+  options->sync = value;
+}
+
 void JNICALL Java_org_apache_hadoop_hdfs_hdfsdb_WriteOptions_destruct(JNIEnv *, jclass, jlong handle) {
   delete reinterpret_cast<leveldb::WriteOptions*>(handle);
 }