Skip to content
Snippets Groups Projects
Commit 8e460911 authored by Sean Busbey's avatar Sean Busbey Committed by GitHub
Browse files

Merge pull request #777 from cmatser/windowsfix

[scripts] Add mvn build if necessary for source checkout on windows. …
parents 20101ddd 24d5a119
No related branches found
No related tags found
No related merge requests found
@REM @REM
@REM Copyright (c) 2012 - 2016 YCSB contributors. All rights reserved. @REM Copyright (c) 2012 - 2016 YCSB contributors. All rights reserved.
@REM @REM
@REM Licensed under the Apache License, Version 2.0 (the "License"); you @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 not use this file except in compliance with the License. You
@REM may obtain a copy of the License at @REM may obtain a copy of the License at
@REM @REM
@REM http://www.apache.org/licenses/LICENSE-2.0 @REM http://www.apache.org/licenses/LICENSE-2.0
@REM @REM
@REM Unless required by applicable law or agreed to in writing, software @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 distributed under the License is distributed on an "AS IS" BASIS,
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
@REM implied. See the License for the specific language governing @REM implied. See the License for the specific language governing
@REM permissions and limitations under the License. See accompanying @REM permissions and limitations under the License. See accompanying
@REM LICENSE file. @REM LICENSE file.
@REM @REM
@REM ----------------------------------------------------------------------- @REM -----------------------------------------------------------------------
@REM Control Script for YCSB @REM Control Script for YCSB
@REM @REM
@REM Environment Variable Prerequisites @REM Environment Variable Prerequisites
@REM @REM
@REM Do not set the variables in this script. Instead put them into a script @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 setenv.sh in YCSB_HOME/bin to keep your customizations separate.
@REM @REM
@REM YCSB_HOME (Optional) YCSB installation directory. If not set @REM YCSB_HOME (Optional) YCSB installation directory. If not set
@REM this script will use the parent directory of where this @REM this script will use the parent directory of where this
@REM script is run from. @REM script is run from.
@REM @REM
@REM JAVA_HOME (Required) Must point at your Java Development Kit @REM JAVA_HOME (Required) Must point at your Java Development Kit
@REM or Java Runtime Environment installation. @REM or Java Runtime Environment installation.
@REM @REM
@REM JAVA_OPTS (Optional) Java runtime options used when any command @REM JAVA_OPTS (Optional) Java runtime options used when any command
@REM is executed. @REM is executed.
@REM @REM
@REM WARNING!!! YCSB home must be located in a directory path that doesn't @REM WARNING!!! YCSB home must be located in a directory path that doesn't
@REM contain spaces. @REM contain spaces.
@REM @REM
@ECHO OFF @ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION SETLOCAL ENABLEDELAYEDEXPANSION
@REM Only set YCSB_HOME if not already set @REM Only set YCSB_HOME if not already set
PUSHD %~dp0.. PUSHD %~dp0..
IF NOT DEFINED YCSB_HOME SET YCSB_HOME=%CD% IF NOT DEFINED YCSB_HOME SET YCSB_HOME=%CD%
POPD POPD
@REM Ensure that any extra CLASSPATH variables are set via setenv.bat @REM Ensure that any extra CLASSPATH variables are set via setenv.bat
SET CLASSPATH= SET CLASSPATH=
@REM Pull in customization options @REM Pull in customization options
if exist "%YCSB_HOME%\bin\setenv.bat" call "%YCSB_HOME%\bin\setenv.bat" if exist "%YCSB_HOME%\bin\setenv.bat" call "%YCSB_HOME%\bin\setenv.bat"
@REM Check if we have a usable JDK @REM Check if we have a usable JDK
IF "%JAVA_HOME%." == "." GOTO noJavaHome IF "%JAVA_HOME%." == "." GOTO noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome IF NOT EXIST "%JAVA_HOME%\bin\java.exe" GOTO noJavaHome
GOTO okJava GOTO okJava
:noJavaHome :noJavaHome
ECHO The JAVA_HOME environment variable is not defined correctly. ECHO The JAVA_HOME environment variable is not defined correctly.
GOTO exit GOTO exit
:okJava :okJava
@REM Determine YCSB command argument @REM Determine YCSB command argument
IF NOT "load" == "%1" GOTO noload IF NOT "load" == "%1" GOTO noload
SET YCSB_COMMAND=-load SET YCSB_COMMAND=-load
SET YCSB_CLASS=com.yahoo.ycsb.Client SET YCSB_CLASS=com.yahoo.ycsb.Client
GOTO gotCommand GOTO gotCommand
:noload :noload
IF NOT "run" == "%1" GOTO noRun IF NOT "run" == "%1" GOTO noRun
SET YCSB_COMMAND=-t SET YCSB_COMMAND=-t
SET YCSB_CLASS=com.yahoo.ycsb.Client SET YCSB_CLASS=com.yahoo.ycsb.Client
GOTO gotCommand GOTO gotCommand
:noRun :noRun
IF NOT "shell" == "%1" GOTO noShell IF NOT "shell" == "%1" GOTO noShell
SET YCSB_COMMAND= SET YCSB_COMMAND=
SET YCSB_CLASS=com.yahoo.ycsb.CommandLine SET YCSB_CLASS=com.yahoo.ycsb.CommandLine
GOTO gotCommand GOTO gotCommand
:noShell :noShell
ECHO [ERROR] Found unknown command '%1' ECHO [ERROR] Found unknown command '%1'
ECHO [ERROR] Expected one of 'load', 'run', or 'shell'. Exiting. ECHO [ERROR] Expected one of 'load', 'run', or 'shell'. Exiting.
GOTO exit GOTO exit
:gotCommand :gotCommand
@REM Find binding information @REM Find binding information
FOR /F "delims=" %%G in ( FOR /F "delims=" %%G in (
'FINDSTR /B "%2:" %YCSB_HOME%\bin\bindings.properties' 'FINDSTR /B "%2:" %YCSB_HOME%\bin\bindings.properties'
) DO SET "BINDING_LINE=%%G" ) DO SET "BINDING_LINE=%%G"
IF NOT "%BINDING_LINE%." == "." GOTO gotBindingLine IF NOT "%BINDING_LINE%." == "." GOTO gotBindingLine
ECHO [ERROR] The specified binding '%2' was not found. Exiting. ECHO [ERROR] The specified binding '%2' was not found. Exiting.
GOTO exit GOTO exit
:gotBindingLine :gotBindingLine
@REM Pull out binding name and class @REM Pull out binding name and class
FOR /F "tokens=1-2 delims=:" %%G IN ("%BINDING_LINE%") DO ( FOR /F "tokens=1-2 delims=:" %%G IN ("%BINDING_LINE%") DO (
SET BINDING_NAME=%%G SET BINDING_NAME=%%G
SET BINDING_CLASS=%%H SET BINDING_CLASS=%%H
) )
@REM Some bindings have multiple versions that are managed in the same @REM Some bindings have multiple versions that are managed in the same
@REM directory. @REM directory.
@REM They are noted with a '-' after the binding name. @REM They are noted with a '-' after the binding name.
@REM (e.g. cassandra-7 & cassandra-8) @REM (e.g. cassandra-7 & cassandra-8)
FOR /F "tokens=1 delims=-" %%G IN ("%BINDING_NAME%") DO ( FOR /F "tokens=1 delims=-" %%G IN ("%BINDING_NAME%") DO (
SET BINDING_DIR=%%G SET BINDING_DIR=%%G
) )
@REM The 'basic' binding is core functionality @REM The 'basic' binding is core functionality
IF NOT "%BINDING_NAME%" == "basic" GOTO noBasic IF NOT "%BINDING_NAME%" == "basic" GOTO noBasic
SET BINDING_DIR=core SET BINDING_DIR=core
:noBasic :noBasic
@REM Add Top level conf to classpath @REM Add Top level conf to classpath
IF "%CLASSPATH%." == "." GOTO emptyClasspath IF "%CLASSPATH%." == "." GOTO emptyClasspath
SET CLASSPATH=%CLASSPATH%;%YCSB_HOME%\conf SET CLASSPATH=%CLASSPATH%;%YCSB_HOME%\conf
GOTO confAdded GOTO confAdded
:emptyClasspath :emptyClasspath
SET CLASSPATH=%YCSB_HOME%\conf SET CLASSPATH=%YCSB_HOME%\conf
:confAdded :confAdded
@REM Build classpath according to source checkout or release distribution @REM Build classpath according to source checkout or release distribution
IF EXIST "%YCSB_HOME%\pom.xml" GOTO gotRelease IF EXIST "%YCSB_HOME%\pom.xml" GOTO gotSource
@REM Core libraries @REM Core libraries
FOR %%F IN (%YCSB_HOME%\lib\*.jar) DO ( FOR %%F IN (%YCSB_HOME%\lib\*.jar) DO (
SET CLASSPATH=!CLASSPATH!;%%F% SET CLASSPATH=!CLASSPATH!;%%F%
) )
@REM Database conf dir @REM Database conf dir
IF NOT EXIST "%YCSB_HOME%\%BINDING_DIR%-binding\conf" GOTO noBindingConf IF NOT EXIST "%YCSB_HOME%\%BINDING_DIR%-binding\conf" GOTO noBindingConf
set CLASSPATH=%CLASSPATH%;%YCSB_HOME%\%BINDING_DIR%-binding\conf set CLASSPATH=%CLASSPATH%;%YCSB_HOME%\%BINDING_DIR%-binding\conf
:noBindingConf :noBindingConf
@REM Database libraries @REM Database libraries
FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%-binding\lib\*.jar) DO ( FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%-binding\lib\*.jar) DO (
SET CLASSPATH=!CLASSPATH!;%%F% SET CLASSPATH=!CLASSPATH!;%%F%
) )
GOTO classpathComplete GOTO classpathComplete
:gotRelease :gotSource
@REM Core libraries @REM Check for some basic libraries to see if the source has been built.
FOR %%F IN (%YCSB_HOME%\core\target\*.jar) DO ( IF EXIST "%YCSB_HOME%\%BINDING_DIR%\target\*.jar" GOTO gotJars
SET CLASSPATH=!CLASSPATH!;%%F%
) @REM Call mvn to build source checkout.
IF "%BINDING_NAME%" == "basic" GOTO buildCore
@REM Database conf (need to find because location is not consistent) SET MVN_PROJECT=%BINDING_DIR%-binding
FOR /D /R %YCSB_HOME%\%BINDING_DIR% %%F IN (*) DO ( goto gotMvnProject
IF "%%~nxF" == "conf" SET CLASSPATH=!CLASSPATH!;%%F% :buildCore
) SET MVN_PROJECT=core
:gotMvnProject
@REM Database libraries
FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%\target\*.jar) DO ( ECHO [WARN] YCSB libraries not found. Attempting to build...
SET CLASSPATH=!CLASSPATH!;%%F% CALL mvn -pl com.yahoo.ycsb:%MVN_PROJECT% -am package -DskipTests
) IF %ERRORLEVEL% NEQ 0 (
ECHO [ERROR] Error trying to build project. Exiting.
@REM Database dependency libraries GOTO exit
FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%\target\dependency\*.jar) DO ( )
SET CLASSPATH=!CLASSPATH!;%%F%
) :gotJars
@REM Core libraries
:classpathComplete FOR %%F IN (%YCSB_HOME%\core\target\*.jar) DO (
SET CLASSPATH=!CLASSPATH!;%%F%
@REM Cassandra deprecation message )
IF NOT "%BINDING_DIR%" == "cassandra" GOTO notOldCassandra
echo [WARN] The 'cassandra-7', 'cassandra-8', 'cassandra-10', and cassandra-cql' clients are deprecated. If you are using Cassandra 2.X try using the 'cassandra2-cql' client instead. @REM Database conf (need to find because location is not consistent)
:notOldCassandra FOR /D /R %YCSB_HOME%\%BINDING_DIR% %%F IN (*) DO (
IF "%%~nxF" == "conf" SET CLASSPATH=!CLASSPATH!;%%F%
@REM Get the rest of the arguments, skipping the first 2 )
FOR /F "tokens=2*" %%G IN ("%*") DO (
SET YCSB_ARGS=%%H @REM Database libraries
) FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%\target\*.jar) DO (
SET CLASSPATH=!CLASSPATH!;%%F%
@REM Run YCSB )
@ECHO ON
"%JAVA_HOME%\bin\java.exe" %JAVA_OPTS% -classpath "%CLASSPATH%" %YCSB_CLASS% %YCSB_COMMAND% -db %BINDING_CLASS% %YCSB_ARGS% @REM Database dependency libraries
@ECHO OFF FOR %%F IN (%YCSB_HOME%\%BINDING_DIR%\target\dependency\*.jar) DO (
SET CLASSPATH=!CLASSPATH!;%%F%
GOTO end )
:exit :classpathComplete
EXIT /B 1;
@REM Cassandra deprecation message
:end IF NOT "%BINDING_DIR%" == "cassandra" GOTO notOldCassandra
echo [WARN] The 'cassandra-7', 'cassandra-8', 'cassandra-10', and cassandra-cql' clients are deprecated. If you are using Cassandra 2.X try using the 'cassandra2-cql' client instead.
:notOldCassandra
@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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment