12
12
// limitations under the License.
13
13
// ----------------------------------------------------------------------------------
14
14
15
+ using System . Collections ;
15
16
using System . Collections . Generic ;
16
17
using System . Management . Automation ;
17
18
using Microsoft . Azure . Commands . HDInsight . Commands ;
@@ -27,7 +28,7 @@ namespace Microsoft.Azure.Commands.HDInsight
27
28
typeof ( AzureHDInsightConfig ) ) ]
28
29
public class AddAzureHDInsightConfigValuesCommand : HDInsightCmdletBase
29
30
{
30
- private Dictionary < string , Dictionary < string , string > > _configurations ;
31
+ private Dictionary < string , Hashtable > _configurations ;
31
32
32
33
#region Input Parameter Definitions
33
34
@@ -38,66 +39,66 @@ public class AddAzureHDInsightConfigValuesCommand : HDInsightCmdletBase
38
39
public AzureHDInsightConfig Config { get ; set ; }
39
40
40
41
[ Parameter ( HelpMessage = "Gets the Core Site configurations of this HDInsight cluster." ) ]
41
- public Dictionary < string , string > Core { get ; set ; }
42
+ public Hashtable Core { get ; set ; }
42
43
43
44
[ Parameter ( HelpMessage = "Gets the Hive Site configurations of this HDInsight cluster." ) ]
44
- public Dictionary < string , string > HiveSite { get ; set ; }
45
+ public Hashtable HiveSite { get ; set ; }
45
46
46
47
[ Parameter ( HelpMessage = "Gets the Hive Env configurations of this HDInsight cluster." ) ]
47
- public Dictionary < string , string > HiveEnv { get ; set ; }
48
+ public Hashtable HiveEnv { get ; set ; }
48
49
49
50
[ Parameter ( HelpMessage = "Gets the Oozie Site configurations of this HDInsight cluster." ) ]
50
- public Dictionary < string , string > OozieSite { get ; set ; }
51
+ public Hashtable OozieSite { get ; set ; }
51
52
52
53
[ Parameter ( HelpMessage = "Gets the Oozie Env configurations of this HDInsight cluster." ) ]
53
- public Dictionary < string , string > OozieEnv { get ; set ; }
54
+ public Hashtable OozieEnv { get ; set ; }
54
55
55
56
[ Parameter ( HelpMessage = "Gets the WebHCat Site configurations of this HDInsight cluster." ) ]
56
- public Dictionary < string , string > WebHCat { get ; set ; }
57
+ public Hashtable WebHCat { get ; set ; }
57
58
58
59
[ Parameter ( HelpMessage = "Gets the HBase Site configurations of this HDInsight cluster." ) ]
59
- public Dictionary < string , string > HBaseSite { get ; set ; }
60
+ public Hashtable HBaseSite { get ; set ; }
60
61
61
62
[ Parameter ( HelpMessage = "Gets the HBase Env configurations of this HDInsight cluster." ) ]
62
- public Dictionary < string , string > HBaseEnv { get ; set ; }
63
+ public Hashtable HBaseEnv { get ; set ; }
63
64
64
65
[ Parameter ( HelpMessage = "Gets the Storm Site configurations of this HDInsight cluster." ) ]
65
- public Dictionary < string , string > Storm { get ; set ; }
66
+ public Hashtable Storm { get ; set ; }
66
67
67
68
[ Parameter ( HelpMessage = "Gets the Yarn Site configurations of this HDInsight cluster." ) ]
68
- public Dictionary < string , string > Yarn { get ; set ; }
69
+ public Hashtable Yarn { get ; set ; }
69
70
70
71
[ Parameter ( HelpMessage = "Gets the MapRed Site configurations of this HDInsight cluster." ) ]
71
- public Dictionary < string , string > MapRed { get ; set ; }
72
+ public Hashtable MapRed { get ; set ; }
72
73
73
74
[ Parameter ( HelpMessage = "Gets the Tez Site configurations of this HDInsight cluster." ) ]
74
- public Dictionary < string , string > Tez { get ; set ; }
75
+ public Hashtable Tez { get ; set ; }
75
76
76
77
[ Parameter ( HelpMessage = "Gets the Hdfs Site configurations of this HDInsight cluster." ) ]
77
- public Dictionary < string , string > Hdfs { get ; set ; }
78
+ public Hashtable Hdfs { get ; set ; }
78
79
79
80
#endregion
80
81
81
82
public AddAzureHDInsightConfigValuesCommand ( )
82
83
{
83
- Core = new Dictionary < string , string > ( ) ;
84
- HiveSite = new Dictionary < string , string > ( ) ;
85
- HiveEnv = new Dictionary < string , string > ( ) ;
86
- OozieSite = new Dictionary < string , string > ( ) ;
87
- OozieEnv = new Dictionary < string , string > ( ) ;
88
- WebHCat = new Dictionary < string , string > ( ) ;
89
- HBaseSite = new Dictionary < string , string > ( ) ;
90
- HBaseEnv = new Dictionary < string , string > ( ) ;
91
- Storm = new Dictionary < string , string > ( ) ;
92
- Yarn = new Dictionary < string , string > ( ) ;
93
- MapRed = new Dictionary < string , string > ( ) ;
94
- Tez = new Dictionary < string , string > ( ) ;
95
- Hdfs = new Dictionary < string , string > ( ) ;
84
+ Core = new Hashtable ( ) ;
85
+ HiveSite = new Hashtable ( ) ;
86
+ HiveEnv = new Hashtable ( ) ;
87
+ OozieSite = new Hashtable ( ) ;
88
+ OozieEnv = new Hashtable ( ) ;
89
+ WebHCat = new Hashtable ( ) ;
90
+ HBaseSite = new Hashtable ( ) ;
91
+ HBaseEnv = new Hashtable ( ) ;
92
+ Storm = new Hashtable ( ) ;
93
+ Yarn = new Hashtable ( ) ;
94
+ MapRed = new Hashtable ( ) ;
95
+ Tez = new Hashtable ( ) ;
96
+ Hdfs = new Hashtable ( ) ;
96
97
}
97
98
98
99
public override void ExecuteCmdlet ( )
99
100
{
100
- _configurations = Config . Configurations ?? new Dictionary < string , Dictionary < string , string > > ( ) ;
101
+ _configurations = Config . Configurations ?? new Dictionary < string , Hashtable > ( ) ;
101
102
102
103
AddConfigToConfigurations ( Core , ConfigurationKey . CoreSite ) ;
103
104
AddConfigToConfigurations ( HiveSite , ConfigurationKey . HiveSite ) ;
@@ -116,15 +117,16 @@ public override void ExecuteCmdlet()
116
117
WriteObject ( Config ) ;
117
118
}
118
119
119
- private void AddConfigToConfigurations ( Dictionary < string , string > userConfigs , string configKey )
120
+ private void AddConfigToConfigurations ( Hashtable userConfigs , string configKey )
120
121
{
122
+ //var userConfigs = HashtableToDictionary(configs);
121
123
//if no configs of this type provided, do nothing
122
124
if ( userConfigs == null || userConfigs . Count == 0 )
123
125
{
124
126
return ;
125
127
}
126
128
127
- Dictionary < string , string > config ;
129
+ Hashtable config ;
128
130
129
131
//if configs provided and key does not already exist, add the key with provided dictionary
130
132
if ( ! _configurations . TryGetValue ( configKey , out config ) )
@@ -134,11 +136,18 @@ private void AddConfigToConfigurations(Dictionary<string, string> userConfigs, s
134
136
}
135
137
136
138
//if configs provided and key already exists, add the provided values to the dictionary for the key
137
- foreach ( var conf in userConfigs )
139
+ var updatedConfig = ConcatHashtables ( config , userConfigs ) ;
140
+
141
+ _configurations [ configKey ] = updatedConfig ;
142
+ }
143
+
144
+ private static Hashtable ConcatHashtables ( Hashtable first , Hashtable second )
145
+ {
146
+ foreach ( DictionaryEntry item in second )
138
147
{
139
- config . Add ( conf . Key , conf . Value ) ;
148
+ first [ item . Key ] = item . Value ;
140
149
}
141
- _configurations [ configKey ] = config ;
150
+ return first ;
142
151
}
143
152
}
144
153
}
0 commit comments