#!/bin/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. # resolve links - $0 may be a softlink THIS="$0" while [ -h "$THIS" ]; do ls=`ls -ld "$THIS"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '.*/.*' > /dev/null; then THIS="$link" else THIS=`dirname "$THIS"`/"$link" fi done # some directories THIS_DIR=`dirname "$THIS"` GIRAPH_HOME=`cd "$THIS_DIR/.." ; pwd` # extra properites to send straight to Hadoop HADOOP_PROPERTIES= while [ $1 ] && [ ${1:0:2} == "-D" ] ; do HADOOP_PROPERTIES="$1 $HADOOP_PROPERTIES" shift done USER_JAR=$1 shift if [ ! -e "$USER_JAR" ]; then echo "Can't find user jar to execute." exit 1 fi # add user jar to classpath CLASSPATH=${USER_JAR} # so that filenames w/ spaces are handled correctly in loops below IFS= # add release dependencies to CLASSPATH for f in $GIRAPH_HOME/lib/*.jar; do CLASSPATH=${CLASSPATH}:$f; done CLASS=org.apache.giraph.GiraphRunner for f in $GIRAPH_HOME/lib/giraph*.jar ; do if [ -e "$f" ]; then JAR=$f fi done # restore ordinary behaviour unset IFS if [ "$JAR" = "" ] ; then echo "Can't find Giraph jar." exit 1 fi if [ "$HADOOP_CONF_DIR" = "" ] ; then HADOOP_CONF_DIR=$HADOOP_HOME/conf echo "No HADOOP_CONF_DIR set, using $HADOOP_HOME/conf " else echo "HADOOP_CONF_DIR=$HADOOP_CONF_DIR" fi # Giraph's jars to add to distributed cache via -libjar, which are csv rather than :sv GIRAPH_JARS=`echo ${JAR}:${CLASSPATH}|sed s/:/,/g` export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$CLASSPATH exec "$HADOOP_HOME/bin/hadoop" --config $HADOOP_CONF_DIR jar $JAR $CLASS $HADOOP_PROPERTIES -libjars $GIRAPH_JARS "$@"