Esempio n. 1
0
 public LocatorI(LookupPrx lookup, Ice.Properties properties, string instanceName, Ice.LocatorPrx voidLocator)
 {
     _lookup = lookup;
     _timeout = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.Timeout", 300);
     _retryCount = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.RetryCount", 3);
     _retryDelay = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.RetryDelay", 2000);
     _timer = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer();
     _instanceName = instanceName;
     _warned = false;
     _locator = lookup.ice_getCommunicator().getDefaultLocator();
     _voidLocator = voidLocator;
     _pendingRetryCount = 0;
 }
Esempio n. 2
0
File: LookupI.cs Progetto: zmyer/ice
 protected override void invokeWithLookup(string domainId, LookupPrx lookup, LookupReplyPrx lookupReply)
 {
     lookup.findAdapterByIdAsync(domainId, _id, lookupReply).ContinueWith(task => {
         try
         {
             task.Wait();
         }
         catch (AggregateException ex)
         {
             lookup_.adapterRequestException(this, ex.InnerException);
         }
     });
 }
Esempio n. 3
0
 LocatorI(LookupPrx lookup, Ice.Properties properties, string instanceName, Ice.LocatorPrx voidLocator)
 {
     _lookup            = lookup;
     _timeout           = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.Timeout", 300);
     _retryCount        = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.RetryCount", 3);
     _retryDelay        = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.RetryDelay", 2000);
     _timer             = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer();
     _instanceName      = instanceName;
     _warned            = false;
     _locator           = lookup.ice_getCommunicator().getDefaultLocator();
     _voidLocator       = voidLocator;
     _pendingRetryCount = 0;
 }
Esempio n. 4
0
 protected override void invokeWithLookup(string domainId, LookupPrx lookup, LookupReplyPrx lookupReply)
 {
     lookup.findObjectByIdAsync(domainId, _id, lookupReply).ContinueWith(task => {
         try
         {
             task.Wait();
         }
         catch (AggregateException ex)
         {
             lookup_.objectRequestException(this, ex.InnerException);
         }
     }, lookup.ice_scheduler());
 }
Esempio n. 5
0
        LocatorI(string name, LookupPrx lookup, Ice.Properties properties, string instanceName,
                 Ice.LocatorPrx voidLocator)
        {
            _timeout           = properties.getPropertyAsIntWithDefault(name + ".Timeout", 300);
            _retryCount        = properties.getPropertyAsIntWithDefault(name + ".RetryCount", 3);
            _retryDelay        = properties.getPropertyAsIntWithDefault(name + ".RetryDelay", 2000);
            _timer             = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer();
            _instanceName      = instanceName;
            _warned            = false;
            _locator           = lookup.ice_getCommunicator().getDefaultLocator();
            _voidLocator       = voidLocator;
            _pendingRetryCount = 0;

            try
            {
                lookup.ice_getConnection();
            }
            catch (Ice.LocalException ex)
            {
                StringBuilder b = new StringBuilder();
                b.Append("IceLocatorDiscovery is unable to establish a multicast connection:\n");
                b.Append("proxy = ");
                b.Append(lookup.ToString());
                b.Append('\n');
                b.Append(ex.ToString());
                throw new Ice.PluginInitializationException(b.ToString());
            }

            //
            // Create one lookup proxy per endpoint from the given proxy. We want to send a multicast
            // datagram on each endpoint.
            //
            var single = new Ice.Endpoint[1];

            foreach (var endpt in lookup.ice_getEndpoints())
            {
                try
                {
                    single[0] = endpt;
                    LookupPrx l = (LookupPrx)lookup.ice_endpoints(single);
                    l.ice_getConnection();
                    _lookup[(LookupPrx)lookup.ice_endpoints(single)] = null;
                }
                catch (Ice.LocalException)
                {
                    // Ignore
                }
            }
            Debug.Assert(_lookup.Count > 0);
        }
