Created
January 21, 2019 11:44
-
-
Save kokosing/6f6e5f19968775efd6c44da33e60d9c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
################################################################################ | |
# Copyright (c) 2018 Starburst Data, Inc. All rights reserved. | |
# | |
# All information herein is owned by Starburst Data Inc. and its licensors | |
# ("Starburst"), if any. This software and the concepts it embodies are | |
# proprietary to Starburst, are protected by trade secret and copyright law, | |
# and may be covered by patents in the U.S. and abroad. Distribution, | |
# reproduction, and relicensing are strictly forbidden without Starburst's prior | |
# written permission. | |
# | |
# THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED. THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE | |
# AND NONINFRINGEMENT ARE EXPRESSLY DISCLAIMED. IN NO EVENT SHALL STARBURST BE | |
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR | |
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR ITS USE | |
# EVEN IF STARBURST HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
# | |
# Please refer to your agreement(s) with Starburst for further information. | |
################################################################################ | |
set -xeuo pipefail | |
version=0.208-e.0.10 | |
server_tarball_filename=presto-server-"${version}" | |
function setup_python36 | |
{ | |
#dependency for presto configure python scripts | |
if command -v python3.6 &>/dev/null; then | |
echo "Python 3.6 is already installed. Skipping.." | |
else | |
echo "Installing Python 3.6..." | |
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz | |
tar -xvf Python-3.6.3.tgz | |
pushd Python-3.6.3 | |
./configure && make && make install | |
popd | |
fi | |
} | |
function is_headnode | |
{ | |
shorthostname=$(hostname -s) | |
[[ $shorthostname == headnode* || $shorthostname == hn* ]] | |
} | |
function is_presto_node | |
{ | |
shorthostname=$(hostname -s) | |
[[ $shorthostname == headnode0* || $shorthostname == hn0* || $shorthostname == workernode* || $shorthostname == wn* ]] | |
} | |
function get_headnodes | |
{ | |
nn1_host=$(hdfs getconf -confKey dfs.namenode.http-address.mycluster.nn1 | cut -d ':' -f 1) | |
nn2_host=$(hdfs getconf -confKey dfs.namenode.http-address.mycluster.nn2 | cut -d ':' -f 1) | |
nn1_hostnumber=$(echo "$nn1_host" | cut -d- -f1 | sed -n -e 's/hn\(.*\)/\1/p') | |
nn2_hostnumber=$(echo "$nn2_host" | cut -d- -f1 | sed -n -e 's/hn\(.*\)/\1/p') | |
#only if both headnode hostnames could be retrieved, hostnames will be returned | |
#else throw an error | |
if [[ ! -z $nn1_host && ! -z $nn2_host ]]; then | |
if (( $nn1_hostnumber < $nn2_hostnumber )); then | |
echo "$nn1_host,$nn2_host" | |
else | |
echo "$nn2_host,$nn1_host" | |
fi | |
else | |
echo "[Error] Cannot find headnodes for the cluster" >&2 | |
exit 1 | |
fi | |
} | |
function get_primary_headnode | |
{ | |
headnodes=$(get_headnodes) | |
echo $headnodes | cut -d ',' -f 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment