Example #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);
				}
			});
		}
Example #2
0
 // Token: 0x06001780 RID: 6016 RVA: 0x000613DC File Offset: 0x0005F5DC
 internal ExchangeNetwork LookupEndPoint(IPAddress ipAddr, out NetworkEndPoint matchingEndPoint)
 {
     matchingEndPoint = null;
     ipAddr           = ExchangeNetworkMap.ConvertIP4Over6To4(ipAddr);
     this.GetReaderLock();
     try
     {
         foreach (KeyValuePair <string, ExchangeNetwork> keyValuePair in this.m_networks)
         {
             ExchangeNetwork value = keyValuePair.Value;
             if (value.EndPoints != null)
             {
                 foreach (NetworkNodeEndPoints networkNodeEndPoints in value.EndPoints)
                 {
                     if (networkNodeEndPoints != null && networkNodeEndPoints.EndPoints.Count > 0)
                     {
                         NetworkEndPoint networkEndPoint = networkNodeEndPoints.EndPoints[0];
                         if (networkEndPoint.IPAddress.Equals(ipAddr))
                         {
                             matchingEndPoint = networkEndPoint;
                             return(value);
                         }
                     }
                 }
             }
         }
     }
     finally
     {
         this.ReleaseReaderLock();
     }
     return(null);
 }
Example #3
0
		internal static ExchangeNetwork GetNetwork(string netName)
		{
			ExchangeNetworkMap map = NetworkManager.GetMap();
			if (map != null)
			{
				return map.GetNetwork(netName);
			}
			return null;
		}
Example #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);
						}
					}
				}
			});
		}
Example #5
0
		internal static ExchangeNetwork LookupEndPoint(IPAddress ipAddr, out NetworkEndPoint endPoint)
		{
			endPoint = null;
			ExchangeNetworkMap map = NetworkManager.GetMap();
			if (map != null)
			{
				return map.LookupEndPoint(ipAddr, out endPoint);
			}
			return null;
		}
Example #6
0
		internal static DagNetworkConfiguration GetDagNetworkConfig()
		{
			DagNetworkConfiguration config = null;
			NetworkManager.RunRpcOperation("GetDagNetworkConfig", delegate(object param0, EventArgs param1)
			{
				ExchangeNetworkMap exchangeNetworkMap = NetworkManager.FetchInitializedMap();
				config = new DagNetworkConfiguration();
				config.NetworkCompression = exchangeNetworkMap.NetworkManager.NetworkCompression;
				config.NetworkEncryption = exchangeNetworkMap.NetworkManager.NetworkEncryption;
				config.ReplicationPort = exchangeNetworkMap.NetworkManager.ReplicationPort;
				config.Networks = exchangeNetworkMap.GetDagNets();
			});
			return config;
		}
Example #7
0
		internal static TcpClientChannel OpenConnection(ref NetworkPath actualPath, int timeoutInMsec, bool ignoreNodeDown)
		{
			NetworkPath networkPath = actualPath;
			NetworkTransportException ex = null;
			ITcpConnector tcpConnector = Dependencies.TcpConnector;
			TcpClientChannel tcpClientChannel = tcpConnector.TryConnect(networkPath, timeoutInMsec, out ex);
			if (tcpClientChannel != null)
			{
				return tcpClientChannel;
			}
			if (!networkPath.NetworkChoiceIsMandatory)
			{
				NetworkManager.TraceError("Attempting alternate routes", new object[0]);
				List<NetworkPath> list = null;
				ExchangeNetworkMap map = NetworkManager.GetMap();
				if (map != null)
				{
					list = map.EnumeratePaths(networkPath.TargetNodeName, ignoreNodeDown);
					if (list != null)
					{
						NetworkPath networkPath2 = null;
						foreach (NetworkPath networkPath3 in list)
						{
							if (string.Equals(networkPath3.NetworkName, networkPath.NetworkName, DatabaseAvailabilityGroupNetwork.NameComparison))
							{
								networkPath2 = networkPath3;
								break;
							}
						}
						if (networkPath2 != null)
						{
							list.Remove(networkPath2);
						}
						DagNetConfig dagConfig = DagNetEnvironment.FetchNetConfig();
						foreach (NetworkPath networkPath4 in list)
						{
							networkPath4.Purpose = networkPath.Purpose;
							networkPath4.ApplyNetworkPolicy(dagConfig);
							tcpClientChannel = tcpConnector.TryConnect(networkPath, timeoutInMsec, out ex);
							if (tcpClientChannel != null)
							{
								actualPath = networkPath4;
								return tcpClientChannel;
							}
						}
					}
				}
			}
			throw ex;
		}
Example #8
0
		private static ExchangeNetworkMap FetchInitializedMap()
		{
			ExchangeNetworkMap map = NetworkManager.GetMap();
			if (map == null)
			{
				NetworkManager.TraceError("NetworkMap has not yet been initialized. Sleeping for {0}ms", new object[]
				{
					NetworkManager.GetInitializationTimeoutInMsec()
				});
				Thread.Sleep(NetworkManager.GetInitializationTimeoutInMsec());
				map = NetworkManager.GetMap();
				if (map == null)
				{
					throw new DagNetworkManagementException(ReplayStrings.NetworkManagerInitError);
				}
			}
			return map;
		}
Example #9
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);
				}
			});
		}
Example #10
0
 public ExchangeNetwork(string name, ExchangeNetworkMap map)
 {
     this.m_name = name;
     this.m_map  = map;
 }
Example #11
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;
					}
				}
			}
		}