This is an automated email from the ASF dual-hosted git repository.

stigahuang pushed a commit to branch branch-3.4.2
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 63bc975e03aa61649760a1cb47eae80982ffb767
Author: Xiang Yang <[email protected]>
AuthorDate: Thu Jan 18 16:08:07 2024 +0000

    IMPALA-12362: (part-1/4) Refactor service management scripts.
    
    Uniform all service management scripts to 'bin/impala.sh', administrator
    can customize environment variables based on their cluster at
    'conf/impala-env.sh', as well as set flags at 'conf/impalad_flags...'.
    
    Usually administrator can override the environment variables in
    'conf/impala-env.sh' with commandline arguments.  The same is true for
    flags in 'conf/impalad_flags...'. This flexibility can be used in
    scenarios such as supporting multi-instance deployments.
    
    The directory structure has been adjusted as follows:
     - put java libs to 'lib/jars' directory.
     - put native libs to 'lib/native' directory.
     - put impalad binary to 'sbin' directory.
    
    Testing:
     - Manually deploy packages on Ubuntu22.04 and verify it.
    
    Backport Notes:
     - Resolved trivial conflicts in CMakeLists.txt
    
    Change-Id: I8f4dcad9cfa12d351d562e7ef8c0a8957d3ca147
    Reviewed-on: http://gerrit.cloudera.org:8080/20921
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
    Reviewed-on: http://gerrit.cloudera.org:8080/21263
    Reviewed-by: Xiang Yang <[email protected]>
    Reviewed-by: Zihao Ye <[email protected]>
    Tested-by: Quanlong Huang <[email protected]>
---
 CMakeLists.txt                                     |  12 +-
 be/src/service/CMakeLists.txt                      |   6 +-
 package/bin/impala-env.sh                          |  85 -------
 package/bin/impala.sh                              | 271 +++++++++++++++++++++
 package/bin/start-catalogd.sh                      |  38 ---
 package/bin/start-impalad.sh                       |  49 ----
 package/bin/stop-catalogd.sh                       |  23 --
 package/bin/stop-impalad.sh                        |  23 --
 package/bin/stop-statestored.sh                    |  23 --
 package/conf/catalogd_flags                        |   1 -
 .../start-statestored.sh => conf/impala-env.sh}    |  36 +--
 package/conf/impalad_flags                         |   1 -
 .../conf/{statestore_flags => statestored_flags}   |   1 -
 13 files changed, 301 insertions(+), 268 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 69b5a64f2..5ad23838e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -421,23 +421,23 @@ add_subdirectory(query-event-hook-api)
 
 install(DIRECTORY "www/" DESTINATION ${IMPALA_INSTALLDIR}/www)
 install(FILES fe/target/impala-frontend-$ENV{IMPALA_VERSION}.jar
-  DESTINATION ${IMPALA_INSTALLDIR}/jar)
+  DESTINATION ${IMPALA_INSTALLDIR}/lib/jars)
 
 FILE(GLOB gcc_lib ${GCC_ROOT}/lib64/libgcc_s.so.1*)
-install(FILES ${gcc_lib} DESTINATION ${IMPALA_INSTALLDIR}/lib)
+install(FILES ${gcc_lib} DESTINATION ${IMPALA_INSTALLDIR}/lib/native)
 
 FILE(GLOB cpp_lib ${GCC_ROOT}/lib64/libstdc++.so.6*)
-install(FILES ${cpp_lib} DESTINATION ${IMPALA_INSTALLDIR}/lib)
+install(FILES ${cpp_lib} DESTINATION ${IMPALA_INSTALLDIR}/lib/native)
 
 set(KUDU_HOME $ENV{IMPALA_TOOLCHAIN}/kudu-$ENV{IMPALA_KUDU_VERSION}/release)
 # The parent folder is lib64 on centos/redhat, while on ubuntu it's lib.
 FILE(GLOB kudu_lib ${KUDU_HOME}/lib*/libkudu_client.so*)
