hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1524872 - in /hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase: master/HMasterCommandLine.java regionserver/HRegionServerCommandLine.java util/ServerCommandLine.java
Date Fri, 20 Sep 2013 00:31:25 GMT
Author: stack
Date: Fri Sep 20 00:31:25 2013
New Revision: 1524872

URL: http://svn.apache.org/r1524872
Log:
HBASE-9577 Log process environment variable on HBase service startup

Modified:
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ServerCommandLine.java

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java?rev=1524872&r1=1524871&r2=1524872&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java
Fri Sep 20 00:31:25 2013
@@ -180,7 +180,7 @@ public class HMasterCommandLine extends 
         cluster.startup();
         waitOnMasterThreads(cluster);
       } else {
-        logJVMInfo();
+        logProcessInfo(getConf());
         HMaster master = HMaster.constructMaster(masterClass, conf);
         if (master.isStopped()) {
           LOG.info("Won't bring the Master up as a shutdown is requested");

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java?rev=1524872&r1=1524871&r2=1524872&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java
Fri Sep 20 00:31:25 2013
@@ -57,7 +57,7 @@ public class HRegionServerCommandLine ex
         LOG.warn("Not starting a distinct region server because "
             + HConstants.CLUSTER_DISTRIBUTED + " is false");
       } else {
-        logJVMInfo();
+        logProcessInfo(getConf());
         HRegionServer hrs = HRegionServer.constructRegionServer(regionServerClass, conf);
         Thread rsThread = HRegionServer.startRegionServer(hrs);
 

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ServerCommandLine.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ServerCommandLine.java?rev=1524872&r1=1524871&r2=1524872&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ServerCommandLine.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ServerCommandLine.java
Fri Sep 20 00:31:25 2013
@@ -18,8 +18,12 @@
  */
 package org.apache.hadoop.hbase.util;
 
-import java.lang.management.RuntimeMXBean;
 import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Map.Entry;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -36,6 +40,15 @@ import org.apache.hadoop.util.ToolRunner
 @InterfaceAudience.Private
 public abstract class ServerCommandLine extends Configured implements Tool {
   private static final Log LOG = LogFactory.getLog(ServerCommandLine.class);
+  @SuppressWarnings("serial")
+  private static final Set<String> DEFAULT_SKIP_WORDS = new HashSet<String>()
{
+    {
+      add("secret");
+      add("passwd");
+      add("password");
+      add("credential");
+    }
+  };
 
   /**
    * Implementing subclasses should return a usage string to print out.
@@ -70,6 +83,41 @@ public abstract class ServerCommandLine 
   }
 
   /**
+   * Logs information about the currently running JVM process including
+   * the environment variables. Logging of env vars can be disabled by
+   * setting {@code "hbase.envvars.logging.disabled"} to {@code "true"}.
+   * <p>If enabled, you can also exclude environment variables containing
+   * certain substrings by setting {@code "hbase.envvars.logging.skipwords"}
+   * to comma separated list of such substrings.
+   */
+  public static void logProcessInfo(Configuration conf) {
+    // log environment variables unless asked not to
+    if (conf == null || !conf.getBoolean("hbase.envvars.logging.disabled", false)) {
+      Set<String> skipWords = new HashSet<String>(DEFAULT_SKIP_WORDS);
+      if (conf != null) {
+        String[] confSkipWords = conf.getStrings("hbase.envvars.logging.skipwords");
+        if (confSkipWords != null) {
+          skipWords.addAll(Arrays.asList(confSkipWords));
+        }
+      }
+
+      nextEnv:
+      for (Entry<String, String> entry : System.getenv().entrySet()) {
+        String key = entry.getKey().toLowerCase();
+        String value = entry.getValue().toLowerCase();
+        // exclude variables which may contain skip words
+        for(String skipWord : skipWords) {
+          if (key.contains(skipWord) || value.contains(skipWord))
+            continue nextEnv;
+        }
+        LOG.info("env:"+entry);
+      }
+    }
+    // and JVM info
+    logJVMInfo();
+  }
+
+  /**
    * Parse and run the given command line. This may exit the JVM if
    * a nonzero exit code is returned from <code>run()</code>.
    */



Mime
View raw message