hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecl...@apache.org
Subject svn commit: r1400958 - in /hbase/branches/0.92/src: main/resources/hbase-webapps/master/table.jsp test/java/org/apache/hadoop/hbase/TestInfoServers.java
Date Mon, 22 Oct 2012 17:10:12 GMT
Author: eclark
Date: Mon Oct 22 17:10:11 2012
New Revision: 1400958

URL: http://svn.apache.org/viewvc?rev=1400958&view=rev
Log:
HBASE-6951 Allow the master info server to be started in a read only mode.

Modified:
    hbase/branches/0.92/src/main/resources/hbase-webapps/master/table.jsp
    hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/TestInfoServers.java

Modified: hbase/branches/0.92/src/main/resources/hbase-webapps/master/table.jsp
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/resources/hbase-webapps/master/table.jsp?rev=1400958&r1=1400957&r2=1400958&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/resources/hbase-webapps/master/table.jsp (original)
+++ hbase/branches/0.92/src/main/resources/hbase-webapps/master/table.jsp Mon Oct 22 17:10:11
2012
@@ -45,6 +45,7 @@
   String tableHeader = "<h2>Table Regions</h2><table><tr><th>Name</th><th>Region
Server</th><th>Start Key</th><th>End Key</th><th>Requests</th></tr>";
   ServerName rl = master.getCatalogTracker().getRootLocation();
   boolean showFragmentation = conf.getBoolean("hbase.master.ui.fragmentation.enabled", false);
+  boolean readOnly = conf.getBoolean("hbase.master.ui.readonly", false);
   Map<String, Integer> frags = null;
   if (showFragmentation) {
       frags = FSUtils.getTableFragmentation(master);
@@ -65,7 +66,7 @@
 <%
   String action = request.getParameter("action");
   String key = request.getParameter("key");
-  if ( action != null ) {
+  if ( !readOnly && action != null ) {
 %>
 <head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
 <link rel="stylesheet" type="text/css" href="/static/hbase.css" />
@@ -237,6 +238,8 @@
 HConnectionManager.deleteConnection(hbadmin.getConfiguration(), false);
 %>
 
+
+<% if (!readOnly) { %>
 <p><hr><p>
 Actions:
 <p>
@@ -273,7 +276,7 @@ Actions:
 </table>
 </center>
 <p>
-
+<% } %>
 <%
 }
 %>

Modified: hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/TestInfoServers.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/TestInfoServers.java?rev=1400958&r1=1400957&r2=1400958&view=diff
==============================================================================
--- hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/TestInfoServers.java (original)
+++ hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/TestInfoServers.java Mon Oct
22 17:10:11 2012
@@ -26,6 +26,7 @@ import java.net.URL;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.util.Bytes;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -45,6 +46,7 @@ public class TestInfoServers {
     // Set them to ephemeral ports so they will start
     UTIL.getConfiguration().setInt("hbase.master.info.port", 0);
     UTIL.getConfiguration().setInt("hbase.regionserver.info.port", 0);
+    UTIL.getConfiguration().setBoolean("hbase.master.ui.readonly", true);
     UTIL.startMiniCluster();
   }
 
@@ -61,12 +63,12 @@ public class TestInfoServers {
     // give the cluster time to start up
     new HTable(UTIL.getConfiguration(), ".META.");
     int port = UTIL.getHBaseCluster().getMaster().getInfoServer().getPort();
-    assertHasExpectedContent(new URL("http://localhost:" + port +
-      "/index.html"), "master-status");
+    assertContainsContent(new URL("http://localhost:" + port +
+        "/index.html"), "master-status");
     port = UTIL.getHBaseCluster().getRegionServerThreads().get(0).getRegionServer().
       getInfoServer().getPort();
-    assertHasExpectedContent(new URL("http://localhost:" + port +
-      "/index.html"), "rs-status");
+    assertContainsContent(new URL("http://localhost:" + port +
+        "/index.html"), "rs-status");
   }
 
   /**
@@ -81,17 +83,49 @@ public class TestInfoServers {
     // give the cluster time to start up
     new HTable(UTIL.getConfiguration(), ".META.");
     int port = UTIL.getHBaseCluster().getMaster().getInfoServer().getPort();
-    assertHasExpectedContent(new URL("http://localhost:" + port +
-      "/master-status"), "META");
+    assertContainsContent(new URL("http://localhost:" + port +
+        "/master-status"), "META");
     port = UTIL.getHBaseCluster().getRegionServerThreads().get(0).getRegionServer().
       getInfoServer().getPort();
-    assertHasExpectedContent(new URL("http://localhost:" + port +
-      "/rs-status"), "META");
+    assertContainsContent(new URL("http://localhost:" + port +
+        "/rs-status"), "META");
   }
 
-  private void assertHasExpectedContent(final URL u, final String expected)
+  @Test
+  public void testMasterServerReadOnly() throws Exception {
+    String sTableName = "testMasterServerReadOnly";
+    byte[] tableName = Bytes.toBytes(sTableName);
+    byte[] cf = Bytes.toBytes("d");
+    UTIL.createTable(tableName, cf);
+    new HTable(UTIL.getConfiguration(), tableName).close();
+    int port = UTIL.getHBaseCluster().getMaster().getInfoServer().getPort();
+    assertDoesNotContainContent(
+      new URL("http://localhost:" + port + "/table.jsp?name=" + sTableName + "&action=split&key="),
+      "Table action request accepted");
+    assertDoesNotContainContent(
+      new URL("http://localhost:" + port + "/table.jsp?name=" + sTableName),
+      "Actions:");
+  }
+
+  private void assertContainsContent(final URL u, final String expected)
   throws IOException {
     LOG.info("Testing " + u.toString() + " has " + expected);
+    String content = getUrlContent(u);
+    assertTrue("expected=" + expected + ", content=" + content,
+      content.contains(expected));
+  }
+
+
+
+  private void assertDoesNotContainContent(final URL u, final String expected)
+      throws IOException {
+    LOG.info("Testing " + u.toString() + " has " + expected);
+    String content = getUrlContent(u);
+    assertTrue("Does Not Contain =" + expected + ", content=" + content,
+        !content.contains(expected));
+  }
+
+  private String getUrlContent(URL u) throws IOException {
     java.net.URLConnection c = u.openConnection();
     c.connect();
     StringBuilder sb = new StringBuilder();
@@ -102,7 +136,6 @@ public class TestInfoServers {
     }
     bis.close();
     String content = sb.toString();
-    assertTrue("expected=" + expected + ", content=" + content,
-      content.contains(expected));
+    return content;
   }
 }



Mime
View raw message