-
Notifications
You must be signed in to change notification settings - Fork 8
/
ycsb.sh
executable file
·125 lines (99 loc) · 4.47 KB
/
ycsb.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
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
#! /usr/bin/env bash
# Set the YCSB specific environment. Adds all the required libraries to the class path.
# Copyright (c) 2010 Yahoo! Inc. All rights reserved.
# *
# * Licensed 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. See accompanying
# * LICENSE file.
#
# The Java implementation to use. This is required.
#export JAVA_HOME=
# Any JVM options to pass.
#export YCSB_OPTS="-Djava.compiler=NONE"
# YCSB client heap size.
#export YCSB_HEAP_SIZE=500
this=`dirname "$0"`
this=`cd "$this"; pwd`
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
bin=`dirname "$this"`
script=`basename "$this"`
bin=`cd "$bin"; pwd`
this="$bin/$script"
# the root of the Hadoop installation
export YCSB_HOME=`dirname "$this"`
echo "YCSB_HOME $YCSB_HOME"
cygwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
esac
# if no args specified, show usage
if [ $# = 0 ]; then
echo "Usage: ycsb CLASSNAME"
echo "where CLASSNAME is the name of the class to run"
echo "The jar file for the class must be in bin, build, lib, or db/*/lib."
exit 1
fi
# get arguments
COMMAND=$1
shift
JAVA=""
if [ "$JAVA_HOME" != "" ]; then
JAVA=$JAVA_HOME/bin/java
else
echo "JAVA_HOME must be set."
exit 1
fi
JAVA_HEAP_MAX=-Xmx500m
# check envvars which might override default args
if [ "$YCSB_HEAP_SIZE" != "" ]; then
JAVA_HEAP_MAX="-Xmx""$YCSB_HEAP_SIZE""m"
fi
# Set the classpath.
if [ "$CLASSPATH" != "" ]; then
CLASSPATH=${CLASSPATH}:$JAVA_HOME/lib/tools.jar
else
CLASSPATH=$JAVA_HOME/lib/tools.jar
fi
# so that filenames w/ spaces are handled correctly in loops below
IFS=
for f in $YCSB_HOME/build/*.jar; do
CLASSPATH=${CLASSPATH}:$f
done
for f in $YCSB_HOME/lib/*.jar; do
CLASSPATH=${CLASSPATH}:$f
done
for f in $YCSB_HOME/db/*; do
if [ -d $f ]; then
for j in $f/lib/*.jar; do
CLASSPATH=${CLASSPATH}:$j
done
fi
done
#echo "CLASSPATH=$CLASSPATH"
# restore ordinary behavior
unset IFS
CLASS=$COMMAND
# cygwin path translation
if $cygwin; then
CLASSPATH=`cygpath -p -w "$CLASSPATH"`
YCSB_HOME=`cygpath -w "$YCSB_HOME"`
fi
#echo "Executing command $CLASS with options $JAVA_HEAP_MAX $YCSB_OPTS $CLASS $@"
exec "$JAVA" $JAVA_HEAP_MAX $YCSB_OPTS -classpath "$CLASSPATH" $CLASS "$@"