private static void AddConfigActionComponent(CustomActionComponent configAction, HDInsight.ClusterCreateParametersV2 inputs, ClusterRole headnodeRole, ClusterRole workernodeRole, ClusterRole zookeperRole) { configAction.CustomActions = new CustomActionList(); // Converts config action from PS/SDK to wire contract. foreach (ConfigAction ca in inputs.ConfigActions) { CustomAction newConfigAction; // Based on the config action type defined in SDK, convert them to config action defined in wire contract. ScriptAction sca = ca as ScriptAction; if (sca != null) { newConfigAction = new ScriptCustomAction { Name = ca.Name, Uri = sca.Uri, Parameters = sca.Parameters }; } else { throw new NotSupportedException("No such config action supported."); } newConfigAction.ClusterRoleCollection = new ClusterRoleCollection(); // Add in cluster role collection for each config action. foreach (ClusterNodeType clusterRoleType in ca.ClusterRoleCollection) { if (clusterRoleType == ClusterNodeType.HeadNode) { newConfigAction.ClusterRoleCollection.Add(headnodeRole); } else if (clusterRoleType == ClusterNodeType.DataNode) { newConfigAction.ClusterRoleCollection.Add(workernodeRole); } else if (clusterRoleType == ClusterNodeType.ZookeperNode) { if (inputs.ClusterType.Equals(ClusterType.HBase) || inputs.ClusterType.Equals(ClusterType.Storm)) { newConfigAction.ClusterRoleCollection.Add(zookeperRole); } else { throw new NotSupportedException(string.Format("Customization of zookeper nodes only supported for cluster types {0} and {1}", ClusterType.HBase.ToString(), ClusterType.Storm.ToString())); } } else { throw new NotSupportedException("No such node type supported."); } } configAction.CustomActions.Add(newConfigAction); } }
private static void AddConfigActionComponent(CustomActionComponent configAction, HDInsight.ClusterCreateParameters inputs, ClusterRole headnodeRole, ClusterRole workernodeRole) { configAction.CustomActions = new CustomActionList(); // Converts config action from PS/SDK to wire contract. foreach (ConfigAction ca in inputs.ConfigActions) { CustomAction newConfigAction; // Based on the config action type defined in SDK, convert them to config action defined in wire contract. ScriptAction sca = ca as ScriptAction; if (sca != null) { newConfigAction = new ScriptCustomAction { Name = ca.Name, Uri = sca.Uri, Parameters = sca.Parameters }; } else { throw new NotSupportedException("No such config action supported."); } newConfigAction.ClusterRoleCollection = new ClusterRoleCollection(); // Add in cluster role collection for each config action. foreach (ClusterNodeType clusterRoleType in ca.ClusterRoleCollection) { if (clusterRoleType == ClusterNodeType.HeadNode) { newConfigAction.ClusterRoleCollection.Add(headnodeRole); } else if (clusterRoleType == ClusterNodeType.DataNode) { newConfigAction.ClusterRoleCollection.Add(workernodeRole); } else { throw new NotSupportedException("No such node type supported."); } } configAction.CustomActions.Add(newConfigAction); } }
private static void CopyConfigurationForCluster( Microsoft.WindowsAzure.Management.HDInsight.Contracts.May2014.ClusterCreateParameters payloadObject, HDInsight.ClusterCreateParameters cluster) { var yarn = payloadObject.Components.OfType <YarnComponent>().Single(); var mapreduce = yarn.Applications.OfType <MapReduceApplication>().Single(); var hive = payloadObject.Components.OfType <HiveComponent>().Single(); var oozie = payloadObject.Components.OfType <OozieComponent>().Single(); var hdfs = payloadObject.Components.OfType <HdfsComponent>().Single(); var hadoopCore = payloadObject.Components.OfType <HadoopCoreComponent>().Single(); HBaseComponent hbase = null; if (payloadObject.Components.OfType <HBaseComponent>().Count() == 1) { hbase = payloadObject.Components.OfType <HBaseComponent>().Single(); } StormComponent storm = null; if (payloadObject.Components.OfType <StormComponent>().Count() == 1) { storm = payloadObject.Components.OfType <StormComponent>().Single(); } CustomActionComponent configActions = null; if (payloadObject.Components.OfType <CustomActionComponent>().Count() == 1) { configActions = payloadObject.Components.OfType <CustomActionComponent>().Single(); } if (hadoopCore.CoreSiteXmlProperties.Any()) { cluster.CoreConfiguration.AddRange( hadoopCore.CoreSiteXmlProperties.Select(prop => new KeyValuePair <string, string>(prop.Name, prop.Value))); } if (hdfs.HdfsSiteXmlProperties.Any()) { cluster.HdfsConfiguration.AddRange(hdfs.HdfsSiteXmlProperties.Select(prop => new KeyValuePair <string, string>(prop.Name, prop.Value))); } if (mapreduce.MapRedSiteXmlProperties.Any()) { cluster.MapReduceConfiguration.ConfigurationCollection.AddRange( mapreduce.MapRedSiteXmlProperties.Select(prop => new KeyValuePair <string, string>(prop.Name, prop.Value))); } if (mapreduce.CapacitySchedulerConfiguration.Any()) { cluster.MapReduceConfiguration.CapacitySchedulerConfigurationCollection.AddRange( mapreduce.CapacitySchedulerConfiguration.Select(prop => new KeyValuePair <string, string>(prop.Name, prop.Value))); } if (mapreduce.AdditionalStorageContainers.ToList().Any()) { cluster.AdditionalStorageAccounts.AddRange( from BlobContainerCredentialBackedResource tem in mapreduce.AdditionalStorageContainers select new WabStorageAccountConfiguration(tem.AccountDnsName, tem.Key, tem.BlobContainerName)); } if (yarn.Configuration.Any()) { cluster.YarnConfiguration.AddRange(yarn.Configuration.Select(prop => new KeyValuePair <string, string>(prop.Name, prop.Value))); } if (hive.HiveSiteXmlProperties.Any()) { cluster.HiveConfiguration.ConfigurationCollection.AddRange( hive.HiveSiteXmlProperties.Select(prop => new KeyValuePair <string, string>(prop.Name, prop.Value))); } if (hive.AdditionalLibraries != null) { cluster.HiveConfiguration.AdditionalLibraries = new WabStorageAccountConfiguration( hive.AdditionalLibraries.AccountDnsName, hive.AdditionalLibraries.Key, hive.AdditionalLibraries.BlobContainerName); } if (!hive.Metastore.ShouldProvisionNew) { var metaStore = (SqlAzureDatabaseCredentialBackedResource)hive.Metastore; cluster.HiveMetastore = new Metastore( metaStore.SqlServerName, metaStore.DatabaseName, metaStore.Credentials.Username, metaStore.Credentials.Password); } if (configActions != null) { foreach (var configAction in configActions.CustomActions) { ScriptCustomAction sca = configAction as ScriptCustomAction; if (sca != null) { cluster.ConfigActions.Add(new ScriptAction( sca.Name, ConvertClusterRoleToClusterNodeType(sca), sca.Uri, sca.Parameters)); } } } if (oozie.Configuration.Any()) { cluster.OozieConfiguration.ConfigurationCollection.AddRange( oozie.Configuration.Select(prop => new KeyValuePair <string, string>(prop.Name, prop.Value))); } if (oozie.AdditionalSharedLibraries != null) { cluster.OozieConfiguration.AdditionalSharedLibraries = new WabStorageAccountConfiguration( oozie.AdditionalSharedLibraries.AccountDnsName, oozie.AdditionalSharedLibraries.Key, oozie.AdditionalSharedLibraries.BlobContainerName); } if (oozie.AdditionalActionExecutorLibraries != null) { cluster.OozieConfiguration.AdditionalActionExecutorLibraries = new WabStorageAccountConfiguration( oozie.AdditionalActionExecutorLibraries.AccountDnsName, oozie.AdditionalActionExecutorLibraries.Key, oozie.AdditionalActionExecutorLibraries.BlobContainerName); } if (!oozie.Metastore.ShouldProvisionNew) { var metaStore = (SqlAzureDatabaseCredentialBackedResource)oozie.Metastore; cluster.OozieMetastore = new Metastore( metaStore.SqlServerName, metaStore.DatabaseName, metaStore.Credentials.Username, metaStore.Credentials.Password); } if (hbase != null && hbase.HBaseConfXmlProperties.Any()) { cluster.HBaseConfiguration.ConfigurationCollection.AddRange( hbase.HBaseConfXmlProperties.Select(prop => new KeyValuePair <string, string>(prop.Name, prop.Value))); } if (hbase != null && hbase.AdditionalLibraries != null) { cluster.HBaseConfiguration.AdditionalLibraries = new WabStorageAccountConfiguration( hbase.AdditionalLibraries.AccountDnsName, hbase.AdditionalLibraries.Key, hbase.AdditionalLibraries.BlobContainerName); } if (storm != null && storm.StormConfiguration.Any()) { cluster.StormConfiguration.AddRange( storm.StormConfiguration.Select(prop => new KeyValuePair <string, string>(prop.Name, prop.Value))); } }