accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bus...@apache.org
Subject [2/3] git commit: ACCUMULO-2816 Ensure LocalWALRecovery looks at WAL.
Date Sat, 17 May 2014 01:31:06 GMT
ACCUMULO-2816 Ensure LocalWALRecovery looks at WAL.

* changed to use of FileSystem api in test to avoid crc handling.
* added better error message for reading an invalid wal
* fixed v2 vs v3 magic header reading


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

Branch: refs/heads/master
Commit: 244c1ab71c4b04794cbd718fc34c7fc2216774c4
Parents: f61abc0
Author: Sean Busbey <busbey@cloudera.com>
Authored: Fri May 16 15:27:18 2014 -0400
Committer: Sean Busbey <busbey@cloudera.com>
Committed: Fri May 16 19:27:05 2014 -0400

----------------------------------------------------------------------
 .../apache/accumulo/tserver/log/DfsLogger.java  |  4 ++--
 .../accumulo/tserver/logger/LogFileKey.java     |  3 +++
 .../tserver/log/LocalWALRecoveryTest.java       | 22 ++++++--------------
 3 files changed, 11 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/244c1ab7/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 eb04f09..61c1059 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
@@ -269,7 +269,7 @@ public class DfsLogger {
     } else {
       input.seek(0);
       byte[] magicV2 = DfsLogger.LOG_FILE_HEADER_V2.getBytes();
-      byte[] magicBufferV2 = new byte[magic.length];
+      byte[] magicBufferV2 = new byte[magicV2.length];
       input.readFully(magicBufferV2);
 
       if (Arrays.equals(magicBufferV2, magicV2)) {
@@ -299,7 +299,7 @@ public class DfsLogger {
           CryptoModuleParameters params = CryptoModuleFactory.createParamsObjectFromAccumuloConfiguration(conf);
 
           input.seek(0);
-          input.readFully(magicBuffer);
+          input.readFully(magicBufferV2);
           params.setEncryptedInputStream(input);
 
           params = cryptoModule.getDecryptingInputStream(params);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/244c1ab7/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogFileKey.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogFileKey.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogFileKey.java
index 1e33569..3a20e8d 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogFileKey.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/logger/LogFileKey.java
@@ -41,6 +41,9 @@ public class LogFileKey implements WritableComparable<LogFileKey>
{
   @Override
   public void readFields(DataInput in) throws IOException {
     int value = in.readByte();
+    if (value >= LogEvents.values().length) {
+      throw new IOException("Invalid LogEvent type, got ordinal " + value + ", but only know
about " + LogEvents.values().length + " possible types.");
+    }
     event = LogEvents.values()[value];
     switch (event) {
       case OPEN:

http://git-wip-us.apache.org/repos/asf/accumulo/blob/244c1ab7/server/tserver/src/test/java/org/apache/accumulo/tserver/log/LocalWALRecoveryTest.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/log/LocalWALRecoveryTest.java
b/server/tserver/src/test/java/org/apache/accumulo/tserver/log/LocalWALRecoveryTest.java
index 99190b2..df6ec2d 100644
--- a/server/tserver/src/test/java/org/apache/accumulo/tserver/log/LocalWALRecoveryTest.java
+++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/log/LocalWALRecoveryTest.java
@@ -24,9 +24,7 @@ import static org.junit.Assert.assertEquals;
 import java.io.DataInputStream;
 import java.io.EOFException;
 import java.io.File;
-import java.io.FilenameFilter;
 import java.io.IOException;
-import java.util.UUID;
 
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
@@ -36,6 +34,7 @@ import org.apache.accumulo.tserver.log.DfsLogger.DFSLoggerInputStreams;
 import org.apache.accumulo.tserver.logger.LogFileKey;
 import org.apache.accumulo.tserver.logger.LogFileValue;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.junit.Before;
@@ -69,23 +68,14 @@ public class LocalWALRecoveryTest {
 
   @Test
   public void testRecoverLocalWriteAheadLogs() throws IOException {
-    FileSystem fs = FileSystem.get(walTarget.toURI(), new Configuration());
+    Path targetPath = new Path(walTarget.toURI());
+    FileSystem fs = FileSystem.get(targetPath.toUri(), new Configuration());
     recovery.recoverLocalWriteAheadLogs(fs);
 
-    assertEquals("Wrong number of WAL files recovered.", 1, walTarget.list(new FilenameFilter()
{
-      @Override
-      public boolean accept(File dir, String name) {
-        try {
-          // Filter out the CRC file
-          UUID.fromString(name);
-          return true;
-        } catch (IllegalArgumentException e) {
-          return false;
-        }
-      }
-    }).length);
+    FileStatus[] recovered = fs.listStatus(targetPath);
+    assertEquals("Wrong number of WAL files recovered.", 1, recovered.length);
 
-    final Path path = new Path(walTarget.listFiles()[0].getAbsolutePath());
+    final Path path = recovered[0].getPath();
     final VolumeManager volumeManager = VolumeManagerImpl.getLocal(folder.getRoot().getAbsolutePath());
 
     final DFSLoggerInputStreams streams = DfsLogger.readHeaderAndReturnStream(volumeManager,
path, configuration);


Mime
View raw message