accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [accumulo] branch master updated: Fixes #810 - Removed MiniAccumulo's custom redirection code (#897)
Date Wed, 16 Jan 2019 16:26:44 GMT
This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new 2d634f2  Fixes #810 - Removed MiniAccumulo's custom redirection code (#897)
2d634f2 is described below

commit 2d634f2a330e8f1b7f925b744770f65da0eab037
Author: Jeffrey L. Zeiberg <Jeffrey.Zeiberg@asrcfederal.com>
AuthorDate: Tue Jan 15 12:28:53 2019 -0500

    Fixes #810 - Removed MiniAccumulo's custom redirection code (#897)
---
 .../MiniAccumuloClusterControl.java                |  5 +-
 .../miniclusterImpl/MiniAccumuloClusterImpl.java   | 77 +++-------------------
 .../org/apache/accumulo/test/AuditMessageIT.java   |  5 --
 .../test/functional/FunctionalTestUtils.java       |  3 -
 4 files changed, 10 insertions(+), 80 deletions(-)

diff --git a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java
b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java
index fe06c27..96eb563 100644
--- a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java
@@ -34,7 +34,6 @@ import org.apache.accumulo.cluster.ClusterControl;
 import org.apache.accumulo.gc.SimpleGarbageCollector;
 import org.apache.accumulo.master.Master;
 import org.apache.accumulo.minicluster.ServerType;
-import org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl.LogWriter;
 import org.apache.accumulo.monitor.Monitor;
 import org.apache.accumulo.server.util.Admin;
 import org.apache.accumulo.tracer.TraceServer;
@@ -95,9 +94,7 @@ public class MiniAccumuloClusterControl implements ClusterControl {
       Thread.currentThread().interrupt();
       throw new IOException(e);
     }
-    for (LogWriter writer : cluster.getLogWriters()) {
-      writer.flush();
-    }
+
     return Maps.immutableEntry(exitCode, readAll(new FileInputStream(cluster.getConfig().getLogDir()
         + "/" + clz.getSimpleName() + "_" + p.hashCode() + ".out")));
   }
diff --git a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
index 0a5e9b0..2c7d21e 100644
--- a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
@@ -19,13 +19,9 @@ package org.apache.accumulo.miniclusterImpl;
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
 
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.net.URI;
@@ -74,7 +70,6 @@ import org.apache.accumulo.core.master.thrift.MasterGoalState;
 import org.apache.accumulo.core.master.thrift.MasterMonitorInfo;
 import org.apache.accumulo.core.trace.Tracer;
 import org.apache.accumulo.core.util.CachedConfiguration;
-import org.apache.accumulo.core.util.Daemon;
 import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
 import org.apache.accumulo.fate.zookeeper.ZooUtil;
@@ -88,7 +83,6 @@ import org.apache.accumulo.server.fs.VolumeManagerImpl;
 import org.apache.accumulo.server.init.Initialize;
 import org.apache.accumulo.server.util.AccumuloStatus;
 import org.apache.accumulo.server.util.PortUtils;
-import org.apache.accumulo.server.util.time.SimpleTimer;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriterFactory;
 import org.apache.accumulo.start.Main;
 import org.apache.accumulo.start.classloader.vfs.MiniDFSUtil;
