Esempio n. 1
0
		internal static void SetDagNetwork(SetDagNetworkRequest changeReq)
		{
			NetworkManager.RunRpcOperation("SetDagNetwork", delegate(object param0, EventArgs param1)
			{
				NetworkManager manager = NetworkManager.GetManager();
				if (manager == null)
				{
					throw new DagNetworkManagementException(ReplayStrings.NetworkManagerInitError);
				}
				lock (manager.m_mapRefreshLock)
				{
					using (DagConfigurationStore dagConfigurationStore = new DagConfigurationStore())
					{
						dagConfigurationStore.Open();
						PersistentDagNetworkConfig persistentDagNetworkConfig = dagConfigurationStore.LoadNetworkConfig();
						if (persistentDagNetworkConfig != null)
						{
							string text = persistentDagNetworkConfig.Serialize();
							ReplayEventLogConstants.Tuple_DagNetworkConfigOld.LogEvent(DateTime.UtcNow.ToString(), new object[]
							{
								text
							});
						}
					}
					ExchangeNetworkMap exchangeNetworkMap = NetworkManager.FetchInitializedMap();
					PersistentDagNetworkConfig netConfig = exchangeNetworkMap.UpdateNetConfig(changeReq);
					manager.UpdateNetworkConfig(netConfig);
				}
			});
		}
Esempio n. 2
0
 public void LoadExistingConfiguration(PersistentDagNetworkConfig existingConfig)
 {
     foreach (PersistentDagNetwork persistentDagNetwork in existingConfig.Networks)
     {
         LogicalNetwork logicalNetwork = this.AddNewLogicalNetwork();
         logicalNetwork.Name               = persistentDagNetwork.Name;
         logicalNetwork.Description        = persistentDagNetwork.Description;
         logicalNetwork.ReplicationEnabled = persistentDagNetwork.ReplicationEnabled;
         logicalNetwork.IgnoreNetwork      = persistentDagNetwork.IgnoreNetwork;
         foreach (string expression in persistentDagNetwork.Subnets)
         {
             DatabaseAvailabilityGroupSubnetId databaseAvailabilityGroupSubnetId = new DatabaseAvailabilityGroupSubnetId(expression);
             if (this.m_subnets.ContainsKey(databaseAvailabilityGroupSubnetId))
             {
                 string errorText = string.Format("Ignoring inconsistent DagNetworkConfig. Subnet {0} is defined in multiple places.", databaseAvailabilityGroupSubnetId);
                 this.RecordInconsistency(errorText);
             }
             else
             {
                 Subnet subnet = new Subnet(databaseAvailabilityGroupSubnetId);
                 subnet.LogicalNetwork = logicalNetwork;
                 this.m_subnets.Add(databaseAvailabilityGroupSubnetId, subnet);
                 logicalNetwork.Add(subnet);
             }
         }
     }
 }
        // Token: 0x060008A6 RID: 2214 RVA: 0x00029210 File Offset: 0x00027410
        public string StoreNetworkConfig(PersistentDagNetworkConfig cfg)
        {
            string text = cfg.Serialize();

            this.StoreNetworkConfig(text);
            return(text);
        }
Esempio n. 4
0
		internal static void SetDagNetworkConfig(SetDagNetworkConfigRequest configChange)
		{
			NetworkManager.RunRpcOperation("SetDagNetworkConfig", delegate(object param0, EventArgs param1)
			{
				NetworkManager manager = NetworkManager.GetManager();
				if (manager == null)
				{
					throw new DagNetworkManagementException(ReplayStrings.NetworkManagerInitError);
				}
				lock (manager.m_mapRefreshLock)
				{
					using (IAmCluster amCluster = ClusterFactory.Instance.Open())
					{
						using (DagConfigurationStore dagConfigurationStore = new DagConfigurationStore())
						{
							dagConfigurationStore.Open();
							PersistentDagNetworkConfig persistentDagNetworkConfig = dagConfigurationStore.LoadNetworkConfig();
							if (persistentDagNetworkConfig == null)
							{
								persistentDagNetworkConfig = new PersistentDagNetworkConfig();
							}
							else
							{
								string text = persistentDagNetworkConfig.Serialize();
								ReplayEventLogConstants.Tuple_DagNetworkConfigOld.LogEvent(DateTime.UtcNow.ToString(), new object[]
								{
									text
								});
							}
							if (configChange.SetPort)
							{
								persistentDagNetworkConfig.ReplicationPort = configChange.ReplicationPort;
								manager.ReplicationPort = configChange.ReplicationPort;
							}
							manager.NetworkCompression = configChange.NetworkCompression;
							persistentDagNetworkConfig.NetworkCompression = configChange.NetworkCompression;
							manager.NetworkEncryption = configChange.NetworkEncryption;
							persistentDagNetworkConfig.NetworkEncryption = configChange.NetworkEncryption;
							manager.ManualDagNetworkConfiguration = configChange.ManualDagNetworkConfiguration;
							persistentDagNetworkConfig.ManualDagNetworkConfiguration = configChange.ManualDagNetworkConfiguration;
							if (configChange.DiscoverNetworks)
							{
								NetworkDiscovery networkDiscovery = new NetworkDiscovery();
								networkDiscovery.LoadClusterObjects(amCluster);
								networkDiscovery.DetermineDnsStatus();
								networkDiscovery.AggregateNetworks(true);
								ExchangeNetworkMap exchangeNetworkMap = new ExchangeNetworkMap(manager);
								exchangeNetworkMap.Load(networkDiscovery);
								persistentDagNetworkConfig = exchangeNetworkMap.BuildPersistentDagNetworkConfig();
							}
							manager.UpdateNetworkConfig(persistentDagNetworkConfig);
						}
					}
				}
			});
		}
        // Token: 0x060008A4 RID: 2212 RVA: 0x000291C4 File Offset: 0x000273C4
        public PersistentDagNetworkConfig LoadNetworkConfig(out string xmlText)
        {
            bool flag = false;

            xmlText = this.m_regHandle.GetValue("Configuration", null, out flag, null);
            if (flag)
            {
                return(PersistentDagNetworkConfig.Deserialize(xmlText));
            }
            return(null);
        }
Esempio n. 6
0
		private void UpdateNetworkConfig(PersistentDagNetworkConfig netConfig)
		{
			using (DagConfigurationStore dagConfigurationStore = new DagConfigurationStore())
			{
				dagConfigurationStore.Open();
				Interlocked.Exchange(ref this.m_skipNextClusterRegistryEvent, 1);
				string text = dagConfigurationStore.StoreNetworkConfig(netConfig);
				this.m_lastWrittenClusterNetConfigXML = text;
				ReplayEventLogConstants.Tuple_DagNetworkConfigNew.LogEvent(DateTime.UtcNow.ToString(), new object[]
				{
					text
				});
				this.EseReplDagNetConfigIsStale = true;
				this.DriveMapRefresh();
			}
		}
Esempio n. 7
0
		internal static void RemoveDagNetwork(RemoveDagNetworkRequest req)
		{
			NetworkManager.RunRpcOperation("RemoveDagNetwork", delegate(object param0, EventArgs param1)
			{
				NetworkManager manager = NetworkManager.GetManager();
				if (manager == null)
				{
					throw new DagNetworkManagementException(ReplayStrings.NetworkManagerInitError);
				}
				lock (manager.m_mapRefreshLock)
				{
					using (DagConfigurationStore dagConfigurationStore = new DagConfigurationStore())
					{
						dagConfigurationStore.Open();
						PersistentDagNetworkConfig persistentDagNetworkConfig = dagConfigurationStore.LoadNetworkConfig();
						if (persistentDagNetworkConfig != null)
						{
							string text = persistentDagNetworkConfig.Serialize();
							ReplayEventLogConstants.Tuple_DagNetworkConfigOld.LogEvent(DateTime.UtcNow.ToString(), new object[]
							{
								text
							});
						}
					}
					ExchangeNetworkMap exchangeNetworkMap = NetworkManager.FetchInitializedMap();
					PersistentDagNetworkConfig persistentDagNetworkConfig2 = exchangeNetworkMap.BuildPersistentDagNetworkConfig();
					if (!persistentDagNetworkConfig2.RemoveNetwork(req.Name))
					{
						NetworkManager.TraceError("RemoveDagNetwork {0} not found", new object[]
						{
							req.Name
						});
						throw new DagNetworkManagementException(ReplayStrings.NetworkNameNotFound(req.Name));
					}
					manager.UpdateNetworkConfig(persistentDagNetworkConfig2);
				}
			});
		}
