hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1541643 - in /hbase/branches/0.96/hbase-server/src: main/java/org/apache/hadoop/hbase/rest/SchemaResource.java test/java/org/apache/hadoop/hbase/rest/TestSchemaResource.java
Date Wed, 13 Nov 2013 18:08:20 GMT
Author: larsh
Date: Wed Nov 13 18:08:20 2013
New Revision: 1541643

URL: http://svn.apache.org/r1541643
Log:
HBASE-9849 [REST] Forbidden schema delete in read only mode (Julian Zhou)

Modified:
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java
    hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestSchemaResource.java

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java?rev=1541643&r1=1541642&r2=1541643&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/SchemaResource.java
Wed Nov 13 18:08:20 2013
@@ -236,6 +236,10 @@ public class SchemaResource extends Reso
       LOG.debug("DELETE " + uriInfo.getAbsolutePath());
     }
     servlet.getMetrics().incrementRequests(1);
+    if (servlet.isReadOnly()) {
+      return Response.status(Response.Status.FORBIDDEN).type(MIMETYPE_TEXT)
+          .entity("Forbidden" + CRLF).build();
+    }
     try {
       HBaseAdmin admin = servlet.getAdmin();
       boolean success = false;

Modified: hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestSchemaResource.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestSchemaResource.java?rev=1541643&r1=1541642&r2=1541643&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestSchemaResource.java
(original)
+++ hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestSchemaResource.java
Wed Nov 13 18:08:20 2013
@@ -123,14 +123,17 @@ public class TestSchemaResource {
     model = testTableSchemaModel.fromJSON(Bytes.toString(response.getBody()));
     testTableSchemaModel.checkModel(model, TABLE1);
 
-    // delete the table
-    client.delete(schemaPath);
-
-    // make sure HBase concurs
-    assertFalse(admin.tableExists(TABLE1));
+    // test delete schema operation is forbidden in read-only mode
+    response = client.delete(schemaPath);
+    assertEquals(response.getCode(), 403);
 
     // return read-only setting back to default
     conf.set("hbase.rest.readonly", "false");
+
+    // delete the table and make sure HBase concurs
+    response = client.delete(schemaPath);
+    assertEquals(response.getCode(), 200);
+    assertFalse(admin.tableExists(TABLE1));
   }
 
   @Test
@@ -171,14 +174,17 @@ public class TestSchemaResource {
     model.getObjectFromMessage(response.getBody());
     testTableSchemaModel.checkModel(model, TABLE2);
 
-    // delete the table
-    client.delete(schemaPath);
-
-    // make sure HBase concurs
-    assertFalse(admin.tableExists(TABLE2));
+    // test delete schema operation is forbidden in read-only mode
+    response = client.delete(schemaPath);
+    assertEquals(response.getCode(), 403);
 
     // return read-only setting back to default
     conf.set("hbase.rest.readonly", "false");
+
+    // delete the table and make sure HBase concurs
+    response = client.delete(schemaPath);
+    assertEquals(response.getCode(), 200);
+    assertFalse(admin.tableExists(TABLE2));
   }
 
 }



Mime
View raw message