Esempio n. 6
0
        public LookupI(LocatorRegistryI registry, LookupPrx lookup, Ice.Properties properties)
        {
            _registry          = registry;
            _timeout           = properties.getPropertyAsIntWithDefault("IceDiscovery.Timeout", 300);
            _retryCount        = properties.getPropertyAsIntWithDefault("IceDiscovery.RetryCount", 3);
            _latencyMultiplier = properties.getPropertyAsIntWithDefault("IceDiscovery.LatencyMultiplier", 1);
            _domainId          = properties.getProperty("IceDiscovery.DomainId");
            _timer             = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer();

            try
            {
                lookup.ice_getConnection();
            }
            catch (Ice.LocalException ex)
            {
                StringBuilder b = new StringBuilder();
                b.Append("IceDiscovery is unable to establish a multicast connection:\n");
                b.Append("proxy = ");
                b.Append(lookup.ToString());
                b.Append('\n');
                b.Append(ex.ToString());
                throw new Ice.PluginInitializationException(b.ToString());
            }

            //
            // Create one lookup proxy per endpoint from the given proxy. We want to send a multicast
            // datagram on each endpoint.
            //
            var single = new Ice.Endpoint[1];

            foreach (var endpt in lookup.ice_getEndpoints())
            {
                try
                {
                    single[0] = endpt;
                    LookupPrx l = (LookupPrx)lookup.ice_endpoints(single);
                    l.ice_getConnection();
                    _lookup[(LookupPrx)lookup.ice_endpoints(single)] = null;
                }
                catch (Ice.LocalException)
                {
                    // Ignore
                }
            }
            Debug.Assert(_lookup.Count > 0);
        }
Esempio n. 7
0
        LocatorI(string name, LookupPrx lookup, Ice.Properties properties, string instanceName,
                 Ice.LocatorPrx voidLocator)
        {
            _lookup  = lookup;
            _timeout = properties.getPropertyAsIntWithDefault(name + ".Timeout", 300);
            if (_timeout < 0)
            {
                _timeout = 300;
            }
            _retryCount = properties.getPropertyAsIntWithDefault(name + ".RetryCount", 3);
            if (_retryCount < 0)
            {
                _retryCount = 0;
            }
            _retryDelay = properties.getPropertyAsIntWithDefault(name + ".RetryDelay", 2000);
            if (_retryDelay < 0)
            {
                _retryDelay = 0;
            }
            _timer             = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer();
            _traceLevel        = properties.getPropertyAsInt(name + ".Trace.Lookup");
            _instanceName      = instanceName;
            _warned            = false;
            _locator           = lookup.ice_getCommunicator().getDefaultLocator();
            _voidLocator       = voidLocator;
            _pending           = false;
            _pendingRetryCount = 0;
            _failureCount      = 0;
            _warnOnce          = true;

            //
            // Create one lookup proxy per endpoint from the given proxy. We want to send a multicast
            // datagram on each endpoint.
            //
            var single = new Ice.Endpoint[1];

            foreach (var endpt in lookup.ice_getEndpoints())
            {
                single[0] = endpt;
                _lookups[(LookupPrx)lookup.ice_endpoints(single)] = null;
            }
            Debug.Assert(_lookups.Count > 0);
        }
Esempio n. 8
0
        LocatorI(string name, LookupPrx lookup, Communicator communicator, string instanceName, LocatorPrx voidLocator)
        {
            _lookup  = lookup;
            _timeout = communicator.GetPropertyAsInt($"{name}.Timeout") ?? 300;
            if (_timeout < 0)
            {
                _timeout = 300;
            }
            _retryCount = communicator.GetPropertyAsInt("${name}.RetryCount") ?? 3;
            if (_retryCount < 0)
            {
                _retryCount = 0;
            }
            _retryDelay = communicator.GetPropertyAsInt($"{name}.RetryDelay") ?? 2000;
            if (_retryDelay < 0)
            {
                _retryDelay = 0;
            }
            _timer             = lookup.Communicator.timer();
            _traceLevel        = communicator.GetPropertyAsInt($"{name}.Trace.Lookup") ?? 0;
            _instanceName      = instanceName;
            _warned            = false;
            _locator           = lookup.Communicator.getDefaultLocator();
            _voidLocator       = voidLocator;
            _pending           = false;
            _pendingRetryCount = 0;
            _failureCount      = 0;
            _warnOnce          = true;

            //
            // Create one lookup proxy per endpoint from the given proxy. We want to send a multicast
            // datagram on each endpoint.
            //
            var single = new Endpoint[1];

            foreach (var endpt in lookup.Endpoints)
            {
                single[0] = endpt;
                _lookups[lookup.Clone(endpoints: single)] = null;
            }
            Debug.Assert(_lookups.Count > 0);
        }
