Exemplo n.º 1
0
        public NetworkPath ChooseDagNetworkPath(string targetServerName, string networkName, NetworkPath.ConnectionPurpose purpose)
        {
            DagNetConfig dagConfig;

            DagNetRoute[] array       = DagNetEnvironment.NetChooser.BuildRoutes(targetServerName, false, networkName, out dagConfig);
            NetworkPath   networkPath = null;

            if (array != null)
            {
                foreach (DagNetRoute dagNetRoute in array)
                {
                    networkPath             = new NetworkPath(targetServerName, dagNetRoute.TargetIPAddr, dagNetRoute.TargetPort, dagNetRoute.SourceIPAddr);
                    networkPath.CrossSubnet = dagNetRoute.IsCrossSubnet;
                    networkPath.ApplyNetworkPolicy(dagConfig);
                }
            }
            return(networkPath);
        }
Exemplo n.º 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, this.GetCurrentReplicationPort());
                this.ApplySocketStreamArgs(netPath, socketStreamBufferPool, socketStreamAsyncArgPool, perfCtrs);
                netPath.ApplyNetworkPolicy(dagConfig);
                tcpClientChannel = this.TryConnect(netPath, out ex);
                if (tcpClientChannel == null)
                {
                    throw ex;
                }
            }
            return(tcpClientChannel);
        }