Пример #1
0
        /// <summary>
        /// Retrieve current cluster configuration
        /// </summary>
        /// <returns>Dictionary of clusters</returns>
        public Dictionary <string, Cluster> GetClusters()
        {
            ClusterContainer clusterContainer = _ariesApi.GetClusters(simulation._id);

            if (clusterContainer == null)
            {
                return(new Dictionary <string, Cluster>());
            }

            return(clusterContainer.clusters);
        }
Пример #2
0
        private static void CopyConfiguration(ClusterContainer payloadObject, HDInsight.ClusterCreateParameters cluster)
        {
            if (payloadObject.Settings.Core != null && payloadObject.Settings.Core.Configuration != null)
            {
                cluster.CoreConfiguration.AddRange(
                    payloadObject.Settings.Core.Configuration.Select(config => new KeyValuePair <string, string>(config.Name, config.Value)));
            }

            if (payloadObject.Settings.Yarn != null && payloadObject.Settings.Yarn.Configuration != null)
            {
                cluster.YarnConfiguration.AddRange(
                    payloadObject.Settings.Yarn.Configuration.Select(config => new KeyValuePair <string, string>(config.Name, config.Value)));
            }

            if (payloadObject.Settings.Hive != null)
            {
                if (payloadObject.Settings.Hive.AdditionalLibraries != null)
                {
                    cluster.HiveConfiguration.AdditionalLibraries =
                        new WabStorageAccountConfiguration(
                            payloadObject.Settings.Hive.AdditionalLibraries.AccountName,
                            payloadObject.Settings.Hive.AdditionalLibraries.Key,
                            payloadObject.Settings.Hive.AdditionalLibraries.BlobContainerName);
                }

                if (payloadObject.Settings.Hive.Configuration != null)
                {
                    cluster.HiveConfiguration.ConfigurationCollection.AddRange(
                        payloadObject.Settings.Hive.Configuration.Select(config => new KeyValuePair <string, string>(config.Name, config.Value)));
                }
            }

            if (payloadObject.Settings.Hdfs != null && payloadObject.Settings.Hdfs.Configuration != null)
            {
                cluster.HdfsConfiguration.AddRange(
                    payloadObject.Settings.Hdfs.Configuration.Select(config => new KeyValuePair <string, string>(config.Name, config.Value)));
            }

            if (payloadObject.Settings.MapReduce != null && payloadObject.Settings.MapReduce.Configuration != null)
            {
                cluster.MapReduceConfiguration = new HDInsight.MapReduceConfiguration();

                if (payloadObject.Settings.MapReduce.Configuration != null)
                {
                    cluster.MapReduceConfiguration.ConfigurationCollection.AddRange(
                        payloadObject.Settings.MapReduce.Configuration.Select(config => new KeyValuePair <string, string>(config.Name, config.Value)));
                }

                if (payloadObject.Settings.MapReduce.CapacitySchedulerConfiguration != null)
                {
                    cluster.MapReduceConfiguration.CapacitySchedulerConfigurationCollection.AddRange(
                        payloadObject.Settings.MapReduce.CapacitySchedulerConfiguration.Select(config => new KeyValuePair <string, string>(config.Name, config.Value)));
                }
            }

            if (payloadObject.Settings.Oozie != null && payloadObject.Settings.Oozie.Configuration != null)
            {
                if (cluster.OozieConfiguration.ConfigurationCollection != null)
                {
                    cluster.OozieConfiguration.ConfigurationCollection.AddRange(
                        payloadObject.Settings.Oozie.Configuration.Select(config => new KeyValuePair <string, string>(config.Name, config.Value)));
                }

                if (payloadObject.Settings.Oozie.AdditionalSharedLibraries != null)
                {
                    cluster.OozieConfiguration.AdditionalSharedLibraries =
                        new WabStorageAccountConfiguration(
                            payloadObject.Settings.Oozie.AdditionalSharedLibraries.AccountName,
                            payloadObject.Settings.Oozie.AdditionalSharedLibraries.Key,
                            payloadObject.Settings.Oozie.AdditionalSharedLibraries.BlobContainerName);
                }

                if (payloadObject.Settings.Oozie.AdditionalActionExecutorLibraries != null)
                {
                    cluster.OozieConfiguration.AdditionalActionExecutorLibraries =
                        new WabStorageAccountConfiguration(
                            payloadObject.Settings.Oozie.AdditionalActionExecutorLibraries.AccountName,
                            payloadObject.Settings.Oozie.AdditionalActionExecutorLibraries.Key,
                            payloadObject.Settings.Oozie.AdditionalActionExecutorLibraries.BlobContainerName);
                }
            }
        }
