aboutsummaryrefslogtreecommitdiff
path: root/lib/hadoop-0.20.0/contrib/hdfsproxy/bin/hdfsproxy
blob: 1b1e597891aff2364d072cc92d865199cf353979 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/env bash

# 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.


# The HdfsProxy command script
#
# Environment Variables
#
#   JAVA_HOME        The java implementation to use.  Overrides JAVA_HOME.
#
#   HDFSPROXY_CLASSPATH Extra Java CLASSPATH entries.
#
#   HDFSPROXY_HEAPSIZE  The maximum amount of heap to use, in MB. 
#                    Default is 1000.
#
#   HDFSPROXY_OPTS      Extra Java runtime options.
#   
#   HDFSPROXY_NAMENODE_OPTS       These options are added to HDFSPROXY_OPTS 
#   HDFSPROXY_CLIENT_OPTS         when the respective command is run.
#   HDFSPROXY_{COMMAND}_OPTS etc  HDFSPROXY_JT_OPTS applies to JobTracker 
#                              for e.g.  HDFSPROXY_CLIENT_OPTS applies to 
#                              more than one command (fs, dfs, fsck, 
#                              dfsadmin etc)  
#
#   HDFSPROXY_CONF_DIR  Alternate conf dir. Default is ${HDFSPROXY_HOME}/conf.
#
#   HDFSPROXY_ROOT_LOGGER The root appender. Default is INFO,console
#

bin=`dirname "$0"`
bin=`cd "$bin"; pwd`

. "$bin"/hdfsproxy-config.sh

cygwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
esac

if [ -f "${HDFSPROXY_CONF_DIR}/hdfsproxy-env.sh" ]; then
  . "${HDFSPROXY_CONF_DIR}/hdfsproxy-env.sh"
fi

# some Java parameters
if [ "$JAVA_HOME" != "" ]; then
  #echo "run java in $JAVA_HOME"
  JAVA_HOME=$JAVA_HOME
fi
  
if [ "$JAVA_HOME" = "" ]; then
  echo "Error: JAVA_HOME is not set."
  exit 1
fi

JAVA=$JAVA_HOME/bin/java
JAVA_HEAP_MAX=-Xmx1000m 

# check envvars which might override default args
if [ "$HDFSPROXY_HEAPSIZE" != "" ]; then
  #echo "run with heapsize $HDFSPROXY_HEAPSIZE"
  JAVA_HEAP_MAX="-Xmx""$HDFSPROXY_HEAPSIZE""m"
  #echo $JAVA_HEAP_MAX
fi

# CLASSPATH initially contains $HDFSPROXY_CONF_DIR
CLASSPATH="${HDFSPROXY_CONF_DIR}"
CLASSPATH=${CLASSPATH}:$JAVA_HOME/lib/tools.jar

# for developers, add HdfsProxy classes to CLASSPATH
if [ -d "$HDFSPROXY_HOME/build/classes" ]; then
  CLASSPATH=${CLASSPATH}:$HDFSPROXY_HOME/build/classes
fi
if [ -d "$HDFSPROXY_HOME/build/webapps" ]; then
  CLASSPATH=${CLASSPATH}:$HDFSPROXY_HOME/build
fi
if [ -d "$HDFSPROXY_HOME/build/test/classes" ]; then
  CLASSPATH=${CLASSPATH}:$HDFSPROXY_HOME/build/test/classes
fi

# so that filenames w/ spaces are handled correctly in loops below
IFS=

# for releases, add hdfsproxy jar & webapps to CLASSPATH
if [ -d "$HDFSPROXY_HOME/webapps" ]; then
  CLASSPATH=${CLASSPATH}:$HDFSPROXY_HOME
fi
for f in $HDFSPROXY_HOME/hdfsproxy-*.jar; do
  CLASSPATH=${CLASSPATH}:$f;
done

# add libs to CLASSPATH
if [ -d "$HDFSPROXY_HOME/lib" ]; then
	for f in $HDFSPROXY_HOME/lib/*.jar; do
	  CLASSPATH=${CLASSPATH}:$f;
	done
fi

if [ -d "$HDFSPROXY_HOME/../../" ]; then
	for f in $HDFSPROXY_HOME/../../*.jar; do
    CLASSPATH=${CLASSPATH}:$f;
  done
fi
if [ -d "$HDFSPROXY_HOME/../../lib" ]; then
	for f in $HDFSPROXY_HOME/../../lib/*.jar; do
    CLASSPATH=${CLASSPATH}:$f;
  done
fi
if [ -d "$HDFSPROXY_HOME/../../lib/jsp-2.1" ]; then
	for f in $HDFSPROXY_HOME/../../lib/jsp-2.1/*.jar; do
    CLASSPATH=${CLASSPATH}:$f;
  done
fi


# add user-specified CLASSPATH last
if [ "$HDFSPROXY_CLASSPATH" != "" ]; then
  CLASSPATH=${CLASSPATH}:${HDFSPROXY_CLASSPATH}
fi

# default log directory & file
if [ "$HDFSPROXY_LOG_DIR" = "" ]; then
  HDFSPROXY_LOG_DIR="$HDFSPROXY_HOME/logs"
fi
if [ "$HDFSPROXY_LOGFILE" = "" ]; then
  HDFSPROXY_LOGFILE='hdfsproxy.log'
fi

# restore ordinary behaviour
unset IFS

# figure out which class to run
CLASS='org.apache.hadoop.hdfsproxy.HdfsProxy'

# cygwin path translation
if $cygwin; then
  CLASSPATH=`cygpath -p -w "$CLASSPATH"`
  HDFSPROXY_HOME=`cygpath -d "$HDFSPROXY_HOME"`
  HDFSPROXY_LOG_DIR=`cygpath -d "$HDFSPROXY_LOG_DIR"`
fi

# cygwin path translation
if $cygwin; then
  JAVA_LIBRARY_PATH=`cygpath -p "$JAVA_LIBRARY_PATH"`
fi

HDFSPROXY_OPTS="$HDFSPROXY_OPTS -Dhdfsproxy.log.dir=$HDFSPROXY_LOG_DIR"
HDFSPROXY_OPTS="$HDFSPROXY_OPTS -Dhdfsproxy.log.file=$HDFSPROXY_LOGFILE"
HDFSPROXY_OPTS="$HDFSPROXY_OPTS -Dhdfsproxy.home.dir=$HDFSPROXY_HOME"
HDFSPROXY_OPTS="$HDFSPROXY_OPTS -Dhdfsproxy.id.str=$HDFSPROXY_IDENT_STRING"
HDFSPROXY_OPTS="$HDFSPROXY_OPTS -Dhdfsproxy.root.logger=${HDFSPROXY_ROOT_LOGGER:-INFO,console}"
if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
  HDFSPROXY_OPTS="$HDFSPROXY_OPTS -Djava.library.path=$JAVA_LIBRARY_PATH"
fi  

# run it
exec "$JAVA" $JAVA_HEAP_MAX $HDFSPROXY_OPTS -classpath "$CLASSPATH" $CLASS "$@"