You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2014/09/05 23:17:25 UTC
[09/18] git commit: ACCUMULO-1957 add durabilty to the simple
Read/Write example
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 <er...@gmail.com>
Authored: Wed Sep 3 10:44:57 2014 -0400
Committer: Eric C. Newton <er...@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");