Пример #1
0
        public override void connectors_async(Ice.EndpointSelectionType selType, EndpointI_connectors callback)
        {
#if SILVERLIGHT
            callback.connectors(connectors(selType));
#else
            instance_.resolve(host_, port_, selType, this, callback);
#endif
        }
Пример #2
0
        public override void connectors_async(Ice.EndpointSelectionType selType, EndpointI_connectors callback)
        {
#if SILVERLIGHT
            callback.connectors(connectors(selType));
#else
            _instance.endpointHostResolver().resolve(_host, _port, selType, this, callback);
#endif
        }
Пример #3
0
        public override void connectors_async(Ice.EndpointSelectionType selType,
                                              EndpointI_connectors callback)
        {
            EndpointI_connectorsI cb =
                new EndpointI_connectorsI(_instance, _delegate.host(), _delegate.port(), _resource, callback);

            _delegate.connectors_async(selType, cb);
        }
Пример #4
0
        public List <Connector> resolve(string host, int port, Ice.EndpointSelectionType selType, EndpointI endpoint)
        {
            //
            // Try to get the addresses without DNS lookup. If this doesn't
            // work, we retry with DNS lookup (and observer).
            //
            NetworkProxy networkProxy = _instance.networkProxy();

            if (networkProxy == null)
            {
                List <EndPoint> addrs = Network.getAddresses(host, port, _protocol, selType, _preferIPv6, false);
                if (addrs.Count > 0)
                {
                    return(endpoint.connectors(addrs, null));
                }
            }

            Ice.Instrumentation.CommunicatorObserver obsv     = _instance.getObserver();
            Ice.Instrumentation.Observer             observer = null;
            if (obsv != null)
            {
                observer = obsv.getEndpointLookupObserver(endpoint);
                if (observer != null)
                {
                    observer.attach();
                }
            }

            List <Connector> connectors = null;

            try
            {
                if (networkProxy != null)
                {
                    networkProxy = networkProxy.resolveHost();
                }

                connectors = endpoint.connectors(Network.getAddresses(host, port, _protocol, selType, _preferIPv6,
                                                                      true),
                                                 networkProxy);
            }
            catch (Ice.LocalException ex)
            {
                if (observer != null)
                {
                    observer.failed(ex.ice_name());
                }
                throw ex;
            }
            finally
            {
                if (observer != null)
                {
                    observer.detach();
                }
            }
            return(connectors);
        }
Пример #5
0
        public void resolve(string host, int port, Ice.EndpointSelectionType selType, EndpointI endpoint,
                            EndpointI_connectors callback)
        {
            //
            // Try to get the addresses without DNS lookup. If this doesn't work, we queue a resolve
            // entry and the thread will take care of getting the endpoint addresses.
            //
            NetworkProxy networkProxy = _instance.networkProxy();

            if (networkProxy == null)
            {
                try
                {
                    List <EndPoint> addrs = Network.getAddresses(host, port, _protocol, selType, _preferIPv6, false);
                    if (addrs.Count > 0)
                    {
                        callback.connectors(endpoint.connectors(addrs, null));
                        return;
                    }
                }
                catch (Ice.LocalException ex)
                {
                    callback.exception(ex);
                    return;
                }
            }

            _m.Lock();
            try
            {
                Debug.Assert(!_destroyed);

                ResolveEntry entry = new ResolveEntry();
                entry.host     = host;
                entry.port     = port;
                entry.selType  = selType;
                entry.endpoint = endpoint;
                entry.callback = callback;

                Ice.Instrumentation.CommunicatorObserver obsv = _instance.getObserver();
                if (obsv != null)
                {
                    entry.observer = obsv.getEndpointLookupObserver(endpoint);
                    if (entry.observer != null)
                    {
                        entry.observer.attach();
                    }
                }

                _queue.AddLast(entry);
                _m.Notify();
            }
            finally
            {
                _m.Unlock();
            }
        }
Пример #6
0
    //
    // Return connectors for this endpoint, or empty list if no connector
    // is available.
    //
    public override List <IceInternal.Connector> connectors(Ice.EndpointSelectionType selType)
    {
        _configuration.checkConnectorsException();
        List <IceInternal.Connector> connectors = new List <IceInternal.Connector>();

        foreach (IceInternal.Connector connector in _endpoint.connectors(selType))
        {
            connectors.Add(new Connector(connector));
        }
        return(connectors);
    }
