Example #1
0
		internal static NetworkPath InternalChooseDagNetworkPath(string targetName, string networkName, NetworkPath.ConnectionPurpose purpose)
		{
			string nodeNameFromFqdn = MachineName.GetNodeNameFromFqdn(targetName);
			NetworkManager manager = NetworkManager.GetManager();
			NetworkPath networkPath = null;
			DagNetConfig dagNetConfig = null;
			manager.TryWaitForInitialization();
			if (manager.m_netMap != null)
			{
				networkPath = manager.m_netMap.ChoosePath(nodeNameFromFqdn, networkName);
			}
			else
			{
				DagNetRoute dagNetRoute = null;
				DagNetRoute[] array = DagNetChooser.ProposeRoutes(targetName, out dagNetConfig);
				if (networkName != null)
				{
					foreach (DagNetRoute dagNetRoute2 in array)
					{
						if (StringUtil.IsEqualIgnoreCase(dagNetRoute2.NetworkName, networkName))
						{
							dagNetRoute = dagNetRoute2;
							break;
						}
					}
				}
				else if (array != null && array.Length > 0)
				{
					dagNetRoute = array[0];
				}
				if (dagNetRoute != null)
				{
					networkPath = new NetworkPath(targetName, dagNetRoute.TargetIPAddr, dagNetRoute.TargetPort, dagNetRoute.SourceIPAddr);
					networkPath.NetworkName = dagNetRoute.NetworkName;
					networkPath.CrossSubnet = dagNetRoute.IsCrossSubnet;
				}
			}
			if (networkPath == null)
			{
				networkPath = NetworkManager.BuildDnsNetworkPath(targetName, NetworkManager.GetReplicationPort());
			}
			networkPath.Purpose = purpose;
			if (dagNetConfig == null)
			{
				dagNetConfig = DagNetEnvironment.FetchNetConfig();
			}
			networkPath.ApplyNetworkPolicy(dagNetConfig);
			return networkPath;
		}
Example #2
0
        public TcpClientChannel OpenChannel(string targetServerName, ISimpleBufferPool socketStreamBufferPool, IPool <SocketStreamAsyncArgs> socketStreamAsyncArgPool, SocketStream.ISocketStreamPerfCounters perfCtrs, out NetworkPath netPath)
        {
            DagNetConfig dagConfig;

            DagNetRoute[]    array            = DagNetChooser.ProposeRoutes(targetServerName, out dagConfig);
            TcpClientChannel tcpClientChannel = null;

            netPath = null;
            NetworkTransportException ex = null;

            if (array != null)
            {
                foreach (DagNetRoute dagNetRoute in array)
                {
                    netPath             = new NetworkPath(targetServerName, dagNetRoute.TargetIPAddr, dagNetRoute.TargetPort, dagNetRoute.SourceIPAddr);
                    netPath.CrossSubnet = dagNetRoute.IsCrossSubnet;
                    this.ApplySocketStreamArgs(netPath, socketStreamBufferPool, socketStreamAsyncArgPool, perfCtrs);
                    netPath.ApplyNetworkPolicy(dagConfig);
                    tcpClientChannel = this.TryConnect(netPath, out ex);
                    if (tcpClientChannel != null)
                    {
                        break;
                    }
                }
            }
            if (tcpClientChannel == null)
            {
                netPath = this.BuildDnsNetworkPath(targetServerName, (int)NetworkManager.GetReplicationPort());
                this.ApplySocketStreamArgs(netPath, socketStreamBufferPool, socketStreamAsyncArgPool, perfCtrs);
                netPath.ApplyNetworkPolicy(dagConfig);
                tcpClientChannel = this.TryConnect(netPath, out ex);
                if (tcpClientChannel == null)
                {
                    throw ex;
                }
            }
            return(tcpClientChannel);
        }