HBASE-795 More Table operation in TableHandler for REST interface

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@686657 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2008-08-17 22:53:25 +00:00
parent c17ecdb420
commit 6cb9d9ff7f
5 changed files with 19 additions and 19 deletions

View File

@ -37,7 +37,9 @@ Release 0.3.0 - Unreleased
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

View File

@ -65,7 +65,6 @@ implements javax.servlet.Servlet {
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 @@ implements javax.servlet.Servlet {
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 @@ implements javax.servlet.Servlet {
&& 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 @@ implements javax.servlet.Servlet {
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 @@ implements javax.servlet.Servlet {
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) {

View File

@ -55,7 +55,6 @@ public abstract class GenericHandler {
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());

View File

@ -23,8 +23,6 @@ import java.io.IOException;
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.Bytes;
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;

View File

@ -78,15 +78,15 @@ public class TableHandler extends GenericHandler {
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 @@ public class TableHandler extends GenericHandler {
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 @@ public class TableHandler extends GenericHandler {
}
try {
String tableName = pathSegments[1];
String tableName = pathSegments[0];
NodeList columnfamily_nodes = doc.getElementsByTagName("columnfamily");
for (int i = 0; i < columnfamily_nodes.getLength(); i++) {