accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [09/18] git commit: ACCUMULO-1957 add durabilty to the simple Read/Write example
Date Fri, 05 Sep 2014 21:17:25 GMT
ACCUMULO-1957 add durabilty to the simple Read/Write example


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/1a2c8d5d
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/1a2c8d5d
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/1a2c8d5d

Branch: refs/heads/master
Commit: 1a2c8d5d47fa0c5d44cc01a26c3ff4dc13105d5f
Parents: e0fe2ae
Author: Eric C. Newton <eric.newton@gmail.com>
Authored: Wed Sep 3 10:44:57 2014 -0400
Committer: Eric C. Newton <eric.newton@gmail.com>
Committed: Fri Sep 5 17:16:59 2014 -0400

----------------------------------------------------------------------
 .../examples/simple/client/ReadWriteExample.java     | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/1a2c8d5d/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java
----------------------------------------------------------------------
diff --git a/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java
b/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java
index a7b288d..7bc44e8 100644
--- a/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java
+++ b/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java
@@ -25,6 +25,7 @@ import org.apache.accumulo.core.cli.ScannerOpts;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.BatchWriterConfig;
 import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Durability;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
@@ -34,6 +35,7 @@ import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.accumulo.core.util.ByteArraySet;
 import org.apache.hadoop.io.Text;
 
+import com.beust.jcommander.IStringConverter;
 import com.beust.jcommander.Parameter;
 
 public class ReadWriteExample {
@@ -43,6 +45,13 @@ public class ReadWriteExample {
   
   private Connector conn;
   
+  static class DurabilityConverter implements IStringConverter<Durability> {
+    @Override
+    public Durability convert(String value) {
+      return Durability.fromString(value);
+    }    
+  }
+  
   static class Opts extends ClientOnDefaultTable {
     @Parameter(names = {"-C", "--createtable"}, description = "create table before doing
anything")
     boolean createtable = false;
@@ -54,6 +63,8 @@ public class ReadWriteExample {
     boolean readEntries = false;
     @Parameter(names = {"-d", "--delete"}, description = "delete entries after any creates")
     boolean deleteEntries = false;
+    @Parameter(names = {"--durability"}, description = "durabilty used for writes (none,
log, flush or sync)", converter=DurabilityConverter.class)
+    Durability durability = Durability.DEFAULT;
     
     public Opts() {
       super(DEFAULT_TABLE_NAME);
@@ -103,7 +114,9 @@ public class ReadWriteExample {
   
   private void createEntries(Opts opts) throws Exception {
     if (opts.createEntries || opts.deleteEntries) {
-      BatchWriter writer = conn.createBatchWriter(opts.getTableName(), new BatchWriterConfig());
+      BatchWriterConfig cfg = new BatchWriterConfig();
+      cfg.setDurability(opts.durability);
+      BatchWriter writer = conn.createBatchWriter(opts.getTableName(), cfg);
       ColumnVisibility cv = new ColumnVisibility(opts.auths.toString().replace(',', '|'));
       
       Text cf = new Text("datatypes");


Mime
View raw message