Exemple #1
0
        protected static TClient CreateClient <TClient>(string serverName, ServiceEndpointAddress serviceEndpoint, Func <Binding, EndpointAddress, ILogger, TClient> constructor, ILogger logger) where TClient : VersionedClientBase <TService>
        {
            logger.Log(MigrationEventType.Verbose, "{0}: Attempting TCP connection to {1}/{2}", new object[]
            {
                typeof(TClient).Name,
                serverName,
                serviceEndpoint
            });
            string        address       = serviceEndpoint.GetAddress(serverName);
            NetTcpBinding netTcpBinding = new NetTcpBinding(SecurityMode.Transport);

            netTcpBinding.Security.Transport.ProtectionLevel      = ProtectionLevel.EncryptAndSign;
            netTcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
            netTcpBinding.Security.Message.ClientCredentialType   = MessageCredentialType.Windows;
            netTcpBinding.MaxReceivedMessageSize = 10485760L;
            netTcpBinding.ReceiveTimeout         = TimeSpan.FromMinutes(10.0);
            netTcpBinding.SendTimeout            = TimeSpan.FromMinutes(10.0);
            EndpointAddress arg;

            try
            {
                arg = new EndpointAddress(address);
            }
            catch (UriFormatException ex)
            {
                throw new InvalidEndpointAddressException(ex.GetType().Name, address, ex);
            }
            TClient tclient = default(TClient);
            bool    flag    = false;

            try
            {
                tclient = constructor(netTcpBinding, arg, logger);
                if (VersionedClientBase <TService> .UseUpdatedBinding)
                {
                    logger.LogVerbose("Using binging: {0} ({1})", new object[]
                    {
                        netTcpBinding.Name,
                        netTcpBinding.MessageVersion
                    });
                    LoadBalanceUtils.UpdateAndLogServiceEndpoint(logger, tclient.Endpoint);
                }
                tclient.ExchangeVersionInformation();
                flag = true;
            }
            finally
            {
                if (!flag && tclient != null)
                {
                    tclient.Dispose();
                }
            }
            logger.Log(MigrationEventType.Verbose, "{0}: Established connection to {1}, version={2}", new object[]
            {
                typeof(TClient).Name,
                tclient.ServerVersion.ComputerName,
                tclient.ServerVersion.ToString()
            });
            return(tclient);
        }
        public override LoadContainer GetLocalServerData(Band[] bands)
        {
            IList <Guid> nonMovableOrgsList         = LoadBalanceUtils.GetNonMovableOrgsList(this.serviceContext.Settings);
            ILogger      logger                     = this.serviceContext.Logger;
            TopologyExtractorFactoryContext context = this.serviceContext.TopologyExtractorFactoryContextPool.GetContext(this.serviceContext.ClientFactory, bands, nonMovableOrgsList, logger);
            TopologyExtractorFactory        loadBalancingLocalFactory = context.GetLoadBalancingLocalFactory(true);

            return(loadBalancingLocalFactory.GetExtractor(base.TargetServer).ExtractTopology());
        }
Exemple #3
0
 protected VersionedClientBase(Binding binding, EndpointAddress remoteAddress, ILogger logger) : base(binding, remoteAddress)
 {
     this.logger = logger;
     LoadBalanceUtils.SetDataContractSerializerBehavior(base.ChannelFactory.Endpoint.Contract);
 }
Exemple #4
0
 protected TopologyExtractorFactoryContext GetTopologyExtractorContext(Band[] bandsToUse)
 {
     return(this.ServiceContext.TopologyExtractorFactoryContextPool.GetContext(this.ServiceContext.ClientFactory, bandsToUse, LoadBalanceUtils.GetNonMovableOrgsList(this.ServiceContext.Settings), this.ServiceContext.Logger));
 }
Exemple #5
0
 public virtual TopologyExtractorFactoryContext GetTopologyExtractorFactoryContext()
 {
     return(this.TopologyExtractorFactoryContextPool.GetContext(this.ClientFactory, this.GetActiveBands(), LoadBalanceUtils.GetNonMovableOrgsList(this.Settings), base.Logger));
 }