hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r686657 - in /hadoop/hbase/trunk: ./ src/java/org/apache/hadoop/hbase/rest/
Date Sun, 17 Aug 2008 22:53:26 GMT
Author: stack
Date: Sun Aug 17 15:53:25 2008
New Revision: 686657

URL: http://svn.apache.org/viewvc?rev=686657&view=rev
Log:
HBASE-795 More Table operation in TableHandler for REST interface

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/GenericHandler.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/ScannerHandler.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/TableHandler.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=686657&r1=686656&r2=686657&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Sun Aug 17 15:53:25 2008
@@ -37,7 +37,9 @@
    HBASE-812  Compaction needs little better skip algo (Daniel Leffel via Stack)
    HBASE-806  Change HbaseMapWritable and RowResult to implement SortedMap
               instead of Map (Jonathan Gray via Stack)
-   HBASE-795  More Table operation in TableHandler for REST interface
+   HBASE-795  More Table operation in TableHandler for REST interface: part 1
+              (Sishen Freecity via Stack)
+   HBASE-795  More Table operation in TableHandler for REST interface: part 2
               (Sishen Freecity via Stack)
    HBASE-830  Debugging HCM.locateRegionInMeta is painful
 

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java?rev=686657&r1=686656&r2=686657&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java Sun Aug 17 15:53:25
2008
@@ -65,7 +65,6 @@
   private RowHandler rowHandler;
   private ScannerHandler scannerHandler;
 
-  private static final String TABLES = "tables";
   private static final String SCANNER = "scanner";
   private static final String ROW = "row";
       
@@ -117,12 +116,13 @@
   throws IOException, ServletException {
     String [] pathSegments = getPathSegments(request);
     
-    if (pathSegments.length == 1 && pathSegments[0].toLowerCase().equals(TABLES))
{
+    if (pathSegments.length == 0 || pathSegments[0].length() <= 0) {
+      // if it was a root request, it must be a create table request
       tableHandler.doPost(request, response, pathSegments);
       return;
     } else {
       // there should be at least two path segments (table name and row or
-      // scanner)
+      // scanner or disable/enable operation)
       if (pathSegments.length >= 2 && pathSegments[0].length() > 0) {
         if (pathSegments[1].toLowerCase().equals(SCANNER)
             && pathSegments.length >= 2) {
@@ -132,8 +132,8 @@
             && pathSegments.length >= 3) {
           rowHandler.doPost(request, response, pathSegments);
           return;
-        } else if (pathSegments[0].toLowerCase().equals(TABLES) && pathSegments[1].length()
> 0 
-            && (pathSegments[2].toLowerCase().equals(TableHandler.DISABLE) || pathSegments[2].toLowerCase().equals(TableHandler.ENABLE)))
{
+        } else if ((pathSegments[1].toLowerCase().equals(TableHandler.DISABLE) || pathSegments[1].toLowerCase().equals(TableHandler.ENABLE))
+            && pathSegments.length == 2) {
           tableHandler.doPost(request, response, pathSegments);
           return;
         }
@@ -147,12 +147,13 @@
 
   protected void doPut(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
-    // Equate PUT with a POST.
     String [] pathSegments = getPathSegments(request);
     
-    if (pathSegments.length == 2 && pathSegments[0].toLowerCase().equals(TABLES)
&& pathSegments[1].length() > 0) {
+    if (pathSegments.length == 1 && pathSegments[0].length() > 0) {
+      // if it has only table name
       tableHandler.doPut(request, response, pathSegments);
     } else {
+      // Equate PUT with a POST.
       doPost(request, response);
     }
   }
@@ -162,7 +163,8 @@
   throws IOException, ServletException {
     String [] pathSegments = getPathSegments(request);
     
-    if (pathSegments.length == 2 && pathSegments[0].toLowerCase().equals(TABLES)
&& pathSegments[1].length() > 0) {
+    if (pathSegments.length == 1 && pathSegments[0].length() > 0) {
+      // if it only has only table name
       tableHandler.doDelete(request, response, pathSegments);
       return;
     } else if (pathSegments.length >= 3 && pathSegments[0].length() > 0) {

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/GenericHandler.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/GenericHandler.java?rev=686657&r1=686656&r2=686657&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/GenericHandler.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/GenericHandler.java Sun Aug 17
15:53:25 2008
@@ -55,7 +55,6 @@
   protected static final String CONTENT_TYPE = "content-type";
   protected static final String ROW = "row";
   protected static final String REGIONS = "regions";
-  protected static final String TABLES = "tables";
   
   protected final Log LOG = LogFactory.getLog(this.getClass());
 

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/ScannerHandler.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/ScannerHandler.java?rev=686657&r1=686656&r2=686657&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/ScannerHandler.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/ScannerHandler.java Sun Aug 17
15:53:25 2008
@@ -23,8 +23,6 @@
 import java.net.URLDecoder;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -39,7 +37,6 @@
 import org.apache.hadoop.hbase.util.JenkinsHash;
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.io.RowResult;
-import org.apache.hadoop.io.Text;
 import org.mortbay.servlet.MultiPartResponse;
 import org.znerd.xmlenc.XMLOutputter;
 

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/TableHandler.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/TableHandler.java?rev=686657&r1=686656&r2=686657&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/TableHandler.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/rest/TableHandler.java Sun Aug 17
15:53:25 2008
@@ -78,15 +78,15 @@
   public void doPost(HttpServletRequest request, HttpServletResponse response, 
     String[] pathSegments)
   throws ServletException, IOException {
-    if (pathSegments.length == 1) {
+    if (pathSegments.length == 0 || pathSegments[0].length() <= 0) {
       // if it's a creation operation
       putTable(request, response, pathSegments);
     } else {
       // if it's a disable operation or enable operation
-      String tableName = pathSegments[1];      
-      if (pathSegments[2].toLowerCase().equals(DISABLE)) {
+      String tableName = pathSegments[0];      
+      if (pathSegments[1].toLowerCase().equals(DISABLE)) {
         admin.disableTable(tableName);
-      } else if (pathSegments[2].toLowerCase().equals(ENABLE)) {
+      } else if (pathSegments[1].toLowerCase().equals(ENABLE)) {
         admin.enableTable(tableName);
       }
       response.setStatus(202);
@@ -240,7 +240,7 @@
   
   private void deleteTable(HttpServletRequest request,
       HttpServletResponse response, String[] pathSegments) throws IOException {
-    String tableName = pathSegments[1];
+    String tableName = pathSegments[0];
     admin.deleteTable(tableName);
     response.setStatus(202);
   }  
@@ -302,7 +302,7 @@
     }
 
     try {
-      String tableName = pathSegments[1];
+      String tableName = pathSegments[0];
 
       NodeList columnfamily_nodes = doc.getElementsByTagName("columnfamily");
       for (int i = 0; i < columnfamily_nodes.getLength(); i++) {



Mime
View raw message