Example #1
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);
						}
					}
				}
			});
		}
Example #2
0
		private DagNetConfig Convert2DagNetConfig(NetworkDiscovery map)
		{
			DagNetConfig dagNetConfig = new DagNetConfig();
			dagNetConfig.ReplicationPort = (int)this.ReplicationPort;
			dagNetConfig.NetworkCompression = NetworkManager.MapESEReplNetworkOption(this.NetworkCompression);
			dagNetConfig.NetworkEncryption = NetworkManager.MapESEReplNetworkOption(this.NetworkEncryption);
			foreach (LogicalNetwork logicalNetwork in map.LogicalNetworks)
			{
				DagNetwork dagNetwork = new DagNetwork();
				dagNetwork.Name = logicalNetwork.Name;
				dagNetwork.Description = logicalNetwork.Description;
				dagNetwork.ReplicationEnabled = logicalNetwork.ReplicationEnabled;
				dagNetwork.IsDnsMapped = logicalNetwork.HasDnsNic();
				foreach (Subnet subnet in logicalNetwork.Subnets)
				{
					dagNetwork.Subnets.Add(subnet.SubnetId.ToString());
				}
				dagNetConfig.Networks.Add(dagNetwork);
			}
			foreach (ClusterNode clusterNode in map.Nodes)
			{
				DagNode dagNode = new DagNode();
				dagNode.Name = clusterNode.Name.NetbiosName;
				foreach (ClusterNic clusterNic in clusterNode.Nics)
				{
					if (clusterNic.IPAddress != null)
					{
						DagNode.Nic nic = new DagNode.Nic();
						nic.IpAddress = clusterNic.IPAddress.ToString();
						nic.NetworkName = clusterNic.ClusterNetwork.LogicalNetwork.Name;
						dagNode.Nics.Add(nic);
					}
				}
				dagNetConfig.Nodes.Add(dagNode);
			}
			return dagNetConfig;
		}
Example #3
0
        // Token: 0x0600177A RID: 6010 RVA: 0x00060C0C File Offset: 0x0005EE0C
        internal void Load(NetworkDiscovery netConfig)
        {
            this.m_preferredNets = new List <ExchangeNetwork>();
            this.m_regularNets   = new List <ExchangeNetwork>();
            foreach (ClusterNode clusterNode in netConfig.Nodes)
            {
                ExchangeNetworkNode exchangeNetworkNode = new ExchangeNetworkNode(clusterNode.Name.NetbiosName);
                exchangeNetworkNode.ClusterState = clusterNode.ClusterState;
                this.m_nodes.Add(exchangeNetworkNode.Name, exchangeNetworkNode);
            }
            string machineName     = Environment.MachineName;
            int    sourceNodeIndex = this.Nodes.IndexOfKey(machineName);

            this.SourceNodeIndex = sourceNodeIndex;
            foreach (LogicalNetwork logicalNetwork in netConfig.LogicalNetworks)
            {
                ExchangeNetwork exchangeNetwork = new ExchangeNetwork(logicalNetwork.Name, this);
                exchangeNetwork.Description        = logicalNetwork.Description;
                exchangeNetwork.ReplicationEnabled = logicalNetwork.ReplicationEnabled;
                exchangeNetwork.IgnoreNetwork      = logicalNetwork.IgnoreNetwork;
                exchangeNetwork.MapiAccessEnabled  = logicalNetwork.HasDnsNic();
                this.m_networks.Add(exchangeNetwork.Name, exchangeNetwork);
                foreach (Subnet subnet in logicalNetwork.Subnets)
                {
                    if (this.m_subnets.ContainsKey(subnet.SubnetId))
                    {
                        exchangeNetwork.IsMisconfigured = true;
                        string errorText = string.Format("Ignoring subnet {0}. It was mapped to multiple nets.", subnet.SubnetId);
                        this.RecordInconsistency(errorText);
                    }
                    else
                    {
                        ExchangeSubnet exchangeSubnet = this.AddSubnetToMap(subnet.SubnetId, exchangeNetwork);
                        ClusterNetwork clusterNetwork = subnet.ClusterNetwork;
                        if (clusterNetwork == null)
                        {
                            exchangeNetwork.IsMisconfigured = true;
                            string errorText2 = string.Format("Subnet {0} configured but no cluster network matched.", subnet.SubnetId);
                            this.RecordInconsistency(errorText2);
                        }
                        else
                        {
                            exchangeSubnet.SubnetAndState.State = ExchangeSubnet.MapSubnetState(clusterNetwork.ClusterState);
                            foreach (ClusterNic clusterNic in clusterNetwork.Nics)
                            {
                                int num = this.Nodes.IndexOfKey(clusterNic.NodeName);
                                if (num < 0)
                                {
                                    string errorText3 = string.Format("Nic {0} has unknown Node {1}.", clusterNic.IPAddress, clusterNic.NodeName);
                                    this.RecordInconsistency(errorText3);
                                }
                                else
                                {
                                    NetworkEndPoint networkEndPoint = new NetworkEndPoint(clusterNic.IPAddress, clusterNic.NodeName, exchangeSubnet);
                                    exchangeSubnet.Network.AddEndPoint(networkEndPoint, num);
                                    networkEndPoint.CopyClusterNicState(clusterNic.ClusterState);
                                }
                            }
                        }
                    }
                }
                if (!exchangeNetwork.IgnoreNetwork && exchangeNetwork.Subnets.Count != 0 && exchangeNetwork.ReplicationEnabled)
                {
                    if (exchangeNetwork.MapiAccessEnabled)
                    {
                        this.m_regularNets.Add(exchangeNetwork);
                    }
                    else
                    {
                        this.m_preferredNets.Add(exchangeNetwork);
                    }
                }
            }
        }
Example #4
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;
					}
				}
			}
		}