示例#1
0
        public Dictionary<string, ICluster> buildClusters(AbstractAquilesClusterBuilder builder, AquilesConfigurationSection section, ILogger logger)
        {
            Dictionary<string, ICluster> clusters = null;
                CassandraClusterCollection clusterCollection = section.CassandraClusters;
                if (clusterCollection != null && clusterCollection.Count > 0)
                {
                    ICluster cluster = null;
                    clusters = new Dictionary<string, ICluster>(clusterCollection.Count);
                    foreach (CassandraClusterElement clusterConfig in section.CassandraClusters)
                    {
                        try
                        {
                            cluster = builder.Build(clusterConfig, logger);
                        }
                        catch (Exception e)
                        {
                            throw new AquilesConfigurationException("Exception found while creating cluster. See internal exception details.", e);
                        }
                        if (cluster != null)
                        {
                            if (!clusters.ContainsKey(cluster.Name))
                            {
                                clusters.Add(cluster.Name, cluster);
                            }
                        }
                    }
                }
                else
                {
                    throw new AquilesConfigurationException("Aquiles Configuration does not have any cluster configured.");
                }

            return clusters;
        }
示例#2
0
 public AquilesHelper(AbstractAquilesClusterBuilder builder, string sectionConfigurationName)
 {
     AquilesConfigurationSection section = (AquilesConfigurationSection)ConfigurationManager.GetSection(sectionConfigurationName);
     if (section != null)
     {
         ILogger logger = new TraceLogger();
         if (section.LoggingManager != null && section.LoggingManager.Text != null && !String.IsNullOrEmpty(section.LoggingManager.Text))
         {
             // I got some logger configured
             logger = this.CreateLogger(section.LoggingManager.Text);
         }
         this.Clusters = this.buildClusters(builder, section, logger);
     }
     else
     {
         throw new AquilesConfigurationException("Configuration Section not found for '" + sectionConfigurationName + "'");
     }
 }