Esempio n. 8
0
        // Token: 0x0600177E RID: 6014 RVA: 0x0006121C File Offset: 0x0005F41C
        internal PersistentDagNetworkConfig UpdateNetConfig(SetDagNetworkRequest changeReq)
        {
            ExchangeNetwork network = this.GetNetwork(changeReq.Name);

            if (changeReq.NewName != null)
            {
                ExchangeNetwork network2 = this.GetNetwork(changeReq.NewName);
                if (network2 != null && network2 != network)
                {
                    NetworkManager.TraceError("SetDagNetwork Cannot rename {0} because {1} already exists", new object[]
                    {
                        changeReq.Name,
                        changeReq.NewName
                    });
                    throw new DagNetworkManagementException(ServerStrings.DagNetworkCreateDupName(changeReq.NewName));
                }
            }
            PersistentDagNetworkConfig persistentDagNetworkConfig = this.BuildNetConfigWithChange(changeReq);

            if (network == null)
            {
                PersistentDagNetwork persistentDagNetwork = new PersistentDagNetwork();
                persistentDagNetwork.Name               = changeReq.Name;
                persistentDagNetwork.Description        = changeReq.Description;
                persistentDagNetwork.IgnoreNetwork      = changeReq.IgnoreNetwork;
                persistentDagNetwork.ReplicationEnabled = changeReq.ReplicationEnabled;
                if (changeReq.Subnets.Count > 0)
                {
                    foreach (DatabaseAvailabilityGroupSubnetId databaseAvailabilityGroupSubnetId in changeReq.Subnets.Keys)
                    {
                        persistentDagNetwork.Subnets.Add(databaseAvailabilityGroupSubnetId.ToString());
                    }
                }
                persistentDagNetworkConfig.Networks.Add(persistentDagNetwork);
            }
            return(persistentDagNetworkConfig);
        }
