forked from brianfrankcooper/YCSB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathycsb.bat
executable file
·235 lines (199 loc) · 7.38 KB
/
ycsb.bat
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
@REM
@REM Copyright (c) 2012 - 2016 YCSB contributors. All rights reserved.
@REM
@REM Licensed under the Apache License, Version 2.0 (the "License"); you
@REM may not use this file except in compliance with the License. You
@REM may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing, software
@REM distributed under the License is distributed on an "AS IS" BASIS,
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
@REM implied. See the License for the specific language governing
@REM permissions and limitations under the License. See accompanying
@REM LICENSE file.
@REM
@REM -----------------------------------------------------------------------
@REM Control Script for YCSB
@REM
@REM Environment Variable Prerequisites
@REM
@REM Do not set the variables in this script. Instead put them into a script
@REM setenv.sh in YCSB_HOME/bin to keep your customizations separate.
@REM
@REM YCSB_HOME (Optional) YCSB installation directory. If not set
@REM this script will use the parent directory of where this
@REM script is run from.
@REM
@REM JAVA_HOME (Required) Must point at your Java Development Kit
@REM or Java Runtime Environment installation.
@REM
@REM JAVA_OPTS (Optional) Java runtime options used when any command
@REM is executed.
@REM
@REM WARNING!!! YCSB home must be located in a directory path that doesn't
@REM contain spaces.
@REM
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
@REM Only set YCSB_HOME if not already set
PUSHD %~dp0..
IF NOT DEFINED YCSB_HOME SET YCSB_HOME=%CD%
POPD
@REM Ensure that any extra CLASSPATH variables are set via setenv.bat
SET CLASSPATH=
@REM Pull in customization options
if exist "%YCSB_HOME%\bin\setenv.bat" call "%YCSB_HOME%\bin\setenv.bat"
@REM Check if we have a usable JDK
IF "%JAVA_HOME%." == "." GOTO noJavaHome
IF NOT EXIST "%JAVA_HOME%\bin\java.exe" GOTO noJavaHome
GOTO okJava
:noJavaHome
ECHO The JAVA_HOME environment variable is not defined correctly.
GOTO exit
:okJava
@REM Determine YCSB command argument
IF NOT "load" == "%1" GOTO noload
SET YCSB_COMMAND=-load
SET YCSB_CLASS=site.ycsb.Client
GOTO gotCommand
:noload
IF NOT "run" == "%1" GOTO noRun
SET YCSB_COMMAND=-t
SET YCSB_CLASS=site.ycsb.Client
GOTO gotCommand
:noRun
IF NOT "shell" == "%1" GOTO noShell
SET YCSB_COMMAND=
SET YCSB_CLASS=site.ycsb.CommandLine
GOTO gotCommand
:noShell
ECHO [ERROR] Found unknown command '%1'
ECHO [ERROR] Expected one of 'load', 'run', or 'shell'. Exiting.
GOTO exit
:gotCommand
@REM Find binding information
FOR /F "delims=" %%G in (
'FINDSTR /B "%2:" %YCSB_HOME%\bin\bindings.properties'
) DO SET "BINDING_LINE=%%G"
IF NOT "%BINDING_LINE%." == "." GOTO gotBindingLine
ECHO [ERROR] The specified binding '%2' was not found. Exiting.
GOTO exit
:gotBindingLine
@REM Pull out binding name and class
FOR /F "tokens=1-2 delims=:" %%G IN ("%BINDING_LINE%") DO (
SET BINDING_NAME=%%G
SET BINDING_CLASS=%%H
)
@REM Some bindings have multiple versions that are managed in the same
@REM directory.
@REM They are noted with a '-' after the binding name.
@REM (e.g. cassandra-7 & cassandra-8)
FOR /F "tokens=1 delims=-" %%G IN ("%BINDING_NAME%") DO (
SET BINDING_DIR=%%G
)
@REM The 'basic' binding is core functionality
IF NOT "%BINDING_NAME%" == "basic" GOTO noBasic
SET BINDING_DIR=core
:noBasic
@REM Add Top level conf to classpath
IF "%CLASSPATH%." == "." GOTO emptyClasspath
SET CLASSPATH=%CLASSPATH%;%YCSB_HOME%\conf
GOTO confAdded
:emptyClasspath
SET CLASSPATH=%YCSB_HOME%\conf
:confAdded
@REM Cassandra2 deprecation message
IF NOT "%BINDING_DIR%" == "cassandra2" GOTO notAliasCassandra
echo [WARN] The 'cassandra2-cql' client has been deprecated. It has been renamed to simply 'cassandra-cql'. This alias will be removed in the next YCSB release.
SET BINDING_DIR=cassandra
:notAliasCassandra
@REM arangodb3 deprecation message
IF NOT "%BINDING_DIR%" == "arangodb3" GOTO notAliasArangodb3
echo [WARN] The 'arangodb3' client has been deprecated. The binding 'arangodb' now covers every ArangoDB version. This alias will be removed in the next YCSB release.
SET BINDING_DIR=arangodb
:notAliasArangodb3
@REM Build classpath according to source checkout or release distribution
IF EXIST "%YCSB_HOME%\pom.xml" GOTO gotSource
@REM Build classpath according to source checkout or release distribution
IF EXIST "%YCSB_HOME%\pom.xml" GOTO gotSource
@REM Core libraries
FOR %%F IN (%YCSB_HOME%\lib\*.jar) DO (
SET CLASSPATH=!CLASSPATH!;%%F%
)
@REM Database conf dir
IF NOT EXIST "%YCSB_HOME%\%BINDING_DIR%-binding\conf" GOTO noBindingConf
set CLASSPATH=%CLASSPATH%;%YCSB_HOME%\%BINDING_DIR%-binding\conf
:noBindingConf
@REM Database libraries
FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%-binding\lib\*.jar) DO (
SET CLASSPATH=!CLASSPATH!;%%F%
)
GOTO classpathComplete
:gotSource
@REM Check for some basic libraries to see if the source has been built.
IF EXIST "%YCSB_HOME%\core\target\dependency\*.jar" (
IF EXIST "%YCSB_HOME%\%BINDING_DIR%\target\*.jar" (
GOTO gotJars
)
)
@REM Call mvn to build source checkout.
IF "%BINDING_NAME%" == "basic" GOTO buildCore
SET MVN_PROJECT=%BINDING_DIR%-binding
goto gotMvnProject
:buildCore
SET MVN_PROJECT=core
:gotMvnProject
ECHO [WARN] YCSB libraries not found. Attempting to build...
CALL mvn -Psource-run -pl site.ycsb:%MVN_PROJECT% -am package -DskipTests
IF %ERRORLEVEL% NEQ 0 (
ECHO [ERROR] Error trying to build project. Exiting.
GOTO exit
)
:gotJars
@REM Core libraries
FOR %%F IN (%YCSB_HOME%\core\target\*.jar) DO (
SET CLASSPATH=!CLASSPATH!;%%F%
)
@REM Core dependency libraries
FOR %%F IN (%YCSB_HOME%\core\target\dependency\*.jar) DO (
SET CLASSPATH=!CLASSPATH!;%%F%
)
@REM Database conf (need to find because location is not consistent)
FOR /D /R %YCSB_HOME%\%BINDING_DIR% %%F IN (*) DO (
IF "%%~nxF" == "conf" SET CLASSPATH=!CLASSPATH!;%%F%
)
@REM Database libraries
FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%\target\*.jar) DO (
SET CLASSPATH=!CLASSPATH!;%%F%
)
@REM Database dependency libraries
FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%\target\dependency\*.jar) DO (
SET CLASSPATH=!CLASSPATH!;%%F%
)
:classpathComplete
@REM Couchbase deprecation message
IF NOT "%BINDING_DIR%" == "couchbase" GOTO notOldCouchbase
echo [WARN] The 'couchbase' client is deprecated. If you are using Couchbase 4.0+ try using the 'couchbase2' client instead.
:notOldCouchbase
@REM HBase 0.98 deprecation message
IF NOT "%BINDING_DIR%" == "hbase098" GOTO not098HBase
echo [WARN] The 'hbase098' client is deprecated because HBase 0.98 is EOM. If you are using HBase 1.2+ try using the 'hbase12' client instead.
:not098HBase
@REM HBase 1.0 deprecation message
IF NOT "%BINDING_DIR%" == "hbase10" GOTO not10HBase
echo [WARN] The 'hbase10' client is deprecated because HBase 1.0 is EOM. If you are using HBase 1.2+ try using the 'hbase12' client instead.
:not10HBase
@REM Get the rest of the arguments, skipping the first 2
FOR /F "tokens=2*" %%G IN ("%*") DO (
SET YCSB_ARGS=%%H
)
@REM Run YCSB
@ECHO ON
"%JAVA_HOME%\bin\java.exe" %JAVA_OPTS% -classpath "%CLASSPATH%" %YCSB_CLASS% %YCSB_COMMAND% -db %BINDING_CLASS% %YCSB_ARGS%
@ECHO OFF
GOTO end
:exit
EXIT /B 1;
:end