2020-06-02 12:38:53 -04:00
|
|
|
#!/usr/bin/env 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.
|
|
|
|
|
2020-12-08 19:02:26 -05:00
|
|
|
|
2020-06-02 12:38:53 -04:00
|
|
|
# wait for hadoop namenode to be up
|
|
|
|
echo "Waiting for hadoop namenode to be up"
|
2020-12-15 02:08:50 -05:00
|
|
|
MAX_ITERATIONS=15
|
|
|
|
i=1
|
2020-06-02 12:38:53 -04:00
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -mkdir -p /druid"
|
2020-12-15 02:08:50 -05:00
|
|
|
while [ $? -ne 0 ] && [ $i -lt $MAX_ITERATIONS ]
|
2020-06-02 12:38:53 -04:00
|
|
|
do
|
|
|
|
sleep 2
|
2020-12-15 02:08:50 -05:00
|
|
|
i=$((i+1))
|
2020-06-02 12:38:53 -04:00
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -mkdir -p /druid"
|
|
|
|
done
|
2020-12-15 02:08:50 -05:00
|
|
|
|
|
|
|
if [ $i -lt $MAX_ITERATIONS ]; then
|
|
|
|
echo "Hadoop namenode is up after $i iterations"
|
|
|
|
else
|
|
|
|
echo "Exhausted all runs while waiting for namenode to be up. Exiting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
2021-11-02 14:20:52 -04:00
|
|
|
if [ -n "${HADOOP_VERSION}" ] && [ "${HADOOP_VERSION:0:1}" == "3" ]; then
|
2021-10-30 13:16:24 -04:00
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -mkdir -p /user/root"
|
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -put /usr/local/hadoop/etc/hadoop/ input"
|
|
|
|
fi
|
2020-06-02 12:38:53 -04:00
|
|
|
|
|
|
|
# Setup hadoop druid dirs
|
|
|
|
echo "Setting up druid hadoop dirs"
|
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -mkdir -p /druid"
|
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -mkdir -p /druid/segments"
|
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -mkdir -p /quickstart"
|
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -chmod 777 /druid"
|
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -chmod 777 /druid/segments"
|
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -chmod 777 /quickstart"
|
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -chmod -R 777 /tmp"
|
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -chmod -R 777 /user"
|
|
|
|
# Copy data files to Hadoop container
|
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -put /shared/wikiticker-it/wikiticker-2015-09-12-sampled.json.gz /quickstart/wikiticker-2015-09-12-sampled.json.gz"
|
|
|
|
docker exec -t druid-it-hadoop sh -c "./usr/local/hadoop/bin/hdfs dfs -put /resources/data/batch_index /batch_index"
|
|
|
|
echo "Finished setting up druid hadoop dirs"
|
|
|
|
|
|
|
|
echo "Copying Hadoop XML files to shared"
|
|
|
|
docker exec -t druid-it-hadoop sh -c "cp /usr/local/hadoop/etc/hadoop/*.xml /shared/hadoop_xml"
|
2020-12-08 19:02:26 -05:00
|
|
|
echo "Copied Hadoop XML files to shared"
|