You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2013/08/07 20:18:30 UTC

svn commit: r1511427 - in /hbase/branches/0.89-fb/src: main/java/org/apache/hadoop/hbase/ main/java/org/apache/hadoop/hbase/ipc/ main/java/org/apache/hadoop/hbase/regionserver/ test/java/org/apache/hadoop/hbase/regionserver/

Author: liyin
Date: Wed Aug  7 18:18:30 2013
New Revision: 1511427

URL: http://svn.apache.org/r1511427
Log:
[HBASE-8576] - Make server side profiling online configurable

Author: zelaine

Summary: Make the parameter to enable/disable server side profiling configurable online.

Test Plan:
Added new unit test case.  Ran unit tests.  Got failures, but they were
similar to the ones I also get when running on master without my changes.

Reviewers: liyintang

Reviewed By: liyintang

CC: gauravm, hbase-eng@

Differential Revision: https://phabricator.fb.com/D906162

Task ID: 2566739

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerOnlineConfigChange.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java?rev=1511427&r1=1511426&r2=1511427&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java Wed Aug  7 18:18:30 2013
@@ -361,6 +361,10 @@ public final class HConstants {
   /** Maximum value length, enforced on KeyValue construction */
   public static final int MAXIMUM_VALUE_LENGTH = Integer.MAX_VALUE;
 
+  /** Conf key for enabling/disabling server profiling */
+  public static final String HREGIONSERVER_ENABLE_SERVERSIDE_PROFILING =
+      "hbase.regionserver.enable.serverside.profiling";
+
   // Always store the location of the root table's HRegion.
   // This HRegion is never split.
 

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java?rev=1511427&r1=1511426&r2=1511427&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java Wed Aug  7 18:18:30 2013
@@ -1230,7 +1230,7 @@ public abstract class HBaseServer {
           String error = null;
           Writable value = null;
 
-          if (HRegionServer.enableServerSideProfilingForAllCalls
+          if (HRegionServer.enableServerSideProfilingForAllCalls.get()
               || call.shouldProfile) {
             call.profilingData = new ProfilingData ();
           } else {
@@ -1254,7 +1254,7 @@ public abstract class HBaseServer {
           UserGroupInformation.setCurrentUser(previous);
           CurCall.set(null);
 
-          if (HRegionServer.enableServerSideProfilingForAllCalls
+          if (HRegionServer.enableServerSideProfilingForAllCalls.get()
               || call.shouldProfile) {
             call.profilingData.addLong(
                 ProfilingData.TOTAL_SERVER_TIME_MS, total);

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1511427&r1=1511426&r2=1511427&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Wed Aug  7 18:18:30 2013
@@ -369,7 +369,8 @@ public class HRegionServer implements HR
   // throw out an Exception. This is done to avoid OutOfMemory Errors, and
   // large GC issues.
   private static long responseSizeLimit;
-  public static boolean enableServerSideProfilingForAllCalls;
+  public static final AtomicBoolean enableServerSideProfilingForAllCalls =
+      new AtomicBoolean(false);
   public static AtomicInteger numOptimizedSeeks = new AtomicInteger(0);
   private int numRowRequests = 0;
 
@@ -437,8 +438,8 @@ public class HRegionServer implements HR
 
     responseSizeLimit = conf.getLong("hbase.regionserver.results.size.max",
         (long)Integer.MAX_VALUE); // set the max to 2G
-    enableServerSideProfilingForAllCalls = conf.getBoolean(
-        "hbase.regionserver.enable.serverside.profiling", false);
+    enableServerSideProfilingForAllCalls.set(conf.getBoolean(
+        HConstants.HREGIONSERVER_ENABLE_SERVERSIDE_PROFILING, false));
 
     reinitialize();
     SchemaMetrics.configureGlobally(conf);
@@ -3840,3 +3841,12 @@ public class HRegionServer implements HR
     return 0;
   }
 }
+    boolean origProfiling = enableServerSideProfilingForAllCalls.get();
+    boolean newProfiling = conf.getBoolean(
+        "hbase.regionserver.enable.serverside.profiling", false);
+    if (origProfiling != newProfiling) {
+      enableServerSideProfilingForAllCalls.set(newProfiling);
+      LOG.info("enableServerSideProfilingForAllCalls changed from " +
+        origProfiling + " to " + newProfiling);
+    }
+

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerOnlineConfigChange.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerOnlineConfigChange.java?rev=1511427&r1=1511426&r2=1511427&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerOnlineConfigChange.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerOnlineConfigChange.java Wed Aug  7 18:18:30 2013
@@ -104,6 +104,28 @@ public class TestRegionServerOnlineConfi
   }
 
   /**
+   * Check if the server side profiling config parameter changes online
+   * @throws IOException
+   */
+  public void testServerSideProfilingOnlineChange() throws IOException {
+    assertTrue(rs1.enableServerSideProfilingForAllCalls != null);
+    boolean origProfiling =
+            rs1.enableServerSideProfilingForAllCalls.get();
+
+    conf.setBoolean("hbase.regionserver.enable.serverside.profiling",
+                    !origProfiling);
+
+    // Confirm that without the notification call, the parameter is unchanged
+    assertEquals(origProfiling,
+                 rs1.enableServerSideProfilingForAllCalls.get());
+
+    // After the notification, it should be changed
+    HRegionServer.configurationManager.notifyAllObservers(conf);
+    assertEquals(!origProfiling,
+                 rs1.enableServerSideProfilingForAllCalls.get());
+  }
+
+  /**
    * Test that the configurations in the CompactionConfiguration class change
    * properly.
    *