Пример #7
0
 public override void ConnectorsAsync(Ice.EndpointSelectionType selType, IceInternal.IEndpointConnectors cb)
 {
     try
     {
         _configuration.checkConnectorsException();
         _endpoint.ConnectorsAsync(selType, new ConnectorsCallback(cb));
     }
     catch (System.Exception ex)
     {
         cb.Exception(ex);
     }
 }
Пример #8
0
 public override void connectors_async(Ice.EndpointSelectionType selType, IceInternal.EndpointI_connectors cb)
 {
     try
     {
         _configuration.checkConnectorsException();
         _endpoint.connectors_async(selType, new ConnectorsCallback(cb));
     }
     catch (Ice.LocalException ex)
     {
         cb.exception(ex);
     }
 }
Пример #9
0
        //
        // Return connectors for this endpoint, or empty list if no connector
        // is available.
        //
        public override List <Connector> connectors(Ice.EndpointSelectionType selType)
        {
#if SILVERLIGHT
            return(connectors(Network.getAddresses(_host,
                                                   _port,
                                                   _instance.protocolSupport(),
                                                   selType,
                                                   _instance.preferIPv6(),
                                                   false),
                              _instance.networkProxy()));
#else
            return(_instance.endpointHostResolver().resolve(_host, _port, selType, this));
#endif
        }
Пример #10
0
 public override void ConnectorsAsync(Ice.EndpointSelectionType endpointSelection,
                                      Ice.IEndpointConnectors callback)
 {
     string host = "";
     for (Ice.Endpoint? p = _delegate; p != null; p = p.Underlying)
     {
         if (p is Ice.IPEndpoint ipEndpoint)
         {
             host = ipEndpoint.Host;
             break;
         }
     }
     _delegate.ConnectorsAsync(endpointSelection, new EndpointI_connectorsI(_instance, host, callback));
 }
Пример #11
0
        public override void connectors_async(Ice.EndpointSelectionType selType, EndpointI_connectors callback)
        {
            string host = "";

            for (Ice.EndpointInfo p = _delegate.getInfo(); p != null; p = p.underlying)
            {
                if (p is Ice.IPEndpointInfo)
                {
                    Ice.IPEndpointInfo ipInfo = (Ice.IPEndpointInfo)p;
                    host = ipInfo.host + ":" + ipInfo.port;
                }
            }
            _delegate.connectors_async(selType, new EndpointI_connectorsI(_instance, host, _resource, callback));
        }
Пример #12
0
        public override void ConnectorsAsync(Ice.EndpointSelectionType endpointSelection, IEndpointConnectors callback)
        {
            string host = "";

            for (Endpoint?p = _delegate; p != null; p = p.Underlying)
            {
                if (p is IPEndpoint ipEndpoint)
                {
                    host = $"{ipEndpoint.Host}:{ipEndpoint.Port.ToString(CultureInfo.InvariantCulture)}";
                    break;
                }
            }
            _delegate.ConnectorsAsync(endpointSelection, new EndpointConnectors(_instance, host, Resource, callback));
        }
Пример #13
0
        public override void connectors_async(Ice.EndpointSelectionType selType,
                                              IceInternal.EndpointI_connectors callback)
        {
            string host = "";

            for (Ice.EndpointInfo p = _delegate.getInfo(); p != null; p = p.underlying)
            {
                if (p is Ice.IPEndpointInfo)
                {
                    host = ((Ice.IPEndpointInfo)p).host;
                    break;
                }
            }
            _delegate.connectors_async(selType, new EndpointI_connectorsI(_instance, host, callback));
        }
Пример #14
0
        ConnectorsAsync(Ice.EndpointSelectionType endptSelection)
        {
            string host = "";

            for (Ice.Endpoint?p = _delegate; p != null; p = p.Underlying)
            {
                if (p is Ice.IPEndpoint ipEndpoint)
                {
                    host = ipEndpoint.Host;
                    break;
                }
            }
            IEnumerable <IceInternal.IConnector> connectors =
                await _delegate.ConnectorsAsync(endptSelection).ConfigureAwait(false);

            return(connectors.Select(item => new ConnectorI(_instance, item, host)));
        }