Esempio n. 9
0
        // Token: 0x0600177D RID: 6013 RVA: 0x00060F88 File Offset: 0x0005F188
        private PersistentDagNetworkConfig BuildNetConfigWithChange(SetDagNetworkRequest changeReq)
        {
            PersistentDagNetworkConfig persistentDagNetworkConfig = new PersistentDagNetworkConfig();

            persistentDagNetworkConfig.ReplicationPort    = this.m_mgr.ReplicationPort;
            persistentDagNetworkConfig.NetworkCompression = this.m_mgr.NetworkCompression;
            persistentDagNetworkConfig.NetworkEncryption  = this.m_mgr.NetworkEncryption;
            foreach (KeyValuePair <string, ExchangeNetwork> keyValuePair in this.m_networks)
            {
                ExchangeNetwork      value = keyValuePair.Value;
                PersistentDagNetwork persistentDagNetwork = new PersistentDagNetwork();
                persistentDagNetwork.Name               = value.Name;
                persistentDagNetwork.Description        = value.Description;
                persistentDagNetwork.ReplicationEnabled = value.ReplicationEnabled;
                persistentDagNetwork.IgnoreNetwork      = value.IgnoreNetwork;
                bool flag = false;
                if (changeReq != null && DatabaseAvailabilityGroupNetwork.NameComparer.Equals(changeReq.Name, value.Name))
                {
                    if (changeReq.NewName != null)
                    {
                        persistentDagNetwork.Name = changeReq.NewName;
                    }
                    if (changeReq.Description != null)
                    {
                        persistentDagNetwork.Description = changeReq.Description;
                    }
                    if (changeReq.IsIgnoreChanged)
                    {
                        persistentDagNetwork.IgnoreNetwork = changeReq.IgnoreNetwork;
                    }
                    if (changeReq.IsReplicationChanged)
                    {
                        persistentDagNetwork.ReplicationEnabled = changeReq.ReplicationEnabled;
                    }
                    if (changeReq.SubnetListIsSet || changeReq.Subnets.Count > 0)
                    {
                        flag = true;
                        foreach (KeyValuePair <DatabaseAvailabilityGroupSubnetId, object> keyValuePair2 in changeReq.Subnets)
                        {
                            persistentDagNetwork.Subnets.Add(keyValuePair2.Key.ToString());
                        }
                    }
                }
                if (!flag)
                {
                    foreach (ExchangeSubnet exchangeSubnet in value.Subnets)
                    {
                        if (changeReq != null && changeReq.Subnets.Count > 0 && changeReq.Subnets.ContainsKey(exchangeSubnet.SubnetId))
                        {
                            NetworkManager.TraceDebug("Subnet '{0}' moving from net '{1}' to net '{2}'", new object[]
                            {
                                exchangeSubnet.SubnetId,
                                value.Name,
                                changeReq.LatestName
                            });
                        }
                        else
                        {
                            string item = exchangeSubnet.SubnetId.ToString();
                            persistentDagNetwork.Subnets.Add(item);
                        }
                    }
                }
                persistentDagNetworkConfig.Networks.Add(persistentDagNetwork);
            }
            return(persistentDagNetworkConfig);
        }
