Skip to content

Commit f70555e

Browse files
committed
feat(hbase): provision hbase-entrypoint.sh
1 parent d3231ba commit f70555e

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

hbase/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-builder /stackable/jmx /stacka
318318

319319
COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-operator-tools-builder /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS} /stackable/hbase-operator-tools-${HBASE_OPERATOR_TOOLS}/
320320
COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-operator-tools-builder /stackable/bin/hbck2 /stackable/bin/hbck2
321+
COPY --chown=${STACKABLE_USER_UID}:0 --from=hbase-operator-tools-builder /stackable/bin/hbase-entrypoint.sh /stackable/hbase-${PRODUCT}/bin/hbase-entrypoint.sh
321322

322323
COPY --chown=${STACKABLE_USER_UID}:0 --from=phoenix-builder /stackable/phoenix /stackable/phoenix/
323324

@@ -367,4 +368,4 @@ ENV PATH="${PATH}:/stackable/bin:/stackable/hbase/bin"
367368
ENV ASYNC_PROFILER_HOME=/stackable/async-profiler
368369

369370
WORKDIR /stackable/hbase
370-
CMD ["./bin/hbase", "master", "start" ]
371+
CMD ["./bin/hbase-entrypoint", "master", "localhost", "16010" ]
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Entrypoint for HBase that ensures services are shutdown gracefuly
4+
#
5+
set -x
6+
set -euo pipefail
7+
8+
HBASE_ROLE_NAME="$1"
9+
HBASE_ROLE_SERVICE_NAME="$2"
10+
HBASE_ROLE_SERVICE_PORT="$3"
11+
12+
# TODO: remove hard coded svc.cluster.local
13+
HBASE_ROLE_SERVICE_HOST="${HOSTNAME}.${HBASE_ROLE_SERVICE_NAME}.${NAMESPACE}.svc.cluster.local"
14+
15+
REGION_MOVER_OPTS="--regionserverhost ${HBASE_ROLE_SERVICE_HOST}:${HBASE_ROLE_SERVICE_PORT} --operation unload ${REGION_MOVER_OPTS}"
16+
17+
prepare_signal_handlers() {
18+
unset term_child_pid
19+
unset term_kill_needed
20+
trap handle_term_signal TERM
21+
}
22+
23+
handle_term_signal() {
24+
if [ "${term_child_pid}" ]; then
25+
if [ "regionserver" == "${HBASE_ROLE_NAME}" ]; then
26+
echo "Running pre-shutdown command: /stackable/hbase/bin/hbase org.apache.hadoop.hbase.util.RegionMover ${REGION_MOVER_OPTS}"
27+
/stackable/hbase/bin/hbase org.apache.hadoop.hbase.util.RegionMover "${REGION_MOVER_OPTS}"
28+
echo "Done pre-shutdown command"
29+
fi
30+
kill -TERM "${term_child_pid}" 2>/dev/null
31+
else
32+
term_kill_needed='yes'
33+
fi
34+
}
35+
36+
wait_for_termination() {
37+
set +e
38+
term_child_pid=$1
39+
if [[ -v term_kill_needed ]]; then
40+
kill -TERM "${term_child_pid}" 2>/dev/null
41+
fi
42+
wait "${term_child_pid}" 2>/dev/null
43+
trap - TERM
44+
wait "${term_child_pid}" 2>/dev/null
45+
set -e
46+
}
47+
48+
# ##################################################################################################
49+
# main
50+
# ##################################################################################################
51+
mkdir -p /stackable/conf
52+
cp /stackable/tmp/hdfs/hdfs-site.xml /stackable/conf
53+
cp /stackable/tmp/hdfs/core-site.xml /stackable/conf
54+
cp /stackable/tmp/hbase/* /stackable/conf
55+
cp /stackable/tmp/log_config/log4j.properties /stackable/conf
56+
57+
rm -f /stackable/log/_vector/shutdown
58+
prepare_signal_handlers
59+
/stackable/hbase/bin/hbase "${HBASE_ROLE_NAME}" start &
60+
wait_for_termination $!
61+
mkdir -p /stackable/log/_vector && touch /stackable/log/_vector/shutdown

0 commit comments

Comments
 (0)