Пример #15
0
        public static List <EndPoint> getAddresses(string host, int port, int protocol,
                                                   Ice.EndpointSelectionType selType, bool preferIPv6, bool blocking)
        {
            List <EndPoint> addresses = new List <EndPoint>();

            if (host.Length == 0)
            {
                foreach (IPAddress a in getLoopbackAddresses(protocol))
                {
                    addresses.Add(new IPEndPoint(a, port));
                }
                if (protocol == EnableBoth)
                {
                    if (preferIPv6)
                    {
                        IceUtilInternal.Collections.Sort(ref addresses, _preferIPv6Comparator);
                    }
                    else
                    {
                        IceUtilInternal.Collections.Sort(ref addresses, _preferIPv4Comparator);
                    }
                }
                return(addresses);
            }

            int retry = 5;

repeatGetHostByName:
            try
            {
                //
                // No need for lookup if host is ip address.
                //
                try
                {
                    IPAddress addr = IPAddress.Parse(host);
                    if ((addr.AddressFamily == AddressFamily.InterNetwork && protocol != EnableIPv6) ||
                        (addr.AddressFamily == AddressFamily.InterNetworkV6 && protocol != EnableIPv4))
                    {
                        addresses.Add(new IPEndPoint(addr, port));
                        return(addresses);
                    }
                    else
                    {
                        Ice.DNSException e = new Ice.DNSException();
                        e.host = host;
                        throw e;
                    }
                }
                catch (FormatException)
                {
                    if (!blocking)
                    {
                        return(addresses);
                    }
                }

                foreach (IPAddress a in Dns.GetHostAddresses(host))
                {
                    if ((a.AddressFamily == AddressFamily.InterNetwork && protocol != EnableIPv6) ||
                        (a.AddressFamily == AddressFamily.InterNetworkV6 && protocol != EnableIPv4))
                    {
                        addresses.Add(new IPEndPoint(a, port));
                    }
                }

                if (selType == Ice.EndpointSelectionType.Random)
                {
                    IceUtilInternal.Collections.Shuffle(ref addresses);
                }

                if (protocol == EnableBoth)
                {
                    if (preferIPv6)
                    {
                        IceUtilInternal.Collections.Sort(ref addresses, _preferIPv6Comparator);
                    }
                    else
                    {
                        IceUtilInternal.Collections.Sort(ref addresses, _preferIPv4Comparator);
                    }
                }
            }
            catch (SocketException ex)
            {
                if (socketErrorCode(ex) == SocketError.TryAgain && --retry >= 0)
                {
                    goto repeatGetHostByName;
                }
                Ice.DNSException e = new Ice.DNSException(ex);
                e.host = host;
                throw e;
            }
            catch (Exception ex)
            {
                Ice.DNSException e = new Ice.DNSException(ex);
                e.host = host;
                throw e;
            }

            //
            // No InterNetwork/InterNetworkV6 available.
            //
            if (addresses.Count == 0)
            {
                Ice.DNSException e = new Ice.DNSException();
                e.host = host;
                throw e;
            }
            return(addresses);
        }
Пример #16
0
 //
 // Return a connector for this endpoint, or empty list if no connector
 // is available.
 //
 public abstract void ConnectorsAsync(Ice.EndpointSelectionType selType, IEndpointConnectors callback);
Пример #17
0
        internal DefaultsAndOverrides(Ice.Properties properties)
        {
            string val;

            defaultProtocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp");

            val = properties.getProperty("Ice.Default.Host");
            if(val.Length != 0)
            {
                defaultHost = val;
            }
            else
            {
                defaultHost = null;
            }

            val = properties.getProperty("Ice.Override.Timeout");
            if(val.Length > 0)
            {
                overrideTimeout = true;
                overrideTimeoutValue = properties.getPropertyAsInt("Ice.Override.Timeout");
            }
            else
            {
                overrideTimeout = false;
                overrideTimeoutValue = -1;
            }

            val = properties.getProperty("Ice.Override.ConnectTimeout");
            if(val.Length > 0)
            {
                overrideConnectTimeout = true;
                overrideConnectTimeoutValue = properties.getPropertyAsInt("Ice.Override.ConnectTimeout");
            }
            else
            {
                overrideConnectTimeout = false;
                overrideConnectTimeoutValue = -1;
            }

            val = properties.getProperty("Ice.Override.CloseTimeout");
            if(val.Length > 0)
            {
                overrideCloseTimeout = true;
                overrideCloseTimeoutValue = properties.getPropertyAsInt("Ice.Override.CloseTimeout");
            }
            else
            {
                overrideCloseTimeout = false;
                overrideCloseTimeoutValue = -1;
            }

            #if COMPACT
            overrideCompress = false;
            overrideCompressValue = false;
            #else
            val = properties.getProperty("Ice.Override.Compress");
            if(val.Length > 0)
            {
                overrideCompress = true;
                overrideCompressValue = properties.getPropertyAsInt("Ice.Override.Compress") != 0;
                if(!BasicStream.compressible() && overrideCompressValue)
                {
                    string lib = AssemblyUtil.runtime_ == AssemblyUtil.Runtime.Mono ? "bzip2 library" : "bzip2.dll";
                    Console.Error.WriteLine("warning: " + lib + " not found, Ice.Override.Compress ignored.");
                    overrideCompressValue = false;
                }
            }
            else
            {
                overrideCompress = !BasicStream.compressible();
                overrideCompressValue = false;
            }
            #endif

            val = properties.getProperty("Ice.Override.Secure");
            if(val.Length > 0)
            {
                overrideSecure = true;
                overrideSecureValue = properties.getPropertyAsInt("Ice.Override.Secure") > 0;
            }
            else
            {
                overrideSecure = false;
                overrideSecureValue = false;
            }

            defaultCollocationOptimization =
                properties.getPropertyAsIntWithDefault("Ice.Default.CollocationOptimized", 1) > 0;

            val = properties.getPropertyWithDefault("Ice.Default.EndpointSelection", "Random");
            if(val.Equals("Random"))
            {
                defaultEndpointSelection = Ice.EndpointSelectionType.Random;
            }
            else if(val.Equals("Ordered"))
            {
                defaultEndpointSelection = Ice.EndpointSelectionType.Ordered;
            }
            else
            {
                Ice.EndpointSelectionTypeParseException ex = new Ice.EndpointSelectionTypeParseException();
                ex.str = "illegal value `" + val + "'; expected `Random' or `Ordered'";
                throw ex;
            }

            defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);

            defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
        }
Пример #18
0
 //
 // Return a connector for this endpoint, or empty list if no connector
 // is available.
 //
 public override List <Connector> connectors(Ice.EndpointSelectionType selType)
 {
     return(connectors(Network.getAddresses(_host, _port, instance_.protocolSupport(), selType,
                                            instance_.preferIPv6(), true),
                       instance_.networkProxy()));
 }
Пример #19
0
 //
 // Return a connector for this endpoint, or empty list if no connector
 // is available.
 //
 public abstract void connectors_async(Ice.EndpointSelectionType selType, EndpointI_connectors callback);
Пример #20
0
 //
 // Return connectors for this endpoint, or empty list if no connector
 // is available.
 //
 public override void ConnectorsAsync(Ice.EndpointSelectionType endSel, IEndpointConnectors callback)
 {
     callback.Connectors(new List <IConnector>());
 }
Пример #21
0
        public static List <EndPoint> GetAddresses(string host, int port, int ipVersion,
                                                   Ice.EndpointSelectionType selType, bool preferIPv6, bool blocking)
        {
            var addresses = new List <EndPoint>();

            if (host.Length == 0)
            {
                foreach (IPAddress a in GetLoopbackAddresses(ipVersion))
                {
                    addresses.Add(new IPEndPoint(a, port));
                }

                if (ipVersion == EnableBoth)
                {
                    if (preferIPv6)
                    {
                        addresses = addresses.OrderByDescending(addr => addr.AddressFamily).ToList();
                    }
                    else
                    {
                        addresses = addresses.OrderBy(addr => addr.AddressFamily).ToList();
                    }
                }

                return(addresses);
            }

            int retry = 5;

repeatGetHostByName:
            try
            {
                //
                // No need for lookup if host is ip address.
                //
                try
                {
                    var addr = IPAddress.Parse(host);
                    if ((addr.AddressFamily == AddressFamily.InterNetwork && ipVersion != EnableIPv6) ||
                        (addr.AddressFamily == AddressFamily.InterNetworkV6 && ipVersion != EnableIPv4))
                    {
                        addresses.Add(new IPEndPoint(addr, port));
                        return(addresses);
                    }
                    else
                    {
                        throw new Ice.DNSException
                              {
                                  Host = host
                              };
                    }
                }
                catch (FormatException)
                {
                    if (!blocking)
                    {
                        return(addresses);
                    }
                }

                foreach (IPAddress a in Dns.GetHostAddresses(host))
                {
                    if ((a.AddressFamily == AddressFamily.InterNetwork && ipVersion != EnableIPv6) ||
                        (a.AddressFamily == AddressFamily.InterNetworkV6 && ipVersion != EnableIPv4))
                    {
                        addresses.Add(new IPEndPoint(a, port));
                    }
                }

                if (selType == Ice.EndpointSelectionType.Random)
                {
                    var rnd = new Random();
                    addresses = addresses.OrderBy(x => (endpoint: rnd.Next(), i: x)).ToList();
                }

                if (ipVersion == EnableBoth)
                {
                    if (preferIPv6)
                    {
                        addresses.OrderByDescending(addr => addr.AddressFamily).ToList();
                    }
                    else
                    {
                        addresses.OrderBy(addr => addr.AddressFamily).ToList();
                    }
                }
            }
            catch (SocketException ex)
            {
                if (SocketErrorCode(ex) == SocketError.TryAgain && --retry >= 0)
                {
                    goto repeatGetHostByName;
                }
                throw new Ice.DNSException(0, host, ex);
            }
            catch (Exception ex)
            {
                throw new Ice.DNSException(0, host, ex);
            }

            //
            // No InterNetwork/InterNetworkV6 available.
            //
            if (addresses.Count == 0)
            {
                throw new Ice.DNSException(0, host);
            }
            return(addresses);
        }
Пример #22
0
 //
 // Return a connector for this endpoint, or empty list if no connector
 // is available.
 //
 public abstract List <Connector> connectors(Ice.EndpointSelectionType selType);
Пример #23
0
        private int _timeout; // Only used if _overrideTimeout == true

        #endregion Fields

        #region Constructors

        public RoutableReference(Instance instance,
                                 Ice.Communicator communicator,
                                 Ice.Identity identity,
                                 string facet,
                                 Reference.Mode mode,
                                 bool secure,
                                 EndpointI[] endpoints,
                                 string adapterId,
                                 LocatorInfo locatorInfo,
                                 RouterInfo routerInfo,
                                 bool collocationOptimized,
                                 bool cacheConnection,
                                 bool preferSecure,
                                 Ice.EndpointSelectionType endpointSelection,
                                 int locatorCacheTimeout)
            : base(instance, communicator, identity, facet, mode, secure)
        {
            _endpoints = endpoints;
            _adapterId = adapterId;
            _locatorInfo = locatorInfo;
            _routerInfo = routerInfo;
            _collocationOptimized = collocationOptimized;
            _cacheConnection = cacheConnection;
            _preferSecure = preferSecure;
            _endpointSelection = endpointSelection;
            _locatorCacheTimeout = locatorCacheTimeout;
            _overrideTimeout = false;
            _timeout = -1;

            if(_endpoints == null)
            {
                _endpoints = _emptyEndpoints;
            }

            if(_adapterId == null)
            {
                _adapterId = "";
            }

            Debug.Assert(_adapterId.Length == 0 || _endpoints.Length == 0);
        }
Пример #24
0
        internal DefaultsAndOverrides(Ice.Properties properties, Ice.Logger logger)
        {
            string val;

            defaultProtocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp");

            val = properties.getProperty("Ice.Default.Host");
            if(val.Length != 0)
            {
                defaultHost = val;
            }
            else
            {
                defaultHost = null;
            }

            val = properties.getProperty("Ice.Default.SourceAddress");
            if(val.Length > 0)
            {
                defaultSourceAddress = Network.getNumericAddress(val);
                if(defaultSourceAddress == null)
                {
                    throw new Ice.InitializationException("invalid IP address set for Ice.Default.SourceAddress: `" +
                                                          val + "'");
                }
            }
            else
            {
                defaultSourceAddress = null;
            }

            val = properties.getProperty("Ice.Override.Timeout");
            if(val.Length > 0)
            {
                overrideTimeout = true;
                overrideTimeoutValue = properties.getPropertyAsInt("Ice.Override.Timeout");
                if(overrideTimeoutValue < 1 && overrideTimeoutValue != -1)
                {
                    overrideTimeoutValue = -1;
                    StringBuilder msg = new StringBuilder("invalid value for Ice.Override.Timeout `");
                    msg.Append(properties.getProperty("Ice.Override.Timeout"));
                    msg.Append("': defaulting to -1");
                    logger.warning(msg.ToString());
                }
            }
            else
            {
                overrideTimeout = false;
                overrideTimeoutValue = -1;
            }

            val = properties.getProperty("Ice.Override.ConnectTimeout");
            if(val.Length > 0)
            {
                overrideConnectTimeout = true;
                overrideConnectTimeoutValue = properties.getPropertyAsInt("Ice.Override.ConnectTimeout");
                if(overrideConnectTimeoutValue < 1 && overrideConnectTimeoutValue != -1)
                {
                    overrideConnectTimeoutValue = -1;
                    StringBuilder msg = new StringBuilder("invalid value for Ice.Override.ConnectTimeout `");
                    msg.Append(properties.getProperty("Ice.Override.ConnectTimeout"));
                    msg.Append("': defaulting to -1");
                    logger.warning(msg.ToString());
                }
            }
            else
            {
                overrideConnectTimeout = false;
                overrideConnectTimeoutValue = -1;
            }

            val = properties.getProperty("Ice.Override.CloseTimeout");
            if(val.Length > 0)
            {
                overrideCloseTimeout = true;
                overrideCloseTimeoutValue = properties.getPropertyAsInt("Ice.Override.CloseTimeout");
                if(overrideCloseTimeoutValue < 1 && overrideCloseTimeoutValue != -1)
                {
                    overrideCloseTimeoutValue = -1;
                    StringBuilder msg = new StringBuilder("invalid value for Ice.Override.CloseTimeout `");
                    msg.Append(properties.getProperty("Ice.Override.CloseTimeout"));
                    msg.Append("': defaulting to -1");
                    logger.warning(msg.ToString());
                }
            }
            else
            {
                overrideCloseTimeout = false;
                overrideCloseTimeoutValue = -1;
            }

            val = properties.getProperty("Ice.Override.Compress");
            if(val.Length > 0)
            {
                overrideCompress = true;
                overrideCompressValue = properties.getPropertyAsInt("Ice.Override.Compress") > 0;
                if(!BZip2.supported() && overrideCompressValue)
                {
                    string lib = AssemblyUtil.runtime_ == AssemblyUtil.Runtime.Mono ? "bzip2 library" : "bzip2.dll";
                    Console.Error.WriteLine("warning: " + lib + " not found, Ice.Override.Compress ignored.");
                    overrideCompressValue = false;
                }
            }
            else
            {
                overrideCompress = !BZip2.supported();
                overrideCompressValue = false;
            }

            val = properties.getProperty("Ice.Override.Secure");
            if(val.Length > 0)
            {
                overrideSecure = true;
                overrideSecureValue = properties.getPropertyAsInt("Ice.Override.Secure") > 0;
            }
            else
            {
                overrideSecure = false;
                overrideSecureValue = false;
            }

            defaultCollocationOptimization =
                properties.getPropertyAsIntWithDefault("Ice.Default.CollocationOptimized", 1) > 0;

            val = properties.getPropertyWithDefault("Ice.Default.EndpointSelection", "Random");
            if(val.Equals("Random"))
            {
                defaultEndpointSelection = Ice.EndpointSelectionType.Random;
            }
            else if(val.Equals("Ordered"))
            {
                defaultEndpointSelection = Ice.EndpointSelectionType.Ordered;
            }
            else
            {
                Ice.EndpointSelectionTypeParseException ex = new Ice.EndpointSelectionTypeParseException();
                ex.str = "illegal value `" + val + "'; expected `Random' or `Ordered'";
                throw ex;
            }

            defaultTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000);
            if(defaultTimeout < 1 && defaultTimeout != -1)
            {
                defaultTimeout = 60000;
                StringBuilder msg = new StringBuilder("invalid value for Ice.Default.Timeout `");
                msg.Append(properties.getProperty("Ice.Default.Timeout"));
                msg.Append("': defaulting to 60000");
                logger.warning(msg.ToString());
            }

            defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
            if(defaultLocatorCacheTimeout < -1)
            {
                defaultLocatorCacheTimeout = -1;
                StringBuilder msg = new StringBuilder("invalid value for Ice.Default.LocatorCacheTimeout `");
                msg.Append(properties.getProperty("Ice.Default.LocatorCacheTimeout"));
                msg.Append("': defaulting to -1");
                logger.warning(msg.ToString());
            }

            defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1);
            if(defaultInvocationTimeout < 1 && defaultInvocationTimeout != -1 && defaultInvocationTimeout != -2)
            {
                defaultInvocationTimeout = -1;
                StringBuilder msg = new StringBuilder("invalid value for Ice.Default.InvocationTimeout `");
                msg.Append(properties.getProperty("Ice.Default.InvocationTimeout"));
                msg.Append("': defaulting to -1");
                logger.warning(msg.ToString());
            }

            defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;

            val = properties.getPropertyWithDefault("Ice.Default.EncodingVersion",
                                                    Ice.Util.encodingVersionToString(Ice.Util.currentEncoding));
            defaultEncoding = Ice.Util.stringToEncodingVersion(val);
            Protocol.checkSupportedEncoding(defaultEncoding);

            bool slicedFormat = properties.getPropertyAsIntWithDefault("Ice.Default.SlicedFormat", 0) > 0;
            defaultFormat = slicedFormat ? Ice.FormatType.SlicedFormat : Ice.FormatType.CompactFormat;
        }
