From 17193dae586daeedba0e45bdf99d442ecc3ef94e Mon Sep 17 00:00:00 2001 From: Nick Dimiduk Date: Mon, 3 May 2021 15:41:36 -0700 Subject: [PATCH] HBASE-25842 move regionserver http-related code into o.a.h.h.regionserver.http Signed-off-by: Duo Zhang --- .../hbase/master/MasterDumpServlet.java | 2 +- .../hbase/regionserver/HRegionServer.java | 23 +++++++++++++++- .../hbase/regionserver/MemStoreFlusher.java | 2 +- .../{ => http}/RSDumpServlet.java | 27 +++++-------------- .../{ => http}/RSStatusServlet.java | 3 ++- .../{ => http}/TestRSStatusServlet.java | 6 ++++- 6 files changed, 37 insertions(+), 26 deletions(-) rename hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/{ => http}/RSDumpServlet.java (86%) rename hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/{ => http}/RSStatusServlet.java (95%) rename hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/{ => http}/TestRSStatusServlet.java (95%) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterDumpServlet.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterDumpServlet.java index 9569480eb262..e1058f9c8fe2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterDumpServlet.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterDumpServlet.java @@ -33,7 +33,7 @@ import org.apache.hadoop.hbase.master.assignment.RegionStateNode; import org.apache.hadoop.hbase.monitoring.StateDumpServlet; import org.apache.hadoop.hbase.monitoring.TaskMonitor; -import org.apache.hadoop.hbase.regionserver.RSDumpServlet; +import org.apache.hadoop.hbase.regionserver.http.RSDumpServlet; import org.apache.hadoop.hbase.util.LogMonitoring; import org.apache.hadoop.hbase.util.Threads; import org.apache.yetus.audience.InterfaceAudience; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 1b045e4f9c53..5f7c5066295c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -24,6 +24,7 @@ import static org.apache.hadoop.hbase.util.DNS.UNSAFE_RS_HOSTNAME_KEY; import java.io.IOException; +import java.io.PrintWriter; import java.lang.management.MemoryType; import java.lang.management.MemoryUsage; import java.lang.reflect.Constructor; @@ -141,6 +142,8 @@ import org.apache.hadoop.hbase.regionserver.handler.CloseRegionHandler; import org.apache.hadoop.hbase.regionserver.handler.RSProcedureHandler; import org.apache.hadoop.hbase.regionserver.handler.RegionReplicaFlushHandler; +import org.apache.hadoop.hbase.regionserver.http.RSDumpServlet; +import org.apache.hadoop.hbase.regionserver.http.RSStatusServlet; import org.apache.hadoop.hbase.regionserver.throttle.FlushThroughputControllerFactory; import org.apache.hadoop.hbase.regionserver.throttle.ThroughputController; import org.apache.hadoop.hbase.replication.regionserver.ReplicationLoad; @@ -818,6 +821,24 @@ protected Class getDumpServlet() { return RSDumpServlet.class; } + /** + * Used by {@link RSDumpServlet} to generate debugging information. + */ + public void dumpRowLocks(final PrintWriter out) { + StringBuilder sb = new StringBuilder(); + for (HRegion region : getRegions()) { + if (region.getLockedRows().size() > 0) { + for (HRegion.RowLockContext rowLockContext : region.getLockedRows().values()) { + sb.setLength(0); + sb.append(region.getTableDescriptor().getTableName()).append(",") + .append(region.getRegionInfo().getEncodedName()).append(","); + sb.append(rowLockContext.toString()); + out.println(sb); + } + } + } + } + @Override public boolean registerService(Service instance) { // No stacking of instances is allowed for a single executorService name @@ -3746,7 +3767,7 @@ public HeapMemoryManager getHeapMemoryManager() { return hMemManager; } - MemStoreFlusher getMemStoreFlusher() { + public MemStoreFlusher getMemStoreFlusher() { return cacheFlusher; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java index 17927ad90b05..d0a28ed771ce 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java @@ -67,7 +67,7 @@ * @see FlushRequester */ @InterfaceAudience.Private -class MemStoreFlusher implements FlushRequester { +public class MemStoreFlusher implements FlushRequester { private static final Logger LOG = LoggerFactory.getLogger(MemStoreFlusher.class); private Configuration conf; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/http/RSDumpServlet.java similarity index 86% rename from hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/http/RSDumpServlet.java index 56b72e5661ac..cc48d9ef18a4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSDumpServlet.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/http/RSDumpServlet.java @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.regionserver; +package org.apache.hadoop.hbase.regionserver.http; import java.io.IOException; import java.io.OutputStream; @@ -29,6 +29,9 @@ import org.apache.hadoop.hbase.ipc.CallQueueInfo; import org.apache.hadoop.hbase.monitoring.StateDumpServlet; import org.apache.hadoop.hbase.monitoring.TaskMonitor; +import org.apache.hadoop.hbase.regionserver.CompactSplit; +import org.apache.hadoop.hbase.regionserver.HRegionServer; +import org.apache.hadoop.hbase.regionserver.MemStoreFlusher; import org.apache.hadoop.hbase.util.LogMonitoring; import org.apache.hadoop.hbase.util.Threads; import org.apache.yetus.audience.InterfaceAudience; @@ -70,7 +73,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) out.println("\n\nRowLocks:"); out.println(LINE); - dumpRowLock(hrs, out); + hrs.dumpRowLocks(out); out.println("\n\nExecutors:"); out.println(LINE); @@ -108,22 +111,6 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) } } - public static void dumpRowLock(HRegionServer hrs, PrintWriter out) { - StringBuilder sb = new StringBuilder(); - for (Region region : hrs.getRegions()) { - HRegion hRegion = (HRegion)region; - if (hRegion.getLockedRows().size() > 0) { - for (HRegion.RowLockContext rowLockContext : hRegion.getLockedRows().values()) { - sb.setLength(0); - sb.append(hRegion.getTableDescriptor().getTableName()).append(",") - .append(hRegion.getRegionInfo().getEncodedName()).append(","); - sb.append(rowLockContext.toString()); - out.println(sb.toString()); - } - } - } - } - public static void dumpQueue(HRegionServer hrs, PrintWriter out) { final CompactSplit compactSplit = hrs.getCompactSplitThread(); if (compactSplit != null) { @@ -143,7 +130,7 @@ public static void dumpQueue(HRegionServer hrs, PrintWriter out) { public static void dumpCallQueues(HRegionServer hrs, PrintWriter out) { - CallQueueInfo callQueueInfo = hrs.rpcServices.rpcServer.getScheduler().getCallQueueInfo(); + CallQueueInfo callQueueInfo = hrs.getRpcServer().getScheduler().getCallQueueInfo(); for(String queueName: callQueueInfo.getCallQueueNames()) { @@ -165,7 +152,5 @@ public static void dumpCallQueues(HRegionServer hrs, PrintWriter out) { out.println("Total call count for queue: "+totalCallCount); out.println("Total call size for queue (bytes): "+totalCallSize); } - } - } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSStatusServlet.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/http/RSStatusServlet.java similarity index 95% rename from hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSStatusServlet.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/http/RSStatusServlet.java index 55250fe17a54..f2d8d48865ce 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSStatusServlet.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/http/RSStatusServlet.java @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.regionserver; +package org.apache.hadoop.hbase.regionserver.http; import java.io.IOException; @@ -24,6 +24,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.yetus.audience.InterfaceAudience; import org.apache.hadoop.hbase.tmpl.regionserver.RSStatusTmpl; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRSStatusServlet.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/http/TestRSStatusServlet.java similarity index 95% rename from hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRSStatusServlet.java rename to hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/http/TestRSStatusServlet.java index 1b1b976497af..f4e29ccd1585 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRSStatusServlet.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/http/TestRSStatusServlet.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.regionserver; +package org.apache.hadoop.hbase.regionserver.http; import java.io.IOException; import java.io.StringWriter; @@ -34,6 +34,10 @@ import org.apache.hadoop.hbase.ipc.MetricsHBaseServer; import org.apache.hadoop.hbase.ipc.MetricsHBaseServerWrapperStub; import org.apache.hadoop.hbase.ipc.RpcServerInterface; +import org.apache.hadoop.hbase.regionserver.HRegionServer; +import org.apache.hadoop.hbase.regionserver.MetricsRegionServer; +import org.apache.hadoop.hbase.regionserver.MetricsRegionServerWrapperStub; +import org.apache.hadoop.hbase.regionserver.RSRpcServices; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.tmpl.regionserver.RSStatusTmpl;