apache-ignite
228 строк · 6.9 Кб
1::
2:: Licensed to the Apache Software Foundation (ASF) under one or more
3:: contributor license agreements. See the NOTICE file distributed with
4:: this work for additional information regarding copyright ownership.
5:: The ASF licenses this file to You under the Apache License, Version 2.0
6:: (the "License"); you may not use this file except in compliance with
7:: the License. You may obtain a copy of the License at
8::
9:: http://www.apache.org/licenses/LICENSE-2.0
10::
11:: Unless required by applicable law or agreed to in writing, software
12:: distributed under the License is distributed on an "AS IS" BASIS,
13:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14:: See the License for the specific language governing permissions and
15:: limitations under the License.
16::
17
18::
19:: Grid command line loader.
20::
21
22@echo off
23Setlocal EnableDelayedExpansion
24
25if "%OS%" == "Windows_NT" setlocal
26
27:: Check JAVA_HOME.
28if defined JAVA_HOME goto checkJdk
29echo %0, ERROR:
30echo JAVA_HOME environment variable is not found.
31echo Please point JAVA_HOME variable to location of JDK 1.8 or later.
32echo You can also download latest JDK at http://java.com/download.
33goto error_finish
34
35:checkJdk
36:: Check that JDK is where it should be.
37if exist "%JAVA_HOME%\bin\java.exe" goto checkJdkVersion
38echo %0, ERROR:
39echo JAVA is not found in JAVA_HOME=%JAVA_HOME%.
40echo Please point JAVA_HOME variable to installation of JDK 1.8 or later.
41echo You can also download latest JDK at http://java.com/download.
42goto error_finish
43
44:checkJdkVersion
45set cmd="%JAVA_HOME%\bin\java.exe"
46for /f "tokens=* USEBACKQ" %%f in (`%cmd% -version 2^>^&1`) do (
47set var=%%f
48goto :LoopEscape
49)
50:LoopEscape
51
52for /f "tokens=1-3 delims= " %%a in ("%var%") do set JAVA_VER_STR=%%c
53set JAVA_VER_STR=%JAVA_VER_STR:"=%
54
55for /f "tokens=1,2 delims=." %%a in ("%JAVA_VER_STR%.x") do set MAJOR_JAVA_VER=%%a& set MINOR_JAVA_VER=%%b
56if %MAJOR_JAVA_VER% == 1 set MAJOR_JAVA_VER=%MINOR_JAVA_VER%
57
58if %MAJOR_JAVA_VER% LSS 8 (
59echo %0, ERROR:
60echo The version of JAVA installed in %JAVA_HOME% is incorrect.
61echo Please point JAVA_HOME variable to installation of JDK 1.8 or later.
62echo You can also download latest JDK at http://java.com/download.
63goto error_finish
64)
65
66:: Check IGNITE_HOME.
67:checkIgniteHome1
68if defined IGNITE_HOME goto checkIgniteHome2
69pushd "%~dp0"/..
70set IGNITE_HOME=%CD%
71popd
72
73:checkIgniteHome2
74:: Strip double quotes from IGNITE_HOME
75set IGNITE_HOME=%IGNITE_HOME:"=%
76
77:: remove all trailing slashes from IGNITE_HOME.
78if %IGNITE_HOME:~-1,1% == \ goto removeTrailingSlash
79if %IGNITE_HOME:~-1,1% == / goto removeTrailingSlash
80goto checkIgniteHome3
81
82:removeTrailingSlash
83set IGNITE_HOME=%IGNITE_HOME:~0,-1%
84goto checkIgniteHome2
85
86:checkIgniteHome3
87if exist "%IGNITE_HOME%\config" goto checkIgniteHome4
88echo %0, ERROR: Ignite installation folder is not found or IGNITE_HOME environment variable is not valid.
89echo Please create IGNITE_HOME environment variable pointing to location of
90echo Ignite installation folder.
91goto error_finish
92
93:checkIgniteHome4
94
95::
96:: Set SCRIPTS_HOME - base path to scripts.
97::
98set SCRIPTS_HOME=%IGNITE_HOME%\bin
99
100:: Remove trailing spaces
101for /l %%a in (1,1,31) do if /i "%SCRIPTS_HOME:~-1%" == " " set SCRIPTS_HOME=%SCRIPTS_HOME:~0,-1%
102
103if /i "%SCRIPTS_HOME%\" == "%~dp0" goto setProgName
104echo %0, WARN: IGNITE_HOME environment variable may be pointing to wrong folder: %IGNITE_HOME%
105
106:setProgName
107::
108:: Set program name.
109::
110set PROG_NAME=ignite.bat
111if "%OS%" == "Windows_NT" set PROG_NAME=%~nx0%
112
113:run
114
115::
116:: Set IGNITE_LIBS
117::
118call "%SCRIPTS_HOME%\include\setenv.bat"
119call "%SCRIPTS_HOME%\include\build-classpath.bat"
120set CP=%IGNITE_LIBS%;%IGNITE_HOME%\libs\optional\ignite-zookeeper\*
121
122::
123:: Process 'restart'.
124::
125set RANDOM_NUMBER_COMMAND="!JAVA_HOME!\bin\java.exe" -cp %CP% org.apache.ignite.startup.cmdline.CommandLineRandomNumberGenerator
126for /f "usebackq tokens=*" %%i in (`!RANDOM_NUMBER_COMMAND!`) do set RANDOM_NUMBER=%%i
127
128set RESTART_SUCCESS_FILE="%IGNITE_HOME%\work\ignite_success_%RANDOM_NUMBER%"
129set RESTART_SUCCESS_OPT=-DIGNITE_SUCCESS_FILE=%RESTART_SUCCESS_FILE%
130
131::
132:: JVM options. See http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp for more details.
133::
134:: ADD YOUR/CHANGE ADDITIONAL OPTIONS HERE
135::
136"%JAVA_HOME%\bin\java.exe" -version 2>&1 | findstr "1\.[7]\." > nul
137if %ERRORLEVEL% equ 0 (
138if "%CONTROL_JVM_OPTS%" == "" set CONTROL_JVM_OPTS=-Xms256m -Xmx1g
139) else (
140if "%CONTROL_JVM_OPTS%" == "" set CONTROL_JVM_OPTS=-Xms256m -Xmx1g
141)
142
143::
144:: Uncomment to enable experimental commands [--wal]
145::
146:: set CONTROL_JVM_OPTS=%CONTROL_JVM_OPTS% -DIGNITE_ENABLE_EXPERIMENTAL_COMMAND=true
147
148::
149:: Uncomment the following GC settings if you see spikes in your throughput due to Garbage Collection.
150::
151:: set CONTROL_JVM_OPTS=%CONTROL_JVM_OPTS% -XX:+UseG1GC
152
153::
154:: Uncomment if you get StackOverflowError.
155:: On 64 bit systems this value can be larger, e.g. -Xss16m
156::
157:: set CONTROL_JVM_OPTS=%CONTROL_JVM_OPTS% -Xss4m
158
159::
160:: Uncomment to set preference to IPv4 stack.
161::
162:: set CONTROL_JVM_OPTS=%CONTROL_JVM_OPTS% -Djava.net.preferIPv4Stack=true
163
164::
165:: Assertions are disabled by default since version 3.5.
166:: If you want to enable them - set 'ENABLE_ASSERTIONS' flag to '1'.
167::
168set ENABLE_ASSERTIONS=1
169
170::
171:: Set '-ea' options if assertions are enabled.
172::
173if %ENABLE_ASSERTIONS% == 1 set CONTROL_JVM_OPTS=%CONTROL_JVM_OPTS% -ea
174
175:run_java
176
177::
178:: Set main class to start service (grid node by default).
179::
180
181if "%MAIN_CLASS%" == "" set MAIN_CLASS=org.apache.ignite.internal.commandline.CommandHandler
182
183::
184:: Remote debugging (JPDA).
185:: Uncomment and change if remote debugging is required.
186:: set CONTROL_JVM_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8787 %CONTROL_JVM_OPTS%
187::
188
189::
190:: Final CONTROL_JVM_OPTS for Java 9+ compatibility
191::
192call "%SCRIPTS_HOME%\include\jvmdefaults.bat" %MAJOR_JAVA_VER% "%CONTROL_JVM_OPTS%" CONTROL_JVM_OPTS
193
194if defined JVM_OPTS (
195echo JVM_OPTS environment variable is set, but will not be used. To pass JVM options use CONTROL_JVM_OPTS
196echo JVM_OPTS=%JVM_OPTS%
197)
198
199if "%INTERACTIVE%" == "1" (
200"%JAVA_HOME%\bin\java.exe" %CONTROL_JVM_OPTS% %QUIET% %RESTART_SUCCESS_OPT% ^
201-DIGNITE_UPDATE_NOTIFIER=false -DIGNITE_HOME="%IGNITE_HOME%" -DIGNITE_PROG_NAME="%PROG_NAME%" %JVM_XOPTS% ^
202-cp "%CP%" %MAIN_CLASS% %*
203) else (
204"%JAVA_HOME%\bin\java.exe" %CONTROL_JVM_OPTS% %QUIET% %RESTART_SUCCESS_OPT% ^
205-DIGNITE_UPDATE_NOTIFIER=false -DIGNITE_HOME="%IGNITE_HOME%" -DIGNITE_PROG_NAME="%PROG_NAME%" %JVM_XOPTS% ^
206-cp "%CP%" %MAIN_CLASS% %*
207)
208
209set JAVA_ERRORLEVEL=%ERRORLEVEL%
210
211:: errorlevel 130 if aborted with Ctrl+c
212if %JAVA_ERRORLEVEL%==130 goto finish
213
214:: Exit if first run unsuccessful (Loader must create file).
215if not exist %RESTART_SUCCESS_FILE% goto error_finish
216del %RESTART_SUCCESS_FILE%
217
218goto run_java
219
220:finish
221if not exist %RESTART_SUCCESS_FILE% goto error_finish
222del %RESTART_SUCCESS_FILE%
223
224:error_finish
225
226if not "%NO_PAUSE%" == "1" pause
227
228goto :eof
229