diff --git bin/ext/cli.cmd bin/ext/cli.cmd new file mode 100644 index 0000000..8d30b68 --- /dev/null +++ bin/ext/cli.cmd @@ -0,0 +1,33 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +set CLASS=org.apache.hadoop.hive.cli.CliDriver +pushd %HIVE_LIB% +for /f %%a IN ('dir /b hive-cli-*.jar') do ( + set JAR=%HIVE_LIB%\%%a +) +popd + +if [%1]==[cli_help] goto :cli_help + +:cli + call %HIVE_BIN_PATH%\ext\util\execHiveCmd.cmd %CLASS% +goto :EOF + +:cli_help + set HIVEARGS=--help + call :cli +goto :EOF \ No newline at end of file diff --git bin/ext/debug.cmd bin/ext/debug.cmd new file mode 100644 index 0000000..6451748 --- /dev/null +++ bin/ext/debug.cmd @@ -0,0 +1,109 @@ +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@echo off + +set RECURSIVE= +set PORT= +set MAINSUSPEND= +set CHILDSUSPEND= +set SWAPSUSPEND= +set HIVE_MAIN_CLIENT_DEBUG_OPTS= +set HIVE_CHILD_CLIENT_DEBUG_OPTS= +if %1==HELP ( + goto :debug_help +) else ( + call :get_debug_params %* +) + +@rem must use java 1.5 or later prereq +:ParseDebugArgs + :ProcessDebugArgsLoop + if [%1]==[] goto :EndProcessDebug + + set params=%1 + set temp=%params:~0, 8% + + @rem trim off the --debug[ if it is the 1st param + if %temp%==--debug[ ( + set params=%params:--debug[=% + ) + + @rem trim off the ] if necessary on the value of the param + set value=%2 + set value=%value:]=% + + if %params%==recursive ( + set RECURSIVE=%value% + shift + shift + goto :ProcessDebugArgsLoop + ) + + if %params%==port ( + set PORT=%value% + shift + shift + goto :ProcessDebugArgsLoop + ) + + if %params%==mainSuspend ( + set MAINSUSPEND=%value% + shift + shift + goto :ProcessDebugArgsLoop + ) + if %params%==childSuspend ( + set CHILDSUSPEND=%value% + shift + shift + goto :ProcessDebugArgsLoop + ) + if %params%==swapSuspend ( + set childTemp=%CHILDSUSPEND% + set MAINSUSPEND=%CHILDSUSPEND% + set CHILDSUSPEND=%MAINSUSPEND% + shift + goto :ProcessDebugArgsLoop + ) + + goto :ProcessDebugArgsLoop + + :EndProcessDebug +goto :EOF + +:set_debug_defaults + set RECURSIVE="y" + set PORT="address=8000" + set MAINSUSPEND="suspend=y" + set CHILDSUSPEND="suspend=n" +goto :EOF + +:get_debug_params + call :set_debug_defaults + call :ParseDebugArgs %* + set HIVE_MAIN_CLIENT_DEBUG_OPTS= -XX:+UseParallelGC -Xdebug -Xrunjdwp:transport=dt_socket,server=y,%PORT%,%MAINSUSPEND% + set HIVE_CHILD_CLIENT_DEBUG_OPTS= -XX:+UseParallelGC -Xdebug -Xrunjdwp:transport=dt_socket,server=y,%CHILDSUSPEND% +goto :EOF + +:debug_help + echo "Allows to debug Hive by connecting to it via JDI API" + echo "Usage: hive --debug[:comma-separated parameters list]" + echo "Parameters:" + echo "recursive= Should child JVMs also be started in debug mode. Default: y" + echo "port= Port on which main JVM listens for debug connection. Default: 8000" + echo "mainSuspend= Should main JVM wait with execution for the debugger to connect. Default: y" + echo "childSuspend= Should child JVMs wait with execution for the debugger to connect. Default: n" + echo "swapSuspend Swaps suspend options between main and child JVMs" +goto :EOF diff --git bin/ext/help.cmd bin/ext/help.cmd new file mode 100644 index 0000000..7814262 --- /dev/null +++ bin/ext/help.cmd @@ -0,0 +1,30 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +:help + echo "Usage ./hive --service serviceName " + echo "Service List: $SERVICE_LIST" + echo "Parameters parsed:" + echo " --auxpath : Auxillary jars " + echo " --config : Hive configuration directory" + echo " --service : Starts specific service/component. cli is default" + echo "Parameters used:" + echo " HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory" + echo " HIVE_OPT : Hive options" + echo "For help on a particular service:" + echo " ./hive --service serviceName --help" + echo "Debug help: ./hive --debug --help" +goto :EOF \ No newline at end of file diff --git bin/ext/hiveserver.cmd bin/ext/hiveserver.cmd new file mode 100644 index 0000000..22ce756 --- /dev/null +++ bin/ext/hiveserver.cmd @@ -0,0 +1,48 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +set CLASS=org.apache.hadoop.hive.service.HiveServer +pushd %HIVE_LIB% +for /f %%a IN ('dir /b hive-service-*.jar') do ( + set JAR=%HIVE_LIB%\%%a +) +popd + +if [%1]==[hiveserver_help] goto :hiveserver_help + +if [%1]==[hiveserver_catservice] goto :hiveserver_catservice + +:hiveserver + echo "Starting Hive Thrift Server" + + @rem hadoop 20 or newer - skip the aux_jars option and hiveconf + call %HIVE_BIN_PATH%\ext\util\execHiveCmd.cmd %CLASS% +goto :EOF + +:hiveserver_help + set HIVEARGS=-h + goto :hiveserver +goto :EOF + +:hiveserver_catservice +@echo ^ +@echo ^HiveServer^ +@echo ^HiveServer^ +@echo ^Hadoop HiveServer Service^ +@echo ^%JAVA_HOME%\bin\java^ +@echo ^%HADOOP_OPTS% %AUX_PARAM% -classpath %CLASSPATH% %CLASS% -hiveconf hive.hadoop.classpath=%HIVE_LIB%\* -hiveconf hive.metastore.local=true -hiveconf hive.server.servermode=http -p 10000 %HIVE_OPTS%^ +@echo ^ +goto :EOF diff --git bin/ext/hwi.cmd bin/ext/hwi.cmd new file mode 100644 index 0000000..f010046 --- /dev/null +++ bin/ext/hwi.cmd @@ -0,0 +1,62 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +set CLASS=org.apache.hadoop.hive.hwi.HWIServer +pushd %HIVE_LIB% +for /f %%a IN ('dir /b hive-hwi-*.jar') do ( + set JAR=%HIVE_LIB%\%%a +) +popd + +if [%1]==[hwi_help] goto :hwi_help + +if [%1]==[hwi_catservice] goto :hwi_catservice + +:hwi + @rem set the hwi jar and war files + pushd %HIVE_LIB% + for /f %%a IN ('dir /b hive-hwi-*') do ( + call :ProcessFileName %%a + ) + popd + + @rem hadoop 20 or newer - skip the aux_jars option and hiveconf + call %HIVE_BIN_PATH%\ext\util\execHiveCmd.cmd %CLASS% +goto :EOF + +@rem process the hwi files +:ProcessFileName + set temp=%1 + set temp=%temp:~-3% + + if %temp%==jar set HWI_JAR_FILE=lib\%1 + + if %temp%==war set HWI_WAR_FILE=lib\%1 +goto :EOF + +:hwi_help + echo "Usage ANT_LIB=XXXX hive --service hwi" +goto :EOF + +:hwi_catservice +@echo ^ +@echo ^HWI^ +@echo ^HWI^ +@echo ^Hadoop HWI Service^ +@echo ^%JAVA_HOME%\bin\java^ +@echo ^%HADOOP_OPTS% %AUX_PARAM% -classpath %CLASSPATH% %CLASS% %HIVE_OPTS%^ +@echo ^ +goto :EOF \ No newline at end of file diff --git bin/ext/jar.cmd bin/ext/jar.cmd new file mode 100644 index 0000000..91e8150 --- /dev/null +++ bin/ext/jar.cmd @@ -0,0 +1,43 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +if [%1]==[jar_help] goto :jar_help + +:jar + + set RUNJAR=%1 + shift + + set RUNCLASS=%1 + shift + + if "%RUNJAR%"== ""( + echo "RUNJAR not specified" + exit 3 + ) + + if "%RUNCLASS%" == "" ( + echo "RUNCLASS not specified" + exit 3 + ) + @rem hadoop 20 or newer - skip the aux_jars option and hiveconf + %HADOOP% jar %$RUNJAR% %RUNCLASS% %HIVE_OPTS% %* +goto :EOF + +:jar_help + echo "Used for applications that require Hadoop and Hive classpath and environment." + echo "./hive --service jar HIVE_OPTS " +goto :EOF \ No newline at end of file diff --git bin/ext/lineage.cmd bin/ext/lineage.cmd new file mode 100644 index 0000000..0ce5024 --- /dev/null +++ bin/ext/lineage.cmd @@ -0,0 +1,30 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +set CLASS=org.apache.hadoop.hive.ql.tools.LineageInfo + +if [%1]==[lineage_help] goto :lineage_help + +:lineage + if not exist %HIVE_LIB%/hive-exec-*.jar ( + echo "Missing Hive exec Jar" + ) + call %HIVE_BIN_PATH%\ext\util\execHiveCmd.cmd %CLASS% +goto :EOF + +:lineage_help + echo "usage hive.cmd 'hql' " +goto :EOF \ No newline at end of file diff --git bin/ext/metastore.cmd bin/ext/metastore.cmd new file mode 100644 index 0000000..68fb050 --- /dev/null +++ bin/ext/metastore.cmd @@ -0,0 +1,48 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +set CLASS=org.apache.hadoop.hive.metastore.HiveMetaStore +pushd %HIVE_LIB% +for /f %%a IN ('dir /b hive-metastore-*.jar') do ( + set JAR=%HIVE_LIB%\%%a +) +popd + +if [%1]==[metastore_help] goto :metastore_help + +if [%1]==[metastore_catservice] goto :metastore_catservice + +:metastore + echo "Starting Hive Metastore Server" + @rem hadoop 20 or newer - skip the aux_jars option and hiveconf + set HADOOP_OPTS=%HIVE_METASTORE_HADOOP_OPTS% %HADOOP_OPTS% + call %HIVE_BIN_PATH%\ext\util\execHiveCmd.cmd %CLASS% +goto :EOF + +:metastore_help + set HIVEARGS=-h + call :metastore +goto :EOF + +:metastore_catservice +@echo ^ +@echo ^Metastore^ +@echo ^Metastore^ +@echo ^Hadoop Metastore Service^ +@echo ^%JAVA_HOME%\bin\java^ +@echo ^%HADOOP_OPTS% %AUX_PARAM% -classpath %CLASSPATH% %CLASS% %HIVE_OPTS%^ +@echo ^ +goto :EOF \ No newline at end of file diff --git bin/ext/orcfiledump.cmd bin/ext/orcfiledump.cmd new file mode 100644 index 0000000..bb1b103 --- /dev/null +++ bin/ext/orcfiledump.cmd @@ -0,0 +1,28 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +set CLASS=org.apache.hadoop.hive.ql.io.orc.FileDump +set HIVE_OPTS= + +if [%1]==[orcfiledump_help] goto :orcfiledump_help + +:orcfiledump + call %HIVE_BIN_PATH%\ext\util\execHiveCmd.cmd %CLASS% +goto :EOF + +:orcfiledump_help + echo "usage ./hive orcfiledump " +goto :EOF diff --git bin/ext/rcfilecat.cmd bin/ext/rcfilecat.cmd new file mode 100644 index 0000000..6ef989f --- /dev/null +++ bin/ext/rcfilecat.cmd @@ -0,0 +1,28 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +set CLASS=org.apache.hadoop.hive.cli.RCFileCat +set HIVE_OPTS= + +if [%1]==[rcfilecat_help] goto :rcfilecat_help + +:rcfilecat + call %HIVE_BIN_PATH%\ext\util\execHiveCmd.cmd %CLASS% +goto :EOF + +:rcfilecat_help + echo "usage ./hive rcfilecat [--start='startoffset'] [--length='len'] " +goto :EOF \ No newline at end of file diff --git bin/ext/util/execHiveCmd.cmd bin/ext/util/execHiveCmd.cmd new file mode 100644 index 0000000..beeffa1 --- /dev/null +++ bin/ext/util/execHiveCmd.cmd @@ -0,0 +1,24 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +if [%1]==[] ( + echo "No class set to run. Please specify the class to run." + exit /b 1 +) +set CLASS=%1 +@rem hadoop 20 or newer - skip the aux_jars option. picked up from hiveconf +call %HADOOP% jar %JAR% %CLASS% %HIVE_OPTS% %HIVEARGS% +goto :EOF \ No newline at end of file diff --git bin/hive-config.cmd bin/hive-config.cmd new file mode 100644 index 0000000..9033a1b --- /dev/null +++ bin/hive-config.cmd @@ -0,0 +1,61 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + + +@rem processes --config and --auxpath option from command line + +if defined HIVE_HOME goto :DoneSetHiveHome +set HIVE_HOME=%~dp0 +for %%i in (%HIVE_HOME%.) do ( + set HIVE_HOME=%%~dpi +) + +if "%HIVE_HOME:~-1%" == "\" ( + set HIVE_HOME=%HIVE_HOME:~0,-1% +) + +:DoneSetHiveHome +set HIVE_CONF_DIR= +rem set HIVE_AUX_JARS_PATH= +:Loop + if [%1]==[] GOTO :FinishLoop + + if [%1]==[--config] ( + goto :SetConfig + ) + + if [%1]==[--auxpath] ( + goto :SetAux + ) + + @rem current argument does not match any aux params, finish loop here + goto :FinishLoop + SHIFT + GOTO Loop + + :SetConfig + set HIVE_CONF_DIR=%2 + shift + shift + goto :Loop + + :SetAux + set HIVE_AUX_JARS_PATH=%2 + shift + shift + goto :Loop + +:FinishLoop \ No newline at end of file diff --git bin/hive.cmd bin/hive.cmd new file mode 100644 index 0000000..c3f4fd6 --- /dev/null +++ bin/hive.cmd @@ -0,0 +1,351 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +SetLocal EnableDelayedExpansion + +@rem Set the path + +if not defined HIVE_BIN_PATH ( + set HIVE_BIN_PATH=%~dp0 +) + +if "%HIVE_BIN_PATH:~-1%" == "\" ( + set HIVE_BIN_PATH=%HIVE_BIN_PATH:~0,-1% +) + + +set HIVE_CONFIG_SCRIPT=%HIVE_BIN_PATH%\hive-config.cmd + +if exist %HIVE_CONFIG_SCRIPT% ( + CALL %HIVE_CONFIG_SCRIPT% %* +) + +set SERVICE= +set HELP= +set CATSERVICE= +set DEBUG= +set CURRENTARG= +set HIVEARGS= +rem set AUX_CLASSPATH= +set AUX_PARAM= + + +@rem parse the command line arguments +:ProcessCmdLine + if [%1]==[] goto :FinishArgs + + set temp=%1 + set temp=%temp:~0, 7% + + if %temp%==--debug ( + set DEBUG=%* + shift + goto :ProcessCmdLine + ) + + if %1==--config ( + shift + shift + goto :ProcessCmdLine + ) + + if %1==--auxpath ( + shift + shift + goto :ProcessCmdLine + ) + + if %1==--service ( + set SERVICE=%2 + + if [%3]==[catservicexml] ( + set CATSERVICE=_catservice + shift + ) + shift + shift + goto :ProcessCmdLine + ) + + if %1==--rcfilecat ( + set SERVICE=rcfilecat + shift + goto :ProcessCmdLine + ) + + if %1==--orcfiledump ( + set SERVICE=orcfiledump + shift + goto :ProcessCmdLine + ) + + if %1==--help ( + set HELP=_help + shift + goto :ProcessCmdLine + ) + + @rem parameter at %1 does not match any option, these are optional params + goto :FinishArgs +:FinishArgs + +if defined DEBUG ( + if defined HELP ( + call %HIVE_BIN_PATH%\ext\debug.cmd HELP + goto :EOF + ) + + call %HIVE_BIN_PATH%\ext\debug.cmd %DEBUG% +) + +if defined HIVE_MAIN_CLIENT_DEBUG_OPTS ( + set HADOOP_CLIENT_OPTS=%HADOOP_CLIENT_OPTS% %HIVE_MAIN_CLIENT_DEBUG_OPTS% + set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS% +) + +if not [%1]==[] ( + set CURRENTARG=%1 + call :MakeHiveArgs %* +) + +if not defined SERVICE ( + if defined HELP ( + set SERVICE=help + ) else ( + set SERVICE=cli + ) +) + +if not defined HIVE_HOME ( + echo "HIVE_HOME needs to be defined to point at the root of the hive install" + exit /b 1 +) + +if not defined HIVE_CONF_DIR ( + set HIVE_CONF_DIR=%HIVE_HOME%\conf +) + +if exist %HIVE_CONF_DIR%/hive-env.cmd CALL %HIVE_CONF_DIR%/hive-env.cmd + +@rem sort out classpath and make sure dependencies exist +set CLASSPATH=%HIVE_CONF_DIR% + +set HIVE_LIB=%HIVE_HOME%\lib + +@rem needed for execution +if not exist %HIVE_LIB%\hive-exec-*.jar ( + echo "Missing Hive Execution Jar: %HIVE_LIB%/hive-exec-*.jar" + exit /b 1 +) + +if not exist %HIVE_LIB%\hive-builtins-*.jar ( + echo "Missing Hive Builtins Jar: ${HIVE_LIB}/hive-builtins-*.jar" + exit /b 1 +) + +if not exist %HIVE_LIB%\hive-metastore-*.jar ( + echo "Missing Hive MetaStore Jar" + exit /b 1 +) + +@rem cli specific code +if not exist %HIVE_LIB%\hive-cli-*.jar ( + echo "Missing Hive CLI Jar" + exit /b 1 +) + +set CLASSPATH=%CLASSPATH%;%HIVE_LIB%\* + +@rem maybe we should just make users set HADOOP_HOME env variable as a prereq +@rem in the next iteration, use "where" command to find directory of hadoop install from path +if not defined HADOOP_HOME ( + echo "HADOOP_HOME needs to be defined to point at the hadoop installation" + exit /b 1 +) + +@rem supress the HADOOP_HOME warnings in 1.x.x +set HADOOP_HOME_WARN_SUPPRESS=true + +set HADOOP=%HADOOP_HOME%\bin\hadoop.cmd +if not exist %HADOOP% ( + echo "Missing hadoop installation: %HADOOP_HOME% must be set" + exit /b 1 +) + +@rem can only run against hadoop 1.0.0 as prereq for this iteration - can't figure out the regex/awk script to determine compatibility + +@rem add auxilary jars such as serdes +if not defined HIVE_AUX_JARS_PATH goto :AddAuxLibDir +setLocal EnableDelayedExpansion +:auxJarLoop + for /f "delims=," %%a in ("!HIVE_AUX_JARS_PATH!") do ( + set auxjar=%%a + if exist %%a ( + if exist "%%a" ( + @rem %%a is a dir + pushd %%a + for /f %%b IN ('dir /b *.jar') do ( + set AUX_CLASSPATH=!AUX_CLASSPATH!;%%a\%%b + call :AddToAuxParam %%a\%%b + ) + popd + ) else ( + @rem %%a is a file + set AUX_CLASSPATH=!AUX_CLASSPATH!;%%a + call :AddToAuxParam %%a + ) + ) + ) + :striploop + set stripchar=!HIVE_AUX_JARS_PATH:~0,1! + set HIVE_AUX_JARS_PATH=!HIVE_AUX_JARS_PATH:~1! + if "!HIVE_AUX_JARS_PATH!" EQU "" goto auxJarLoopEnd + if "!stripchar!" NEQ "," goto striploop + goto auxJarLoop + +:auxJarLoopEnd + +if defined HIVE_AUX_JARS_PATH ( + echo "setting aux param %HIVE_AUX_JARS_PATH%" + set AUX_CLASSPATH=%HIVE_AUX_JARS_PATH% + set AUX_PARAM=file://%HIVE_AUX_JARS_PATH% +) + + +:AddAuxLibDir +@rem adding jars from auxlib directory +if exist %HIVE_HOME%\auxlib ( + pushd %HIVE_HOME%\auxlib + for /f %%a IN ('dir /b *.jar') do ( + set AUX_CLASSPATH=%AUX_CLASSPATH%;%%a + call :AddToAuxParam %%a + ) + popd +) + +@rem pass classpath to hadoop +set HADOOP_CLASSPATH=%HADOOP_CLASSPATH%;%CLASSPATH%;%AUX_CLASSPATH% + +if defined AUX_PARAM ( + set HIVE_OPTS=%HIVE_OPTS% -hiveconf hive.aux.jars.path="%AUX_PARAM%" + set AUX_JARS_CMD_LINE="-libjars %AUX_PARAM%" +) + +@rem Get ready to run the services +set SERVICE_COUNT=0 +set TORUN="" +call :AddServices +For /L %%i in (1,1,%SERVICE_COUNT%) do ( + if "%SERVICE%" == "!VAR%%i!" ( + set TORUN=!VAR%%i! + ) +) + +if %TORUN% == "" ( + echo "Service %SERVICE% not available" + exit /b 1 +) + + +if defined HELP ( + call %HIVE_BIN_PATH%\ext\%TORUN%.cmd %TORUN%%HELP% %* + goto :EOF +) + +@rem generate xml for the service, also append hadoop dependencies to the classpath +if defined CATSERVICE ( + call %HADOOP_HOME%\bin\hadoop-config.cmd + call %HIVE_BIN_PATH%\ext\%TORUN%.cmd %TORUN%%CATSERVICE% %* + goto :EOF +) + +call %HIVE_BIN_PATH%\ext\%TORUN%.cmd %TORUN% %* + +goto :EOF +@rem done body of script + + +@rem start utility functions here + +@rem strip off preceding arguments like --service so that subsequent args can be passed on +:MakeHiveArgs + set _count=0 + set _shift=1 + set HIVEARGS= + + if not defined CURRENTARG ( + goto :EndLoop + ) + :HiveArgsLoop + if [%1]==[] ( + goto :EndLoop + ) + if not %1==%CURRENTARG% ( + shift + goto :HiveArgsLoop + ) + + if not defined HIVEARGS ( + set HIVEARGS=%1 + ) else ( + set HIVEARGS=%HIVEARGS% %1 + ) + shift + set CURRENTARG=%1 + goto :HiveArgsLoop + :EndLoop +goto :EOF + + @rem makes list of available services +:AddServices + set /a SERVICE_COUNT = %SERVICE_COUNT% + 1 + set VAR%SERVICE_COUNT%=cli + + set /a SERVICE_COUNT = %SERVICE_COUNT% + 1 + set VAR%SERVICE_COUNT%=help + + set /a SERVICE_COUNT = %SERVICE_COUNT% + 1 + set VAR%SERVICE_COUNT%=hiveserver + + set /a SERVICE_COUNT = %SERVICE_COUNT% + 1 + set VAR%SERVICE_COUNT%=hiveserver2 + + set /a SERVICE_COUNT = %SERVICE_COUNT% + 1 + set VAR%SERVICE_COUNT%=hwi + + set /a SERVICE_COUNT = %SERVICE_COUNT% + 1 + set VAR%SERVICE_COUNT%=jar + + set /a SERVICE_COUNT = %SERVICE_COUNT% + 1 + set VAR%SERVICE_COUNT%=lineage + + set /a SERVICE_COUNT = %SERVICE_COUNT% + 1 + set VAR%SERVICE_COUNT%=metastore + + set /a SERVICE_COUNT = %SERVICE_COUNT% + 1 + set VAR%SERVICE_COUNT%=rcfilecat + + set /a SERVICE_COUNT = %SERVICE_COUNT% + 1 + set VAR%SERVICE_COUNT%=orcfiledump +goto :EOF + +:AddToAuxParam +if not defined AUX_PARAM ( + set AUX_PARAM=file:///%1 + ) else ( + set AUX_PARAM=%AUX_PARAM%,file:///%1 + ) +) +goto :EOF diff --git bin/init-hive-dfs.cmd bin/init-hive-dfs.cmd new file mode 100644 index 0000000..a059634 --- /dev/null +++ bin/init-hive-dfs.cmd @@ -0,0 +1,85 @@ +@echo off +@rem Licensed to the Apache Software Foundation (ASF) under one or more +@rem contributor license agreements. See the NOTICE file distributed with +@rem this work for additional information regarding copyright ownership. +@rem The ASF licenses this file to You under the Apache License, Version 2.0 +@rem (the "License"); you may not use this file except in compliance with +@rem the License. You 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 implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. + +set DEFAULT_WAREHOUSE_DIR=/user/hive/warehouse +set DEFAULT_TMP_DIR=/tmp + +set WAREHOUSE_DIR=%DEFAULT_WAREHOUSE_DIR% +set TMP_DIR=%DEFAULT_TMP_DIR% +set HELP= +set SCRIPT_NAME=%0 + +@rem parse the command line arguments +:ProcessCmdLine + if [%1]==[] goto :FinishArgs + + if %1==--warehouse-dir ( + set WAREHOUSE_DIR=%2 + shift + shift + goto :ProcessCmdLine + ) + + if %1==--tmp-dir ( + set TMP_DIR=%2 + shift + shift + goto :ProcessCmdLine + ) + + if %1==--help ( + set HELP=_help + shift + goto :ProcessCmdLine + ) + + @rem parameter at %1 does not match any option + echo Invalid parameter: %1 + set HELP=_help + goto :FinishArgs +:FinishArgs + +if defined HELP ( + echo Usage %SCRIPT_NAME% [--warehouse-dir ] [--tmp-dir ] + echo Default value of warehouse directory is: [%DEFAULT_WAREHOUSE_DIR%] + echo Default value of the temporary directory is: [%DEFAULT_TMP_DIR%] + exit /b 1 +) + +if not defined HADOOP_HOME ( + echo HADOOP_HOME needs to be defined to point at the hadoop installation + exit /b 1 +) + +set HADOOP_EXEC=%HADOOP_HOME%\bin\hadoop.cmd +if not exist %HADOOP_EXEC% ( + echo Missing hadoop installation: HADOOP_HOME must be set + exit /b 1 +) + +cmd /C %HADOOP_EXEC% fs -mkdir %TMP_DIR% > /NUL 2>&1 +echo Setting writeable group rights for directory [%TMP_DIR%] +cmd /C %HADOOP_EXEC% fs -chmod g+w %TMP_DIR% +cmd /C %HADOOP_EXEC% fs -mkdir %WAREHOUSE_DIR% > /NUL 2>&1 +echo Setting writeable group rights for directory [%WAREHOUSE_DIR%] +cmd /C %HADOOP_EXEC% fs -chmod g+w %WAREHOUSE_DIR% + +echo Initialization done. +echo Please, do not forget to set the following configuration properties in hive-site.xml: +echo hive.metastore.warehouse.dir=%WAREHOUSE_DIR% +echo hive.exec.scratchdir=%TMP_DIR% + +goto :EOF