hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1296664 - in /hbase/branches/0.94: bin/hbase src/main/java/org/apache/hadoop/hbase/util/GetJavaProperty.java
Date Sat, 03 Mar 2012 16:47:56 GMT
Author: stack
Date: Sat Mar  3 16:47:55 2012
New Revision: 1296664

URL: http://svn.apache.org/viewvc?rev=1296664&view=rev
Log:
HBASE-5286 bin/hbase's logic of adding Hadoop jar files to the classpath is fragile when presented
with split packaged Hadoop 0.23 installation

Added:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/GetJavaProperty.java
Modified:
    hbase/branches/0.94/bin/hbase

Modified: hbase/branches/0.94/bin/hbase
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/bin/hbase?rev=1296664&r1=1296663&r2=1296664&view=diff
==============================================================================
--- hbase/branches/0.94/bin/hbase (original)
+++ hbase/branches/0.94/bin/hbase Sat Mar  3 16:47:55 2012
@@ -217,31 +217,14 @@ function append_path() {
 JAVA_PLATFORM=""
 
 #If avail, add Hadoop to the CLASSPATH and to the JAVA_LIBRARY_PATH
-if [ ! -z $HADOOP_HOME ]; then
-  HADOOPCPPATH=""
-  if [ -z $HADOOP_CONF_DIR ]; then
-    HADOOPCPPATH=$(append_path "${HADOOPCPPATH}" "${HADOOP_HOME}/conf")
-  else
-    HADOOPCPPATH=$(append_path "${HADOOPCPPATH}" "${HADOOP_CONF_DIR}")
-  fi
-  if [ "`echo ${HADOOP_HOME}/hadoop-core*.jar`" != "${HADOOP_HOME}/hadoop-core*.jar" ] ;
then
-    HADOOPCPPATH=$(append_path "${HADOOPCPPATH}" `ls ${HADOOP_HOME}/hadoop-core*.jar | head
-1`)
-  else
-    HADOOPCPPATH=$(append_path "${HADOOPCPPATH}" `ls ${HADOOP_HOME}/hadoop-common*.jar |
head -1`)
-    HADOOPCPPATH=$(append_path "${HADOOPCPPATH}" `ls ${HADOOP_HOME}/hadoop-hdfs*.jar | head
-1`)
-    HADOOPCPPATH=$(append_path "${HADOOPCPPATH}" `ls ${HADOOP_HOME}/hadoop-mapred*.jar |
head -1`)
-  fi
-  for i in "${HADOOP_HOME}/lib/"*.jar; do
-    HADOOPCPPATH="${HADOOPCPPATH}:$i"
-  done
-  CLASSPATH=$(append_path "${CLASSPATH}" "${HADOOPCPPATH}")
-  
-  if [ -d "${HADOOP_HOME}/lib/native" ]; then
-    JAVA_PLATFORM=`CLASSPATH=${HADOOPCPPATH} ${JAVA} org.apache.hadoop.util.PlatformName
| sed -e "s/ /_/g"`
-    if [ -d "${HADOOP_HOME}/lib/native/${JAVA_PLATFORM}" ]; then
-      JAVA_LIBRARY_PATH=$(append_path "${JAVA_LIBRARY_PATH}" "${HADOOP_HOME}/lib/native/${JAVA_PLATFORM}")
-    fi
+HADOOP_IN_PATH=$(PATH="${HADOOP_HOME:-${HADOOP_PREFIX}}/bin:$PATH" which hadoop 2>/dev/null)
+if [ -f ${HADOOP_IN_PATH} ]; then
+  HADOOP_JAVA_LIBRARY_PATH=$(HADOOP_CLASSPATH="$CLASSPATH" ${HADOOP_IN_PATH} \
+                             org.apache.hadoop.hbase.util.GetJavaProperty java.library.path
2>/dev/null)
+  if [ -n "$HADOOP_JAVA_LIBRARY_PATH" ]; then
+    JAVA_LIBRARY_PATH=$(append_path "${JAVA_LIBRARY_PATH}" "$HADOOP_JAVA_LIBRARY_PATH")
   fi
+  CLASSPATH=$(append_path "${CLASSPATH}" `${HADOOP_IN_PATH} classpath 2>/dev/null`)
 fi
 
 if [ -d "${HBASE_HOME}/build/native" -o -d "${HBASE_HOME}/lib/native" ]; then

Added: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/GetJavaProperty.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/GetJavaProperty.java?rev=1296664&view=auto
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/GetJavaProperty.java (added)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/GetJavaProperty.java Sat
Mar  3 16:47:55 2012
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2012 The Apache Software Foundation
+ *
+ * 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.hbase.util;
+
+/**
+ * A generic way for querying Java properties.
+ */
+public class GetJavaProperty {
+  public static void main(String args[]) {
+    if (args.length == 0) {
+      for (Object prop: System.getProperties().keySet()) {
+        System.out.println(prop + "=" + System.getProperty((String)prop, ""));
+      }
+    } else {
+      for (String prop: args) {
+        System.out.println(System.getProperty(prop, ""));
+      }
+    }
+  }
+}



Mime
View raw message