Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/*
3
 * Copyright 2010-2012 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
 
18
/*%******************************************************************************************%*/
19
// CLASS
20
 
21
/**
22
 * Contains a set of pre-built Amazon EMR Hadoop steps.
23
 *
24
 * @version 2011.05.03
25
 * @license See the included NOTICE.md file for more information.
26
 * @copyright See the included NOTICE.md file for more information.
27
 * @link http://aws.amazon.com/php/ PHP Developer Center
28
 * @link http://hadoop.apache.org Apache Hadoop
29
 */
30
class CFHadoopStep extends CFHadoopBase
31
{
32
	/**
33
	 * When ran as the first step in your job flow, enables the Hadoop debugging UI in the AWS
34
	 * Management Console.
35
	 *
36
	 * @return array A standard array that is intended to be passed into a <CFStepConfig> object.
37
	 */
38
	public static function enable_debugging()
39
	{
40
		return self::script_runner('s3://us-east-1.elasticmapreduce/libs/state-pusher/0.1/fetch');
41
	}
42
 
43
	/**
44
	 * Step that installs Hive on your job flow.
45
	 *
46
	 * @return array A standard array that is intended to be passed into a <CFStepConfig> object.
47
	 * @link http://hive.apache.org Apache Hive
48
	 */
49
	public static function install_hive()
50
	{
51
		return self::hive_pig_script('hive', '--install-hive');
52
	}
53
 
54
	/**
55
	 * Step that runs a Hive script on your job flow.
56
	 *
57
	 * @param string $script (Required) The script to run with `script-runner.jar`.
58
	 * @param array $args (Optional) An indexed array of arguments to pass to the script.
59
	 * @return array A standard array that is intended to be passed into a <CFStepConfig> object.
60
	 * @link http://hive.apache.org Apache Hive
61
	 */
62
	public static function run_hive_script($script, $args = null)
63
	{
64
		if (!$args) $args = array();
65
		$args = is_array($args) ? $args : array($args);
66
		$args = array_merge(array('--run-hive-script', '--args', '-f', $script), $args);
67
 
68
        return self::hive_pig_script('hive', $args);
69
	}
70
 
71
	/**
72
	 * Step that installs Pig on your job flow.
73
	 *
74
	 * @return array A standard array that is intended to be passed into a <CFStepConfig> object.
75
	 * @link http://pig.apache.org Apache Pig
76
	 */
77
	public static function install_pig()
78
	{
79
		return self::hive_pig_script('pig', '--install-pig');
80
	}
81
 
82
	/**
83
	 * Step that runs a Pig script on your job flow.
84
	 *
85
	 * @param string $script (Required) The script to run with `script-runner.jar`.
86
	 * @param array $args (Optional) An indexed array of arguments to pass to the script.
87
	 * @return array A standard array that is intended to be passed into a <CFStepConfig> object.
88
	 * @link http://pig.apache.org Apache Pig
89
	 */
90
	public static function run_pig_script($script, $args = null)
91
	{
92
		if (!$args) $args = array();
93
		$args = is_array($args) ? $args : array($args);
94
		$args = array_merge(array('--run-pig-script', '--args', '-f', $script), $args);
95
 
96
        return self::hive_pig_script('pig', $args);
97
	}
98
}