forked from philemonf/transactional-key-value-store-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·78 lines (65 loc) · 2.33 KB
/
start.sh
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
#!/bin/sh
RED='\033[0;31m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
#create slaves if local mode is set as a parameter
if [ "$1" = "local" ];
then
HOSTNAME=$(hostname)
mkdir -p config
echo "$HOSTNAME" > config/slaves
fi
# Sets the hadoop classpath.
HADOOP_CP=`hadoop classpath`
if [ -z "$HADOOP_CP" ]
then
HADOOP_CP="$HADOOP_CLASSPATH"
fi
# Cleans old build.
rm -f *.jar
rm -r -f build
# Builds the jar.
echo ${CYAN}* Building TKVS.jar...${BLUE}
mkdir build
find . -name "*.java" > .sources
javac -cp "lib:$HADOOP_CP" -d build @.sources || { echo ${RED}ERROR: javac! Exiting.${NC} ; exit 1; }
jar cf TKVS.jar -C build . || { echo ${RED}ERROR: jar! Exiting.${NC} ; exit 1; }
rm -f .sources
rm -r -f build
# Puts the jar in HDFS under /projects/transaction-manager/.
echo ${CYAN}* Putting TKVS.jar and config in HDFS...${BLUE}
PROJECT_HOME='/projects/transaction-manager'
hadoop fs -rm -r -f "$PROJECT_HOME/*" || { echo ${RED}ERROR: hadoop fs -rm! Exiting.${NC} ; exit 1; }
JAR_PATH="$PROJECT_HOME/TKVS.jar"
CONFIG_PATH="$PROJECT_HOME/config"
hadoop fs -mkdir -p "$PROJECT_HOME" || { echo ${RED}ERROR: hadoop -mkdir! Exiting.${NC} ; exit 1; }
hadoop fs -copyFromLocal TKVS.jar "$JAR_PATH" || { echo ${RED}ERROR: hadoop -copyFromLocal! Exiting.${NC} ; exit 1; }
hadoop fs -chmod -R 777 "$JAR_PATH" || { echo ${RED}ERROR: hadoop -chmod! Exiting.${NC} ; exit 1; }
hadoop fs -copyFromLocal config "$PROJECT_HOME" || { echo ${RED}ERROR: hadoop -copyFromLocal! Exiting.${NC} ; exit 1; }
hadoop fs -chmod -R 777 "$CONFIG_PATH" || { echo ${RED}ERROR: hadoop -chmod! Exiting.${NC} ; exit 1; }
RESULT_DIR="./benchmarks/results"
if [ ! -d "$RESULT_DIR" ]; then
mkdir $RESULT_DIR
fi
algorithmName=`head -1 ./config/algorithm`
echo $algorithmName
if [ "$algorithmName" = "simple_2pl" ];
then
algorithmName="2PL"
elif [ "$algorithmName" = "mvcc2pl" ];
then
algorithmName="MVCC2PL"
else
algorithmName="MVTO"
fi
RESULT_FILE="$RESULT_DIR/"$algorithmName"_results.csv"
# Executes the Client.
echo ${CYAN}* Executing YARN Client...${NC}
if [ $# -gt 1 ];
then
hadoop fs -copyFromLocal $2 /projects/transaction-manager/
hadoop jar TKVS.jar ch.epfl.tkvs.yarn.Client < "$2" > "$RESULT_FILE" || { echo ${RED}ERROR: hadoop jar! Exiting.${NC} ; exit 1; }
else
hadoop jar TKVS.jar ch.epfl.tkvs.yarn.Client || { echo ${RED}ERROR: hadoop jar! Exiting.${NC} ; exit 1; }
fi