HBASE-21843 RegionGroupingProvider breaks the meta wal file name pattern which may...
[hbase.git] / hbase-server / src / main / java / org / apache / hadoop / hbase / master / MasterStatusServlet.java
blob58e57c4b1b3413dfdc27bcacd034eadd77b4f273
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.util.List;
23 import java.util.Map;
24 import java.util.Set;
25 import javax.servlet.http.HttpServlet;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
28 import org.apache.hadoop.conf.Configuration;
29 import org.apache.hadoop.hbase.ServerName;
30 import org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl;
31 import org.apache.hadoop.hbase.util.FSUtils;
32 import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
33 import org.apache.yetus.audience.InterfaceAudience;
35 /**
36 * The servlet responsible for rendering the index page of the
37 * master.
39 @InterfaceAudience.Private
40 public class MasterStatusServlet extends HttpServlet {
41 private static final long serialVersionUID = 1L;
43 @Override
44 public void doGet(HttpServletRequest request, HttpServletResponse response)
45 throws IOException
47 HMaster master = (HMaster) getServletContext().getAttribute(HMaster.MASTER);
48 assert master != null : "No Master in context!";
50 response.setContentType("text/html");
52 Configuration conf = master.getConfiguration();
54 Map<String, Integer> frags = getFragmentationInfo(master, conf);
55 ServerName metaLocation = null;
56 List<ServerName> servers = null;
57 Set<ServerName> deadServers = null;
59 if(master.isActiveMaster()) {
60 metaLocation = getMetaLocationOrNull(master);
61 ServerManager serverManager = master.getServerManager();
62 if (serverManager != null) {
63 deadServers = serverManager.getDeadServers().copyServerNames();
64 servers = serverManager.getOnlineServersList();
68 MasterStatusTmpl tmpl = new MasterStatusTmpl()
69 .setFrags(frags)
70 .setMetaLocation(metaLocation)
71 .setServers(servers)
72 .setDeadServers(deadServers)
73 .setCatalogJanitorEnabled(master.isCatalogJanitorEnabled());
75 if (request.getParameter("filter") != null)
76 tmpl.setFilter(request.getParameter("filter"));
77 if (request.getParameter("format") != null)
78 tmpl.setFormat(request.getParameter("format"));
79 tmpl.render(response.getWriter(), master);
82 private ServerName getMetaLocationOrNull(HMaster master) {
83 return MetaTableLocator.getMetaRegionLocation(master.getZooKeeper());
86 private Map<String, Integer> getFragmentationInfo(
87 HMaster master, Configuration conf) throws IOException {
88 boolean showFragmentation = conf.getBoolean(
89 "hbase.master.ui.fragmentation.enabled", false);
90 if (showFragmentation) {
91 return FSUtils.getTableFragmentation(master);
92 } else {
93 return null;