Пример #25
0
 //
 // Return connectors for this endpoint, or empty list if no connector
 // is available.
 //
 public override List <IceInternal.Connector> connectors(Ice.EndpointSelectionType selType)
 {
     return(_instance.endpointHostResolver().resolve(_host, _port, selType, this));
 }
Пример #26
0
 //
 // Return connectors for this endpoint, or empty list if no connector
 // is available.
 //
 public override void connectors_async(Ice.EndpointSelectionType endSel, EndpointI_connectors callback)
 {
     callback.connectors(new List <Connector>());
 }
Пример #27
0
 public override void connectors_async(Ice.EndpointSelectionType selType,
                                       IceInternal.EndpointI_connectors callback)
 {
     _instance.endpointHostResolver().resolve(_host, _port, selType, this, callback);
 }
Пример #28
0
 public override void connectors_async(Ice.EndpointSelectionType selType, EndpointI_connectors callback)
 {
     instance_.resolve(host_, port_, selType, this, callback);
 }
Пример #29
0
 public List <Connector> connectors(Ice.EndpointSelectionType selType)
 {
     return(connectors(Network.getAddresses(host_, port_, instance_.protocolSupport(), selType,
                                            instance_.preferIPv6(), false),
                       instance_.networkProxy()));
 }
Пример #30
0
 public void Resolve(string host, int port, Ice.EndpointSelectionType type, IPEndpoint endpt,
                     IEndpointConnectors callback) =>
 Communicator.Resolve(host, port, type, endpt, callback);