Esempio n. 9
0
        public LookupI(LocatorRegistryI registry, LookupPrx lookup, Ice.Properties properties)
        {
            _registry          = registry;
            _lookup            = lookup;
            _timeout           = properties.getPropertyAsIntWithDefault("IceDiscovery.Timeout", 300);
            _retryCount        = properties.getPropertyAsIntWithDefault("IceDiscovery.RetryCount", 3);
            _latencyMultiplier = properties.getPropertyAsIntWithDefault("IceDiscovery.LatencyMultiplier", 1);
            _domainId          = properties.getProperty("IceDiscovery.DomainId");
            _timer             = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer();

            //
            // Create one lookup proxy per endpoint from the given proxy. We want to send a multicast
            // datagram on each endpoint.
            //
            var single = new Ice.Endpoint[1];

            foreach (var endpt in lookup.ice_getEndpoints())
            {
                single[0] = endpt;
                _lookups[(LookupPrx)lookup.ice_endpoints(single)] = null;
            }
            Debug.Assert(_lookups.Count > 0);
        }
Esempio n. 10
0
        public LookupI(LocatorRegistryI registry, LookupPrx lookup, Ice.Communicator communicator)
        {
            _registry          = registry;
            _lookup            = lookup;
            _timeout           = communicator.GetPropertyAsInt("IceDiscovery.Timeout") ?? 300;
            _retryCount        = communicator.GetPropertyAsInt("IceDiscovery.RetryCount") ?? 3;
            _latencyMultiplier = communicator.GetPropertyAsInt("IceDiscovery.LatencyMultiplier") ?? 1;
            _domainId          = communicator.GetProperty("IceDiscovery.DomainId") ?? "";
            _timer             = lookup.Communicator.timer();

            //
            // Create one lookup proxy per endpoint from the given proxy. We want to send a multicast
            // datagram on each endpoint.
            //
            var single = new Ice.Endpoint[1];

            foreach (var endpt in lookup.Endpoints)
            {
                single[0] = endpt;
                _lookups[lookup.Clone(endpoints: single)] = null;
            }
            Debug.Assert(_lookups.Count > 0);
        }
Esempio n. 11
0
 abstract protected void invokeWithLookup(string domainId, LookupPrx lookup, LookupReplyPrx lookupReply);
Esempio n. 12
0
        public void initialize()
        {
            Properties properties = _communicator.Properties;

            bool   ipv4       = properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0;
            bool   preferIPv6 = properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0;
            string address;

            if (ipv4 && !preferIPv6)
            {
                address = properties.getPropertyWithDefault("IceDiscovery.Address", "239.255.0.1");
            }
            else
            {
                address = properties.getPropertyWithDefault("IceDiscovery.Address", "ff15::1");
            }
            int    port = properties.getPropertyAsIntWithDefault("IceDiscovery.Port", 4061);
            string intf = properties.getProperty("IceDiscovery.Interface");

            if (properties.getProperty("IceDiscovery.Multicast.Endpoints").Length == 0)
            {
                StringBuilder s = new StringBuilder();
                s.Append("udp -h \"").Append(address).Append("\" -p ").Append(port);
                if (intf.Length != 0)
                {
                    s.Append(" --interface \"").Append(intf).Append("\"");
                }
                properties.setProperty("IceDiscovery.Multicast.Endpoints", s.ToString());
            }

            string lookupEndpoints = properties.getProperty("IceDiscovery.Lookup");

            if (lookupEndpoints.Length == 0)
            {
                int protocol   = ipv4 && !preferIPv6 ? IceInternal.Network.EnableIPv4 : IceInternal.Network.EnableIPv6;
                var interfaces = IceInternal.Network.getInterfacesForMulticast(intf, protocol);
                foreach (string p in interfaces)
                {
                    if (p != interfaces[0])
                    {
                        lookupEndpoints += ":";
                    }
                    lookupEndpoints += "udp -h \"" + address + "\" -p " + port + " --interface \"" + p + "\"";
                }
            }

            if (properties.getProperty("IceDiscovery.Reply.Endpoints").Length == 0)
            {
                properties.setProperty("IceDiscovery.Reply.Endpoints",
                                       "udp -h " + (intf.Length == 0 ? "*" : "\"" + intf + "\""));
            }

            if (properties.getProperty("IceDiscovery.Locator.Endpoints").Length == 0)
            {
                properties.setProperty("IceDiscovery.Locator.AdapterId", Guid.NewGuid().ToString());
            }

            _multicastAdapter = _communicator.createObjectAdapter("IceDiscovery.Multicast");
            _replyAdapter     = _communicator.createObjectAdapter("IceDiscovery.Reply");
            _locatorAdapter   = _communicator.createObjectAdapter("IceDiscovery.Locator");

            //
            // Setup locatory registry.
            //
            LocatorRegistryI   locatorRegistry    = new LocatorRegistryI(_communicator);
            LocatorRegistryPrx locatorRegistryPrx = _locatorAdapter.Add(locatorRegistry);

            LookupPrx lookupPrx = LookupPrx.Parse("IceDiscovery/Lookup -d:" + lookupEndpoints, _communicator).Clone(
                clearRouter: true, collocationOptimized: false); // No colloc optimization or router for the multicast proxy!

            //
            // Add lookup and lookup reply Ice objects
            //
            LookupI lookup = new LookupI(locatorRegistry, lookupPrx, properties);

            _multicastAdapter.Add(lookup, "IceDiscovery/Lookup");

            LookupReplyTraits lookupT     = default;
            LookupReplyI      lookupReply = new LookupReplyI(lookup);

            _replyAdapter.AddDefaultServant(
                (current, incoming) => lookupT.Dispatch(lookupReply, current, incoming), "");
            lookup.setLookupReply(LookupReplyPrx.UncheckedCast(_replyAdapter.CreateProxy("dummy")).Clone(invocationMode: InvocationMode.Datagram));

            //
            // Setup locator on the communicator.
            //
            _locator        = _locatorAdapter.Add(new LocatorI(lookup, locatorRegistryPrx));
            _defaultLocator = _communicator.getDefaultLocator();
            _communicator.setDefaultLocator(_locator);

            _multicastAdapter.Activate();
            _replyAdapter.Activate();
            _locatorAdapter.Activate();
        }
