示例#1
0
        private static ServerInfo GetLocalConfiguration()
        {
            //LOCAL override CLUSTER
            var entries        = new Network.ServerInfo();
            var server_entries = s_current_cluster_config.GetMyServerInfo();
            var proxy_entries  = s_current_cluster_config.GetMyProxyInfo();

            if (proxy_entries != null)
            {
                entries.Merge(proxy_entries);
            }
            if (server_entries != null)
            {
                entries.Merge(server_entries);
            }

            foreach (var entry in s_localConfigurationSection)
            {
                entries[entry.Key] = entry.Value;
            }

            return(entries);
        }
示例#2
0
        internal static void LoadTrinityConfig(string trinity_config_file, bool forceLoad = false)
        {
            lock (config_load_lock)
            {
                if (is_config_loaded && !forceLoad)
                {
                    return;
                }
                if (!File.Exists(trinity_config_file))
                {
                    return;
                }

                var config = XmlConfiguration.Load(trinity_config_file);

                s_clusterConfigurations.Clear();
                s_localConfigurationSection.Clear();

                if (config.RootConfigVersion == ConfigurationConstants.Tags.LEGACYVER)
                {
                    LoadConfigLegacy(trinity_config_file);
                }
                else if (config.RootConfigVersion == ConfigurationConstants.Tags.CURRENTVER)
                {
                    s_localConfigurationSection = new ConfigurationSection(config.LocalSection);
                    var clusterSections = config.ClusterSections;
                    foreach (var clusterSection in clusterSections)
                    {
                        if (clusterSection.Attribute(ConfigurationConstants.Attrs.ID) != null)
                        {
                            s_clusterConfigurations.Add(clusterSection.Attribute(ConfigurationConstants.Attrs.ID).Value, new ClusterConfig(clusterSection));
                        }
                    }

                    s_current_cluster_config = new ClusterConfig(clusterSections.FirstOrDefault(
                                                                     _ => _.Attribute(ConfigurationConstants.Attrs.ID) == null) ??
                                                                 new XElement(ConfigurationConstants.Tags.CLUSTER));

                    s_clusterConfigurations.Add(ConfigurationConstants.Tags.DEFAULT_CLUSTER, s_current_cluster_config);
                }
                else
                {
                    throw new TrinityConfigException("Unrecognized " + ConfigurationConstants.Attrs.CONFIG_VERSION);
                }
                //LOCAL override CLUSTER
                var entries        = new Network.ServerInfo();
                var server_entries = s_current_cluster_config.GetMyServerInfo();
                var proxy_entries  = s_current_cluster_config.GetMyProxyInfo();
                if (proxy_entries != null)
                {
                    entries.Merge(proxy_entries);
                }
                if (server_entries != null)
                {
                    entries.Merge(server_entries);
                }

                foreach (var entry in s_localConfigurationSection)
                {
                    entries[entry.Key] = entry.Value;
                }

                ApplyConfigurationSettings(entries);

                is_config_loaded = true;
            }
        }
 /// <summary>
 /// Initializes a new instance of <see cref="Trinity.Network.AvailabilityGroup"/> class with one server.
 /// </summary>
 /// <param name="id">The id of the availability group.</param>
 /// <param name="serverInfo">A <see cref="Trinity.Network.ServerConfigurationSection"/> instance containing the information of the specified server.</param>
 public AvailabilityGroup(string id, ServerInfo serverInfo)
 {
     this.Id   = id;
     Instances = new List <ServerInfo>();
     Instances.Add(serverInfo);
 }