You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/12/19 19:34:17 UTC

[GitHub] milleruntime closed pull request #829: Stop creating double OuputStreams for WAL

milleruntime closed pull request #829: Stop creating double OuputStreams for WAL
URL: https://github.com/apache/accumulo/pull/829
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/main/java/org/apache/accumulo/core/crypto/streams/NoFlushOutputStream.java b/core/src/main/java/org/apache/accumulo/core/crypto/streams/NoFlushOutputStream.java
index a8b6901768..cea7798112 100644
--- a/core/src/main/java/org/apache/accumulo/core/crypto/streams/NoFlushOutputStream.java
+++ b/core/src/main/java/org/apache/accumulo/core/crypto/streams/NoFlushOutputStream.java
@@ -16,11 +16,11 @@
  */
 package org.apache.accumulo.core.crypto.streams;
 
-import java.io.FilterOutputStream;
+import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 
-public class NoFlushOutputStream extends FilterOutputStream {
+public class NoFlushOutputStream extends DataOutputStream {
 
   public NoFlushOutputStream(OutputStream out) {
     super(out);
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 a0bebabeb9..746a59f92b 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
@@ -48,6 +48,7 @@
 import org.apache.accumulo.core.crypto.streams.NoFlushOutputStream;
 import org.apache.accumulo.core.cryptoImpl.CryptoEnvironmentImpl;
 import org.apache.accumulo.core.cryptoImpl.NoCryptoService;
+import org.apache.accumulo.core.cryptoImpl.NoFileEncrypter;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.dataImpl.KeyExtent;
 import org.apache.accumulo.core.spi.crypto.CryptoEnvironment;
@@ -130,17 +131,9 @@ public FSDataInputStream getOriginalInput() {
       return originalInput;
     }
 
-    public void setOriginalInput(FSDataInputStream originalInput) {
-      this.originalInput = originalInput;
-    }
-
     public DataInputStream getDecryptingInputStream() {
       return decryptingInputStream;
     }
-
-    public void setDecryptingInputStream(DataInputStream decryptingInputStream) {
-      this.decryptingInputStream = decryptingInputStream;
-    }
   }
 
   public interface ServerResources {
@@ -443,8 +436,16 @@ public synchronized void open(String address) throws IOException {
       byte[] cryptoParams = encrypter.getDecryptionParameters();
       CryptoUtils.writeParams(cryptoParams, logFile);
 
-      encryptingLogFile = new DataOutputStream(
-          encrypter.encryptStream(new NoFlushOutputStream(logFile)));
+      /** Always wrap the WAL in a NoFlushOutputStream to prevent extra flushing to HDFS.
+       * The {@link #write(LogFileKey, LogFileValue)} method will flush crypto data or do nothing
+       * when crypto is not enabled.
+       **/
+      OutputStream encryptedStream = encrypter.encryptStream(new NoFlushOutputStream(logFile));
+      if (encryptedStream instanceof NoFlushOutputStream) {
+        encryptingLogFile = (NoFlushOutputStream)encryptedStream;
+      } else {
+        encryptingLogFile = new DataOutputStream(encryptedStream);
+      }
 
       LogFileKey key = new LogFileKey();
       key.event = OPEN;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services