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:23 UTC
[07/18] git commit: ACCUMULO-1957 more updates based on review
comments
ACCUMULO-1957 more updates based on review comments
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/549d1c25
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/549d1c25
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/549d1c25
Branch: refs/heads/master
Commit: 549d1c25336c4201da802e2b2117bd252636979d
Parents: c2d95a1
Author: Eric C. Newton <er...@gmail.com>
Authored: Tue Sep 2 17:27:53 2014 -0400
Committer: Eric C. Newton <er...@gmail.com>
Committed: Fri Sep 5 17:16:59 2014 -0400
----------------------------------------------------------------------
.../apache/accumulo/tserver/log/DfsLogger.java | 3 ++
.../accumulo/test/functional/DurabilityIT.java | 41 +++++++++++++++++++-
.../test/functional/SessionDurabilityIT.java | 13 +++++++
3 files changed, 56 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/549d1c25/server/tserver/src/main/java/org/apache/accumulo/tserver/log/DfsLogger.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/DfsLogger.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/DfsLogger.java
index f6829ea..e166a60 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/DfsLogger.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/DfsLogger.java
@@ -532,6 +532,9 @@ public class DfsLogger {
}
}
+ if (durability == Durability.LOG)
+ return null;
+
synchronized (closeLock) {
// use a different lock for close check so that adding to work queue does not need
// to wait on walog I/O operations
http://git-wip-us.apache.org/repos/asf/accumulo/blob/549d1c25/test/src/test/java/org/apache/accumulo/test/functional/DurabilityIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/DurabilityIT.java b/test/src/test/java/org/apache/accumulo/test/functional/DurabilityIT.java
index 05e3bef..74df598 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/DurabilityIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/DurabilityIT.java
@@ -19,6 +19,8 @@ package org.apache.accumulo.test.functional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Map.Entry;
import org.apache.accumulo.core.client.BatchWriter;
@@ -28,6 +30,7 @@ import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.util.UtilWaitThread;
import org.apache.accumulo.minicluster.ServerType;
@@ -60,7 +63,6 @@ public class DurabilityIT extends ConfigurableMacIT {
tableOps.setProperty(tableNames[1], Property.TABLE_DURABILITY.getKey(), "flush");
tableOps.setProperty(tableNames[2], Property.TABLE_DURABILITY.getKey(), "log");
tableOps.setProperty(tableNames[3], Property.TABLE_DURABILITY.getKey(), "none");
- UtilWaitThread.sleep(1000);
return tableNames;
}
@@ -130,6 +132,43 @@ public class DurabilityIT extends ConfigurableMacIT {
assertTrue(N > readSome(tableNames[3], N));
cleanup(tableNames);
}
+
+ @Test(timeout = 4 * 60 * 1000)
+ public void testIncreaseDurability() throws Exception {
+ Connector c = getConnector();
+ String tableName = getUniqueNames(1)[0];
+ c.tableOperations().create(tableName);
+ c.tableOperations().setProperty(tableName, Property.TABLE_DURABILITY.getKey(), "none");
+ UtilWaitThread.sleep(1000);
+ writeSome(tableName, N);
+ restartTServer();
+ assertTrue(N > readSome(tableName, N));
+ c.tableOperations().setProperty(tableName, Property.TABLE_DURABILITY.getKey(), "sync");
+ writeSome(tableName, N);
+ restartTServer();
+ assertTrue(N == readSome(tableName, N));
+ }
+
+ private static Map<String, String> map(Iterable<Entry<String, String>> entries) {
+ Map<String, String> result = new HashMap<String,String>();
+ for (Entry<String,String> entry : entries) {
+ result.put(entry.getKey(), entry.getValue());
+ }
+ return result;
+ }
+
+ @Test(timeout = 4 * 60 * 1000)
+ public void testMetaDurability() throws Exception {
+ Connector c = getConnector();
+ String tableName = getUniqueNames(1)[0];
+ c.instanceOperations().setProperty(Property.TABLE_DURABILITY.getKey(), "none");
+ Map<String, String> props = map(c.tableOperations().getProperties(MetadataTable.NAME));
+ assertEquals("sync", props.get(Property.TABLE_DURABILITY.getKey()));
+ c.tableOperations().create(tableName);
+ props = map(c.tableOperations().getProperties(tableName));
+ assertEquals("none", props.get(Property.TABLE_DURABILITY.getKey()));
+
+ }
private long readSome(String table, long n) throws Exception {
long count = 0;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/549d1c25/test/src/test/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java b/test/src/test/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java
index 1f84327..91041a9 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java
@@ -44,6 +44,19 @@ public class SessionDurabilityIT extends ConfigurableMacIT {
assertEquals(10, count(tableName));
}
+ @Test
+ public void durableTableLosesNonDurableWrites() throws Exception {
+ Connector c = getConnector();
+ String tableName = getUniqueNames(1)[0];
+ c.tableOperations().create(tableName);
+ c.tableOperations().setProperty(tableName, Property.TABLE_DURABILITY.getKey(), "sync");
+ BatchWriterConfig cfg = new BatchWriterConfig();
+ cfg.setDurability(Durability.NONE);
+ write(tableName, 10, cfg);
+ restartTServer();
+ assertTrue(10 > count(tableName));
+ }
+
private int count(String tableName) throws Exception {
Connector c = getConnector();
Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY);