knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject git commit: KNOX-85: Provide Knox client DSL for HBase REST API
Date Thu, 18 Jul 2013 14:10:02 GMT
Updated Branches:
  refs/heads/master 80c829f6b -> 41b4b8bea


KNOX-85: Provide Knox client DSL for HBase REST API


Project: http://git-wip-us.apache.org/repos/asf/incubator-knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-knox/commit/41b4b8be
Tree: http://git-wip-us.apache.org/repos/asf/incubator-knox/tree/41b4b8be
Diff: http://git-wip-us.apache.org/repos/asf/incubator-knox/diff/41b4b8be

Branch: refs/heads/master
Commit: 41b4b8bea57dd5dae05f5a6892f19acff8e6d7db
Parents: 80c829f
Author: Kevin Minder <kevin.minder@hortonworks.com>
Authored: Thu Jul 18 10:06:54 2013 -0400
Committer: Kevin Minder <kevin.minder@hortonworks.com>
Committed: Thu Jul 18 10:06:54 2013 -0400

----------------------------------------------------------------------
 .../gateway/shell/hbase/ClusterVersion.java     |  55 +++++
 .../hadoop/gateway/shell/hbase/Example.groovy   | 173 +++++++++++++++
 .../hadoop/gateway/shell/hbase/HBase.java       |  56 +++++
 .../hadoop/gateway/shell/hbase/Status.java      |  55 +++++
 .../gateway/shell/hbase/SystemVersion.java      |  55 +++++
 .../gateway/shell/hbase/table/Attribute.java    |  36 ++++
 .../gateway/shell/hbase/table/CreateTable.java  | 129 +++++++++++
 .../gateway/shell/hbase/table/DeleteTable.java  |  58 +++++
 .../gateway/shell/hbase/table/Family.java       |  55 +++++
 .../shell/hbase/table/FamilyContainer.java      |  22 ++
 .../hadoop/gateway/shell/hbase/table/Table.java |  84 ++++++++
 .../gateway/shell/hbase/table/TableList.java    |  56 +++++
 .../gateway/shell/hbase/table/TableRegions.java |  59 +++++
 .../gateway/shell/hbase/table/TableSchema.java  |  59 +++++
 .../gateway/shell/hbase/table/UpdateTable.java  | 119 +++++++++++
 .../gateway/shell/hbase/table/row/Column.java   |  48 +++++
 .../shell/hbase/table/row/DeleteRows.java       |  93 ++++++++
 .../shell/hbase/table/row/InsertableColumn.java |  53 +++++
 .../shell/hbase/table/row/QueryRows.java        | 126 +++++++++++
 .../gateway/shell/hbase/table/row/Row.java      |  50 +++++
 .../gateway/shell/hbase/table/row/StoreRow.java | 128 +++++++++++
 .../hbase/table/scanner/CreateScanner.java      | 213 +++++++++++++++++++
 .../hbase/table/scanner/DeleteScanner.java      |  60 ++++++
 .../shell/hbase/table/scanner/Scanner.java      |  50 +++++
 .../hbase/table/scanner/ScannerGetNext.java     |  61 ++++++
 25 files changed, 1953 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/ClusterVersion.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/ClusterVersion.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/ClusterVersion.java
