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/24 16:30:52 UTC
[4/4] git commit: KNOX-99: Create samples for Hive.
KNOX-99: Create samples for Hive.
Project: http://git-wip-us.apache.org/repos/asf/incubator-knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-knox/commit/c44e0102
Tree: http://git-wip-us.apache.org/repos/asf/incubator-knox/tree/c44e0102
Diff: http://git-wip-us.apache.org/repos/asf/incubator-knox/diff/c44e0102
Branch: refs/heads/master
Commit: c44e01027f393d11f6e843c2b30169f2f43a0a9e
Parents: 0f51ced
Author: Kevin Minder <ke...@hortonworks.com>
Authored: Tue Sep 24 10:30:44 2013 -0400
Committer: Kevin Minder <ke...@hortonworks.com>
Committed: Tue Sep 24 10:30:44 2013 -0400
----------------------------------------------------------------------
.../home/samples/HiveJDBCSample.java | 93 --
.../HiveJDBCSample.groovy | 52 +
.../groovy/jdbc/sandbox-with-knox-inside/README | 2 +
.../groovy/jdbc/sandbox/HiveJDBCSample.groovy | 52 +
.../samples/hive/groovy/jdbc/sandbox/README | 1 +
.../HiveJDBCSample.java | 93 ++
.../java/jdbc/sandbox-with-knox-inside/README | 2 +
.../hive/java/jdbc/sandbox/HiveJDBCSample.java | 93 ++
.../home/samples/hive/java/jdbc/sandbox/README | 1 +
gateway-release/home/samples/hive/sample.log | 1387 +++++++++++++++++
gateway-release/home/samples/sample.log | 1402 ------------------
.../home/samples/sandbox-with-knox-inside.xml | 88 ++
12 files changed, 1771 insertions(+), 1495 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/c44e0102/gateway-release/home/samples/HiveJDBCSample.java
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/HiveJDBCSample.java b/gateway-release/home/samples/HiveJDBCSample.java
deleted file mode 100644
index fd5a97a..0000000
--- a/gateway-release/home/samples/HiveJDBCSample.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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.
- */
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-public class HiveJDBCSample {
-
- public static void main( String[] args ) {
- Connection connection = null;
- Statement statement = null;
- ResultSet resultSet = null;
-
- try {
- String user = "guest";
- String password = user + "-password";
- String gatewayHost = "localhost";
- int gatewayPort = 8443;
- String contextPath = "gateway/sandbox/hive/api/v1";
- String connectionString = String.format( "jdbc:hive2://%s:%d/?hive.server2.servermode=https;hive.server2.http.path=%s", gatewayHost, gatewayPort, contextPath );
-
- // Load Hive JDBC Driver
- Class.forName( "org.apache.hive.jdbc.HiveDriver" );
-
- // Configure JDBC connection
- connection = DriverManager.getConnection( connectionString, user, password );
-
- statement = connection.createStatement();
-
- // Disable Hive authorization - This can be ommited if Hive authorization is configured properly
- statement.execute( "set hive.security.authorization.enabled=false" );
-
- // Create sample table
- statement.execute( "CREATE TABLE logs(column1 string, column2 string, column3 string, column4 string, column5 string, column6 string, column7 string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ' '" );
-
- // Load data into Hive from file /tmp/log.txt which is placed on the local file system
- statement.execute( "LOAD DATA LOCAL INPATH '/tmp/sample.log' OVERWRITE INTO TABLE logs" );
-
- resultSet = statement.executeQuery( "SELECT * FROM logs" );
-
- while ( resultSet.next() ) {
- System.out.println( resultSet.getString( 1 ) + " --- " + resultSet.getString( 2 ) );
- }
- } catch ( ClassNotFoundException ex ) {
- Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
- } catch ( SQLException ex ) {
- Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
- } finally {
- if ( resultSet != null ) {
- try {
- resultSet.close();
- } catch ( SQLException ex ) {
- Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
- }
- }
- if ( statement != null ) {
- try {
- statement.close();
- } catch ( SQLException ex ) {
- Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
- }
- }
- if ( connection != null ) {
- try {
- connection.close();
- } catch ( SQLException ex ) {
- Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/c44e0102/gateway-release/home/samples/hive/groovy/jdbc/sandbox-with-knox-inside/HiveJDBCSample.groovy
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/hive/groovy/jdbc/sandbox-with-knox-inside/HiveJDBCSample.groovy b/gateway-release/home/samples/hive/groovy/jdbc/sandbox-with-knox-inside/HiveJDBCSample.groovy
new file mode 100644
index 0000000..24e7daa
--- /dev/null
+++ b/gateway-release/home/samples/hive/groovy/jdbc/sandbox-with-knox-inside/HiveJDBCSample.groovy
@@ -0,0 +1,52 @@
+/**
+ * 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.
+ */
+import java.sql.DriverManager
+
+user = "guest";
+password = user + "-password";
+gatewayHost = "localhost";
+gatewayPort = 8443;
+contextPath = "gateway/sandbox-with-knox-inside/hive/api/v1";
+connectionString = String.format( "jdbc:hive2://%s:%d/?hive.server2.servermode=https;hive.server2.http.path=%s", gatewayHost, gatewayPort, contextPath );
+
+// Load Hive JDBC Driver
+Class.forName( "org.apache.hive.jdbc.HiveDriver" );
+
+// Configure JDBC connection
+connection = DriverManager.getConnection( connectionString, user, password );
+
+statement = connection.createStatement();
+
+// Disable Hive authorization - This can be ommited if Hive authorization is configured properly
+statement.execute( "set hive.security.authorization.enabled=false" );
+
+// Create sample table
+statement.execute( "CREATE TABLE logs(column1 string, column2 string, column3 string, column4 string, column5 string, column6 string, column7 string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ' '" );
+
+// Load data into Hive from file /tmp/log.txt which is placed on the local file system
+statement.execute( "LOAD DATA LOCAL INPATH '/tmp/sample.log' OVERWRITE INTO TABLE logs" );
+
+resultSet = statement.executeQuery( "SELECT * FROM logs" );
+
+while ( resultSet.next() ) {
+ System.out.println( resultSet.getString( 1 ) + " --- " + resultSet.getString( 2 ) );
+}
+
+resultSet.close();
+statement.close();
+connection.close();
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/c44e0102/gateway-release/home/samples/hive/groovy/jdbc/sandbox-with-knox-inside/README
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/hive/groovy/jdbc/sandbox-with-knox-inside/README b/gateway-release/home/samples/hive/groovy/jdbc/sandbox-with-knox-inside/README
new file mode 100644
index 0000000..8ff61e4
--- /dev/null
+++ b/gateway-release/home/samples/hive/groovy/jdbc/sandbox-with-knox-inside/README
@@ -0,0 +1,2 @@
+This sample assumes that Knox is deployed on Sandbox.
+Use sandbox-with-knox-inside.xml as deployment configuration.
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/c44e0102/gateway-release/home/samples/hive/groovy/jdbc/sandbox/HiveJDBCSample.groovy
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/hive/groovy/jdbc/sandbox/HiveJDBCSample.groovy b/gateway-release/home/samples/hive/groovy/jdbc/sandbox/HiveJDBCSample.groovy
new file mode 100644
index 0000000..cf8b5ce
--- /dev/null
+++ b/gateway-release/home/samples/hive/groovy/jdbc/sandbox/HiveJDBCSample.groovy
@@ -0,0 +1,52 @@
+/**
+ * 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.
+ */
+import java.sql.DriverManager
+
+user = "guest";
+password = user + "-password";
+gatewayHost = "localhost";
+gatewayPort = 8443;
+contextPath = "gateway/sandbox/hive/api/v1";
+connectionString = String.format( "jdbc:hive2://%s:%d/?hive.server2.servermode=https;hive.server2.http.path=%s", gatewayHost, gatewayPort, contextPath );
+
+// Load Hive JDBC Driver
+Class.forName( "org.apache.hive.jdbc.HiveDriver" );
+
+// Configure JDBC connection
+connection = DriverManager.getConnection( connectionString, user, password );
+
+statement = connection.createStatement();
+
+// Disable Hive authorization - This can be ommited if Hive authorization is configured properly
+statement.execute( "set hive.security.authorization.enabled=false" );
+
+// Create sample table
+statement.execute( "CREATE TABLE logs(column1 string, column2 string, column3 string, column4 string, column5 string, column6 string, column7 string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ' '" );
+
+// Load data into Hive from file /tmp/log.txt which is placed on the local file system
+statement.execute( "LOAD DATA LOCAL INPATH '/tmp/sample.log' OVERWRITE INTO TABLE logs" );
+
+resultSet = statement.executeQuery( "SELECT * FROM logs" );
+
+while ( resultSet.next() ) {
+ System.out.println( resultSet.getString( 1 ) + " --- " + resultSet.getString( 2 ) );
+}
+
+resultSet.close();
+statement.close();
+connection.close();
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/c44e0102/gateway-release/home/samples/hive/groovy/jdbc/sandbox/README
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/hive/groovy/jdbc/sandbox/README b/gateway-release/home/samples/hive/groovy/jdbc/sandbox/README
new file mode 100644
index 0000000..f31ab55
--- /dev/null
+++ b/gateway-release/home/samples/hive/groovy/jdbc/sandbox/README
@@ -0,0 +1 @@
+This sample assumes that Sandbox is running on the host where Knox is deployed.
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/c44e0102/gateway-release/home/samples/hive/java/jdbc/sandbox-with-knox-inside/HiveJDBCSample.java
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/hive/java/jdbc/sandbox-with-knox-inside/HiveJDBCSample.java b/gateway-release/home/samples/hive/java/jdbc/sandbox-with-knox-inside/HiveJDBCSample.java
new file mode 100644
index 0000000..3d6154a
--- /dev/null
+++ b/gateway-release/home/samples/hive/java/jdbc/sandbox-with-knox-inside/HiveJDBCSample.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.
+ */
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class HiveJDBCSample {
+
+ public static void main( String[] args ) {
+ Connection connection = null;
+ Statement statement = null;
+ ResultSet resultSet = null;
+
+ try {
+ String user = "guest";
+ String password = user + "-password";
+ String gatewayHost = "localhost";
+ int gatewayPort = 8443;
+ String contextPath = "gateway/sandbox-with-knox-inside/hive/api/v1";
+ String connectionString = String.format( "jdbc:hive2://%s:%d/?hive.server2.servermode=https;hive.server2.http.path=%s", gatewayHost, gatewayPort, contextPath );
+
+ // Load Hive JDBC Driver
+ Class.forName( "org.apache.hive.jdbc.HiveDriver" );
+
+ // Configure JDBC connection
+ connection = DriverManager.getConnection( connectionString, user, password );
+
+ statement = connection.createStatement();
+
+ // Disable Hive authorization - This can be ommited if Hive authorization is configured properly
+ statement.execute( "set hive.security.authorization.enabled=false" );
+
+ // Create sample table
+ statement.execute( "CREATE TABLE logs(column1 string, column2 string, column3 string, column4 string, column5 string, column6 string, column7 string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ' '" );
+
+ // Load data into Hive from file /tmp/log.txt which is placed on the local file system
+ statement.execute( "LOAD DATA LOCAL INPATH '/tmp/sample.log' OVERWRITE INTO TABLE logs" );
+
+ resultSet = statement.executeQuery( "SELECT * FROM logs" );
+
+ while ( resultSet.next() ) {
+ System.out.println( resultSet.getString( 1 ) + " --- " + resultSet.getString( 2 ) );
+ }
+ } catch ( ClassNotFoundException ex ) {
+ Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
+ } catch ( SQLException ex ) {
+ Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
+ } finally {
+ if ( resultSet != null ) {
+ try {
+ resultSet.close();
+ } catch ( SQLException ex ) {
+ Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ }
+ if ( statement != null ) {
+ try {
+ statement.close();
+ } catch ( SQLException ex ) {
+ Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ }
+ if ( connection != null ) {
+ try {
+ connection.close();
+ } catch ( SQLException ex ) {
+ Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/c44e0102/gateway-release/home/samples/hive/java/jdbc/sandbox-with-knox-inside/README
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/hive/java/jdbc/sandbox-with-knox-inside/README b/gateway-release/home/samples/hive/java/jdbc/sandbox-with-knox-inside/README
new file mode 100644
index 0000000..8ff61e4
--- /dev/null
+++ b/gateway-release/home/samples/hive/java/jdbc/sandbox-with-knox-inside/README
@@ -0,0 +1,2 @@
+This sample assumes that Knox is deployed on Sandbox.
+Use sandbox-with-knox-inside.xml as deployment configuration.
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/c44e0102/gateway-release/home/samples/hive/java/jdbc/sandbox/HiveJDBCSample.java
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/hive/java/jdbc/sandbox/HiveJDBCSample.java b/gateway-release/home/samples/hive/java/jdbc/sandbox/HiveJDBCSample.java
new file mode 100644
index 0000000..fd5a97a
--- /dev/null
+++ b/gateway-release/home/samples/hive/java/jdbc/sandbox/HiveJDBCSample.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.
+ */
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class HiveJDBCSample {
+
+ public static void main( String[] args ) {
+ Connection connection = null;
+ Statement statement = null;
+ ResultSet resultSet = null;
+
+ try {
+ String user = "guest";
+ String password = user + "-password";
+ String gatewayHost = "localhost";
+ int gatewayPort = 8443;
+ String contextPath = "gateway/sandbox/hive/api/v1";
+ String connectionString = String.format( "jdbc:hive2://%s:%d/?hive.server2.servermode=https;hive.server2.http.path=%s", gatewayHost, gatewayPort, contextPath );
+
+ // Load Hive JDBC Driver
+ Class.forName( "org.apache.hive.jdbc.HiveDriver" );
+
+ // Configure JDBC connection
+ connection = DriverManager.getConnection( connectionString, user, password );
+
+ statement = connection.createStatement();
+
+ // Disable Hive authorization - This can be ommited if Hive authorization is configured properly
+ statement.execute( "set hive.security.authorization.enabled=false" );
+
+ // Create sample table
+ statement.execute( "CREATE TABLE logs(column1 string, column2 string, column3 string, column4 string, column5 string, column6 string, column7 string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ' '" );
+
+ // Load data into Hive from file /tmp/log.txt which is placed on the local file system
+ statement.execute( "LOAD DATA LOCAL INPATH '/tmp/sample.log' OVERWRITE INTO TABLE logs" );
+
+ resultSet = statement.executeQuery( "SELECT * FROM logs" );
+
+ while ( resultSet.next() ) {
+ System.out.println( resultSet.getString( 1 ) + " --- " + resultSet.getString( 2 ) );
+ }
+ } catch ( ClassNotFoundException ex ) {
+ Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
+ } catch ( SQLException ex ) {
+ Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
+ } finally {
+ if ( resultSet != null ) {
+ try {
+ resultSet.close();
+ } catch ( SQLException ex ) {
+ Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ }
+ if ( statement != null ) {
+ try {
+ statement.close();
+ } catch ( SQLException ex ) {
+ Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ }
+ if ( connection != null ) {
+ try {
+ connection.close();
+ } catch ( SQLException ex ) {
+ Logger.getLogger( HiveJDBCSample.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/c44e0102/gateway-release/home/samples/hive/java/jdbc/sandbox/README
----------------------------------------------------------------------
diff --git a/gateway-release/home/samples/hive/java/jdbc/sandbox/README b/gateway-release/home/samples/hive/java/jdbc/sandbox/README
new file mode 100644
index 0000000..f31ab55
--- /dev/null
+++ b/gateway-release/home/samples/hive/java/jdbc/sandbox/README
@@ -0,0 +1 @@
+This sample assumes that Sandbox is running on the host where Knox is deployed.