Пример #31
0
        private Reference create(Ice.Identity ident,
                                 string facet,
                                 Reference.Mode mode,
                                 bool secure,
                                 Ice.ProtocolVersion protocol,
                                 Ice.EncodingVersion encoding,
                                 EndpointI[] endpoints,
                                 string adapterId,
                                 string propertyPrefix)
        {
            DefaultsAndOverrides defaultsAndOverrides = instance_.defaultsAndOverrides();

            //
            // Default local proxy options.
            //
            LocatorInfo locatorInfo = null;

            if (_defaultLocator != null)
            {
                if (!((Ice.ObjectPrxHelperBase)_defaultLocator).reference__().getEncoding().Equals(encoding))
                {
                    locatorInfo = instance_.locatorManager().get(
                        (Ice.LocatorPrx)_defaultLocator.ice_encodingVersion(encoding));
                }
                else
                {
                    locatorInfo = instance_.locatorManager().get(_defaultLocator);
                }
            }
            RouterInfo routerInfo      = instance_.routerManager().get(_defaultRouter);
            bool       collocOptimized = defaultsAndOverrides.defaultCollocationOptimization;
            bool       cacheConnection = true;
            bool       preferSecure    = defaultsAndOverrides.defaultPreferSecure;

            Ice.EndpointSelectionType endpointSelection = defaultsAndOverrides.defaultEndpointSelection;
            int locatorCacheTimeout             = defaultsAndOverrides.defaultLocatorCacheTimeout;
            int invocationTimeout               = defaultsAndOverrides.defaultInvocationTimeout;
            Dictionary <string, string> context = null;

            //
            // Override the defaults with the proxy properties if a property prefix is defined.
            //
            if (propertyPrefix != null && propertyPrefix.Length > 0)
            {
                Ice.Properties properties = instance_.initializationData().properties;

                //
                // Warn about unknown properties.
                //
                if (properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0)
                {
                    checkForUnknownProperties(propertyPrefix);
                }

                string property;

                property = propertyPrefix + ".Locator";
                Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(_communicator.propertyToProxy(property));
                if (locator != null)
                {
                    if (!((Ice.ObjectPrxHelperBase)locator).reference__().getEncoding().Equals(encoding))
                    {
                        locatorInfo = instance_.locatorManager().get(
                            (Ice.LocatorPrx)locator.ice_encodingVersion(encoding));
                    }
                    else
                    {
                        locatorInfo = instance_.locatorManager().get(locator);
                    }
                }

                property = propertyPrefix + ".Router";
                Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(_communicator.propertyToProxy(property));
                if (router != null)
                {
                    if (propertyPrefix.EndsWith(".Router", StringComparison.Ordinal))
                    {
                        string s = "`" + property + "=" + properties.getProperty(property) +
                                   "': cannot set a router on a router; setting ignored";
                        instance_.initializationData().logger.warning(s);
                    }
                    else
                    {
                        routerInfo = instance_.routerManager().get(router);
                    }
                }

                property        = propertyPrefix + ".CollocationOptimized";
                collocOptimized = properties.getPropertyAsIntWithDefault(property, collocOptimized ? 1 : 0) > 0;

                property        = propertyPrefix + ".ConnectionCached";
                cacheConnection = properties.getPropertyAsIntWithDefault(property, cacheConnection ? 1 : 0) > 0;

                property     = propertyPrefix + ".PreferSecure";
                preferSecure = properties.getPropertyAsIntWithDefault(property, preferSecure ? 1 : 0) > 0;

                property = propertyPrefix + ".EndpointSelection";
                if (properties.getProperty(property).Length > 0)
                {
                    string type = properties.getProperty(property);
                    if (type.Equals("Random"))
                    {
                        endpointSelection = Ice.EndpointSelectionType.Random;
                    }
                    else if (type.Equals("Ordered"))
                    {
                        endpointSelection = Ice.EndpointSelectionType.Ordered;
                    }
                    else
                    {
                        throw new Ice.EndpointSelectionTypeParseException("illegal value `" + type +
                                                                          "'; expected `Random' or `Ordered'");
                    }
                }

                property = propertyPrefix + ".LocatorCacheTimeout";
                string val = properties.getProperty(property);
                if (val.Length > 0)
                {
                    locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout);
                    if (locatorCacheTimeout < -1)
                    {
                        locatorCacheTimeout = -1;

                        StringBuilder msg = new StringBuilder("invalid value for ");
                        msg.Append(property);
                        msg.Append(" `");
                        msg.Append(properties.getProperty(property));
                        msg.Append("': defaulting to -1");
                        instance_.initializationData().logger.warning(msg.ToString());
                    }
                }

                property = propertyPrefix + ".InvocationTimeout";
                val      = properties.getProperty(property);
                if (val.Length > 0)
                {
                    invocationTimeout = properties.getPropertyAsIntWithDefault(property, invocationTimeout);
                    if (invocationTimeout < 1 && invocationTimeout != -1)
                    {
                        invocationTimeout = -1;

                        StringBuilder msg = new StringBuilder("invalid value for ");
                        msg.Append(property);
                        msg.Append(" `");
                        msg.Append(properties.getProperty(property));
                        msg.Append("': defaulting to -1");
                        instance_.initializationData().logger.warning(msg.ToString());
                    }
                }

                property = propertyPrefix + ".Context.";
                Dictionary <string, string> contexts = properties.getPropertiesForPrefix(property);
                if (contexts.Count != 0)
                {
                    context = new Dictionary <string, string>();
                    foreach (KeyValuePair <string, string> e in contexts)
                    {
                        context.Add(e.Key.Substring(property.Length), e.Value);
                    }
                }
            }

            //
            // Create new reference
            //
            return(new RoutableReference(instance_,
                                         _communicator,
                                         ident,
                                         facet,
                                         mode,
                                         secure,
                                         protocol,
                                         encoding,
                                         endpoints,
                                         adapterId,
                                         locatorInfo,
                                         routerInfo,
                                         collocOptimized,
                                         cacheConnection,
                                         preferSecure,
                                         endpointSelection,
                                         locatorCacheTimeout,
                                         invocationTimeout,
                                         context));
        }
Пример #32
0
 public void resolve(string host, int port, Ice.EndpointSelectionType type, IPEndpointI endpt,
                     EndpointI_connectors callback)
 {
     instance_.endpointHostResolver().resolve(host, port, type, endpt, callback);
 }
Пример #33
0
 //
 // Return connectors for this endpoint, or empty list if no connector
 // is available.
 //
 public override List <Connector> connectors(Ice.EndpointSelectionType endSel)
 {
     return(new List <Connector>());
 }