You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2012/03/16 15:57:48 UTC
svn commit: r1301568 - in /hive/trunk/service/src:
java/org/apache/hadoop/hive/service/HiveServer.java
test/org/apache/hadoop/hive/service/TestHiveServerSessions.java
Author: hashutosh
Date: Fri Mar 16 14:57:47 2012
New Revision: 1301568
URL: http://svn.apache.org/viewvc?rev=1301568&view=rev
Log:
HIVE-2503: HiveServer should provide per session configuration (navis via hashutosh)
Added:
hive/trunk/service/src/test/org/apache/hadoop/hive/service/TestHiveServerSessions.java
Modified:
hive/trunk/service/src/java/org/apache/hadoop/hive/service/HiveServer.java
Modified: hive/trunk/service/src/java/org/apache/hadoop/hive/service/HiveServer.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hadoop/hive/service/HiveServer.java?rev=1301568&r1=1301567&r2=1301568&view=diff
==============================================================================
--- hive/trunk/service/src/java/org/apache/hadoop/hive/service/HiveServer.java (original)
+++ hive/trunk/service/src/java/org/apache/hadoop/hive/service/HiveServer.java Fri Mar 16 14:57:47 2012
@@ -547,7 +547,7 @@ public class HiveServer extends ThriftHi
@Override
public TProcessor getProcessor(TTransport trans) {
try {
- Iface handler = new HiveServerHandler(conf);
+ Iface handler = new HiveServerHandler(new HiveConf(conf));
return new ThriftHive.Processor(handler);
} catch (Exception e) {
throw new RuntimeException(e);
Added: hive/trunk/service/src/test/org/apache/hadoop/hive/service/TestHiveServerSessions.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/test/org/apache/hadoop/hive/service/TestHiveServerSessions.java?rev=1301568&view=auto
==============================================================================
--- hive/trunk/service/src/test/org/apache/hadoop/hive/service/TestHiveServerSessions.java (added)
+++ hive/trunk/service/src/test/org/apache/hadoop/hive/service/TestHiveServerSessions.java Fri Mar 16 14:57:47 2012
@@ -0,0 +1,99 @@
+/**
+ * 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.hive.service;
+
+import junit.framework.TestCase;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.transport.TSocket;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+
+/**
+ * For testing HiveServer in server mode
+ *
+ */
+public class TestHiveServerSessions extends TestCase {
+
+ private static final int clientNum = 2;
+
+ private int port;
+ private Thread server;
+
+ private TSocket[] transports = new TSocket[clientNum];
+ private HiveClient[] clients = new HiveClient[clientNum];
+
+ public TestHiveServerSessions(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ port = findFreePort();
+ server = new Thread(new Runnable() {
+ public void run() {
+ HiveServer.main(new String[]{"-p", String.valueOf(port)});
+ }
+ });
+ server.start();
+ Thread.sleep(1000);
+
+ for (int i = 0; i < transports.length ; i++) {
+ TSocket transport = new TSocket("localhost", port);
+ transport.open();
+ transports[i] = transport;
+ clients[i] = new HiveClient(new TBinaryProtocol(transport));
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ for (TSocket socket : transports) {
+ if (socket != null) {
+ try {
+ socket.close();
+ } catch (Exception e) {
+ // ignroe
+ }
+ }
+ }
+ if (server != null) {
+ server.interrupt();
+ }
+ }
+
+ private int findFreePort() throws IOException {
+ ServerSocket socket= new ServerSocket(0);
+ int port = socket.getLocalPort();
+ socket.close();
+ return port;
+ }
+
+ public void testSessionVars() throws Exception {
+ for (int i = 0; i < clients.length; i++) {
+ clients[i].execute("set hiveconf:var=value" + i);
+ }
+
+ for (int i = 0; i < clients.length; i++) {
+ clients[i].execute("set hiveconf:var");
+ assertEquals("hiveconf:var=value" + i, clients[i].fetchOne());
+ }
+ }
+}