| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. See License.txt in the project root for |
| | 3 | | // license information. |
| | 4 | |
|
| | 5 | | namespace Microsoft.Azure.HDInsight.Job.Models |
| | 6 | | { |
| | 7 | | using System.Collections.Generic; |
| | 8 | |
|
| | 9 | | /// <summary> |
| | 10 | | /// Parameters specifying the HDInsight MapReduce Streaming job definition. |
| | 11 | | /// </summary> |
| | 12 | | public partial class MapReduceStreamingJobSubmissionParameters |
| | 13 | | { |
| | 14 | | /// <summary> |
| | 15 | | /// Optional. Gets the arguments for the jobDetails. |
| | 16 | | /// </summary> |
| 0 | 17 | | public IList<string> Arguments { get; set; } |
| | 18 | |
|
| | 19 | | /// <summary> |
| | 20 | | /// Optional. Set list of environment variables. |
| | 21 | | /// </summary> |
| 0 | 22 | | public IDictionary<string, string> CmdEnv { get; set; } |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// Optional. Gets or sets define parameters. |
| | 26 | | /// </summary> |
| 0 | 27 | | public IDictionary<string, string> Defines { get; set; } |
| | 28 | |
|
| | 29 | | /// <summary> |
| | 30 | | /// Optional. File to add to the distributed cache. |
| | 31 | | /// </summary> |
| 0 | 32 | | public string File { get; set; } |
| | 33 | |
|
| | 34 | | /// <summary> |
| | 35 | | /// Optional. List of files to be copied to the cluster. |
| | 36 | | /// </summary> |
| 0 | 37 | | public IList<string> Files { get; set; } |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Optional. Location of the input data in Hadoop. |
| | 41 | | /// </summary> |
| 12 | 42 | | public string Input { get; set; } |
| | 43 | |
|
| | 44 | | /// <summary> |
| | 45 | | /// Optional. Gets or sets Mapper executable or Java class name. |
| | 46 | | /// </summary> |
| 12 | 47 | | public string Mapper { get; set; } |
| | 48 | |
|
| | 49 | | /// <summary> |
| | 50 | | /// Optional. Location in which to store the output data. |
| | 51 | | /// </summary> |
| 12 | 52 | | public string Output { get; set; } |
| | 53 | |
|
| | 54 | | /// <summary> |
| | 55 | | /// Optional. Gets or sets Reducer executable or Java class name. |
| | 56 | | /// </summary> |
| 12 | 57 | | public string Reducer { get; set; } |
| | 58 | |
|
| | 59 | | /// <summary> |
| | 60 | | /// Optional. Status directory in the default storage account to store job files stderr, stdout and exit. |
| | 61 | | /// </summary> |
| 0 | 62 | | public string StatusDir { get; set; } |
| | 63 | |
|
| | 64 | | /// <summary> |
| | 65 | | /// Initializes a new instance of the |
| | 66 | | /// MapReduceStreamingJobSubmissionParameters class. |
| | 67 | | /// </summary> |
| 4 | 68 | | public MapReduceStreamingJobSubmissionParameters() |
| | 69 | | { |
| 4 | 70 | | } |
| | 71 | |
|
| | 72 | | internal string GetJobPostRequestContent() |
| | 73 | | { |
| | 74 | | // Check input parameters and transform them to required format before sending request to templeton. |
| 4 | 75 | | var values = new List<KeyValuePair<string, string>>(); |
| | 76 | |
|
| 4 | 77 | | if (!string.IsNullOrEmpty(this.Input)) |
| | 78 | | { |
| 4 | 79 | | values.Add(new KeyValuePair<string, string>("input", this.Input)); |
| | 80 | | } |
| | 81 | |
|
| 4 | 82 | | if (!string.IsNullOrEmpty(this.Output)) |
| | 83 | | { |
| 4 | 84 | | values.Add(new KeyValuePair<string, string>("output", this.Output)); |
| | 85 | | } |
| | 86 | |
|
| 4 | 87 | | if (!string.IsNullOrEmpty(this.Mapper)) |
| | 88 | | { |
| 4 | 89 | | values.Add(new KeyValuePair<string, string>("mapper", this.Mapper)); |
| | 90 | | } |
| | 91 | |
|
| 4 | 92 | | if (!string.IsNullOrEmpty(this.Reducer)) |
| | 93 | | { |
| 4 | 94 | | values.Add(new KeyValuePair<string, string>("reducer", this.Reducer)); |
| | 95 | | } |
| | 96 | |
|
| 4 | 97 | | if (!string.IsNullOrEmpty(this.File)) |
| | 98 | | { |
| 0 | 99 | | values.Add(new KeyValuePair<string, string>("file", this.File)); |
| | 100 | | } |
| | 101 | |
|
| 4 | 102 | | if (this.Files != null && this.Files.Count > 0) |
| | 103 | | { |
| 0 | 104 | | values.Add(new KeyValuePair<string, string>("files", ModelHelper.BuildListToCommaSeparatedString(this.Fi |
| | 105 | | } |
| | 106 | |
|
| 4 | 107 | | if (this.Arguments != null && this.Arguments.Count > 0) |
| | 108 | | { |
| 0 | 109 | | values.AddRange(ModelHelper.BuildList("arg", this.Arguments)); |
| | 110 | | } |
| | 111 | |
|
| 4 | 112 | | if (this.Defines != null && this.Defines.Count > 0) |
| | 113 | | { |
| 0 | 114 | | values.AddRange(ModelHelper.BuildNameValueList("define", this.Defines)); |
| | 115 | | } |
| | 116 | |
|
| 4 | 117 | | if (this.CmdEnv != null && this.CmdEnv.Count > 0) |
| | 118 | | { |
| 0 | 119 | | values.AddRange(ModelHelper.BuildNameValueList("cmdenv", this.CmdEnv)); |
| | 120 | | } |
| | 121 | |
|
| 4 | 122 | | values.Add(new KeyValuePair<string, string>("statusdir", ModelHelper.GetStatusDirectory(this.StatusDir))); |
| | 123 | |
|
| 4 | 124 | | return ModelHelper.ConvertItemsToString(values); |
| | 125 | | } |
| | 126 | | } |
| | 127 | | } |