forked from LLNL/magpie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
magpie-setup-core
executable file
·262 lines (223 loc) · 8.4 KB
/
magpie-setup-core
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#!/bin/bash
#############################################################################
# Copyright (C) 2013-2015 Lawrence Livermore National Security, LLC.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
# Written by Albert Chu <[email protected]>
# LLNL-CODE-644248
#
# This file is part of Magpie, scripts for running Hadoop on
# traditional HPC systems. For details, see https://github.com/llnl/magpie.
#
# Magpie is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Magpie is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Magpie. If not, see <http://www.gnu.org/licenses/>.
#############################################################################
# This script sets up core configuration files for jobs. For the most
# part, it shouldn't be editted. See job submission files for
# configuration details.
source ${MAGPIE_SCRIPTS_HOME}/magpie/exports/magpie-exports-submission-type
source ${MAGPIE_SCRIPTS_HOME}/magpie/exports/magpie-exports-dirs
source ${MAGPIE_SCRIPTS_HOME}/magpie/lib/magpie-lib-hadoop-helper
source ${MAGPIE_SCRIPTS_HOME}/magpie/lib/magpie-lib-helper
#
# Setup a whole bunch of environment variables and directories
#
# Create conf & log dirs node specific
Magpie_make_all_local_dirs_node_specific
mkdir -p $MAGPIE_LOCAL_CONF_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${MAGPIE_LOCAL_CONF_DIR}"
exit 1
fi
mkdir -p $MAGPIE_LOCAL_LOG_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${MAGPIE_LOCAL_LOG_DIR}"
exit 1
fi
mkdir -p $MAGPIE_LOCAL_PID_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${MAGPIE_LOCAL_PID_DIR}"
exit 1
fi
mkdir -p $MAGPIE_LOCAL_SCRATCHSPACE_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${MAGPIE_LOCAL_SCRATCHSPACE_DIR}"
exit 1
fi
#
# Setup primary conf, log, and local scratchspace directories for projects
#
magpieprojects="HADOOP PIG MAHOUT HBASE HIVE PHOENIX SPARK KAFKA ZEPPELIN STORM ZOOKEEPER RAY"
for project in ${magpieprojects}
do
setupvar="${project}_SETUP"
confdirvar="${project}_CONF_DIR"
logdirvar="${project}_LOG_DIR"
piddirvar="${project}_PID_DIR"
localscratchspacedirvar="${project}_LOCAL_SCRATCHSPACE_DIR"
if [ "${!setupvar}" == "yes" ]
then
if [ "${!confdirvar}X" != "X" ]
then
mkdir -p ${!confdirvar}
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${!confdirvar}"
exit 1
fi
fi
if [ "${!logdirvar}X" != "X" ]
then
mkdir -p ${!logdirvar}
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${!logdirvar}"
exit 1
fi
fi
if [ "${!piddirvar}X" != "X" ]
then
mkdir -p ${!piddirvar}
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${!piddirvar}"
exit 1
fi
fi
if [ "${!localscratchspacedirvar}X" != "X" ]
then
mkdir -p ${!localscratchspacedirvar}
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${!localscratchspacedirvar}"
exit 1
fi
fi
fi
done
#
# Setup/Calculate Core Master/Worker files
#
# Sets magpie_hostrangescript and magpie_hostrangescriptoptions
Magpie_get_hostlist_command
Magpie_get_magpie_hostname
myhostname=${magpie_hostname}
${magpie_hostrangescript} ${magpie_hostrangescriptoptions} ${MAGPIE_NODELIST} | head -1 > ${MAGPIE_LOCAL_CONF_DIR}/tmp_masters
${magpie_hostrangescript} ${magpie_hostrangescriptoptions} ${MAGPIE_NODELIST} | tail -n+2 > ${MAGPIE_LOCAL_CONF_DIR}/tmp_workers
# Convert nodenames if necessary
if [ "${MAGPIE_HOSTNAME_SCHEDULER_MAP}X" != "X" ]
then
masterhosts=`cat ${MAGPIE_LOCAL_CONF_DIR}/tmp_masters`
workerhosts=`cat ${MAGPIE_LOCAL_CONF_DIR}/tmp_workers`
for host in ${masterhosts}
do
newhost=`${MAGPIE_HOSTNAME_SCHEDULER_MAP} $host`
if [ $? -ne 0 ]
then
echo "Error in MAGPIE_HOSTNAME_SCHEDULER_MAP = ${MAGPIE_HOSTNAME_SCHEDULER_MAP}"
exit 1
fi
echo $newhost >> ${MAGPIE_LOCAL_CONF_DIR}/tmp_masters_convert
done
for host in ${workerhosts}
do
newhost=`${MAGPIE_HOSTNAME_SCHEDULER_MAP} $host`
if [ $? -ne 0 ]
then
echo "Error in MAGPIE_HOSTNAME_SCHEDULER_MAP = ${MAGPIE_HOSTNAME_SCHEDULER_MAP}"
exit 1
fi
echo $newhost >> ${MAGPIE_LOCAL_CONF_DIR}/tmp_workers_convert
done
rm -f ${MAGPIE_LOCAL_CONF_DIR}/tmp_masters
rm -f ${MAGPIE_LOCAL_CONF_DIR}/tmp_workers
mv ${MAGPIE_LOCAL_CONF_DIR}/tmp_masters_convert ${MAGPIE_LOCAL_CONF_DIR}/tmp_masters
mv ${MAGPIE_LOCAL_CONF_DIR}/tmp_workers_convert ${MAGPIE_LOCAL_CONF_DIR}/tmp_workers
fi
if ! grep -q ${myhostname} ${MAGPIE_LOCAL_CONF_DIR}/tmp_masters \
&& ! grep -q ${myhostname} ${MAGPIE_LOCAL_CONF_DIR}/tmp_workers
then
if [ "${MAGPIE_HOSTNAME_CMD_MAP}X" != "X" ]
then
echo "WARNING: MAGPIE_HOSTNAME_CMD_MAP command returned a node not listed in nodelist."
echo "WARNING: ${MAGPIE_HOSTNAME_CMD_MAP} may need tweaking"
else
echo "WARNING: hostname command returned a node not listed in nodelist."
echo "WARNING: Consider configuring MAGPIE_HOSTNAME_CMD_MAP"
fi
fi
if [ "${ZOOKEEPER_SETUP}" == "yes" ]
then
tmpworkercount=`cat ${MAGPIE_LOCAL_CONF_DIR}/tmp_workers | wc -l`
jobworkercount=`expr ${tmpworkercount} - ${ZOOKEEPER_REPLICATION_COUNT}`
zookeeperworkerstart=`expr ${jobworkercount} + 1`
cp ${MAGPIE_LOCAL_CONF_DIR}/tmp_masters ${MAGPIE_LOCAL_CONF_DIR}/job_masters
if [ "${ZOOKEEPER_SHARE_NODES}" != "yes" ]
then
head -${jobworkercount} ${MAGPIE_LOCAL_CONF_DIR}/tmp_workers > ${MAGPIE_LOCAL_CONF_DIR}/job_workers
else
cp ${MAGPIE_LOCAL_CONF_DIR}/tmp_workers ${MAGPIE_LOCAL_CONF_DIR}/job_workers
fi
tail -n+${zookeeperworkerstart} ${MAGPIE_LOCAL_CONF_DIR}/tmp_workers > ${ZOOKEEPER_CONF_DIR}/workers
# The Zookeeper master is not an actual Zookeeper node, this is
# predominantly to indicate to magpie that Zookeeper should be
# launched via the "master" node
cp ${MAGPIE_LOCAL_CONF_DIR}/job_masters ${ZOOKEEPER_CONF_DIR}/masters
else
cp ${MAGPIE_LOCAL_CONF_DIR}/tmp_masters ${MAGPIE_LOCAL_CONF_DIR}/job_masters
cp ${MAGPIE_LOCAL_CONF_DIR}/tmp_workers ${MAGPIE_LOCAL_CONF_DIR}/job_workers
fi
if [ "${HADOOP_SETUP}" == "yes" ]
then
cp ${MAGPIE_LOCAL_CONF_DIR}/job_masters ${HADOOP_CONF_DIR}/masters
if echo ${HADOOP_VERSION} | grep -q -E "3\.[0-9]\.[0-9]"
then
cp ${MAGPIE_LOCAL_CONF_DIR}/job_workers ${HADOOP_CONF_DIR}/workers
else
cp ${MAGPIE_LOCAL_CONF_DIR}/job_workers ${HADOOP_CONF_DIR}/slaves
fi
fi
if [ "${HBASE_SETUP}" == "yes" ]
then
cp ${MAGPIE_LOCAL_CONF_DIR}/job_masters ${HBASE_CONF_DIR}/masters
cp ${MAGPIE_LOCAL_CONF_DIR}/job_workers ${HBASE_CONF_DIR}/regionservers
fi
if [ "${HIVE_SETUP}" == "yes" ]
then
cp ${MAGPIE_LOCAL_CONF_DIR}/job_masters ${HIVE_CONF_DIR}/masters
fi
if [ "${PHOENIX_SETUP}" == "yes" ]
then
cp ${MAGPIE_LOCAL_CONF_DIR}/job_workers ${PHOENIX_CONF_DIR}/regionservers
fi
if [ "${SPARK_SETUP}" == "yes" ]
then
# Create regardless of using yarn or not, needed for other code
cp ${MAGPIE_LOCAL_CONF_DIR}/job_masters ${SPARK_CONF_DIR}/masters
cp ${MAGPIE_LOCAL_CONF_DIR}/job_workers ${SPARK_CONF_DIR}/slaves
fi
if [ "${KAFKA_SETUP}" == "yes" ]
then
cp ${MAGPIE_LOCAL_CONF_DIR}/job_masters ${KAFKA_CONF_DIR}/masters
cp ${MAGPIE_LOCAL_CONF_DIR}/job_workers ${KAFKA_CONF_DIR}/workers
fi
if [ "${ZEPPELIN_SETUP}" == "yes" ]
then
cp ${MAGPIE_LOCAL_CONF_DIR}/job_masters ${ZEPPELIN_CONF_DIR}/masters
fi
if [ "${STORM_SETUP}" == "yes" ]
then
cp ${MAGPIE_LOCAL_CONF_DIR}/job_masters ${STORM_CONF_DIR}/masters
cp ${MAGPIE_LOCAL_CONF_DIR}/job_workers ${STORM_CONF_DIR}/workers
fi
if [ "${RAY_SETUP}" == "yes" ]
then
cp ${MAGPIE_LOCAL_CONF_DIR}/job_masters ${RAY_CONF_DIR}/masters
cp ${MAGPIE_LOCAL_CONF_DIR}/job_workers ${RAY_CONF_DIR}/workers
fi
exit 0