Skip to content

Commit

Permalink
HBASE-25842 move regionserver http-related code into o.a.h.h.regionse…
Browse files Browse the repository at this point in the history
…rver.http

Signed-off-by: Duo Zhang <zhangduo@apache.org>
  • Loading branch information
ndimiduk committed May 4, 2021
1 parent 432d141 commit 17193da
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -818,6 +821,24 @@ protected Class<? extends HttpServlet> 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
Expand Down Expand Up @@ -3746,7 +3767,7 @@ public HeapMemoryManager getHeapMemoryManager() {
return hMemManager;
}

MemStoreFlusher getMemStoreFlusher() {
public MemStoreFlusher getMemStoreFlusher() {
return cacheFlusher;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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()) {

Expand All @@ -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);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
* 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 javax.servlet.ServletException;
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 17193da

Please sign in to comment.