Esempio n. 13
0
        initialize()
        {
            bool ipv4       = (_communicator.GetPropertyAsInt("Ice.IPv4") ?? 1) > 0;
            bool preferIPv6 = _communicator.GetPropertyAsInt("Ice.PreferIPv6Address") > 0;

            string address;

            if (ipv4 && !preferIPv6)
            {
                address = _communicator.GetProperty($"{_name}.Address") ?? "239.255.0.1";
            }
            else
            {
                address = _communicator.GetProperty($"{_name}.Address") ?? "ff15::1";
            }
            int    port = _communicator.GetPropertyAsInt($"{_name}.Port") ?? 4061;
            string intf = _communicator.GetProperty($"{_name}.Interface") ?? "";

            string lookupEndpoints = _communicator.GetProperty($"{_name}.Lookup") ?? "";

            if (lookupEndpoints.Length == 0)
            {
                int protocol   = ipv4 && !preferIPv6 ? IceInternal.Network.EnableIPv4 : IceInternal.Network.EnableIPv6;
                var interfaces = IceInternal.Network.getInterfacesForMulticast(intf, protocol);
                foreach (string p in interfaces)
                {
                    if (p != interfaces[0])
                    {
                        lookupEndpoints += ":";
                    }
                    lookupEndpoints += "udp -h \"" + address + "\" -p " + port + " --interface \"" + p + "\"";
                }
            }

            if (_communicator.GetProperty($"{_name}.Reply.Endpoints") == null)
            {
                _communicator.SetProperty($"{_name}.Reply.Endpoints",
                                          intf.Length == 0 ? "udp -h *" : $"udp -h \"{intf}\"");
            }

            if (_communicator.GetProperty($"{_name}.Locator.Endpoints") == null)
            {
                _communicator.SetProperty($"{_name}.Locator.AdapterId", Guid.NewGuid().ToString());
            }

            _replyAdapter   = _communicator.createObjectAdapter(_name + ".Reply");
            _locatorAdapter = _communicator.createObjectAdapter(_name + ".Locator");

            // We don't want those adapters to be registered with the locator so clear their locator.
            _replyAdapter.SetLocator(null);
            _locatorAdapter.SetLocator(null);

            var lookupPrx = LookupPrx.Parse($"IceLocatorDiscovery/Lookup -d:{lookupEndpoints}", _communicator);

            // No colloc optimization or router for the multicast proxy!
            lookupPrx = lookupPrx.Clone(clearRouter: false, collocationOptimized: false);

            LocatorPrx voidLo = _locatorAdapter.Add(new VoidLocatorI());

            string instanceName = _communicator.GetProperty($"{_name}.InstanceName") ?? "";
            var    id           = new Identity("Locator", instanceName.Length > 0 ? instanceName : Guid.NewGuid().ToString());

            _defaultLocator = _communicator.getDefaultLocator();
            _locator        = new LocatorI(_name, lookupPrx, _communicator, instanceName, voidLo);
            _locatorPrx     = LocatorPrx.UncheckedCast(
                _locatorAdapter.Add((current, incoming) => _locator.Dispatch(current, incoming)));
            _communicator.setDefaultLocator(_locatorPrx);

            LookupReply lookupReplyI = new LookupReplyI(_locator);

            _locator.setLookupReply(_replyAdapter.Add(lookupReplyI).Clone(invocationMode: InvocationMode.Datagram));

            _replyAdapter.Activate();
            _locatorAdapter.Activate();
        }
