You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by km...@apache.org on 2013/09/16 19:04:34 UTC
git commit: KNOX-98: Minor fixes in sample including correcting port.
Updated Branches:
refs/heads/master e2bdee47e -> ae535b2ed
KNOX-98: Minor fixes in sample including correcting port.
Project: http://git-wip-us.apache.org/repos/asf/incubator-knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-knox/commit/ae535b2e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-knox/tree/ae535b2e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-knox/diff/ae535b2e
Branch: refs/heads/master
Commit: ae535b2eddc627d351b072dc8219647f8ce2afe1
Parents: e2bdee4
Author: Kevin Minder <ke...@hortonworks.com>
Authored: Mon Sep 16 13:04:28 2013 -0400
Committer: Kevin Minder <ke...@hortonworks.com>
Committed: Mon Sep 16 13:04:28 2013 -0400
----------------------------------------------------------------------
gateway-release/home/deployments/sample.xml | 2 +-
.../home/samples/ExampleHBaseUseCase.groovy | 173 +++++++++++++++++++
gateway-release/home/templates/sample.conf | 2 +-
gateway-release/home/templates/topology.xml | 74 --------
.../gateway/shell/hbase/ClusterVersion.java | 2 +-
.../hadoop/gateway/shell/hbase/HBase.java | 2 +-
6 files changed, 177 insertions(+), 78 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/ae535b2e/gateway-release/home/deployments/sample.xml
----------------------------------------------------------------------
diff --git a/gateway-release/home/deployments/sample.xml b/gateway-release/home/deployments/sample.xml
index d20464f..0bc585f 100644
--- a/gateway-release/home/deployments/sample.xml
+++ b/gateway-release/home/deployments/sample.xml
@@ -78,7 +78,7 @@
</service>
<service>
<role>STARGATE</role>
- <url>http://localhost:60000/</url>
+ <url>http://localhost:60080/</url>
</service>
<service>
<role>HIVE</role>
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/ae535b2e/gateway-release/home/samples/ExampleHBaseUseCase.groovy
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/ExampleHBaseUseCase.groovy b/gateway-release/home/samples/ExampleHBaseUseCase.groovy
new file mode 100644
index 0000000..e3856e8
--- /dev/null
+++ b/gateway-release/home/samples/ExampleHBaseUseCase.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 = "guest"
+password = "guest-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/ae535b2e/gateway-release/home/templates/sample.conf
----------------------------------------------------------------------
diff --git a/gateway-release/home/templates/sample.conf b/gateway-release/home/templates/sample.conf
index c4d1ed9..d12345d 100644
--- a/gateway-release/home/templates/sample.conf
+++ b/gateway-release/home/templates/sample.conf
@@ -70,7 +70,7 @@
</property>
<property>
<name>topology.service.STARGATE..url</name>
- <value>http://localhost:60000</value>
+ <value>http://localhost:60080</value>
</property>
<property>
<name>topology.service.HIVE..url</name>
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/ae535b2e/gateway-release/home/templates/topology.xml
----------------------------------------------------------------------
diff --git a/gateway-release/home/templates/topology.xml b/gateway-release/home/templates/topology.xml
deleted file mode 100644
index a15485e..0000000
--- a/gateway-release/home/templates/topology.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- 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.
--->
-<topology>
-
- <gateway>
- <provider>
- <role>authentication</role>
- <enabled>true</enabled>
- <name>ShiroProvider</name>
- <param>
- <name>main.ldapRealm</name>
- <value>org.apache.shiro.realm.ldap.JndiLdapRealm</value>
- </param>
- <param>
- <name>main.ldapRealm.userDnTemplate</name>
- <value>uid={0},ou=people,dc=hadoop,dc=apache,dc=org</value>
- </param>
- <param>
- <name>main.ldapRealm.contextFactory.url</name>
- <value>ldap://localhost:33389</value>
- </param>
- <param>
- <name>main.ldapRealm.contextFactory.authenticationMechanism</name>
- <value>simple</value>
- </param>
- <param>
- <name>urls./**</name>
- <value>authcBasic</value>
- </param>
- </provider>
- <provider>
- <role>identity-assertion</role>
- <enabled>true</enabled>
- <name>Pseudo</name>
- </provider>
- </gateway>
-
- <service>
- <role>WEBHDFS</role>
- <url>http://localhost:50070/webhdfs/v1</url>
- </service>
- <service>
- <role>TEMPLETON</role>
- <url>http://localhost:50111/templeton/v1</url>
- </service>
- <service>
- <role>OOZIE</role>
- <url>http://localhost:11000/oozie</url>
- </service>
- <service>
- <role>STARGATE</role>
- <url>http://localhost:60080</url>
- </service>
- <service>
- <role>HIVE</role>
- <url>http://localhost:10000</url>
- </service>
-
-</topology>
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/ae535b2e/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
index b059bd0..34d020c 100644
--- 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
@@ -39,7 +39,7 @@ public class ClusterVersion {
public Response call() throws Exception {
URIBuilder uri = uri( HBase.SERVICE_PATH, "/version/cluster" );
HttpGet get = new HttpGet( uri.build() );
- get.setHeader( "Accept", "application/json" );
+ get.setHeader( "Accept", "text/plain" );
return new Response( execute( get ) );
}
};
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/ae535b2e/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
index 184c799..a86d055 100644
--- 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
@@ -21,7 +21,7 @@ import org.apache.hadoop.gateway.shell.hbase.table.Table;
public class HBase {
- public static final String SERVICE_PATH = "/hbase/api";
+ public static final String SERVICE_PATH = "/hbase/api/v1";
private Hadoop session;