@@ -124,48 +118,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 public class MiniAccumuloClusterImpl implements AccumuloCluster {
   private static final Logger log = LoggerFactory.getLogger(MiniAccumuloClusterImpl.class);
 
-  public static class LogWriter extends Daemon {
-    private BufferedReader in;
-    private BufferedWriter out;
-
-    public LogWriter(InputStream stream, File logFile) throws IOException {
-      this.in = new BufferedReader(new InputStreamReader(stream));
-      out = new BufferedWriter(new FileWriter(logFile));
-
-      SimpleTimer.getInstance(null).schedule(() -> {
-        try {
-          flush();
-        } catch (IOException e) {
-          log.error("Exception while attempting to flush.", e);
-        }
-      }, 1000, 1000);
-    }
-
-    public synchronized void flush() throws IOException {
-      if (out != null)
-        out.flush();
-    }
-
-    @Override
-    public void run() {
-      String line;
-
-      try {
-        while ((line = in.readLine()) != null) {
-          out.append(line);
-          out.append("\n");
-        }
-
-        synchronized (this) {
-          out.close();
-          out = null;
-          in.close();
-        }
-
-      } catch (IOException e) {}
-    }
-  }
-
   private boolean initialized = false;
 
   private Set<Pair<ServerType,Integer>> debugPorts = new HashSet<>();
@@ -176,12 +128,6 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
   private ServerContext context;
   private Properties clientProperties;
 
-  public List<LogWriter> getLogWriters() {
-    return logWriters;
-  }
-
-  private List<LogWriter> logWriters = new ArrayList<>();
-
   private MiniAccumuloConfigImpl config;
   private MiniDFSCluster miniDFS = null;
   private List<Process> cleanup = new ArrayList<>();
@@ -333,17 +279,16 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
     log.debug("Starting MiniAccumuloCluster process with class: " + clazz.getSimpleName()
         + "\n, jvmOpts: " + extraJvmOpts + "\n, classpath: " + classpath + "\n, args: " +
argList
         + "\n, environment: " + builder.environment());
-    Process process = builder.start();
 
-    LogWriter lw;
-    lw = new LogWriter(process.getErrorStream(),
-        new File(config.getLogDir(), clazz.getSimpleName() + "_" + process.hashCode() + ".err"));
-    logWriters.add(lw);
-    lw.start();
-    lw = new LogWriter(process.getInputStream(),
-        new File(config.getLogDir(), clazz.getSimpleName() + "_" + process.hashCode() + ".out"));
-    logWriters.add(lw);
-    lw.start();
+    Integer hashcode = builder.hashCode();
+
+    builder = builder
+        .redirectError(
+            new File(config.getLogDir(), clazz.getSimpleName() + "_" + hashcode + ".err"))
+        .redirectOutput(
+            new File(config.getLogDir(), clazz.getSimpleName() + "_" + hashcode + ".out"));
+
+    Process process = builder.start();
 
     cleanup.add(process);
 
@@ -738,10 +683,6 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
       return;
     }
 
-    for (LogWriter lw : logWriters) {
-      lw.flush();
-    }
-
     MiniAccumuloClusterControl control = getClusterControl();
 
     control.stop(ServerType.GARBAGE_COLLECTOR, null);
diff --git a/test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java b/test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java
index 9a37ee9..947b6a5 100644
--- a/test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java
@@ -47,7 +47,6 @@ import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.SystemPermission;
 import org.apache.accumulo.core.security.TablePermission;
-import org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl;
 import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
 import org.apache.accumulo.server.security.AuditedSecurityOperation;
 import org.apache.accumulo.test.functional.ConfigurableMacBase;
@@ -112,10 +111,6 @@ public class AuditMessageIT extends ConfigurableMacBase {
       throw new IOException("Interrupted waiting for data to be flushed to output streams");
     }
 
-    for (MiniAccumuloClusterImpl.LogWriter lw : getCluster().getLogWriters()) {
-      lw.flush();
-    }
-
     // Grab the audit messages
     System.out.println("Start of captured audit messages for step " + stepName);
 
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java
b/test/src/main/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java
index bb2d7f1..383388e 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java
@@ -53,7 +53,6 @@ import org.apache.accumulo.fate.AdminUtil.FateStatus;
 import org.apache.accumulo.fate.ZooStore;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
 import org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl;
-import org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl.LogWriter;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriterFactory;
 import org.apache.accumulo.test.TestIngest;
 import org.apache.hadoop.fs.FileSystem;
@@ -169,8 +168,6 @@ public class FunctionalTestUtils {
   @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "path provided by test")
   public static String readAll(MiniAccumuloClusterImpl c, Class<?> klass, Process p)
       throws Exception {
-    for (LogWriter writer : c.getLogWriters())
-      writer.flush();
     return readAll(new FileInputStream(
         c.getConfig().getLogDir() + "/" + klass.getSimpleName() + "_" + p.hashCode() + ".out"));
   }


Mime
View raw message