Пример #3
0
        private static HDInsight.ClusterCreateParameters CreateClusterRequest_FromInternal(ClusterContainer payloadObject)
        {
            var cluster = new HDInsight.ClusterCreateParameters
            {
                Location = payloadObject.Region,
                Name     = payloadObject.ClusterName
            };

            cluster.UserName = payloadObject.Deployment.ClusterUsername;
            cluster.Password = payloadObject.Deployment.ClusterPassword;
            cluster.Version  = payloadObject.Deployment.Version;
            cluster.DefaultStorageAccountName = payloadObject.StorageAccounts[0].AccountName;
            cluster.DefaultStorageAccountKey  = payloadObject.StorageAccounts[0].Key;
            cluster.DefaultStorageContainer   = payloadObject.StorageAccounts[0].BlobContainerName;

            var headnodeRole = payloadObject.Deployment.Roles.Single(r => r.RoleType == ClusterRoleType.HeadNode);

            //if headnode count is 1 and size XL, then we treat it as Default on the server side
            if (headnodeRole.VMSize == Microsoft.WindowsAzure.Management.HDInsight.Contracts.May2013.NodeVMSize.ExtraLarge && headnodeRole.Count == 1)
            {
                cluster.HeadNodeSize = HDInsight.NodeVMSize.Default;
            }
            else
            {
                switch (headnodeRole.VMSize)
                {
                case Microsoft.WindowsAzure.Management.HDInsight.Contracts.May2013.NodeVMSize.ExtraLarge:
                    cluster.HeadNodeSize = HDInsight.NodeVMSize.ExtraLarge;
                    break;

                case Microsoft.WindowsAzure.Management.HDInsight.Contracts.May2013.NodeVMSize.Large:
                    cluster.HeadNodeSize = HDInsight.NodeVMSize.Large;
                    break;

                default:
                    throw new InvalidDataContractException(string.Format("The server returned an unsupported value for head node VM size '{0}", headnodeRole.VMSize));
                }
            }

            foreach (var asv in payloadObject.StorageAccounts.Skip(1))
            {
                cluster.AdditionalStorageAccounts.Add(new WabStorageAccountConfiguration(asv.AccountName, asv.Key));
            }

            if (payloadObject.Settings != null)
            {
                CopyConfiguration(payloadObject, cluster);

                if (payloadObject.Settings.Oozie != null)
                {
                    if (payloadObject.Settings.Oozie.Catalog != null)
                    {
                        var oozieMetaStore = payloadObject.Settings.Oozie.Catalog;
                        cluster.OozieMetastore = new Metastore(oozieMetaStore.Server,
                                                               oozieMetaStore.DatabaseName,
                                                               oozieMetaStore.Username,
                                                               oozieMetaStore.Password);
                    }
                }

                if (payloadObject.Settings.Hive != null)
                {
                    if (payloadObject.Settings.Hive.Catalog != null)
                    {
                        var hiveMetaStore = payloadObject.Settings.Hive.Catalog;
                        cluster.HiveMetastore = new Metastore(hiveMetaStore.Server,
                                                              hiveMetaStore.DatabaseName,
                                                              hiveMetaStore.Username,
                                                              hiveMetaStore.Password);
                    }
                }
            }

            cluster.ClusterSizeInNodes = payloadObject.Deployment.Roles.Sum(role => role.Count);
            return(cluster);
        }