hadoopstep.class.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /*
  3. * Copyright 2010-2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License").
  6. * You may not use this file except in compliance with the License.
  7. * A copy of the License is located at
  8. *
  9. * http://aws.amazon.com/apache2.0
  10. *
  11. * or in the "license" file accompanying this file. This file is distributed
  12. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  13. * express or implied. See the License for the specific language governing
  14. * permissions and limitations under the License.
  15. */
  16. /*%******************************************************************************************%*/
  17. // CLASS
  18. /**
  19. * Contains a set of pre-built Amazon EMR Hadoop steps.
  20. *
  21. * @version 2011.05.03
  22. * @license See the included NOTICE.md file for more information.
  23. * @copyright See the included NOTICE.md file for more information.
  24. * @link http://aws.amazon.com/php/ PHP Developer Center
  25. * @link http://hadoop.apache.org Apache Hadoop
  26. */
  27. class CFHadoopStep extends CFHadoopBase
  28. {
  29. /**
  30. * When ran as the first step in your job flow, enables the Hadoop debugging UI in the AWS
  31. * Management Console.
  32. *
  33. * @return array A standard array that is intended to be passed into a <CFStepConfig> object.
  34. */
  35. public static function enable_debugging()
  36. {
  37. return self::script_runner('s3://us-east-1.elasticmapreduce/libs/state-pusher/0.1/fetch');
  38. }
  39. /**
  40. * Step that installs Hive on your job flow.
  41. *
  42. * @return array A standard array that is intended to be passed into a <CFStepConfig> object.
  43. * @link http://hive.apache.org Apache Hive
  44. */
  45. public static function install_hive()
  46. {
  47. return self::hive_pig_script('hive', '--install-hive');
  48. }
  49. /**
  50. * Step that runs a Hive script on your job flow.
  51. *
  52. * @param string $script (Required) The script to run with `script-runner.jar`.
  53. * @param array $args (Optional) An indexed array of arguments to pass to the script.
  54. * @return array A standard array that is intended to be passed into a <CFStepConfig> object.
  55. * @link http://hive.apache.org Apache Hive
  56. */
  57. public static function run_hive_script($script, $args = null)
  58. {
  59. if (!$args) $args = array();
  60. $args = is_array($args) ? $args : array($args);
  61. $args = array_merge(array('--run-hive-script', '--args', '-f', $script), $args);
  62. return self::hive_pig_script('hive', $args);
  63. }
  64. /**
  65. * Step that installs Pig on your job flow.
  66. *
  67. * @return array A standard array that is intended to be passed into a <CFStepConfig> object.
  68. * @link http://pig.apache.org Apache Pig
  69. */
  70. public static function install_pig()
  71. {
  72. return self::hive_pig_script('pig', '--install-pig');
  73. }
  74. /**
  75. * Step that runs a Pig script on your job flow.
  76. *
  77. * @param string $script (Required) The script to run with `script-runner.jar`.
  78. * @param array $args (Optional) An indexed array of arguments to pass to the script.
  79. * @return array A standard array that is intended to be passed into a <CFStepConfig> object.
  80. * @link http://pig.apache.org Apache Pig
  81. */
  82. public static function run_pig_script($script, $args = null)
  83. {
  84. if (!$args) $args = array();
  85. $args = is_array($args) ? $args : array($args);
  86. $args = array_merge(array('--run-pig-script', '--args', '-f', $script), $args);
  87. return self::hive_pig_script('pig', $args);
  88. }
  89. }