forked from LLNL/magpie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
magpie-setup-core
executable file
·327 lines (276 loc) · 8.31 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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#!/bin/bash
#############################################################################
# Copyright (C) 2013 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 <URL>.
#
# 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 configuration files for jobs. For the most
# part, it shouldn't be editted. See job submission files for
# configuration details.
#
# Setup a whole bunch of environment variables and directories
#
mkdir -p $MAGPIE_LOCAL_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${MAGPIE_LOCAL_DIR}"
exit 1
fi
source ${MAGPIE_SCRIPTS_HOME}/magpie-submission-convert
source ${MAGPIE_SCRIPTS_HOME}/magpie-common-exports
source ${MAGPIE_SCRIPTS_HOME}/magpie-common-functions
#
# Setup Hadoop directories
#
if [ "${HADOOP_SETUP}" == "yes" ]
then
mkdir -p $HADOOP_LOCAL_JOB_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${HADOOP_LOCAL_JOB_DIR}"
exit 1
fi
mkdir -p $HADOOP_CONF_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${HADOOP_CONF_DIR}"
exit 1
fi
mkdir -p $HADOOP_LOG_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${HADOOP_LOG_DIR}"
exit 1
fi
fi
#
# Setup Pig directories
#
if [ "${PIG_SETUP}" == "yes" ]
then
mkdir -p $PIG_LOCAL_JOB_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${PIG_LOCAL_JOB_DIR}"
exit 1
fi
mkdir -p $PIG_CONF_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${PIG_CONF_DIR}"
exit 1
fi
fi
#
# Setup Hbase directories
#
if [ "${HBASE_SETUP}" == "yes" ]
then
mkdir -p $HBASE_LOCAL_JOB_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${HBASE_LOCAL_JOB_DIR}"
exit 1
fi
mkdir -p $HBASE_CONF_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${HBASE_CONF_DIR}"
exit 1
fi
mkdir -p $HBASE_LOG_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${HBASE_LOG_DIR}"
exit 1
fi
fi
#
# Setup Spark directories
#
if [ "${SPARK_SETUP}" == "yes" ]
then
mkdir -p $SPARK_LOCAL_JOB_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${SPARK_LOCAL_JOB_DIR}"
exit 1
fi
mkdir -p $SPARK_CONF_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${SPARK_CONF_DIR}"
exit 1
fi
mkdir -p $SPARK_LOG_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${SPARK_LOG_DIR}"
exit 1
fi
fi
#
# Setup Storm directories
#
if [ "${STORM_SETUP}" == "yes" ]
then
mkdir -p $STORM_LOCAL_JOB_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${STORM_LOCAL_JOB_DIR}"
exit 1
fi
mkdir -p $STORM_CONF_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${STORM_CONF_DIR}"
exit 1
fi
mkdir -p $STORM_LOG_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${STORM_LOG_DIR}"
exit 1
fi
fi
#
# Setup Tachyon directories
#
if [ "${TACHYON_SETUP}" == "yes" ]
then
mkdir -p $TACHYON_LOCAL_JOB_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${TACHYON_LOCAL_JOB_DIR}"
exit 1
fi
mkdir -p $TACHYON_CONF_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${TACHYON_CONF_DIR}"
exit 1
fi
mkdir -p $TACHYON_LOG_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${TACHYON_LOG_DIR}"
exit 1
fi
fi
#
# Setup Zookeeper directories
#
if [ "${ZOOKEEPER_SETUP}" == "yes" ]
then
mkdir -p $ZOOKEEPER_LOCAL_JOB_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${ZOOKEEPER_LOCAL_JOB_DIR}"
exit 1
fi
mkdir -p $ZOOKEEPER_CONF_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${ZOOKEEPER_CONF_DIR}"
exit 1
fi
mkdir -p $ZOOKEEPER_LOG_DIR
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${ZOOKEEPER_LOG_DIR}"
exit 1
fi
fi
#
# Setup/Calculate Core Master/Slave files
#
hash hostlist 2>/dev/null
if [ $? -eq 0 ]
then
hostrangescript="hostlist"
hostrangescriptoptions="-e -d \n"
else
if [ -x ${MAGPIE_SCRIPTS_HOME}/bin/magpie-expand-nodes ]
then
hostrangescript="${MAGPIE_SCRIPTS_HOME}/bin/magpie-expand-nodes"
hostrangescriptoptions=""
else
echo "Cannot find tool to expand host ranges"
exit 1
fi
fi
${hostrangescript} ${hostrangescriptoptions} ${MAGPIE_NODELIST} | head -1 > ${MAGPIE_LOCAL_DIR}/tmp_masters
${hostrangescript} ${hostrangescriptoptions} ${MAGPIE_NODELIST} | tail -n+2 > ${MAGPIE_LOCAL_DIR}/tmp_slaves
if [ "${HADOOP_SETUP}" == "yes" ] \
&& ([ "${HADOOP_FILESYSTEM_MODE}" == "hdfs" ] \
|| [ "${HADOOP_FILESYSTEM_MODE}" == "hdfsoverlustre" ] \
|| [ "${HADOOP_FILESYSTEM_MODE}" == "hdfsovernetworkfs" ]) \
&& [ "${HDFS_FEDERATION_NAMENODE_COUNT}" -gt 1 ]
then
extranamenodecount=`expr ${HDFS_FEDERATION_NAMENODE_COUNT} - 1`
head -${extranamenodecount} ${MAGPIE_LOCAL_DIR}/tmp_slaves > ${MAGPIE_LOCAL_DIR}/namenode_hdfs_federation
tail -n+${HDFS_FEDERATION_NAMENODE_COUNT} ${MAGPIE_LOCAL_DIR}/tmp_slaves > ${MAGPIE_LOCAL_DIR}/tmp_slaves_tmp
cp ${MAGPIE_LOCAL_DIR}/tmp_slaves_tmp ${MAGPIE_LOCAL_DIR}/tmp_slaves
fi
if [ "${ZOOKEEPER_SETUP}" == "yes" ]
then
tmpslavecount=`cat ${MAGPIE_LOCAL_DIR}/tmp_slaves | wc -l`
jobslavecount=`expr ${tmpslavecount} - ${ZOOKEEPER_REPLICATION_COUNT}`
zookeeperslavestart=`expr ${jobslavecount} + 1`
cp ${MAGPIE_LOCAL_DIR}/tmp_masters ${MAGPIE_LOCAL_DIR}/job_masters
if [ "${ZOOKEEPER_SHARE_NODES}" != "yes" ]
then
head -${jobslavecount} ${MAGPIE_LOCAL_DIR}/tmp_slaves > ${MAGPIE_LOCAL_DIR}/job_slaves
else
cp ${MAGPIE_LOCAL_DIR}/tmp_slaves ${MAGPIE_LOCAL_DIR}/job_slaves
fi
tail -n+${zookeeperslavestart} ${MAGPIE_LOCAL_DIR}/tmp_slaves > ${ZOOKEEPER_CONF_DIR}/zookeeper_slaves
# The Zookeeper master is not a real Zookeeper node
cp ${MAGPIE_LOCAL_DIR}/job_masters ${ZOOKEEPER_CONF_DIR}/zookeeper_master
else
cp ${MAGPIE_LOCAL_DIR}/tmp_masters ${MAGPIE_LOCAL_DIR}/job_masters
cp ${MAGPIE_LOCAL_DIR}/tmp_slaves ${MAGPIE_LOCAL_DIR}/job_slaves
fi
if [ "${HADOOP_SETUP}" == "yes" ]
then
cp ${MAGPIE_LOCAL_DIR}/job_masters ${HADOOP_CONF_DIR}/masters
cp ${MAGPIE_LOCAL_DIR}/job_slaves ${HADOOP_CONF_DIR}/slaves
if [ -f "${MAGPIE_LOCAL_DIR}/namenode_hdfs_federation" ]
then
cp ${MAGPIE_LOCAL_DIR}/namenode_hdfs_federation ${HADOOP_CONF_DIR}/namenode_hdfs_federation
fi
slavenodes=`cat ${HADOOP_CONF_DIR}/slaves`
`touch ${HADOOP_CONF_DIR}/slaves_fqdn`
dnsdomainname=`dnsdomainname`
# We assume FQDN across all nodes is the same
for node in ${slavenodes}
do
echo "${node}.${dnsdomainname}" >> ${HADOOP_CONF_DIR}/slaves_fqdn
done
fi
if [ "${HBASE_SETUP}" == "yes" ]
then
cp ${MAGPIE_LOCAL_DIR}/job_masters ${HBASE_CONF_DIR}/masters
cp ${MAGPIE_LOCAL_DIR}/job_slaves ${HBASE_CONF_DIR}/regionservers
fi
if [ "${SPARK_SETUP}" == "yes" ]
then
cp ${MAGPIE_LOCAL_DIR}/job_masters ${SPARK_CONF_DIR}/masters
cp ${MAGPIE_LOCAL_DIR}/job_slaves ${SPARK_CONF_DIR}/slaves
fi
if [ "${STORM_SETUP}" == "yes" ]
then
cp ${MAGPIE_LOCAL_DIR}/job_masters ${STORM_CONF_DIR}/masters
cp ${MAGPIE_LOCAL_DIR}/job_slaves ${STORM_CONF_DIR}/workers
fi
if [ "${TACHYON_SETUP}" == "yes" ]
then
# Tachyon assumes setup node is master, so no need for masters
# file but we still output it b/c there are functions in Magpie
# that assume it exists
cp ${MAGPIE_LOCAL_DIR}/job_masters ${TACHYON_CONF_DIR}/masters
if [ "${TACHYON_WORKER_ON_MASTER}" == "yes" ]
then
cp ${MAGPIE_LOCAL_DIR}/job_masters ${TACHYON_CONF_DIR}/workers
cat ${MAGPIE_LOCAL_DIR}/job_slaves >> ${TACHYON_CONF_DIR}/workers
else
cp ${MAGPIE_LOCAL_DIR}/job_slaves ${TACHYON_CONF_DIR}/workers
fi
fi
exit 0