| | 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 Hive job definition. |
| | 11 | | /// </summary> |
| | 12 | | public partial class HiveJobSubmissionParameters |
| | 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. Gets or sets the Hive parameters. |
| | 21 | | /// </summary> |
| 26 | 22 | | public IDictionary<string, string> Defines { get; set; } |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// Optional. Gets or sets the query file to use for a Hive job. |
| | 26 | | /// </summary> |
| 0 | 27 | | public string File { get; set; } |
| | 28 | |
|
| | 29 | | /// <summary> |
| | 30 | | /// Optional. Gets or sets the files to be copied to the cluster. |
| | 31 | | /// </summary> |
| 0 | 32 | | public IList<string> Files { get; set; } |
| | 33 | |
|
| | 34 | | /// <summary> |
| | 35 | | /// Optional. Gets or sets the query to use for a Hive job. |
| | 36 | | /// </summary> |
| 54 | 37 | | public string Query { get; set; } |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Optional. Status directory in the default storage account to store job files stderr, stdout and exit. |
| | 41 | | /// </summary> |
| 22 | 42 | | public string StatusDir { get; set; } |
| | 43 | |
|
| | 44 | | /// <summary> |
| | 45 | | /// Initializes a new instance of the HiveJobSubmissionParameters class. |
| | 46 | | /// </summary> |
| 14 | 47 | | public HiveJobSubmissionParameters() |
| | 48 | | { |
| 14 | 49 | | } |
| | 50 | |
|
| | 51 | | internal string GetJobPostRequestContent() |
| | 52 | | { |
| | 53 | | // Check input parameters and transform them to required format before sending request to templeton. |
| 20 | 54 | | var values = new List<KeyValuePair<string, string>>(); |
| | 55 | |
|
| 20 | 56 | | if (!string.IsNullOrEmpty(this.Query)) |
| | 57 | | { |
| 20 | 58 | | values.Add(new KeyValuePair<string, string>("execute", this.Query)); |
| | 59 | | } |
| | 60 | |
|
| 20 | 61 | | if (!string.IsNullOrEmpty(this.File)) |
| | 62 | | { |
| 0 | 63 | | values.Add(new KeyValuePair<string, string>("file", this.File)); |
| | 64 | | } |
| | 65 | |
|
| 20 | 66 | | if (this.Arguments != null && this.Arguments.Count > 0) |
| | 67 | | { |
| 0 | 68 | | values.AddRange(ModelHelper.BuildList("arg", this.Arguments)); |
| | 69 | | } |
| | 70 | |
|
| 20 | 71 | | if (this.Defines != null && this.Defines.Count > 0) |
| | 72 | | { |
| 2 | 73 | | values.AddRange(ModelHelper.BuildNameValueList("define", this.Defines)); |
| | 74 | | } |
| | 75 | |
|
| 20 | 76 | | if (this.Files != null && this.Files.Count > 0) |
| | 77 | | { |
| 0 | 78 | | values.Add(new KeyValuePair<string, string>("files", ModelHelper.BuildListToCommaSeparatedString(this.Fi |
| | 79 | | } |
| | 80 | |
|
| 20 | 81 | | values.Add(new KeyValuePair<string, string>("statusdir", ModelHelper.GetStatusDirectory(this.StatusDir))); |
| | 82 | |
|
| 20 | 83 | | return ModelHelper.ConvertItemsToString(values); |
| | 84 | | } |
| | 85 | | } |
| | 86 | | } |