nrg4878 commented on code in PR #3386:
URL: https://github.com/apache/hive/pull/3386#discussion_r907965147
##########
bin/ext/hiveserver2.sh:
##########
@@ -16,24 +16,83 @@
THISSERVICE=hiveserver2
export SERVICE_LIST="${SERVICE_LIST}${THISSERVICE} "
+if [ "$HIVESERVER2_PID_DIR" = "" ]; then
+ HIVESERVER2_PID_DIR=$HIVE_CONF_DIR
+fi
+
+HIVESERVER2_PID=$HIVESERVER2_PID_DIR/hiveserver2.pid
+
+before_start() {
+ #ckeck if the process is not running
+ mkdir -p "$HIVESERVER2_PID_DIR"
+ if [ -f $HIVESERVER2_PID ]; then
+ if kill -0 $(cat $HIVESERVER2_PID) >/dev/null 2>&1; then
+ echo "HiveServer2 running as process $(cat $HIVESERVER2_PID). Stop it
first."
+ exit 1
+ fi
+ fi
+}
+
hiveserver2() {
- >&2 echo "$(timestamp): Starting HiveServer2"
- CLASS=org.apache.hive.service.server.HiveServer2
- if $cygwin; then
- HIVE_LIB=`cygpath -w "$HIVE_LIB"`
+ if [ "$1" = "--graceful_stop" ]; then
+ pid=$2
+ if [ "$pid" = "" -a -f $HIVESERVER2_PID ]; then
+ pid=$(cat $HIVESERVER2_PID)
+ fi
+ if [ "$pid" != "" ]; then
+ timeout=$3
+ killAndWait $pid ${timeout:-1800}
Review Comment:
timeout is hardcoded here. I think it should be better to pick this up from
the hive-site.xml for HS2. Not sure how we could do that.
##########
bin/ext/hiveserver2.sh:
##########
@@ -16,24 +16,83 @@
THISSERVICE=hiveserver2
export SERVICE_LIST="${SERVICE_LIST}${THISSERVICE} "
+if [ "$HIVESERVER2_PID_DIR" = "" ]; then
+ HIVESERVER2_PID_DIR=$HIVE_CONF_DIR
+fi
+
+HIVESERVER2_PID=$HIVESERVER2_PID_DIR/hiveserver2.pid
+
+before_start() {
+ #ckeck if the process is not running
+ mkdir -p "$HIVESERVER2_PID_DIR"
+ if [ -f $HIVESERVER2_PID ]; then
+ if kill -0 $(cat $HIVESERVER2_PID) >/dev/null 2>&1; then
+ echo "HiveServer2 running as process $(cat $HIVESERVER2_PID). Stop it
first."
+ exit 1
+ fi
+ fi
+}
+
hiveserver2() {
- >&2 echo "$(timestamp): Starting HiveServer2"
- CLASS=org.apache.hive.service.server.HiveServer2
- if $cygwin; then
- HIVE_LIB=`cygpath -w "$HIVE_LIB"`
+ if [ "$1" = "--graceful_stop" ]; then
+ pid=$2
+ if [ "$pid" = "" -a -f $HIVESERVER2_PID ]; then
+ pid=$(cat $HIVESERVER2_PID)
+ fi
+ if [ "$pid" != "" ]; then
+ timeout=$3
+ killAndWait $pid ${timeout:-1800}
+ fi
+ else
+ before_start
+ echo >&2 "$(timestamp): Starting HiveServer2"
+ CLASS=org.apache.hive.service.server.HiveServer2
+ if $cygwin; then
+ HIVE_LIB=$(cygpath -w "$HIVE_LIB")
+ fi
+ JAR=${HIVE_LIB}/hive-service-[0-9].*.jar
+
+ export HADOOP_CLIENT_OPTS=" -Dproc_hiveserver2 $HADOOP_CLIENT_OPTS "
+ export HADOOP_OPTS="$HIVESERVER2_HADOOP_OPTS $HADOOP_OPTS"
+ hiveserver2_pid="$$"
Review Comment:
so this would be the PID of the current shell script that starts HS2 right?
At this point, we havent launched the HS2 process yet. Dont we need the PID of
HS2 process? if so, should HS2 write this file? also, what happens when there
are multiple HS2 instances?
##########
service/src/java/org/apache/hive/service/cli/operation/OperationManager.java:
##########
@@ -106,58 +114,64 @@ public ExecuteStatementOperation
newExecuteStatementOperation(HiveSession parent
return executeStatementOperation;
}
- public GetTypeInfoOperation newGetTypeInfoOperation(HiveSession
parentSession) {
+ public GetTypeInfoOperation newGetTypeInfoOperation(HiveSession
parentSession)
+ throws HiveSQLException {
Review Comment:
Should we create a new exception type that more indicative of the state of
HS2?
##########
service/src/java/org/apache/hive/service/Service.java:
##########
@@ -63,6 +68,15 @@ public enum STATE {
*/
void start();
+ /**
+ * Shut down the service properly before stopping
Review Comment:
can you add more detailed comment on what happens when this method is called
and how it works?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]