Example #1
0
        public override void findAdapterById(string domainId, string adapterId, LookupReplyPrx reply,
                                             Ice.Current current)
        {
            if (!domainId.Equals(_domainId))
            {
                return; // Ignore
            }

            bool isReplicaGroup;

            Ice.ObjectPrx proxy = _registry.findAdapter(adapterId, out isReplicaGroup);
            if (proxy != null)
            {
                //
                // Reply to the multicast request using the given proxy.
                //
                try
                {
                    reply.foundAdapterByIdAsync(adapterId, proxy, isReplicaGroup);
                }
                catch (Ice.LocalException)
                {
                    // Ignore.
                }
            }
        }
Example #2
0
        public void setLookupReply(LookupReplyPrx lookupReply)
        {
            //
            // Use a lookup reply proxy whose adress matches the interface used to send multicast datagrams.
            //
            var single = new Ice.Endpoint[1];

            foreach (var key in new List <LookupPrx>(_lookups.Keys))
            {
                var info = (Ice.UDPEndpointInfo)key.ice_getEndpoints()[0].getInfo();
                if (info.mcastInterface.Length > 0)
                {
                    foreach (var q in lookupReply.ice_getEndpoints())
                    {
                        var r = q.getInfo();
                        if (r is Ice.IPEndpointInfo && ((Ice.IPEndpointInfo)r).host.Equals(info.mcastInterface))
                        {
                            single[0]     = q;
                            _lookups[key] = (LookupReplyPrx)lookupReply.ice_endpoints(single);
                        }
                    }
                }

                if (_lookups[key] == null)
                {
                    // Fallback: just use the given lookup reply proxy if no matching endpoint found.
                    _lookups[key] = lookupReply;
                }
            }
        }
Example #3
0
 public void invoke(string domainId, Dictionary <LookupPrx, LookupReplyPrx?> lookups)
 {
     _lookupCount  = lookups.Count;
     _failureCount = 0;
     Ice.Identity id = new Ice.Identity(_requestId, "");
     foreach (var entry in lookups)
     {
         invokeWithLookup(domainId, entry.Key, LookupReplyPrx.UncheckedCast(entry.Value.Clone(id)));
     }
 }
Example #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());
 }
Example #5
0
 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);
         }
     });
 }
Example #6
0
        public override void findObjectById(string domainId, Ice.Identity id, LookupReplyPrx reply,
                                            Ice.Current current)
        {
            if (!domainId.Equals(_domainId))
            {
                return; // Ignore
            }

            Ice.ObjectPrx proxy = _registry.findObject(id);
            if (proxy != null)
            {
                //
                // Reply to the mulicast request using the given proxy.
                //
                try
                {
                    reply.foundObjectByIdAsync(id, proxy);
                }
                catch (Ice.LocalException)
                {
                    // Ignore.
                }
            }
        }
Example #7
0
 abstract protected void invokeWithLookup(string domainId, LookupPrx lookup, LookupReplyPrx lookupReply);
Example #8
0
 setLookupReply(LookupReplyPrx lookupReply)
 {
     _lookupReply = lookupReply;
 }
Example #9
0
 public void setLookupReply(LookupReplyPrx lookupReply)
 {
     _lookupReply = lookupReply;
 }
Example #10
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();
        }
Example #11
0
 public void setLookupReply(LookupReplyPrx lookupReply)
 {
     _lookupReply = lookupReply;
 }
Example #12
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();
        }
Example #13
0
 setLookupReply(LookupReplyPrx lookupReply)
 {
     _lookupReply = lookupReply;
 }