001/** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019package org.apache.hadoop.hbase.regionserver; 020 021import java.io.IOException; 022 023import javax.servlet.ServletException; 024import javax.servlet.http.HttpServlet; 025import javax.servlet.http.HttpServletRequest; 026import javax.servlet.http.HttpServletResponse; 027import org.apache.yetus.audience.InterfaceAudience; 028 029import org.apache.hadoop.hbase.tmpl.regionserver.RSStatusTmpl; 030 031@InterfaceAudience.Private 032public class RSStatusServlet extends HttpServlet { 033 private static final long serialVersionUID = 1L; 034 035 @Override 036 protected void doGet(HttpServletRequest req, HttpServletResponse resp) 037 throws ServletException, IOException { 038 HRegionServer hrs = (HRegionServer)getServletContext().getAttribute(HRegionServer.REGIONSERVER); 039 assert hrs != null : "No RS in context!"; 040 041 resp.setContentType("text/html"); 042 043 if (!hrs.isOnline()) { 044 resp.getWriter().write("The RegionServer is initializing!"); 045 resp.getWriter().close(); 046 return; 047 } 048 049 RSStatusTmpl tmpl = new RSStatusTmpl(); 050 if (req.getParameter("format") != null) 051 tmpl.setFormat(req.getParameter("format")); 052 if (req.getParameter("filter") != null) 053 tmpl.setFilter(req.getParameter("filter")); 054 if (req.getParameter("bcn") != null) 055 tmpl.setBcn(req.getParameter("bcn")); 056 if (req.getParameter("bcv") != null) 057 tmpl.setBcv(req.getParameter("bcv")); 058 tmpl.render(resp.getWriter(), hrs); 059 } 060}