HBASE-21843 RegionGroupingProvider breaks the meta wal file name pattern which may...
[hbase.git] / hbase-server / src / main / java / org / apache / hadoop / hbase / master / MasterDumpServlet.java
blobec8e5238c29fad50c6beaf901fe6104d1f6d98e7
1 /**
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 package org.apache.hadoop.hbase.master;
21 import java.io.IOException;
22 import java.io.OutputStream;
23 import java.io.PrintStream;
24 import java.io.PrintWriter;
25 import java.util.Date;
26 import java.util.Map;
27 import javax.servlet.http.HttpServletRequest;
28 import javax.servlet.http.HttpServletResponse;
29 import org.apache.hadoop.conf.Configuration;
30 import org.apache.hadoop.hbase.ServerMetrics;
31 import org.apache.hadoop.hbase.ServerName;
32 import org.apache.hadoop.hbase.master.assignment.AssignmentManager;
33 import org.apache.hadoop.hbase.master.assignment.RegionStateNode;
34 import org.apache.hadoop.hbase.monitoring.LogMonitoring;
35 import org.apache.hadoop.hbase.monitoring.StateDumpServlet;
36 import org.apache.hadoop.hbase.monitoring.TaskMonitor;
37 import org.apache.hadoop.hbase.regionserver.RSDumpServlet;
38 import org.apache.hadoop.hbase.util.Threads;
39 import org.apache.yetus.audience.InterfaceAudience;
41 @InterfaceAudience.Private
42 public class MasterDumpServlet extends StateDumpServlet {
43 private static final long serialVersionUID = 1L;
44 private static final String LINE =
45 "===========================================================";
47 @Override
48 public void doGet(HttpServletRequest request, HttpServletResponse response)
49 throws IOException {
50 HMaster master = (HMaster) getServletContext().getAttribute(HMaster.MASTER);
51 assert master != null : "No Master in context!";
53 response.setContentType("text/plain");
54 OutputStream os = response.getOutputStream();
55 try (PrintWriter out = new PrintWriter(os)) {
57 out.println("Master status for " + master.getServerName()
58 + " as of " + new Date());
60 out.println("\n\nVersion Info:");
61 out.println(LINE);
62 dumpVersionInfo(out);
64 out.println("\n\nTasks:");
65 out.println(LINE);
66 TaskMonitor.get().dumpAsText(out);
68 out.println("\n\nServers:");
69 out.println(LINE);
70 dumpServers(master, out);
72 out.println("\n\nRegions-in-transition:");
73 out.println(LINE);
74 dumpRIT(master, out);
76 out.println("\n\nExecutors:");
77 out.println(LINE);
78 dumpExecutors(master.getExecutorService(), out);
80 out.println("\n\nStacks:");
81 out.println(LINE);
82 out.flush();
83 PrintStream ps = new PrintStream(response.getOutputStream(), false, "UTF-8");
84 Threads.printThreadInfo(ps, "");
85 ps.flush();
87 out.println("\n\nMaster configuration:");
88 out.println(LINE);
89 Configuration conf = master.getConfiguration();
90 out.flush();
91 conf.writeXml(os);
92 os.flush();
94 out.println("\n\nRecent regionserver aborts:");
95 out.println(LINE);
96 master.getRegionServerFatalLogBuffer().dumpTo(out);
98 out.println("\n\nLogs");
99 out.println(LINE);
100 long tailKb = getTailKbParam(request);
101 LogMonitoring.dumpTailOfLogs(out, tailKb);
103 out.println("\n\nRS Queue:");
104 out.println(LINE);
105 if (isShowQueueDump(conf)) {
106 RSDumpServlet.dumpQueue(master, out);
108 out.flush();
113 private void dumpRIT(HMaster master, PrintWriter out) {
114 AssignmentManager am = master.getAssignmentManager();
115 if (am == null) {
116 out.println("AssignmentManager is not initialized");
117 return;
120 for (RegionStateNode rs : am.getRegionsInTransition()) {
121 String rid = rs.getRegionInfo().getEncodedName();
122 out.println("Region " + rid + ": " + rs.toDescriptiveString());
126 private void dumpServers(HMaster master, PrintWriter out) {
127 ServerManager sm = master.getServerManager();
128 if (sm == null) {
129 out.println("ServerManager is not initialized");
130 return;
133 Map<ServerName, ServerMetrics> servers = sm.getOnlineServers();
134 for (Map.Entry<ServerName, ServerMetrics> e : servers.entrySet()) {
135 out.println(e.getKey() + ": " + e.getValue());