#!/usr/bin/bash
#############################################################################
#  Copyright (C) 2013-2015 Lawrence Livermore National Security, LLC.
#  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
#  Written by Albert Chu <chu11@llnl.gov>
#  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 is for running the 'testall' facility.  For the most
# part, it shouldn't be editted.  See job submission files for
# configuration details.

source ${MAGPIE_SCRIPTS_HOME}/magpie/lib/magpie-lib-hadoop-helper

if [ "${HADOOP_SETUP}" == "yes" ] \
   && Magpie_hadoop_setup_type_enables_yarn
then
    echo "*******************************************************"
    echo "* Running Hadoop Terasort"
    echo "*******************************************************"
    (${MAGPIE_SCRIPTS_HOME}/magpie/job/magpie-job-hadoop-terasort)
fi

if [ "${PIG_SETUP}" == "yes" ]
then
    echo "*******************************************************"
    echo "* Running Pig Testpig"
    echo "*******************************************************"
    (${MAGPIE_SCRIPTS_HOME}/magpie/job/magpie-job-pig-testpig)
fi

if [ "${HBASE_SETUP}" == "yes" ]
then
    echo "*******************************************************"
    echo "* Running Hbase Performance Evaluation"
    echo "*******************************************************"
    (${MAGPIE_SCRIPTS_HOME}/magpie/job/magpie-job-hbase-performanceeval)
fi

if [ "${PHOENIX_SETUP}" == "yes" ]
then
    echo "*******************************************************"
    echo "* Running Phoenix Performance Evaluation"
    echo "*******************************************************"
    (${MAGPIE_SCRIPTS_HOME}/magpie/job/magpie-job-phoenix-performanceeval)
fi

if [ "${SPARK_SETUP}" == "yes" ]
then
    echo "*******************************************************"
    echo "* Running Spark SparkPi"
    echo "*******************************************************"
    (${MAGPIE_SCRIPTS_HOME}/magpie/job/magpie-job-spark-sparkpi)
fi

if [ "${KAFKA_SETUP}" == "yes" ]
then
    echo "*******************************************************"
    echo "* Running Kafka Performance"
    echo "*******************************************************"
    (${MAGPIE_SCRIPTS_HOME}/magpie/job/magpie-job-kafka-performance)
fi

if [ "${STORM_SETUP}" == "yes" ]
then
    echo "*******************************************************"
    echo "* Running Storm Foobar"
    echo "*******************************************************"
    (${MAGPIE_SCRIPTS_HOME}/magpie/job/magpie-job-storm-stormwordcount)
fi

if [ "${ZOOKEEPER_SETUP}" == "yes" ]
then
    echo "*******************************************************"
    echo "* Running Zookeeper Zookeeperruok"
    echo "*******************************************************"
    (${MAGPIE_SCRIPTS_HOME}/magpie/job/magpie-job-zookeeper-zookeeperruok)
fi

if [ "${ZEPPELIN_SETUP}" == "yes" ] \
   && [ "${ZEPPELIN_MODE}" != "setuponly" ]
then
    echo "*******************************************************"
    echo "* Running Zeppelin CheckZeppelinUp"
    echo "*******************************************************"
    (${MAGPIE_SCRIPTS_HOME}/magpie/job/magpie-job-zeppelin-checkzeppelinup.py)
fi

exit 0
