forked from facebookarchive/hadoop-20
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync github to internal FB hadoop code.
- Loading branch information
1 parent
41f4b6f
commit 9f1ea1b
Showing
1,065 changed files
with
115,982 additions
and
35,121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/bin/bash | ||
|
||
# Mount an HDFS uri into a local directory. Start up an instance of the proxy | ||
# if there isn't one already running. | ||
|
||
hdfs_uri=$1 | ||
local_dir=$2 | ||
|
||
START_PORT=34550 | ||
END_PORT=34700 | ||
|
||
# Needs to be root user to restart rpcidmapd. Will sudo as hadoop later | ||
if [ $UID -ne 0 ]; then | ||
echo "Error: must run as root user" | ||
exit 1 | ||
fi | ||
|
||
# Does hadoop user exist on system? | ||
if ! /usr/bin/getent passwd hadoop >/dev/null 2>/dev/null; then echo | ||
echo "Error: hadoop user does not exist on system." | ||
exit 1 | ||
fi | ||
|
||
# Find a free port to bind to between the start and end ports | ||
# Return 0 if nothing was free in that range | ||
find_free_port() { | ||
start=$1 | ||
end=$2 | ||
port=$start | ||
while true; do | ||
free=$(lsof -iTCP:$port | wc -l) | ||
if [ $free == "0" ]; then | ||
break | ||
fi | ||
port=$(( $port + 1)) | ||
if [ $port -gt $end ]; then | ||
port=0 | ||
break | ||
fi | ||
done | ||
echo $port | ||
} | ||
|
||
# Get a port of an existing NFS proxy. If there isn't one, return 0 | ||
get_existing_port() { | ||
running_pid=$(/usr/bin/pgrep -f org.apache.hadoop.hdfs.nfs.nfs4.NFS4Server) | ||
if [ $? != "0" ]; then | ||
echo "0" | ||
return | ||
fi | ||
|
||
if [ $(echo "${running_pid}" | wc -l) != "1" ]; then | ||
# More than one proxy. What's going on? | ||
exit 6 | ||
fi | ||
|
||
port=$(/bin/awk -F'\0' '{ print $(NF-1) }' /proc/$running_pid/cmdline) | ||
if ! echo "${port}" | /bin/egrep -q '^[0-9]+$'; then | ||
# Command line looks weird. What's going on? | ||
exit 7 | ||
fi | ||
|
||
echo ${port} | ||
} | ||
|
||
# Start up an instance of the proxy | ||
start_proxy() { | ||
# Pick a free port to run on | ||
free_port=$(find_free_port $START_PORT $END_PORT) | ||
if [ $free_port -eq 0 ]; then | ||
echo "Error: could not find a free port" | ||
exit 4 | ||
fi | ||
$(dirname ${BASH_SOURCE[0]})/start-nfs-server.sh $free_port >/dev/null 2>/dev/null | ||
sleep 5 | ||
echo $free_port | ||
} | ||
|
||
if [ $# -ne 2 ]; then | ||
echo "Usage: $0 <hdfs uri> <directory>" | ||
echo | ||
echo " Mounts the HDFS location into the local directory" | ||
echo | ||
exit 1 | ||
fi | ||
|
||
if ! echo $1 | /bin/egrep -q "^hdfs://[^:/]+:[0-9]+/.+$"; then | ||
echo "Error: HDFS URI '$hdfs_uri' is not valid" | ||
exit 2 | ||
fi | ||
|
||
short_uri=$(echo "${hdfs_uri}" | sed -e 's/^hdfs:\/\/*//' -e 's/^\([^:]*\):\([0-9]*\)/\1.\2/') | ||
|
||
if [ ! -d "${local_dir}" ]; then | ||
echo "Error: Directory '${local_dir}' does not exist" | ||
exit 3 | ||
fi | ||
|
||
existing_port=$(get_existing_port) | ||
|
||
if [ $existing_port == "0" ]; then | ||
existing_port=$(start_proxy) | ||
fi | ||
|
||
/bin/mount -t nfs4 "localhost:/${short_uri}" "${local_dir}" -o rw,intr,port=${existing_port} | ||
|
||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/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. | ||
|
||
usage="Usage: start-journalnode.sh" | ||
|
||
params=$# | ||
bin=`dirname "$0"` | ||
bin=`cd "$bin"; pwd` | ||
|
||
. "$bin"/hadoop-config.sh | ||
. "$bin"/../conf/hadoop-env.sh | ||
|
||
# get arguments | ||
if [ $# -ge 1 ]; then | ||
echo $usage | ||
fi | ||
|
||
"$bin"/hadoop-daemon.sh --config $HADOOP_CONF_DIR start journalnode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.