new file mode 100644
index 0000000..b059bd0
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/ClusterVersion.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.BasicResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+
+import java.util.concurrent.Callable;
+
+public class ClusterVersion {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    public Request( Hadoop session ) {
+      super( session );
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/version/cluster" );
+          HttpGet get = new HttpGet( uri.build() );
+          get.setHeader( "Accept", "application/json" );
+          return new Response( execute( get ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends BasicResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/Example.groovy
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/Example.groovy b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/Example.groovy
new file mode 100644
index 0000000..bf1b67e
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/Example.groovy
@@ -0,0 +1,173 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase
+
+import org.apache.hadoop.gateway.shell.Hadoop
+
+import static java.util.concurrent.TimeUnit.SECONDS
+
+gateway = "https://localhost:8443/gateway/sample"
+username = "bob"
+password = "bob-password"
+tableName = "test_table"
+
+session = Hadoop.login(gateway, username, password)
+
+println "System version : " + HBase.session(session).systemVersion().now().string
+
+println "Cluster version : " + HBase.session(session).clusterVersion().now().string
+
+println "Status : " + HBase.session(session).status().now().string
+
+println "Creating table '" + tableName + "'..."
+
+HBase.session(session).table(tableName).create()  \
+    .attribute("tb_attr1", "value1")  \
+    .attribute("tb_attr2", "value2")  \
+    .family("family1")  \
+        .attribute("fm_attr1", "value3")  \
+        .attribute("fm_attr2", "value4")  \
+    .endFamilyDef()  \
+    .family("family2")  \
+    .family("family3")  \
+    .endFamilyDef()  \
+    .attribute("tb_attr3", "value5")  \
+    .now()
+
+println "Done"
+
+println "Table List : " + HBase.session(session).table().list().now().string
+
+println "Schema for table '" + tableName + "' : " + HBase.session(session)  \
+    .table(tableName)  \
+    .schema()  \
+    .now().string
+
+println "Updating schema of table '" + tableName + "'..."
+
+HBase.session(session).table(tableName).update()  \
+    .family("family1")  \
+        .attribute("fm_attr1", "new_value3")  \
+    .endFamilyDef()  \
+    .family("family4")  \
+        .attribute("fm_attr3", "value6")  \
+    .endFamilyDef()  \
+    .now()
+
+println "Done"
+
+println "Schema for table '" + tableName + "' : " + HBase.session(session)  \
+    .table(tableName)  \
+    .schema()  \
+    .now().string
+
+println "Inserting data into table..."
+
+HBase.session(session).table(tableName).row("row_id_1").store()  \
+    .column("family1", "col1", "col_value1")  \
+    .column("family1", "col2", "col_value2", 1234567890l)  \
+    .column("family2", null, "fam_value1")  \
+    .now()
+
+HBase.session(session).table(tableName).row("row_id_2").store()  \
+    .column("family1", "row2_col1", "row2_col_value1")  \
+    .now()
+
+println "Done"
+
+println "Querying row by id..."
+
+println HBase.session(session).table(tableName).row("row_id_1")  \
+    .query()  \
+    .now().string
+
+println "Querying all rows..."
+
+println HBase.session(session).table(tableName).row().query().now().string
+
+println "Querying row by id with extended settings..."
+
+println HBase.session(session).table(tableName).row().query()  \
+    .column("family1", "row2_col1")  \
+    .column("family2")  \
+    .times(0, Long.MAX_VALUE)  \
+    .numVersions(1)  \
+    .now().string
+
+println "Deleting cell..."
+
+HBase.session(session).table(tableName).row("row_id_1")  \
+    .delete()  \
+    .column("family1", "col1")  \
+    .now()
+
+println "Rows after delete:"
+
+println HBase.session(session).table(tableName).row().query().now().string
+
+println "Extended cell delete"
+
+HBase.session(session).table(tableName).row("row_id_1")  \
+    .delete()  \
+    .column("family2")  \
+    .time(Long.MAX_VALUE)  \
+    .now()
+
+println "Rows after delete:"
+
+println HBase.session(session).table(tableName).row().query().now().string
+
+println "Table regions : " + HBase.session(session).table(tableName)  \
+    .regions()  \
+    .now().string
+
+println "Creating scanner..."
+
+scannerId = HBase.session(session).table(tableName).scanner().create()  \
+    .column("family1", "col2")  \
+    .column("family2")  \
+    .startRow("row_id_1")  \
+    .endRow("row_id_2")  \
+    .batch(1)  \
+    .startTime(0)  \
+    .endTime(Long.MAX_VALUE)  \
+    .filter("")  \
+    .maxVersions(100)  \
+    .now().scannerId
+
+println "Scanner id=" + scannerId
+
+println "Scanner get next..."
+
+println HBase.session(session).table(tableName).scanner(scannerId)  \
+    .getNext()  \
+    .now().string
+
+println "Dropping scanner with id=" + scannerId
+
+HBase.session(session).table(tableName).scanner(scannerId).delete().now()
+
+println "Done"
+
+println "Dropping table '" + tableName + "'..."
+
+HBase.session(session).table(tableName).delete().now()
+
+println "Done"
+
+session.shutdown(10, SECONDS)

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/HBase.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/HBase.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/HBase.java
new file mode 100644
index 0000000..184c799
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/HBase.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase;
+
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.table.Table;
+
+public class HBase {
+
+  public static final String SERVICE_PATH = "/hbase/api";
+
+  private Hadoop session;
+
+  public HBase( Hadoop session ) {
+    this.session = session;
+  }
+
+  public static HBase session( Hadoop session ) {
+    HBase hbase = new HBase( session );
+    return hbase;
+  }
+
+  public SystemVersion.Request systemVersion() {
+    return new SystemVersion.Request( session );
+  }
+
+  public ClusterVersion.Request clusterVersion() {
+    return new ClusterVersion.Request( session );
+  }
+
+  public Status.Request status() {
+    return new Status.Request( session );
+  }
+
+  public Table table( String name ) {
+    return new Table( name ).session( session );
+  }
+
+  public Table table() {
+    return new Table( null ).session( session );
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/Status.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/Status.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/Status.java
new file mode 100644
index 0000000..88b9c92
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/Status.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.BasicResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+
+import java.util.concurrent.Callable;
+
+public class Status {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    public Request( Hadoop session ) {
+      super( session );
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/status/cluster" );
+          HttpGet get = new HttpGet( uri.build() );
+          get.setHeader( "Accept", "application/json" );
+          return new Response( execute( get ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends BasicResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/SystemVersion.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/SystemVersion.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/SystemVersion.java
new file mode 100644
index 0000000..585637b
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/SystemVersion.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.BasicResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+
+import java.util.concurrent.Callable;
+
+public class SystemVersion {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    public Request( Hadoop session ) {
+      super( session );
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/version" );
+          HttpGet get = new HttpGet( uri.build() );
+          get.setHeader( "Accept", "application/json" );
+          return new Response( execute( get ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends BasicResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/Attribute.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/Attribute.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/Attribute.java
new file mode 100644
index 0000000..d6187aa
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/Attribute.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table;
+
+public class Attribute {
+
+  private String name;
+  private Object value;
+
+  public Attribute( String name, Object value ) {
+    this.name = name;
+    this.value = value;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public Object getValue() {
+    return value;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/CreateTable.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/CreateTable.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/CreateTable.java
new file mode 100644
index 0000000..cb63757
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/CreateTable.java
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.EmptyResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.HBase;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+public class CreateTable {
+
+  public static class Request extends AbstractRequest<Response> implements FamilyContainer<Request> {
+
+    private static final String ELEMENT_TABLE_SCHEMA = "TableSchema";
+    private static final String ELEMENT_COLUMN_SCHEMA = "ColumnSchema";
+    private static final String ATTRIBUTE_NAME = "name";
+
+    private String tableName;
+    private List<Attribute> attributes = new ArrayList<Attribute>();
+    private List<Family<Request>> families = new ArrayList<Family<Request>>();
+
+    public Request( Hadoop session, String tableName ) {
+      super( session );
+      this.tableName = tableName;
+    }
+
+    public Request attribute( String name, Object value ) {
+      attributes.add( new Attribute( name, value ) );
+      return this;
+    }
+
+    public Family<Request> family( String name ) {
+      Family<Request> family = new Family<Request>( this, name );
+      families.add( family );
+      return family;
+    }
+
+    @Override
+    public Request addFamily( Family<Request> family ) {
+      families.add( family );
+      return this;
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
+          DocumentBuilder builder = builderFactory.newDocumentBuilder();
+          Document document = builder.newDocument();
+          document.setXmlStandalone( true );
+
+          Element root = document.createElement( ELEMENT_TABLE_SCHEMA );
+          root.setAttribute( ATTRIBUTE_NAME, tableName );
+          for( Attribute attribute : attributes ) {
+            root.setAttribute( attribute.getName(), attribute.getValue().toString() );
+          }
+          document.appendChild( root );
+
+          for( Family<Request> family : families ) {
+            Element columnSchema = document.createElement( ELEMENT_COLUMN_SCHEMA );
+            columnSchema.setAttribute( ATTRIBUTE_NAME, family.name() );
+            for( Attribute attribute : family.attributes() ) {
+              columnSchema.setAttribute( attribute.getName(), attribute.getValue().toString() );
+            }
+            root.appendChild( columnSchema );
+          }
+
+          TransformerFactory transformerFactory = TransformerFactory.newInstance();
+          Transformer transformer = transformerFactory.newTransformer();
+          transformer.setOutputProperty( OutputKeys.STANDALONE, "yes" );
+
+          StringWriter writer = new StringWriter();
+          StreamResult result = new StreamResult( writer );
+          DOMSource source = new DOMSource( document );
+          transformer.transform( source, result );
+
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/schema" );
+          HttpPut request = new HttpPut( uri.build() );
+          HttpEntity entity = new StringEntity( writer.toString(), ContentType.create( "text/xml", "UTF-8" ) );
+          request.setEntity( entity );
+
+          return new Response( execute( request ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends EmptyResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/DeleteTable.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/DeleteTable.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/DeleteTable.java
new file mode 100644
index 0000000..00faffd
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/DeleteTable.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.EmptyResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.HBase;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.utils.URIBuilder;
+
+import java.util.concurrent.Callable;
+
+public class DeleteTable {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    private String tableName;
+
+    public Request( Hadoop session, String tableName ) {
+      super( session );
+      this.tableName = tableName;
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/schema" );
+          HttpDelete delete = new HttpDelete( uri.build() );
+          return new Response( execute( delete ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends EmptyResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/Family.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/Family.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/Family.java
new file mode 100644
index 0000000..cfe6223
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/Family.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Family<T extends FamilyContainer> {
+
+  private T parent;
+  private String name;
+  private List<Attribute> attributes = new ArrayList<Attribute>();
+
+  public Family( T parent, String name ) {
+    this.parent = parent;
+    this.name = name;
+  }
+
+  public String name() {
+    return name;
+  }
+
+  public Family<T> attribute( String name, Object value ) {
+    attributes.add( new Attribute( name, value ) );
+    return this;
+  }
+
+  public List<Attribute> attributes() {
+    return attributes;
+  }
+
+  public T endFamilyDef() {
+    return parent;
+  }
+
+  public Family<T> family( String name ) {
+    Family<T> family = new Family<T>( parent, name );
+    parent.addFamily( family );
+    return family;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/FamilyContainer.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/FamilyContainer.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/FamilyContainer.java
new file mode 100644
index 0000000..5250090
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/FamilyContainer.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table;
+
+public interface FamilyContainer<T extends FamilyContainer<T>> {
+
+  FamilyContainer addFamily( Family<T> family );
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/Table.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/Table.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/Table.java
new file mode 100644
index 0000000..d727f4f
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/Table.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table;
+
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.table.row.Row;
+import org.apache.hadoop.gateway.shell.hbase.table.scanner.Scanner;
+
+public class Table {
+
+  private String name;
+  private Hadoop session;
+
+  public Table( String name ) {
+    this.name = name;
+  }
+
+  public String name() {
+    return name;
+  }
+
+  public Table session( Hadoop session ) {
+    this.session = session;
+    return this;
+  }
+
+  public Hadoop session() {
+    return session;
+  }
+
+  public TableList.Request list() {
+    return new TableList.Request( session );
+  }
+
+  public TableSchema.Request schema() {
+    return new TableSchema.Request( session, name );
+  }
+
+  public CreateTable.Request create() {
+    return new CreateTable.Request( session, name );
+  }
+
+  public UpdateTable.Request update() {
+    return new UpdateTable.Request( session, name );
+  }
+
+  public TableRegions.Request regions() {
+    return new TableRegions.Request( session, name );
+  }
+
+  public DeleteTable.Request delete() {
+    return new DeleteTable.Request( session, name );
+  }
+
+  public Row row( String id ) {
+    return new Row( id ).table( this );
+  }
+
+  public Row row() {
+    return row( null );
+  }
+
+  public Scanner scanner( String id ) {
+    return new Scanner( id ).table( this );
+  }
+
+  public Scanner scanner() {
+    return scanner( null );
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/TableList.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/TableList.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/TableList.java
new file mode 100644
index 0000000..8bf532d
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/TableList.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.BasicResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.HBase;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+
+import java.util.concurrent.Callable;
+
+public class TableList {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    public Request( Hadoop session ) {
+      super( session );
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          URIBuilder uri = uri( HBase.SERVICE_PATH );
+          HttpGet get = new HttpGet( uri.build() );
+          get.setHeader( "Accept", "application/json" );
+          return new Response( execute( get ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends BasicResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/TableRegions.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/TableRegions.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/TableRegions.java
new file mode 100644
index 0000000..14e0965
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/TableRegions.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.BasicResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.HBase;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+
+import java.util.concurrent.Callable;
+
+public class TableRegions {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    private String tableName;
+
+    public Request( Hadoop session, String tableName ) {
+      super( session );
+      this.tableName = tableName;
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/regions" );
+          HttpGet get = new HttpGet( uri.build() );
+          get.setHeader( "Accept", "application/json" );
+          return new Response( execute( get ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends BasicResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/TableSchema.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/TableSchema.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/TableSchema.java
new file mode 100644
index 0000000..69e2bc5
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/TableSchema.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.BasicResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.HBase;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+
+import java.util.concurrent.Callable;
+
+public class TableSchema {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    private String tableName;
+
+    public Request( Hadoop session, String tableName ) {
+      super( session );
+      this.tableName = tableName;
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/schema" );
+          HttpGet get = new HttpGet( uri.build() );
+          get.setHeader( "Accept", "application/json" );
+          return new Response( execute( get ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends BasicResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/UpdateTable.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/UpdateTable.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/UpdateTable.java
new file mode 100644
index 0000000..ea4f02e
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/UpdateTable.java
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.EmptyResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.HBase;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+public class UpdateTable {
+
+  public static class Request extends AbstractRequest<Response> implements FamilyContainer<Request> {
+
+    private static final String ELEMENT_TABLE_SCHEMA = "TableSchema";
+    private static final String ELEMENT_COLUMN_SCHEMA = "ColumnSchema";
+    private static final String ATTRIBUTE_NAME = "name";
+
+    private String tableName;
+    private List<Family<Request>> families = new ArrayList<Family<Request>>();
+
+    public Request( Hadoop session, String tableName ) {
+      super( session );
+      this.tableName = tableName;
+    }
+
+    public Family<Request> family( String name ) {
+      Family<Request> family = new Family<Request>( this, name );
+      families.add( family );
+      return family;
+    }
+
+    @Override
+    public Request addFamily( Family<Request> family ) {
+      families.add( family );
+      return this;
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
+          DocumentBuilder builder = builderFactory.newDocumentBuilder();
+          Document document = builder.newDocument();
+          document.setXmlStandalone( true );
+
+          Element root = document.createElement( ELEMENT_TABLE_SCHEMA );
+          document.appendChild( root );
+
+          for( Family<Request> family : families ) {
+            Element columnSchema = document.createElement( ELEMENT_COLUMN_SCHEMA );
+            columnSchema.setAttribute( ATTRIBUTE_NAME, family.name() );
+            for( Attribute attribute : family.attributes() ) {
+              columnSchema.setAttribute( attribute.getName(), attribute.getValue().toString() );
+            }
+            root.appendChild( columnSchema );
+          }
+
+          TransformerFactory transformerFactory = TransformerFactory.newInstance();
+          Transformer transformer = transformerFactory.newTransformer();
+          transformer.setOutputProperty( OutputKeys.STANDALONE, "yes" );
+
+          StringWriter writer = new StringWriter();
+          StreamResult result = new StreamResult( writer );
+          DOMSource source = new DOMSource( document );
+          transformer.transform( source, result );
+
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/schema" );
+          HttpPost request = new HttpPost( uri.build() );
+          HttpEntity entity = new StringEntity( writer.toString(), ContentType.create( "text/xml", "UTF-8" ) );
+          request.setEntity( entity );
+
+          return new Response( execute( request ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends EmptyResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/Column.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/Column.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/Column.java
new file mode 100644
index 0000000..fee425c
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/Column.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table.row;
+
+public class Column {
+
+  private String family;
+  private String qualifier;
+
+  public Column( String family, String qualifier ) {
+    this.family = family;
+    this.qualifier = qualifier;
+  }
+
+  public Column( String family ) {
+    this( family, null );
+  }
+
+  public String family() {
+    return family;
+  }
+
+  public String qualifier() {
+    return qualifier;
+  }
+
+  public String toURIPart() {
+    StringBuilder sb = new StringBuilder( family );
+    if( qualifier != null && !qualifier.isEmpty() ) {
+      sb.append( ":" ).append( qualifier );
+    }
+    return sb.toString();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/DeleteRows.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/DeleteRows.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/DeleteRows.java
new file mode 100644
index 0000000..803f50d
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/DeleteRows.java
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table.row;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.EmptyResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.HBase;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.utils.URIBuilder;
+
+import java.util.concurrent.Callable;
+
+public class DeleteRows {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    private String rowsId;
+    private String tableName;
+    private Column column;
+    private Long time;
+
+    public Request( Hadoop session, String rowsId, String tableName ) {
+      super( session );
+      this.rowsId = rowsId;
+      this.tableName = tableName;
+    }
+
+    public Request column( String family, String qualifier ) {
+      column = new Column( family, qualifier );
+      return this;
+    }
+
+    public Request column( String family ) {
+      column = new Column( family );
+      return this;
+    }
+
+    public Request time( Long time ) {
+      this.time = time;
+      return this;
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          String rowsIdToQuery = rowsId;
+          if( rowsIdToQuery == null || rowsIdToQuery.isEmpty() ) {
+            rowsIdToQuery = "*";
+          }
+
+          StringBuilder columnsURIPart = new StringBuilder( "/" );
+          if( column != null ) {
+            columnsURIPart.append( column.toURIPart() );
+          }
+          columnsURIPart.append( "/" );
+
+          String timeURIPart = "";
+          if( time != null ) {
+            timeURIPart = time.toString();
+          }
+
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/", rowsIdToQuery, columnsURIPart.toString(), timeURIPart );
+          HttpDelete delete = new HttpDelete( uri.build() );
+          return new Response( execute( delete ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends EmptyResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/InsertableColumn.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/InsertableColumn.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/InsertableColumn.java
new file mode 100644
index 0000000..12c4c29
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/InsertableColumn.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table.row;
+
+import org.apache.commons.codec.binary.Base64;
+
+import java.io.UnsupportedEncodingException;
+
+public class InsertableColumn extends Column {
+
+  private Object value;
+  private Long time;
+
+  public InsertableColumn( String family, String qualifier, Object value, Long time ) {
+    super( family, qualifier );
+    this.value = value;
+    this.time = time;
+  }
+
+  public Object value() {
+    return value;
+  }
+
+  public Long time() {
+    return time;
+  }
+
+  public String encodedName() throws UnsupportedEncodingException {
+    return Base64.encodeBase64String( toURIPart().getBytes( "UTF-8" ) );
+  }
+
+  public String encodedValue() throws UnsupportedEncodingException {
+    String stringValue = value.toString();
+    if( stringValue == null ) {
+      stringValue = "";
+    }
+    return Base64.encodeBase64String( stringValue.getBytes( "UTF-8" ) );
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/QueryRows.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/QueryRows.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/QueryRows.java
new file mode 100644
index 0000000..427a69d
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/QueryRows.java
@@ -0,0 +1,126 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table.row;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.BasicResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.HBase;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+public class QueryRows {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    private String rowsId;
+    private String tableName;
+    private List<Column> columns = new ArrayList<Column>();
+    private Long startTime;
+    private Long endTime;
+    private Long numVersions;
+
+    public Request( Hadoop session, String rowsId, String tableName ) {
+      super( session );
+      this.rowsId = rowsId;
+      this.tableName = tableName;
+    }
+
+    public Request column( String family, String qualifier ) {
+      Column column = new Column( family, qualifier );
+      columns.add( column );
+      return this;
+    }
+
+    public Request column( String family ) {
+      return column( family, null );
+    }
+
+    public Request startTime( Long startTime ) {
+      this.startTime = startTime;
+      return this;
+    }
+
+    public Request endTime( Long endTime ) {
+      this.endTime = endTime;
+      return this;
+    }
+
+    public Request times( Long startTime, Long endTime ) {
+      this.startTime = startTime;
+      this.endTime = endTime;
+      return this;
+    }
+
+    public Request numVersions( Long numVersions ) {
+      this.numVersions = numVersions;
+      return this;
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          String rowsIdToQuery = rowsId;
+          if( rowsIdToQuery == null || rowsIdToQuery.isEmpty() ) {
+            rowsIdToQuery = "*";
+          }
+
+          StringBuilder columnsURIPart = new StringBuilder( "/" );
+          int index = 0;
+          for( Column column : columns ) {
+            if( index++ > 0 ) {
+              columnsURIPart.append( "," );
+            }
+            columnsURIPart.append( column.toURIPart() );
+          }
+          columnsURIPart.append( "/" );
+
+          StringBuilder timesURIPart = new StringBuilder();
+          if( startTime != null && endTime != null ) {
+            timesURIPart.append( startTime ).append( "," ).append( endTime );
+          } else if( startTime != null ) {
+            timesURIPart.append( startTime ).append( "," ).append( Long.MAX_VALUE );
+          } else if( endTime != null ) {
+            timesURIPart.append( endTime );
+          }
+          StringBuilder versionURIPart = new StringBuilder();
+          if( numVersions != null ) {
+            versionURIPart.append( "?v=" ).append( numVersions );
+          }
+
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/", rowsIdToQuery, columnsURIPart.toString(), timesURIPart.toString(), versionURIPart.toString() );
+          HttpGet get = new HttpGet( uri.build() );
+          get.setHeader( "Accept", "application/json" );
+          return new Response( execute( get ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends BasicResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/Row.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/Row.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/Row.java
new file mode 100644
index 0000000..09625d3
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/Row.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table.row;
+
+import org.apache.hadoop.gateway.shell.hbase.table.Table;
+
+public class Row {
+
+  private String id;
+  private Table table;
+
+  public Row( String id ) {
+    this.id = id;
+  }
+
+  public Row() {
+    this( null );
+  }
+
+  public Row table( Table table ) {
+    this.table = table;
+    return this;
+  }
+
+  public StoreRow.Request store() {
+    return new StoreRow.Request( table.session(), id, table.name() );
+  }
+
+  public QueryRows.Request query() {
+    return new QueryRows.Request( table.session(), id, table.name() );
+  }
+
+  public DeleteRows.Request delete() {
+    return new DeleteRows.Request( table.session(), id, table.name() );
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/StoreRow.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/StoreRow.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/StoreRow.java
new file mode 100644
index 0000000..42a2703
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/row/StoreRow.java
@@ -0,0 +1,128 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table.row;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.EmptyResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.HBase;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+public class StoreRow {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    private static final String ELEMENT_CELL_SET = "CellSet";
+    private static final String ELEMENT_ROW = "Row";
+    private static final String ELEMENT_CELL = "Cell";
+    private static final String ATTRIBUTE_KEY = "key";
+    private static final String ATTRIBUTE_COLUMN = "column";
+    private static final String ATTRIBUTE_TIMESTAMP = "timestamp";
+
+    private String rowId;
+    private String tableName;
+    private List<InsertableColumn> columns = new ArrayList<InsertableColumn>();
+
+    public Request( Hadoop session, String rowId, String tableName ) {
+      super( session );
+      this.rowId = rowId;
+      this.tableName = tableName;
+    }
+
+    public Request column( String family, String qualifier, Object value, Long time ) {
+      columns.add( new InsertableColumn( family, qualifier, value, time ) );
+      return this;
+    }
+
+    public Request column( String family, String qualifier, Object value ) {
+      columns.add( new InsertableColumn( family, qualifier, value, null ) );
+      return this;
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
+          DocumentBuilder builder = builderFactory.newDocumentBuilder();
+          Document document = builder.newDocument();
+          document.setXmlStandalone( true );
+
+          Element root = document.createElement( ELEMENT_CELL_SET );
+          document.appendChild( root );
+
+          Element row = document.createElement( ELEMENT_ROW );
+          row.setAttribute( ATTRIBUTE_KEY, Base64.encodeBase64String( rowId.getBytes( "UTF-8" ) ) );
+          root.appendChild( row );
+
+          for( InsertableColumn column : columns ) {
+            Element cell = document.createElement( ELEMENT_CELL );
+            cell.setAttribute( ATTRIBUTE_COLUMN, column.encodedName() );
+            if( column.time() != null ) {
+              cell.setAttribute( ATTRIBUTE_TIMESTAMP, column.time().toString() );
+            }
+            cell.setTextContent( column.encodedValue() );
+            row.appendChild( cell );
+          }
+
+          TransformerFactory transformerFactory = TransformerFactory.newInstance();
+          Transformer transformer = transformerFactory.newTransformer();
+          transformer.setOutputProperty( OutputKeys.STANDALONE, "yes" );
+
+          StringWriter writer = new StringWriter();
+          StreamResult result = new StreamResult( writer );
+          DOMSource source = new DOMSource( document );
+          transformer.transform( source, result );
+
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/false-row-key" );
+          HttpPost request = new HttpPost( uri.build() );
+          HttpEntity entity = new StringEntity( writer.toString(), ContentType.create( "text/xml", "UTF-8" ) );
+          request.setEntity( entity );
+
+          return new Response( execute( request ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends EmptyResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/CreateScanner.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/CreateScanner.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/CreateScanner.java
new file mode 100644
index 0000000..d0ff0f8
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/CreateScanner.java
@@ -0,0 +1,213 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table.scanner;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.EmptyResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.HBase;
+import org.apache.hadoop.gateway.shell.hbase.table.row.Column;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+public class CreateScanner {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    private static final String ELEMENT_SCANNER = "Scanner";
+    private static final String ELEMENT_COLUMN = "column";
+    private static final String ELEMENT_FILTER = "filter";
+    private static final String ATTRIBUTE_START_ROW = "startRow";
+    private static final String ATTRIBUTE_END_ROW = "endRow";
+    private static final String ATTRIBUTE_BATCH = "batch";
+    private static final String ATTRIBUTE_START_TIME = "startTime";
+    private static final String ATTRIBUTE_END_TIME = "endTime";
+    private static final String ATTRIBUTE_MAX_VERSIONS = "maxVersions";
+
+    private String tableName;
+    private String startRow;
+    private String endRow;
+    private List<Column> columns = new ArrayList<Column>();
+    private Integer batch;
+    private Long startTime;
+    private Long endTime;
+    private String filter;
+    private Integer maxVersions;
+
+    public Request( Hadoop session, String tableName ) {
+      super( session );
+      this.tableName = tableName;
+    }
+
+    public Request rows( String startRow, String endRow ) {
+      this.startRow = startRow;
+      this.endRow = endRow;
+      return this;
+    }
+
+    public Request startRow( String startRow ) {
+      this.startRow = startRow;
+      return this;
+    }
+
+    public Request endRow( String endRow ) {
+      this.endRow = endRow;
+      return this;
+    }
+
+    public Request column( String family, String qualifier ) {
+      Column column = new Column( family, qualifier );
+      columns.add( column );
+      return this;
+    }
+
+    public Request column( String family ) {
+      return column( family, null );
+    }
+
+    public Request batch( Integer batch ) {
+      this.batch = batch;
+      return this;
+    }
+
+    public Request times( Long startTime, Long endTime ) {
+      this.startTime = startTime;
+      this.endTime = endTime;
+      return this;
+    }
+
+    public Request startTime( Long startTime ) {
+      this.startTime = startTime;
+      return this;
+    }
+
+    public Request endTime( Long endTime ) {
+      this.endTime = endTime;
+      return this;
+    }
+
+    public Request filter( String filter ) {
+      this.filter = filter;
+      return this;
+    }
+
+    public Request maxVersions( Integer maxVersions ) {
+      this.maxVersions = maxVersions;
+      return this;
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
+          DocumentBuilder builder = builderFactory.newDocumentBuilder();
+          Document document = builder.newDocument();
+          document.setXmlStandalone( true );
+
+          Element root = document.createElement( ELEMENT_SCANNER );
+          if( startRow != null ) {
+            root.setAttribute( ATTRIBUTE_START_ROW, Base64.encodeBase64String( startRow.getBytes( "UTF-8" ) ) );
+          }
+          if( endRow != null ) {
+            root.setAttribute( ATTRIBUTE_END_ROW, Base64.encodeBase64String( endRow.getBytes( "UTF-8" ) ) );
+          }
+          if( batch != null ) {
+            root.setAttribute( ATTRIBUTE_BATCH, batch.toString() );
+          }
+          if( startTime != null ) {
+            root.setAttribute( ATTRIBUTE_START_TIME, startTime.toString() );
+          }
+          if( endTime != null ) {
+            root.setAttribute( ATTRIBUTE_END_TIME, endTime.toString() );
+          }
+          if( maxVersions != null ) {
+            root.setAttribute( ATTRIBUTE_MAX_VERSIONS, maxVersions.toString() );
+          }
+          document.appendChild( root );
+
+          for( Column column : columns ) {
+            Element columnElement = document.createElement( ELEMENT_COLUMN );
+            columnElement.setTextContent( Base64.encodeBase64String( column.toURIPart().getBytes( "UTF-8" ) ) );
+            root.appendChild( columnElement );
+          }
+
+          if( filter != null && !filter.isEmpty() ) {
+            Element filterElement = document.createElement( ELEMENT_FILTER );
+            filterElement.setTextContent( filter );
+            root.appendChild( filterElement );
+          }
+
+          TransformerFactory transformerFactory = TransformerFactory.newInstance();
+          Transformer transformer = transformerFactory.newTransformer();
+          transformer.setOutputProperty( OutputKeys.STANDALONE, "yes" );
+
+          StringWriter writer = new StringWriter();
+          StreamResult result = new StreamResult( writer );
+          DOMSource source = new DOMSource( document );
+          transformer.transform( source, result );
+
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/scanner" );
+          HttpPut request = new HttpPut( uri.build() );
+          HttpEntity entity = new StringEntity( writer.toString(), ContentType.create( "text/xml", "UTF-8" ) );
+          request.setEntity( entity );
+
+          return new Response( execute( request ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends EmptyResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+
+    public String getScannerId() {
+      Header locationHeader = response().getFirstHeader( "Location" );
+      if( locationHeader != null && locationHeader.getValue() != null && !locationHeader.getValue().isEmpty() ) {
+        String location = locationHeader.getValue();
+        int position = location.lastIndexOf( "/" );
+        if( position != -1 ) {
+          return location.substring( position + 1 );
+        }
+      }
+      return null;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/DeleteScanner.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/DeleteScanner.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/DeleteScanner.java
new file mode 100644
index 0000000..81f9a94
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/DeleteScanner.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table.scanner;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.EmptyResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.HBase;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.utils.URIBuilder;
+
+import java.util.concurrent.Callable;
+
+public class DeleteScanner {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    private String scannerId;
+    private String tableName;
+
+    public Request( Hadoop session, String scannerId, String tableName ) {
+      super( session );
+      this.scannerId = scannerId;
+      this.tableName = tableName;
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/scanner/", scannerId );
+          HttpDelete request = new HttpDelete( uri.build() );
+          return new Response( execute( request ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends EmptyResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/Scanner.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/Scanner.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/Scanner.java
new file mode 100644
index 0000000..0b1a038
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/Scanner.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table.scanner;
+
+import org.apache.hadoop.gateway.shell.hbase.table.Table;
+
+public class Scanner {
+
+  private String id;
+  private Table table;
+
+  public Scanner( String id ) {
+    this.id = id;
+  }
+
+  public Scanner() {
+    this( null );
+  }
+
+  public Scanner table( Table table ) {
+    this.table = table;
+    return this;
+  }
+
+  public CreateScanner.Request create() {
+    return new CreateScanner.Request( table.session(), table.name() );
+  }
+
+  public ScannerGetNext.Request getNext() {
+    return new ScannerGetNext.Request( table.session(), id, table.name() );
+  }
+
+  public DeleteScanner.Request delete() {
+    return new DeleteScanner.Request( table.session(), id, table.name() );
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/41b4b8be/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/ScannerGetNext.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/ScannerGetNext.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/ScannerGetNext.java
new file mode 100644
index 0000000..07ceb1d
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hbase/table/scanner/ScannerGetNext.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.shell.hbase.table.scanner;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.BasicResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.hadoop.gateway.shell.hbase.HBase;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+
+import java.util.concurrent.Callable;
+
+public class ScannerGetNext {
+
+  public static class Request extends AbstractRequest<Response> {
+
+    private String scannerId;
+    private String tableName;
+
+    public Request( Hadoop session, String scannerId, String tableName ) {
+      super( session );
+      this.scannerId = scannerId;
+      this.tableName = tableName;
+    }
+
+    protected Callable<Response> callable() {
+      return new Callable<Response>() {
+        @Override
+        public Response call() throws Exception {
+          URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/scanner/", scannerId );
+          HttpGet get = new HttpGet( uri.build() );
+          get.setHeader( "Accept", "application/json" );
+          return new Response( execute( get ) );
+        }
+      };
+    }
+  }
+
+  public static class Response extends BasicResponse {
+
+    Response( HttpResponse response ) {
+      super( response );
+    }
+  }
+}


Mime
View raw message