ACCUMULO-2690 fixing output stream short circuiting in walog

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

Branch: refs/heads/master
Commit: 8e3dc7b475b6b803c4c4402e54ad185cf60b3d89
Parents: 1734489
Author: John Vines <vi...@apache.org>
Authored: Thu Apr 17 18:00:49 2014 -0400
Committer: John Vines <vi...@apache.org>
Committed: Thu Apr 17 18:00:49 2014 -0400

----------------------------------------------------------------------
 .../core/security/crypto/NoFlushOutputStream.java         | 10 ++--------
 .../java/org/apache/accumulo/tserver/log/DfsLogger.java   |  9 ++++++---
 2 files changed, 8 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/8e3dc7b4/core/src/main/java/org/apache/accumulo/core/security/crypto/NoFlushOutputStream.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/accumulo/core/security/crypto/NoFlushOutputStream.java
 
b/core/src/main/java/org/apache/accumulo/core/security/crypto/NoFlushOutputStream.java
index 2f9f4bb..17fc06a 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/security/crypto/NoFlushOutputStream.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/security/crypto/NoFlushOutputStream.java
@@ -16,22 +16,16 @@
  */
 package org.apache.accumulo.core.security.crypto;
 
-import java.io.FilterOutputStream;
-import java.io.IOException;
+import java.io.DataOutputStream;
 import java.io.OutputStream;
 
-public class NoFlushOutputStream extends FilterOutputStream {
+public class NoFlushOutputStream extends DataOutputStream {
 
   public NoFlushOutputStream(OutputStream out) {
     super(out);
   }
 
   @Override
-  public void write(byte[] b, int off, int len) throws IOException {
-    out.write(b, off, len);
-  }
-
-  @Override
   public void flush() {}
 
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8e3dc7b4/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 c960bd6..eb04f09 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
@@ -368,7 +368,8 @@ public class DfsLogger {
 
       CryptoModuleParameters params = 
CryptoModuleFactory.createParamsObjectFromAccumuloConfiguration(conf.getConfiguration());
 
-      params.setPlaintextOutputStream(new NoFlushOutputStream(logFile));
+      NoFlushOutputStream nfos = new NoFlushOutputStream(logFile);
+      params.setPlaintextOutputStream(nfos);
 
       // In order to bootstrap the reading of this file later, we have to 
record the CryptoModule that was used to encipher it here,
       // so that that crypto module can re-read its own parameters.
@@ -380,9 +381,11 @@ public class DfsLogger {
 
       // If the module just kicks back our original stream, then just use it, 
don't wrap it in
       // another data OutputStream.
-      if (encipheringOutputStream == logFile) {
-        encryptingLogFile = logFile;
+      if (encipheringOutputStream == nfos) {
+        log.debug("No enciphering, using raw output stream");
+        encryptingLogFile = nfos;
       } else {
+        log.debug("Enciphering found, wrapping in DataOutputStream");
         encryptingLogFile = new DataOutputStream(encipheringOutputStream);
       }
 

Reply via email to