Index: conf/hive-default.xml
===================================================================
--- conf/hive-default.xml (revision 6993)
+++ conf/hive-default.xml (working copy)
@@ -528,6 +528,12 @@
+ hive.metastore.server.tcp.keepalive
+ true
+ Whether to enable TCP keepalive for the metastore server. Keepalive will prevent accumulation of half-open connections.
+
+
+
hive.optimize.reducededuplication
true
Remove extra map-reduce jobs if the data is already clustered by the same key which needs to be used again. This should always be set to true. Since it is a new feature, it has been made configurable.
Index: metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (revision 6993)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (working copy)
@@ -1678,8 +1678,11 @@
// pool to min.
int minWorkerThreads = conf.getIntVar(HiveConf.ConfVars.METASTORESERVERMINTHREADS);
int maxWorkerThreads = conf.getIntVar(HiveConf.ConfVars.METASTORESERVERMAXTHREADS);
+ boolean tcpKeepAlive = conf.getBoolVar(HiveConf.ConfVars.METASTORE_TCP_KEEP_ALIVE);
- TServerTransport serverTransport = new TServerSocket(port);
+ TServerTransport serverTransport = tcpKeepAlive ?
+ new TServerSocketKeepAlive(port) : new TServerSocket(port);
+
FacebookService.Processor processor = new ThriftHiveMetastore.Processor(
handler);
TThreadPoolServer.Options options = new TThreadPoolServer.Options();
@@ -1694,6 +1697,8 @@
+ options.minWorkerThreads);
HMSHandler.LOG.info("Options.maxWorkerThreads = "
+ options.maxWorkerThreads);
+ HMSHandler.LOG.info("TCP keepalive = " + tcpKeepAlive);
+
server.serve();
} catch (Throwable x) {
x.printStackTrace();
Index: metastore/src/java/org/apache/hadoop/hive/metastore/TServerSocketKeepAlive.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/TServerSocketKeepAlive.java (revision 0)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/TServerSocketKeepAlive.java (revision 0)
@@ -0,0 +1,47 @@
+/**
+ * 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.metastore;
+
+import java.net.SocketException;
+
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransportException;
+
+/**
+ * TServerSocketKeepAlive - like TServerSocket, but will enable keepalive for
+ * accepted sockets.
+ *
+ */
+public class TServerSocketKeepAlive extends TServerSocket {
+ public TServerSocketKeepAlive(int port) throws TTransportException {
+ super(port, 0);
+ }
+
+ @Override
+ protected TSocket acceptImpl() throws TTransportException {
+ TSocket ts = super.acceptImpl();
+ try {
+ ts.getSocket().setKeepAlive(true);
+ } catch (SocketException e) {
+ throw new TTransportException(e);
+ }
+ return ts;
+ }
+}
Index: common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
===================================================================
--- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (revision 6993)
+++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (working copy)
@@ -46,7 +46,9 @@
private static final Log l4j = LogFactory.getLog(HiveConf.class);
/**
- * Metastore related options that the db is initialized against.
+ * Metastore related options that the db is initialized against. When a conf
+ * var in this is list is changed, the metastore instance for the CLI will
+ * be recreated so that the change will take effect.
*/
public static final HiveConf.ConfVars[] metaVars = {
HiveConf.ConfVars.METASTOREDIRECTORY,
@@ -126,6 +128,7 @@
METASTOREFORCERELOADCONF("hive.metastore.force.reload.conf", false),
METASTORESERVERMINTHREADS("hive.metastore.server.min.threads", 200),
METASTORESERVERMAXTHREADS("hive.metastore.server.max.threads", Integer.MAX_VALUE),
+ METASTORE_TCP_KEEP_ALIVE("hive.metastore.server.tcp.keepalive", true),
// Intermediate dir suffixes used for archiving. Not important what they
// are, as long as collisions are avoided
METASTORE_INT_ORIGINAL("hive.metastore.archive.intermediate.original",