Index: metastore/src/java/org/apache/hadoop/hive/metastore/MXBean.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/MXBean.java (revision 0)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/MXBean.java (revision 0)
@@ -0,0 +1,18 @@
+package org.apache.hadoop.hive.metastore;
+
+public interface MXBean {
+ /**
+ * @return hostname of the metastore server
+ */
+ String getHostname();
+
+ /**
+ * @return version of the code base
+ */
+ String getVersion();
+
+ /**
+ * @return number of threads of the metastore jvm
+ */
+ int getMaxWorkerThreads();
+}
Index: metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (revision 1309492)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (working copy)
@@ -24,6 +24,7 @@
import static org.apache.hadoop.hive.metastore.MetaStoreUtils.validateName;
import java.io.IOException;
+import java.net.InetAddress;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
@@ -114,6 +115,7 @@
import org.apache.hadoop.hive.shims.ShimLoader;
import org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge;
import org.apache.hadoop.hive.thrift.TUGIContainingTransport;
+import org.apache.hadoop.metrics.util.MBeanUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.ReflectionUtils;
import org.apache.hadoop.util.StringUtils;
@@ -144,6 +146,9 @@
private static HadoopThriftAuthBridge.Server saslServer;
private static boolean useSasl;
+ private static String hostname;
+ private static int maxWorkerThreads;
+
public static class HMSHandler extends FacebookBase implements
ThriftHiveMetastore.Iface {
public static final Log LOG = HiveMetaStore.LOG;
@@ -2987,10 +2992,15 @@
// period, it will destory threads to keep the number of threads in the
// pool to min.
int minWorkerThreads = conf.getIntVar(HiveConf.ConfVars.METASTORESERVERMINTHREADS);
- int maxWorkerThreads = conf.getIntVar(HiveConf.ConfVars.METASTORESERVERMAXTHREADS);
+ maxWorkerThreads = conf.getIntVar(HiveConf.ConfVars.METASTORESERVERMAXTHREADS);
boolean tcpKeepAlive = conf.getBoolVar(HiveConf.ConfVars.METASTORE_TCP_KEEP_ALIVE);
useSasl = conf.getBoolVar(HiveConf.ConfVars.METASTORE_USE_THRIFT_SASL);
+ InetAddress addr = InetAddress.getLocalHost();
+ hostname = addr.getCanonicalHostName();
+ MXBean mxBeanInfo = MXBeanImpl.init();
+ MBeanUtil.registerMBean("MetaStore", "MetaStore", mxBeanInfo);
+
TServerTransport serverTransport = tcpKeepAlive ?
new TServerSocketKeepAlive(port) : new TServerSocket(port);
@@ -3043,4 +3053,11 @@
throw x;
}
}
+
+ public static String getStoreHostname() {
+ return hostname;
+ }
+ public static int getMaxWorkerThreads() {
+ return maxWorkerThreads;
+ }
}
Index: metastore/src/java/org/apache/hadoop/hive/metastore/MXBeanImpl.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/MXBeanImpl.java (revision 0)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/MXBeanImpl.java (revision 0)
@@ -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.hive.metastore;
+
+import org.apache.hadoop.hive.common.VersionInfo;
+import org.apache.hadoop.util.StringUtils;
+
+public class MXBeanImpl implements MXBean {
+ private static MXBeanImpl instance = null;
+
+ @Override
+ public String getHostname() {
+ return StringUtils.simpleHostname(HiveMetaStore.getStoreHostname());
+ }
+
+ @Override
+ public String getVersion() {
+ return VersionInfo.getVersion() +", r"+ VersionInfo.getRevision();
+ }
+
+ @Override
+ public int getMaxWorkerThreads() {
+ return HiveMetaStore.getMaxWorkerThreads();
+ }
+
+ public synchronized static MXBeanImpl init() {
+ if (instance == null) {
+ instance = new MXBeanImpl();
+ }
+ return instance;
+ }
+
+}
Index: common/src/java/org/apache/hadoop/hive/common/VersionInfo.java
===================================================================
--- common/src/java/org/apache/hadoop/hive/common/VersionInfo.java (revision 0)
+++ common/src/java/org/apache/hadoop/hive/common/VersionInfo.java (revision 0)
@@ -0,0 +1,107 @@
+/*
+ * 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.common;
+
+/**
+ * This class finds the package info for Hive and the HiveVersionAnnotation
+ * information.
+ */
+public class VersionInfo {
+ private static Package myPackage;
+ private static HiveVersionAnnotation version;
+
+ static {
+ myPackage = HiveVersionAnnotation.class.getPackage();
+ version = myPackage.getAnnotation(HiveVersionAnnotation.class);
+ }
+
+ /**
+ * Get the meta-data for the hive package.
+ * @return
+ */
+ static Package getPackage() {
+ return myPackage;
+ }
+
+ /**
+ * Get the hive version.
+ * @return the hive version string, eg. "0.6.3-dev"
+ */
+ public static String getVersion() {
+ return version != null ? version.version() : "Unknown";
+ }
+
+ /**
+ * Get the subversion revision number for the root directory
+ * @return the revision number, eg. "451451"
+ */
+ public static String getRevision() {
+ return version != null ? version.revision() : "Unknown";
+ }
+
+ /**
+ * The date that hive was compiled.
+ * @return the compilation date in unix date format
+ */
+ public static String getDate() {
+ return version != null ? version.date() : "Unknown";
+ }
+
+ /**
+ * The user that compiled hive.
+ * @return the username of the user
+ */
+ public static String getUser() {
+ return version != null ? version.user() : "Unknown";
+ }
+
+ /**
+ * Get the subversion URL for the root hive directory.
+ */
+ public static String getUrl() {
+ return version != null ? version.url() : "Unknown";
+ }
+
+ /**
+ * Get the checksum of the source files from which hive was
+ * built.
+ **/
+ public static String getSrcChecksum() {
+ return version != null ? version.srcChecksum() : "Unknown";
+ }
+
+ /**
+ * Returns the buildVersion which includes version,
+ * revision, user and date.
+ */
+ public static String getBuildVersion(){
+ return VersionInfo.getVersion() +
+ " from " + VersionInfo.getRevision() +
+ " by " + VersionInfo.getUser() +
+ " source checksum " + VersionInfo.getSrcChecksum();
+ }
+
+ public static void main(String[] args) {
+ System.out.println("Hive " + getVersion());
+ System.out.println("Subversion " + getUrl() + " -r " + getRevision());
+ System.out.println("Compiled by " + getUser() + " on " + getDate());
+ System.out.println("From source with checksum " + getSrcChecksum());
+
+ }
+}
Index: common/src/java/org/apache/hadoop/hive/common/HiveVersionAnnotation.java
===================================================================
--- common/src/java/org/apache/hadoop/hive/common/HiveVersionAnnotation.java (revision 0)
+++ common/src/java/org/apache/hadoop/hive/common/HiveVersionAnnotation.java (revision 0)
@@ -0,0 +1,66 @@
+/*
+ * 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.common;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A package attribute that captures the version of Hadoop that was compiled.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PACKAGE)
+public @interface HiveVersionAnnotation {
+
+ /**
+ * Get the Hadoop version
+ * @return the version string "0.6.3-dev"
+ */
+ String version();
+
+ /**
+ * Get the username that compiled Hadoop.
+ */
+ String user();
+
+ /**
+ * Get the date when Hadoop was compiled.
+ * @return the date in unix 'date' format
+ */
+ String date();
+
+ /**
+ * Get the url for the subversion repository.
+ */
+ String url();
+
+ /**
+ * Get the subversion revision.
+ * @return the revision number as a string (eg. "451451")
+ */
+ String revision();
+
+ /**
+ * Get a checksum of the source files from which
+ * Hadoop was compiled.
+ * @return a string that uniquely identifies the source
+ **/
+ String srcChecksum();
+}
Index: common/saveVersion.sh
===================================================================
--- common/saveVersion.sh (revision 0)
+++ common/saveVersion.sh (revision 0)
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# 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.
+
+
+# This file is used to generate the BuildStamp.java class that
+# records the user, url, revision and timestamp.
+unset LANG
+unset LC_CTYPE
+version=$1
+build_dir=$2
+user=`whoami`
+date=`date`
+if [ -d .git ]; then
+ revision=`git log -1 --pretty=format:"%H"`
+ hostname=`hostname`
+ branch=`git branch | sed -n -e 's/^* //p'`
+ url="git://$hostname/$cwd on branch $branch"
+else
+ revision=`svn info | sed -n -e 's/Last Changed Rev: \(.*\)/\1/p'`
+ url=`svn info | sed -n -e 's/URL: \(.*\)/\1/p'`
+fi
+srcChecksum=`find src/java -name '*.java' | LC_ALL=C sort | xargs md5sum | md5sum | cut -d ' ' -f 1`
+
+mkdir -p $build_dir/src/java/org/apache/hadoop/hive/common/
+cat << EOF | \
+ sed -e "s/VERSION/$version/" -e "s/USER/$user/" -e "s/DATE/$date/" \
+ -e "s|URL|$url|" -e "s/REV/$revision/" -e "s/SRCCHECKSUM/$srcChecksum/" \
+ > $build_dir/src/java/org/apache/hadoop/hive/common/package-info.java
+/*
+ * Generated by saveVersion.sh
+ */
+@HiveVersionAnnotation(version="VERSION", revision="REV",
+ user="USER", date="DATE", url="URL",
+ srcChecksum="SRCCHECKSUM")
+package org.apache.hadoop.hive.common;
+EOF
Index: common/build.xml
===================================================================
--- common/build.xml (revision 1309492)
+++ common/build.xml (working copy)
@@ -27,11 +27,17 @@
-
+
+
+
+
+
+
+