slsrun.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/bin/bash
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License. See accompanying LICENSE file.
  14. #
  15. ###############################################################################
  16. printUsage() {
  17. echo "Usage: slsrun.sh <OPTIONS>"
  18. echo " --tracetype=<SYNTH | SLS | RUMEN>"
  19. echo " --tracelocation=<FILE1,FILE2,...>"
  20. echo " (deprecated --input-rumen=<FILE1,FILE2,...> | --input-sls=<FILE1,FILE2,...>)"
  21. echo " --output-dir=<SLS_SIMULATION_OUTPUT_DIRECTORY>"
  22. echo " [--nodes=<SLS_NODES_FILE>]"
  23. echo " [--track-jobs=<JOBID1,JOBID2,...>]"
  24. echo " [--print-simulation]"
  25. echo
  26. }
  27. ###############################################################################
  28. parseArgs() {
  29. for i in $*
  30. do
  31. case $i in
  32. --tracetype=*)
  33. tracetype=${i#*=}
  34. ;;
  35. --tracelocation=*)
  36. tracelocation=${i#*=}
  37. ;;
  38. --input-rumen=*)
  39. inputrumen=${i#*=}
  40. ;;
  41. --input-sls=*)
  42. inputsls=${i#*=}
  43. ;;
  44. --output-dir=*)
  45. outputdir=${i#*=}
  46. ;;
  47. --nodes=*)
  48. nodes=${i#*=}
  49. ;;
  50. --track-jobs=*)
  51. trackjobs=${i#*=}
  52. ;;
  53. --print-simulation)
  54. printsimulation="true"
  55. ;;
  56. *)
  57. echo "Invalid option"
  58. echo
  59. printUsage
  60. exit 1
  61. ;;
  62. esac
  63. done
  64. if [[ "${inputrumen}" == "" && "${inputsls}" == "" && "${tracetype}" == "" ]] ; then
  65. echo "Either --input-rumen or --input-sls or --tracetype must be specified"
  66. echo
  67. printUsage
  68. exit 1
  69. fi
  70. if [[ "${outputdir}" == "" ]] ; then
  71. echo "The output directory --output-dir must be specified"
  72. echo
  73. printUsage
  74. exit 1
  75. fi
  76. }
  77. ###############################################################################
  78. calculateClasspath() {
  79. HADOOP_BASE=`which hadoop`
  80. HADOOP_BASE=`dirname $HADOOP_BASE`
  81. DEFAULT_LIBEXEC_DIR=${HADOOP_BASE}/../libexec
  82. HADOOP_LIBEXEC_DIR=${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}
  83. . $HADOOP_LIBEXEC_DIR/hadoop-config.sh
  84. SLS_HTML="${HADOOP_PREFIX}/share/hadoop/tools/sls/html"
  85. export HADOOP_CLASSPATH="${HADOOP_CLASSPATH}:${TOOL_PATH}:${SLS_HTML}"
  86. }
  87. ###############################################################################
  88. runSimulation() {
  89. if [[ "${tracetype}" != "" ]] ; then
  90. args="${args} -tracetype ${tracetype}"
  91. args="${args} -tracelocation ${tracelocation}"
  92. fi
  93. if [[ "${nodes}" != "" ]] ; then
  94. args="${args} -nodes ${nodes}"
  95. fi
  96. if [[ "${inputsls}" != "" ]] ; then
  97. args="-inputsls ${inputsls}"
  98. fi
  99. if [[ "${inputrumen}" != "" ]] ; then
  100. args="-inputrumen ${inputrumen}"
  101. fi
  102. args="${args} -output ${outputdir}"
  103. if [[ "${nodes}" != "" ]] ; then
  104. args="${args} -nodes ${nodes}"
  105. fi
  106. if [[ "${trackjobs}" != "" ]] ; then
  107. args="${args} -trackjobs ${trackjobs}"
  108. fi
  109. if [[ "${printsimulation}" == "true" ]] ; then
  110. args="${args} -printsimulation"
  111. fi
  112. hadoop org.apache.hadoop.yarn.sls.SLSRunner ${args}
  113. }
  114. ###############################################################################
  115. calculateClasspath
  116. parseArgs "$@"
  117. runSimulation
  118. exit 0