Esempio n. 14
0
        public void initialize()
        {
            bool   ipv4       = (_communicator.GetPropertyAsInt("Ice.IPv4") ?? 1) > 0;
            bool   preferIPv6 = _communicator.GetPropertyAsInt("Ice.PreferIPv6Address") > 0;
            string address;

            if (ipv4 && !preferIPv6)
            {
                address = _communicator.GetProperty("IceDiscovery.Address") ?? "239.255.0.1";
            }
            else
            {
                address = _communicator.GetProperty("IceDiscovery.Address") ?? "ff15::1";
            }
            int    port = _communicator.GetPropertyAsInt("IceDiscovery.Port") ?? 4061;
            string intf = _communicator.GetProperty("IceDiscovery.Interface") ?? "";

            if (_communicator.GetProperty("IceDiscovery.Multicast.Endpoints") == null)
            {
                _communicator.SetProperty("IceDiscovery.Multicast.Endpoints", intf.Length > 0 ?
                                          $"udp -h \"{address}\" -p {port} --interface \"{intf}\"" : $"udp -h \"{address}\" -p {port}");
            }

            string lookupEndpoints = _communicator.GetProperty("IceDiscovery.Lookup") ?? "";

            if (lookupEndpoints.Length == 0)
            {
                int protocol   = ipv4 && !preferIPv6 ? IceInternal.Network.EnableIPv4 : IceInternal.Network.EnableIPv6;
                var interfaces = IceInternal.Network.getInterfacesForMulticast(intf, protocol);
                foreach (string p in interfaces)
                {
                    if (p != interfaces[0])
                    {
                        lookupEndpoints += ":";
                    }
                    lookupEndpoints += $"udp -h \"{address}\" -p {port} --interface \"{p}\"";
                }
            }

            if (_communicator.GetProperty("IceDiscovery.Reply.Endpoints") == null)
            {
                _communicator.SetProperty("IceDiscovery.Reply.Endpoints",
                                          intf.Length == 0 ? "udp -h *" : $"udp -h \"{intf}\"");
            }

            if (_communicator.GetProperty("IceDiscovery.Locator.Endpoints") == null)
            {
                _communicator.SetProperty("IceDiscovery.Locator.AdapterId", Guid.NewGuid().ToString());
            }

            _multicastAdapter = _communicator.createObjectAdapter("IceDiscovery.Multicast");
            _replyAdapter     = _communicator.createObjectAdapter("IceDiscovery.Reply");
            _locatorAdapter   = _communicator.createObjectAdapter("IceDiscovery.Locator");

            //
            // Setup locatory registry.
            //
            LocatorRegistryI   locatorRegistry    = new LocatorRegistryI(_communicator);
            LocatorRegistryPrx locatorRegistryPrx = _locatorAdapter.Add(locatorRegistry);

            LookupPrx lookupPrx = LookupPrx.Parse("IceDiscovery/Lookup -d:" + lookupEndpoints, _communicator).Clone(
                clearRouter: true, collocationOptimized: false); // No colloc optimization or router for the multicast proxy!

            //
            // Add lookup and lookup reply Ice objects
            //
            LookupI lookup = new LookupI(locatorRegistry, lookupPrx, _communicator);

            _multicastAdapter.Add(lookup, "IceDiscovery/Lookup");

            LookupReplyTraits lookupT     = default;
            LookupReplyI      lookupReply = new LookupReplyI(lookup);

            _replyAdapter.AddDefaultServant(
                (current, incoming) => lookupT.Dispatch(lookupReply, current, incoming), "");
            lookup.setLookupReply(LookupReplyPrx.UncheckedCast(_replyAdapter.CreateProxy("dummy")).Clone(invocationMode: InvocationMode.Datagram));

            //
            // Setup locator on the communicator.
            //
            _locator        = _locatorAdapter.Add(new LocatorI(lookup, locatorRegistryPrx));
            _defaultLocator = _communicator.getDefaultLocator();
            _communicator.setDefaultLocator(_locator);

            _multicastAdapter.Activate();
            _replyAdapter.Activate();
            _locatorAdapter.Activate();
        }