Search in sources :

Example 1 with MasterStatusTmpl

use of org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl in project hbase by apache.

the class MasterStatusServlet method doGet.

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    HMaster master = (HMaster) getServletContext().getAttribute(HMaster.MASTER);
    assert master != null : "No Master in context!";
    response.setContentType("text/html");
    Configuration conf = master.getConfiguration();
    Map<String, Integer> frags = getFragmentationInfo(master, conf);
    ServerName metaLocation = null;
    List<ServerName> servers = null;
    Set<ServerName> deadServers = null;
    if (master.isActiveMaster()) {
        metaLocation = getMetaLocationOrNull(master);
        ServerManager serverManager = master.getServerManager();
        if (serverManager != null) {
            deadServers = serverManager.getDeadServers().copyServerNames();
            servers = serverManager.getOnlineServersList();
        }
    }
    MasterStatusTmpl tmpl = new MasterStatusTmpl().setFrags(frags).setMetaLocation(metaLocation).setServers(servers).setDeadServers(deadServers).setCatalogJanitorEnabled(master.isCatalogJanitorEnabled());
    if (request.getParameter("filter") != null)
        tmpl.setFilter(request.getParameter("filter"));
    if (request.getParameter("format") != null)
        tmpl.setFormat(request.getParameter("format"));
    tmpl.render(response.getWriter(), master);
}
Also used : MasterStatusTmpl(org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl) Configuration(org.apache.hadoop.conf.Configuration) ServerName(org.apache.hadoop.hbase.ServerName)

Example 2 with MasterStatusTmpl

use of org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl in project hbase by apache.

the class TestMasterStatusServlet method testStatusTemplateWithServers.

@Test
public void testStatusTemplateWithServers() throws IOException {
    setupMockTables();
    List<ServerName> servers = Lists.newArrayList(ServerName.valueOf("rootserver,123,12345"), ServerName.valueOf("metaserver,123,12345"));
    Set<ServerName> deadServers = new HashSet<>(Lists.newArrayList(ServerName.valueOf("badserver,123,12345"), ServerName.valueOf("uglyserver,123,12345")));
    new MasterStatusTmpl().setMetaLocation(ServerName.valueOf("metaserver,123,12345")).setServers(servers).setDeadServers(deadServers).render(new StringWriter(), master);
}
Also used : MasterStatusTmpl(org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl) StringWriter(java.io.StringWriter) ServerName(org.apache.hadoop.hbase.ServerName) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with MasterStatusTmpl

use of org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl in project hbase by apache.

the class TestMasterStatusServlet method testStatusTemplateMetaAvailable.

@Test
public void testStatusTemplateMetaAvailable() throws IOException {
    setupMockTables();
    new MasterStatusTmpl().setMetaLocation(ServerName.valueOf("metaserver,123,12345")).render(new StringWriter(), master);
}
Also used : MasterStatusTmpl(org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl) StringWriter(java.io.StringWriter) Test(org.junit.Test)

Example 4 with MasterStatusTmpl

use of org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl in project hbase by apache.

the class TestMasterStatusServlet method testStatusTemplateMetaAvailable.

@Test
public void testStatusTemplateMetaAvailable() throws IOException {
    setupMockTables();
    new MasterStatusTmpl().setMetaLocation(ServerName.valueOf("metaserver,123,12345")).render(new StringWriter(), master);
}
Also used : MasterStatusTmpl(org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl) StringWriter(java.io.StringWriter) Test(org.junit.Test)

Example 5 with MasterStatusTmpl

use of org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl in project hbase by apache.

the class MasterStatusServlet method doGet.

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    HMaster master = (HMaster) getServletContext().getAttribute(HMaster.MASTER);
    assert master != null : "No Master in context!";
    response.setContentType("text/html");
    Configuration conf = master.getConfiguration();
    Map<String, Integer> frags = getFragmentationInfo(master, conf);
    ServerName metaLocation = null;
    List<ServerName> servers = null;
    Set<ServerName> deadServers = null;
    if (master.isActiveMaster()) {
        metaLocation = getMetaLocationOrNull(master);
        ServerManager serverManager = master.getServerManager();
        if (serverManager != null) {
            deadServers = serverManager.getDeadServers().copyServerNames();
            servers = serverManager.getOnlineServersList();
        }
    }
    MasterStatusTmpl tmpl = new MasterStatusTmpl().setFrags(frags).setMetaLocation(metaLocation).setServers(servers).setDeadServers(deadServers).setCatalogJanitorEnabled(master.isCatalogJanitorEnabled());
    if (request.getParameter("filter") != null)
        tmpl.setFilter(request.getParameter("filter"));
    if (request.getParameter("format") != null)
        tmpl.setFormat(request.getParameter("format"));
    tmpl.render(response.getWriter(), master);
}
Also used : ServerManager(org.apache.hadoop.hbase.master.ServerManager) MasterStatusTmpl(org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl) Configuration(org.apache.hadoop.conf.Configuration) ServerName(org.apache.hadoop.hbase.ServerName) HMaster(org.apache.hadoop.hbase.master.HMaster)

Aggregations

MasterStatusTmpl (org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl)6 StringWriter (java.io.StringWriter)4 ServerName (org.apache.hadoop.hbase.ServerName)4 Test (org.junit.Test)4 HashSet (java.util.HashSet)2 Configuration (org.apache.hadoop.conf.Configuration)2 HMaster (org.apache.hadoop.hbase.master.HMaster)1 ServerManager (org.apache.hadoop.hbase.master.ServerManager)1