Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Post start #42

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion dockerization/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ RUN chmod +x /opt/drill/bin/*
RUN chown drill:drill /tmp/drill
RUN chmod 700 /tmp/drill

RUN paxctl -c /usr/lib/jvm/java-8-oracle/jre/bin/java && paxctl -m /usr/lib/jvm/java-8-oracle/jre/bin/java
RUN paxctl -c /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java && paxctl -m /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

COPY files/drill_ddl.sql /
COPY files/test.sql /tmp/
COPY files/post-start.sh /
COPY files/docker-entrypoint.sh /
COPY files/wait-for.sh /

COPY files/version.sh /version.sh
RUN ln -s /version.sh /usr/bin/version
RUN ln -s /post-start.sh /usr/bin/post-start
RUN ln -s /wait-for.sh /usr/bin/wait-for

USER drill
CMD ["/docker-entrypoint.sh"]
Expand Down
42 changes: 42 additions & 0 deletions dockerization/files/post-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

readonly HOSTNAME=$(hostname)
readonly PORT=8047

echo "INFO: waiting for Drill Java initialization."
echo "INFO: Checking if Drill is up ..."
wait-for "$HOSTNAME" "$PORT" || exit 1

chown drill:drill /tmp/drill/ -R

echo "INFO: configuring DFS storage inside Apache Drill container."
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"name\":\"dfs\",\"config\":{\"type\":\"file\",\"enabled\":true,\"connection\":\"file:///\",\"workspaces\":{\"root\":{\"location\":\"/\",\"writable\":false,\"defaultInputFormat\":null},\"tmp\":{\"location\":\"/tmp\",\"writable\":true,\"defaultIn putFormat\":null},\"views\":{\"location\":\"/data\",\"writable\":true,\"defaultInputFormat\":null},\"parquet\":{\"location\":\"/mnt/backup\",\"writable\":true,\"defaultInputFormat\":null}},\"formats\":{\"psv\":{\"type\":\"text\",\"extensions\":[\"tbl\"],\"delimiter\":\"|\"},\"csv\":{\"type\":\"text\",\"extensions\":[\"csv\"],\"delimiter\":\",\"},\"tsv\":{\"type\":\"text\",\"extensions\":[\"tsv\"],\"delimiter\":\"\\t\"},\"parquet\":{\"type\":\"parquet\"},\"json\":{\"type\":\"json\",\"extensions\":[\"json\"]},\"avro\":{\"type\":\"avro\"},\"sequencefile\":{\"type\":\"sequencefile\",\"extensions\":[\"seq\"]},\"csvh\":{\"type\":\"text\",\"extensions\":[\"csvh\"],\"extractHeader\":\"true\",\"delimiter\":\",\"}}}}" \
${DRILL_CONFIG_URL}/storage/dfs.json

echo "INFO: configuring Kudu storage inside Apache Drill container."
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"name\":\"kudu\", \"config\": {\"type\": \"kudu\", \"masterAddresses\": \"${KUDU_MASTER_INT_IP}\", \"operationTimeoutMs\": \"600000\", \"optimizerMaxNonPrimaryKeyAlternatives\": \"20\", \"allUnsignedINT8\": true, \"allUnsignedINT16\": true, \"enabled\": \"true\"}}" \
${DRILL_CONFIG_URL}/storage/kudu.json

echo "INFO: configuring Netdisco storage inside Apache Drill container."
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"name\":\"netdisco\", \"config\": {\"type\": \"jdbc\", \"url\": \"jdbc:postgresql://${NETDISCO_DB_HOST}:${NETDISCO_DB_PORT}/${NETDISCO_DB_NAME}\", \"driver\": \"org.postgresql.Driver\", \"username\": \"${NETDISCO_DB_USER}\", \"password\": \"${NETDISCO_DB_PASS}\", \"enabled\": \"true\"}}" \
${DRILL_CONFIG_URL}/storage/netdisco.json

echo "INFO: enabling multithreading in Drill queries."
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"queryType\":\"SQL\",\"query\":\"ALTER SYSTEM SET planner.slice_target = 1000\"}" \
${DRILL_CONFIG_URL}/query.json

echo "INFO: enabling fallback for hash aggregations."
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"queryType\":\"SQL\",\"query\":\"ALERT SYSTEM SET \`drill.exec.hashagg.fallback.enabled\` = true\"}" \
${DRILL_CONFIG_URL}/query.json

echo "INFO: Drill container started."
28 changes: 28 additions & 0 deletions dockerization/files/wait-for.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

HOST=$1
PORT=$2
STARTUP_TIMEOUT=$3

TIMEOUT=${STARTUP_TIMEOUT:-30}
SLEEP_TIME=1

printf "Waiting for ${HOST}:${PORT} to be accessible..."

counter=0
result="1"
while [ "$result" != 200 ]; do
result=$(curl -s -o /dev/null -w "%{http_code}" ${DRILL_CONFIG_URL}/storage/dfs.json)

counter=$[$counter + $SLEEP_TIME]
if [ $counter -gt $TIMEOUT ]; then
printf " FAIL\n"
echo "The service ${HOST}:${PORT} is not accessible after ${TIMEOUT} sec timeout. Exiting."
exit 1
fi
[[ "$result" != 200 ]] && sleep $SLEEP_TIME;
printf "%s" "." ;
done
printf " OK\n"

exit 0