Esempio n. 10
0
		private void EnumerateNetworkMap()
		{
			NetworkManager.TraceDebug("EnumerateNetworkMap: attempting to reload", new object[0]);
			using (IAmCluster amCluster = ClusterFactory.Instance.Open())
			{
				PersistentDagNetworkConfig persistentDagNetworkConfig = null;
				string text = null;
				Exception ex = null;
				using (DagConfigurationStore dagConfigurationStore = new DagConfigurationStore())
				{
					dagConfigurationStore.Open();
					persistentDagNetworkConfig = dagConfigurationStore.LoadNetworkConfig(out text);
					PersistentDagNetworkConfig persistentDagNetworkConfig2;
					if (persistentDagNetworkConfig == null)
					{
						persistentDagNetworkConfig2 = new PersistentDagNetworkConfig();
					}
					else
					{
						persistentDagNetworkConfig2 = persistentDagNetworkConfig.Copy();
					}
					IADDatabaseAvailabilityGroup localDag = Dependencies.ADConfig.GetLocalDag();
					if (localDag == null)
					{
						NetworkManager.TraceError("EnumerateNetworkMap can't get the DAG!", new object[0]);
					}
					else
					{
						if (persistentDagNetworkConfig2.NetworkCompression != localDag.NetworkCompression)
						{
							persistentDagNetworkConfig2.NetworkCompression = localDag.NetworkCompression;
						}
						if (persistentDagNetworkConfig2.NetworkEncryption != localDag.NetworkEncryption)
						{
							persistentDagNetworkConfig2.NetworkEncryption = localDag.NetworkEncryption;
						}
						if (persistentDagNetworkConfig2.ManualDagNetworkConfiguration != localDag.ManualDagNetworkConfiguration)
						{
							persistentDagNetworkConfig2.ManualDagNetworkConfiguration = localDag.ManualDagNetworkConfiguration;
						}
					}
					this.NetworkCompression = persistentDagNetworkConfig2.NetworkCompression;
					this.NetworkEncryption = persistentDagNetworkConfig2.NetworkEncryption;
					this.ReplicationPort = persistentDagNetworkConfig2.ReplicationPort;
					this.ManualDagNetworkConfiguration = persistentDagNetworkConfig2.ManualDagNetworkConfiguration;
					if (this.m_portInLocalRegistry != this.ReplicationPort && TcpPortFallback.StorePortNumber(this.ReplicationPort))
					{
						this.m_portInLocalRegistry = this.ReplicationPort;
					}
					NetworkDiscovery networkDiscovery = new NetworkDiscovery();
					networkDiscovery.LoadClusterObjects(amCluster);
					if (this.ManualDagNetworkConfiguration)
					{
						networkDiscovery.LoadExistingConfiguration(persistentDagNetworkConfig2);
					}
					networkDiscovery.DetermineDnsStatus();
					networkDiscovery.AggregateNetworks(true);
					if (!this.ManualDagNetworkConfiguration)
					{
						networkDiscovery.RemoveEmptyNets();
					}
					ExchangeNetworkMap exchangeNetworkMap = new ExchangeNetworkMap(this);
					exchangeNetworkMap.Load(networkDiscovery);
					AmConfig config = AmSystemManager.Instance.Config;
					if (config.IsPAM)
					{
						try
						{
							exchangeNetworkMap.SynchronizeClusterNetworkRoles(amCluster);
						}
						catch (ClusCommonFailException ex2)
						{
							NetworkManager.TraceError("SynchronizeClusterNetworkRoles threw: {0}", new object[]
							{
								ex2
							});
							ex = ex2;
						}
					}
					exchangeNetworkMap.SetupPerfmon();
					persistentDagNetworkConfig2 = exchangeNetworkMap.BuildPersistentDagNetworkConfig();
					string text2 = persistentDagNetworkConfig2.Serialize();
					bool flag = false;
					if (config.IsPAM)
					{
						if (persistentDagNetworkConfig == null || text != text2)
						{
							flag = true;
							Interlocked.Exchange(ref this.m_skipNextClusterRegistryEvent, 1);
							dagConfigurationStore.StoreNetworkConfig(text2);
							if (persistentDagNetworkConfig != null)
							{
								ReplayEventLogConstants.Tuple_DagNetworkConfigOld.LogEvent("DAGNET", new object[]
								{
									text
								});
							}
						}
					}
					else if (this.m_lastWrittenClusterNetConfigXML != null && this.m_lastWrittenClusterNetConfigXML != text2)
					{
						flag = true;
					}
					if (flag)
					{
						ReplayEventLogConstants.Tuple_DagNetworkConfigNew.LogEvent("DAGNET", new object[]
						{
							text2
						});
					}
					this.m_lastWrittenClusterNetConfigXML = text2;
					DagNetConfig dagNetConfig = this.Convert2DagNetConfig(networkDiscovery);
					string text3 = dagNetConfig.Serialize();
					if (this.m_lastWrittenEseReplNetConfigXML == null || this.EseReplDagNetConfigIsStale || text3 != this.m_lastWrittenEseReplNetConfigXML)
					{
						DagNetEnvironment.PublishDagNetConfig(text3);
						this.EseReplDagNetConfigIsStale = false;
					}
					this.m_lastWrittenEseReplNetConfigXML = text3;
					this.m_mapLoadTime = ExDateTime.Now;
					this.m_netMap = exchangeNetworkMap;
					NetworkManager.TraceDebug("EnumerateNetworkMap: completed reload", new object[0]);
					AmSystemManager instance = AmSystemManager.Instance;
					if (instance != null)
					{
						AmNetworkMonitor networkMonitor = instance.NetworkMonitor;
						if (networkMonitor != null)
						{
							networkMonitor.RefreshMapiNetwork();
						}
					}
					if (ex != null)
					{
						throw ex;
					}
				}
			}
		}
Esempio n. 11
0
        // Token: 0x060017E7 RID: 6119 RVA: 0x00062F4C File Offset: 0x0006114C
        internal PersistentDagNetworkConfig Copy()
        {
            string xmlText = this.Serialize();

            return(PersistentDagNetworkConfig.Deserialize(xmlText));
        }