-install(FILES ${kudu_lib} DESTINATION ${IMPALA_INSTALLDIR}/lib)
+install(FILES ${kudu_lib} DESTINATION ${IMPALA_INSTALLDIR}/lib/native)
 
 FILE(GLOB hadoop_lib $ENV{HADOOP_LIB_DIR}/native/libhadoop.so*)
-install(FILES ${hadoop_lib} DESTINATION ${IMPALA_INSTALLDIR}/lib)
+install(FILES ${hadoop_lib} DESTINATION ${IMPALA_INSTALLDIR}/lib/native)
 
-install(DIRECTORY fe/target/dependency/ DESTINATION ${IMPALA_INSTALLDIR}/jar
+install(DIRECTORY fe/target/dependency/ DESTINATION 
${IMPALA_INSTALLDIR}/lib/jars
   FILES_MATCHING PATTERN "*.jar")
 
 install(DIRECTORY shell/build/impala-shell-$ENV{IMPALA_VERSION}/
diff --git a/be/src/service/CMakeLists.txt b/be/src/service/CMakeLists.txt
index 844b6587c..fc2b80a48 100644
--- a/be/src/service/CMakeLists.txt
+++ b/be/src/service/CMakeLists.txt
@@ -95,9 +95,9 @@ target_link_libraries(impalad
   ${IMPALA_LINK_LIBS}
 )
 
-install(FILES ${STATESTORED_SYMLINK} DESTINATION ${IMPALA_INSTALLDIR}/bin)
-install(FILES ${CATALOGD_SYMLINK} DESTINATION ${IMPALA_INSTALLDIR}/bin)
-install(TARGETS impalad DESTINATION ${IMPALA_INSTALLDIR}/bin)
+install(FILES ${STATESTORED_SYMLINK} DESTINATION ${IMPALA_INSTALLDIR}/sbin)
+install(FILES ${CATALOGD_SYMLINK} DESTINATION ${IMPALA_INSTALLDIR}/sbin)
+install(TARGETS impalad DESTINATION ${IMPALA_INSTALLDIR}/sbin)
 
 if (BUILD_WITH_NO_TESTS)
   return()
diff --git a/package/bin/impala-env.sh b/package/bin/impala-env.sh
deleted file mode 100644
index 3655ac6cf..000000000
--- a/package/bin/impala-env.sh
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/bin/bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-if [[ -z "$JAVA_HOME" ]]; then
-  echo "JAVA_HOME not set!"
-  exit 1
-fi
-
-echo "Using JAVA_HOME: $JAVA_HOME"
-LIB_JVM_DIR=$(dirname $(find $JAVA_HOME -type f -name libjvm.so))
-LIB_JSIG_DIR=$(dirname $(find $JAVA_HOME -type f -name libjsig.so))
-
-export LC_ALL=en_US.utf8
-export LD_LIBRARY_PATH="/opt/impala/lib/:$LIB_JVM_DIR:$LIB_JSIG_DIR"
-export CLASSPATH="/opt/impala/conf:/opt/impala/jar/*"
-
-#TODO: Add graceful shutdown for impalads
-function stop_process {
-  name=$1
-  pid_file="/tmp/${name}.pid"
-  if [[ -f $pid_file ]]; then
-    PID=$(cat $pid_file)
-    if ps $PID | grep $name; then
-      echo "Killing $name with PID=$PID"
-      kill $PID
-      rm $pid_file
-      echo "Killed $name"
-    else
-      rm $pid_file
-      echo "Already stopped: $name is not running with PID=$PID. Removed stale 
$pid_file"
-    fi
-  else
-    echo "PID file $pid_file not found!"
-  fi
-}
-
-function wait_for_ready {
-  name=$1
-  port=$2
-  pid=$3
-
-  NUM_WAIT_ITERATIONS=20
-  i=0
-  while [[ $i -lt $NUM_WAIT_ITERATIONS ]]; do
-    if ! ps $pid | grep $name > /dev/null 2>&1; then
-      echo "$name with PID $pid doesn't exist"
-      break
-    fi
-    STATUS=$(curl -s http://localhost:$port/healthz)
-    if [[ $? != 0 ]]; then
-      echo "Waiting for $name. Port $port not ready."
-    elif [[ "$STATUS" != "OK" ]]; then
-      echo "Waiting for $name to be ready"
-    else
-      echo "$name is ready"
-      break
-    fi
-    sleep 2
-    i=$((i+1))
-  done
-  if [[ "$STATUS" == "OK" ]]; then
-    echo "Launched $name with PID $pid"
-  elif [[ $i -eq $NUM_WAIT_ITERATIONS ]]; then
-    echo "Timed out waiting for $name to be ready. Check logs for more 
details."
-  else
-    echo "Failed to launch $name"
-    exit 1
-  fi
-}
diff --git a/package/bin/impala.sh b/package/bin/impala.sh
new file mode 100755
index 000000000..f480f5c24
--- /dev/null
+++ b/package/bin/impala.sh
@@ -0,0 +1,271 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# Script to manage Apache Impala services.
+# User can customize environment variables in '../conf/impala-env.sh'.
+# User can customize flags in '../conf/[impalad_flags...]', or override them in
+# commandline arguments when needed(e.g. multiple instance).
+#
+# To launch impalad using another username (e.g. "impala"):
+# sudo -E -u impala bin/impala.sh start impalad
+#
+# Note for setup:
+# Please set the correct JAVA_HOME in '../conf/impala-env.sh'.
+# Please set the correct hostnames in '../conf/[impalad_flags...]'.
+# Please modify core-site.xml, hdfs-site.xml, hive-site.xml in conf based on 
the cluster.
+set -euo pipefail
+
+init() {
+  : ${IMPALA_HOME:=$(cd $(dirname ${0})/..;pwd)}
+  export IMPALA_HOME
+  . ${IMPALA_HOME}/conf/impala-env.sh
+}
+
+check_counts() {
+  local counts=${1} period=${2}
+  [[ ${counts} =~ ^[0-9]+$ ]] || (echo "Invalid waiting counts:${counts}." && 
exit 1)
+  [[ ${period} =~ ^[1-9][0-9]*$ ]] || (echo "Invalid waiting 
period:${period}." && exit 1)
+}
+
+# Return 0 if service is running, else otherwise.
+status() {
+  local service=
+  while [[ $# -gt 0 ]]; do
+    case ${1} in
+      impalad|catalogd|statestored) service=${1} && shift && break ;;
+      *) usage && exit 1 ;;
+    esac
+  done
+  local service_pidfile_key=${service^^}_PIDFILE
+  local service_pidfile=${!service_pidfile_key}
+  if [[ ! -f ${service_pidfile} ]]; then
+    echo "${service} is stopped."
+    return 1
+  fi
+  local pid=$(cat ${service_pidfile})
+  if ps -p ${pid} -o comm=|grep ${service} &> /dev/null ; then
+    echo "${service} is running with PID ${pid}."
+    return 0
+  fi
+  echo "${service} is stopped."
+  return 1
+}
+
+# Return 0 if service is stopped in expected time, else otherwise.
+stop_await() {
+  local service=${1} service_pidfile=${2} counts=${3} period=${4}
+  [[ "${counts}" == "0" ]] && exit 0
+  for ((i=1; i<=${counts}; i++)); do
+    [[ ${i} -gt 1 ]] && sleep ${period}
+    if ! kill -0 ${pid} &> /dev/null; then
+      rm ${service_pidfile} && echo "(${i}/${counts}) ${service} is stopped." 
&& return 0
+    else
+      echo "(${i}/${counts}) Waiting ${service} to stop."
+    fi
+  done
+  return 1
+}
+
+#TODO: Add graceful shutdown for impalads
+stop() {
+  local service= counts=20 period=2
+  while [[ $# -gt 0 ]]; do
+    case ${1} in
+      -c) counts=${2} && shift 2 ;;
+      -p) period=${2} && shift 2 ;;
+      impalad|catalogd|statestored) service=${1} && shift && break ;;
+      *) usage && exit 1 ;;
+    esac
+  done
+  check_counts ${counts} ${period}
+  local service_pidfile_key=${service^^}_PIDFILE
+  local service_pidfile=${!service_pidfile_key}
+  if [[ ! -f ${service_pidfile} ]]; then
+    echo "Already stopped: PID file '${service_pidfile}' not found."
+    exit 0
+  fi
+  local pid=$(cat ${service_pidfile})
+  if ! ps -p ${pid} -o comm=|grep ${service} &> /dev/null ; then
+    rm ${service_pidfile}
+    echo "Already stopped: ${service} is not running with PID ${pid}." \
+    "Removed stale file '${service_pidfile}'."
+    exit 0
+  fi
+  echo "Killing ${service} with PID ${pid}."
+  kill ${pid}
+  if ! stop_await ${service} ${service_pidfile} ${counts} ${period}; then
+    echo "Timed out waiting ${service} to stop, check logs for more details."
+    exit 1
+  fi
+}
+
+prerun() {
+  local message=${1:-"on"}
+  : ${JAVA_HOME:?"JAVA_HOME must be set to the location of your JDK!"}
+  if [[ ${message} == "on" ]]; then
+    echo "Using JAVA_HOME: ${JAVA_HOME}"
+  fi
+  local lib_jvm_dir=$(dirname $(find ${JAVA_HOME} -type f -name libjvm.so | 
head -1))
+  local lib_jsig_dir=$(dirname $(find ${JAVA_HOME} -type f -name libjsig.so | 
head -1))
+  if [[ -n "${HADOOP_HOME:=}" ]]; then
+    : ${HADOOP_LIB_DIR:=${HADOOP_HOME}/lib/native}
+    if [[ ${message} == "on" ]]; then
+      echo "Using hadoop native libs in '${HADOOP_LIB_DIR}'"
+    fi
+  else
+    : ${HADOOP_LIB_DIR:=${IMPALA_HOME}/lib/native}
+    if [[ ${message} == "on" ]]; then
+      echo "HADOOP_HOME not set, using hadoop native libs in 
'${HADOOP_LIB_DIR}'"
+    fi
+  fi
+  export LIBHDFS_OPTS="${LIBHDFS_OPTS:=} -Djava.library.path=${HADOOP_LIB_DIR}"
+  export LC_ALL=en_US.utf8
+  export CLASSPATH="${CLASSPATH}:${IMPALA_HOME}/conf:${IMPALA_HOME}/lib/jars/*"
+  export 
LD_LIBRARY_PATH+=":${IMPALA_HOME}/lib/native:${lib_jvm_dir}:${lib_jsig_dir}"
+}
+
+start() {
+  prerun
+  local service= counts=20 period=2
+  while [[ $# -gt 0 ]]; do
+    case ${1} in
+      -c) counts=${2} && shift 2 ;;
+      -p) period=${2} && shift 2 ;;
+      impalad|catalogd|statestored) service=${1} && shift && break ;;
+      *) usage && exit 1 ;;
+    esac
+  done
+  check_counts ${counts} ${period}
+  status ${service} && exit 0
+  local service_flagfile=${IMPALA_HOME}/conf/${service}_flags
+  local service_pidfile_key=${service^^}_PIDFILE
+  local service_pidfile=${!service_pidfile_key}
+  mkdir -p $(dirname ${service_pidfile})
+  # User can override '--flagfile' in the following commandline arguments.
+  ${IMPALA_HOME}/sbin/${service} \
+    --flagfile=${service_flagfile} \
+    ${@} &
+  local pid=$!
+  echo ${pid} > ${service_pidfile}
+  # Sleep 1s so the glog output won't be messed up with waiting messages.
+  sleep 1
+  health -c ${counts} -p ${period} ${service}
+}
+
+restart() {
+  stop ${@} && start ${@}
+}
+
+health() {
+  local service= counts=20 period=2
+  while [[ $# -gt 0 ]]; do
+    case ${1} in
+      -c) counts=${2} && shift 2 ;;
+      -p) period=${2} && shift 2 ;;
+      impalad|catalogd|statestored) service=${1} && shift ;;
+      *) usage && exit 1 ;;
+    esac
+  done
+  check_counts ${counts} ${period}
+  [[ "${counts}" == "0" ]] && exit 0
+  status ${service} || exit 1
+  # Determine Web Server port
+  local service_flagfile=${IMPALA_HOME}/conf/${service}_flags
+  local service_pidfile_key=${service^^}_PIDFILE
+  local service_pidfile=${!service_pidfile_key}
+  local pid=$(cat ${service_pidfile})
+  local port=
+  if [[ $(ps --cols 10000 -o args= -p ${pid}) =~ -webserver_port=([0-9]+) ]]; 
then
+    port=${BASH_REMATCH[1]}
+  else
+    port=$(awk -F= '/-webserver_port=/ {print $2;}' ${service_flagfile})
+  fi
+  if [[ -z "${port}" ]]; then
+    case ${service} in
+      impalad) port=25000;;
+      catalogd) port=25020;;
+      statestored) port=25010;;
+    esac
+  fi
+  # Request healthz code
+  for ((i=1; i<=${counts}; i++)); do
+    [[ ${i} -gt 1 ]] && sleep ${period} || true
+    local code=$(curl -s http://localhost:${port}/healthz)
+    if [[ $? != 0 ]]; then
+      echo "(${i}/${counts}) ${service} on port ${port} is not ready."
+    elif [[ "${code}" != "OK" ]]; then
+      echo "(${i}/${counts}) Waiting for ${service} to be ready."
+    else
+      echo "(${i}/${counts}) ${service} is ready."
+      exit 0
+    fi
+  done
+  echo "Timed out waiting for ${service} to be ready, check logs for more 
details."
+  exit 1
+}
+
+usage() {
+  echo "Usage: $0 <command> [<options>] <service> [<flags>]"
+  echo "       $0 --version"
+  echo "       $0 --help"
+  echo "  command: {start|stop|restart|status|health}"
+  echo "  service: {impalad|catalogd|statestored}"
+  echo "  flags: in pattern '-key=val...'."
+  echo
+  echo "  start: start an Impala daemon service, wait until service is ready."
+  echo "    options:"
+  echo "      -c: maximum count of checks, defaults to 20."
+  echo "      -p: seconds of period between checks, defaults to 2."
+  echo
+  echo "  stop: stop an Impala daemon service, wait until service is stopped."
+  echo "    options:"
+  echo "      -c: maximum count of checks, defaults to 20."
+  echo "      -p: seconds of period between checks, defaults to 2."
+  echo
+  echo "  restart: restart an Impala daemon service."
+  echo "    options: same as start command."
+  echo
+  echo "  status: check the process status of an Impala daemon service."
+  echo
+  echo "  health: waiting until an Impala daemon service is ready."
+  echo "    options:"
+  echo "      -c: maximum count of checks, defaults to 20."
+  echo "      -p: seconds of period between checks, defaults to 2."
+}
+
+version() {
+    if init &> /dev/null && prerun off && ${IMPALA_HOME}/sbin/impalad 
--version ; then
+      exit 0
+    fi
+    echo "Failed to get version!"
+    exit 1
+}
+
+main() {
+  [[ $# -ge 1 && ${1} == "--help" ]] && usage && exit 0
+  [[ $# -ge 1 && ${1} == "--version" ]] && version && exit 0
+  [[ $# -lt 2 ]] && usage && exit 1
+  local command=${1}
+  case ${command} in
+    start|stop|restart|status|health) shift && init && ${command} $@ ;;
+    *) usage && exit 1 ;;
+  esac
+}
+
+main ${@}
diff --git a/package/bin/start-catalogd.sh b/package/bin/start-catalogd.sh
deleted file mode 100755
index 9b472fe60..000000000
--- a/package/bin/start-catalogd.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-# Script to launch catalogd. Required JAVA_HOME being set.
-# Edit conf/catalogd_flags to set the correct hostname and state_store_host.
-# Edit core-site.xml, hdfs-site.xml, hive-site.xml, etc. in conf based on the 
cluster.
-# Example usage:
-#   export JAVA_HOME=/usr/java/jdk1.8.0_232-cloudera
-#   bin/start-catalogd.sh
-# To launch catalogd using another username (e.g. "impala"):
-#   sudo -E -u impala bin/start-catalogd.sh
-
-echo "Using IMPALA_HOME: ${IMPALA_HOME:=/opt/impala}"
-source $IMPALA_HOME/bin/impala-env.sh
-$IMPALA_HOME/bin/catalogd --flagfile=$IMPALA_HOME/conf/catalogd_flags &
-PID=$!
-echo $PID > /tmp/catalogd.pid
-
-# Sleep 1s so the glog output won't be messed up with waiting messages
-sleep 1
-
-wait_for_ready catalogd 25020 $PID
diff --git a/package/bin/start-impalad.sh b/package/bin/start-impalad.sh
deleted file mode 100755
index 89ccbbd21..000000000
--- a/package/bin/start-impalad.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-# Script to launch impalad. Required JAVA_HOME being set.
-# Edit conf/impalad_flags to set the correct hostnames.
-# Edit core-site.xml, hdfs-site.xml, hive-site.xml, etc. in conf based on the 
cluster.
-# Example usage:
-#   export JAVA_HOME=/usr/java/jdk1.8.0_232-cloudera
-#   bin/start-impalad.sh
-# To launch impalad using another username (e.g. "impala"):
-#   sudo -E -u impala bin/start-impalad.sh
-
-echo "Using IMPALA_HOME: ${IMPALA_HOME:=/opt/impala}"
-source $IMPALA_HOME/bin/impala-env.sh
-
-if [[ -n "$HADOOP_HOME" ]]; then
-  echo "Using HADOOP_HOME: $HADOOP_HOME"
-  export HADOOP_LIB_DIR="${HADOOP_HOME}/lib"
-  export LIBHDFS_OPTS="${LIBHDFS_OPTS:-} 
-Djava.library.path=${HADOOP_LIB_DIR}/native/"
-  echo "Using hadoop native libs in ${HADOOP_LIB_DIR}/native/"
-else
-  export LIBHDFS_OPTS="${LIBHDFS_OPTS:-} 
-Djava.library.path=${IMPALA_HOME}/lib"
-  echo "HADOOP_HOME not set. Using hadoop native libs in ${IMPALA_HOME}/lib"
-fi
-
-$IMPALA_HOME/bin/impalad --flagfile=$IMPALA_HOME/conf/impalad_flags &
-PID=$!
-echo $PID > /tmp/impalad.pid
-
-# Sleep 1s so the glog output won't be messed up with waiting messages
-sleep 1
-
-wait_for_ready impalad 25000 $PID
diff --git a/package/bin/stop-catalogd.sh b/package/bin/stop-catalogd.sh
deleted file mode 100755
index 8649ed143..000000000
--- a/package/bin/stop-catalogd.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-echo "Using IMPALA_HOME: ${IMPALA_HOME:=/opt/impala}"
-source $IMPALA_HOME/bin/impala-env.sh
-
-stop_process catalogd
diff --git a/package/bin/stop-impalad.sh b/package/bin/stop-impalad.sh
deleted file mode 100755
index 4e323e889..000000000
--- a/package/bin/stop-impalad.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-echo "Using IMPALA_HOME: ${IMPALA_HOME:=/opt/impala}"
-source $IMPALA_HOME/bin/impala-env.sh
-
-stop_process impalad
diff --git a/package/bin/stop-statestored.sh b/package/bin/stop-statestored.sh
deleted file mode 100755
index e5aa9578d..000000000
--- a/package/bin/stop-statestored.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-echo "Using IMPALA_HOME: ${IMPALA_HOME:=/opt/impala}"
-source $IMPALA_HOME/bin/impala-env.sh
-
-stop_process statestored
diff --git a/package/conf/catalogd_flags b/package/conf/catalogd_flags
index 7b94816a2..bbbf580ae 100644
--- a/package/conf/catalogd_flags
+++ b/package/conf/catalogd_flags
@@ -6,7 +6,6 @@
 -log_filename=catalogd
 -state_store_port=24000
 -minidump_path=/var/log/impala-minidumps
--webserver_doc_root=/opt/impala
 -catalog_topic_mode=minimal
 -hms_event_polling_interval_s=0
 -v=1
diff --git a/package/bin/start-statestored.sh b/package/conf/impala-env.sh
old mode 100755
new mode 100644
similarity index 50%
rename from package/bin/start-statestored.sh
rename to package/conf/impala-env.sh
index e3c78cd34..c5bb78de6
--- a/package/bin/start-statestored.sh
+++ b/package/conf/impala-env.sh
@@ -17,21 +17,27 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-# Script to launch statestore. Required JAVA_HOME being set.
-# Edit conf/statestore_flags to set a correct hostname.
-# Example usage:
-#   export JAVA_HOME=/usr/java/jdk1.8.0_232-cloudera
-#   bin/start-statestored.sh
-# To launch statestore using another username (e.g. "impala"):
-#   sudo -E -u impala bin/start-statestored.sh
+# Specify default value for user-specific environment variables.
+# It's recommended to use a form that can be overridden from the command line, 
like
+# ': ${FOO:="bar"}', or 'export FOO=${FOO:-"bar"}' when the variable need to 
be exported.
 
-echo "Using IMPALA_HOME: ${IMPALA_HOME:=/opt/impala}"
-source $IMPALA_HOME/bin/impala-env.sh
-$IMPALA_HOME/bin/statestored --flagfile=$IMPALA_HOME/conf/statestore_flags &
-PID=$!
-echo $PID > /tmp/statestored.pid
+# Uncomment and modify next line to specify a valid JDK location.
+# : ${JAVA_HOME:="/usr/lib/jvm/java"}
 
-# Sleep 1s so the glog output won't be messed up with waiting messages
-sleep 1
+# Specify extra CLASSPATH.
+: ${CLASSPATH:=}
 
-wait_for_ready statestored 25010 $PID
+# Specify extra LD_LIBRARY_PATH.
+: ${LD_LIBRARY_PATH:=}
+
+# Uncomment next line to enable coredump.
+# ulimit -c unlimited
+
+# Specify JVM options.
+export JAVA_TOOL_OPTIONS=${JAVA_TOOL_OPTIONS:-}
+
+# Specify default pidfile directories.
+: ${IMPALAD_PIDFILE:="/tmp/impalad.pid"}
+: ${CATALOGD_PIDFILE:="/tmp/catalogd.pid"}
+: ${ADMISSIOND_PIDFILE:="/tmp/admissiond.pid"}
+: ${STATESTORED_PIDFILE:="/tmp/statestored.pid"}
diff --git a/package/conf/impalad_flags b/package/conf/impalad_flags
index 4c2dc3a92..6cd2a9d68 100644
--- a/package/conf/impalad_flags
+++ b/package/conf/impalad_flags
@@ -11,6 +11,5 @@
 -local_library_dir=/var/lib/impala/udfs
 -fair_scheduler_allocation_path=/opt/impala/conf/fair-scheduler.xml
 -llama_site_path=/opt/impala/conf/llama-site.xml
--webserver_doc_root=/opt/impala
 -v=1
 -max_log_size=200
diff --git a/package/conf/statestore_flags b/package/conf/statestored_flags
similarity index 81%
rename from package/conf/statestore_flags
rename to package/conf/statestored_flags
index 9e53d3a70..10b0e9870 100644
--- a/package/conf/statestore_flags
+++ b/package/conf/statestored_flags
@@ -2,6 +2,5 @@
 -log_dir=/var/log/statestore
 -log_filename=statestored
 -minidump_path=/var/log/impala-minidumps
--webserver_doc_root=/opt/impala
 -v=1
 -max_log_size=200

Reply via email to