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(); }
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); }
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); }
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); }
public void initialize() { Ice.Properties properties = _communicator.getProperties(); 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); Ice.LocatorRegistryPrx locatorRegistryPrx = Ice.LocatorRegistryPrxHelper.uncheckedCast( _locatorAdapter.addWithUUID(locatorRegistry)); Ice.ObjectPrx lookupPrx = _communicator.stringToProxy("IceDiscovery/Lookup -d:" + lookupEndpoints); // No colloc optimization or router for the multicast proxy! lookupPrx = lookupPrx.ice_collocationOptimized(false).ice_router(null); // // Add lookup and lookup reply Ice objects // LookupI lookup = new LookupI(locatorRegistry, LookupPrxHelper.uncheckedCast(lookupPrx), properties); _multicastAdapter.add(lookup, Ice.Util.stringToIdentity("IceDiscovery/Lookup")); _replyAdapter.addDefaultServant(new LookupReplyI(lookup), ""); Ice.Identity id = new Ice.Identity("dummy", ""); lookup.setLookupReply(LookupReplyPrxHelper.uncheckedCast(_replyAdapter.createProxy(id).ice_datagram())); // // Setup locator on the communicator. // Ice.ObjectPrx loc; loc = _locatorAdapter.addWithUUID( new LocatorI(lookup, Ice.LocatorRegistryPrxHelper.uncheckedCast(locatorRegistryPrx))); _defaultLocator = _communicator.getDefaultLocator(); _locator = Ice.LocatorPrxHelper.uncheckedCast(loc); _communicator.setDefaultLocator(_locator); _multicastAdapter.activate(); _replyAdapter.activate(); _locatorAdapter.activate(); }
public void initialize() { Ice.Properties properties = _communicator.getProperties(); 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()); } if(properties.getProperty("IceDiscovery.Reply.Endpoints").Length == 0) { StringBuilder s = new StringBuilder(); s.Append("udp"); if(intf.Length != 0) { s.Append(" -h \"").Append(intf).Append("\""); } properties.setProperty("IceDiscovery.Reply.Endpoints", s.ToString()); } 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); Ice.LocatorRegistryPrx locatorRegistryPrx = Ice.LocatorRegistryPrxHelper.uncheckedCast( _locatorAdapter.addWithUUID(locatorRegistry)); string lookupEndpoints = properties.getProperty("IceDiscovery.Lookup"); if(lookupEndpoints.Length == 0) { lookupEndpoints = "udp -h \"" + address + "\" -p " + port; if(intf.Length > 0) { lookupEndpoints += " --interface \"" + intf + "\""; } } Ice.ObjectPrx lookupPrx = _communicator.stringToProxy("IceDiscovery/Lookup -d:" + lookupEndpoints); lookupPrx = lookupPrx.ice_collocationOptimized(false); try { lookupPrx.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(lookupPrx.ToString()); b.Append('\n'); b.Append(ex.ToString()); throw new Ice.PluginInitializationException(b.ToString()); } // // Add lookup and lookup reply Ice objects // LookupI lookup = new LookupI(locatorRegistry, LookupPrxHelper.uncheckedCast(lookupPrx), properties); _multicastAdapter.add(lookup, _communicator.stringToIdentity("IceDiscovery/Lookup")); Ice.ObjectPrx lookupReply = _replyAdapter.addWithUUID(new LookupReplyI(lookup)).ice_datagram(); lookup.setLookupReply(LookupReplyPrxHelper.uncheckedCast(lookupReply)); // // Setup locator on the communicator. // Ice.ObjectPrx loc; loc = _locatorAdapter.addWithUUID( new LocatorI(lookup, Ice.LocatorRegistryPrxHelper.uncheckedCast(locatorRegistryPrx))); _communicator.setDefaultLocator(Ice.LocatorPrxHelper.uncheckedCast(loc)); _multicastAdapter.activate(); _replyAdapter.activate(); _locatorAdapter.activate(); }
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(); }
public void initialize() { Ice.Properties properties = _communicator.getProperties(); 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()); } if (properties.getProperty("IceDiscovery.Reply.Endpoints").Length == 0) { StringBuilder s = new StringBuilder(); s.Append("udp"); if (intf.Length != 0) { s.Append(" -h \"").Append(intf).Append("\""); } properties.setProperty("IceDiscovery.Reply.Endpoints", s.ToString()); } 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); Ice.LocatorRegistryPrx locatorRegistryPrx = Ice.LocatorRegistryPrxHelper.uncheckedCast( _locatorAdapter.addWithUUID(locatorRegistry)); string lookupEndpoints = properties.getProperty("IceDiscovery.Lookup"); if (lookupEndpoints.Length == 0) { lookupEndpoints = "udp -h \"" + address + "\" -p " + port; if (intf.Length > 0) { lookupEndpoints += " --interface \"" + intf + "\""; } } Ice.ObjectPrx lookupPrx = _communicator.stringToProxy("IceDiscovery/Lookup -d:" + lookupEndpoints); lookupPrx = lookupPrx.ice_collocationOptimized(false); try { lookupPrx.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(lookupPrx.ToString()); b.Append('\n'); b.Append(ex.ToString()); throw new Ice.PluginInitializationException(b.ToString()); } // // Add lookup and lookup reply Ice objects // LookupI lookup = new LookupI(locatorRegistry, LookupPrxHelper.uncheckedCast(lookupPrx), properties); _multicastAdapter.add(lookup, Ice.Util.stringToIdentity("IceDiscovery/Lookup")); Ice.ObjectPrx lookupReply = _replyAdapter.addWithUUID(new LookupReplyI(lookup)).ice_datagram(); lookup.setLookupReply(LookupReplyPrxHelper.uncheckedCast(lookupReply)); // // Setup locator on the communicator. // Ice.ObjectPrx loc; loc = _locatorAdapter.addWithUUID( new LocatorI(lookup, Ice.LocatorRegistryPrxHelper.uncheckedCast(locatorRegistryPrx))); _communicator.setDefaultLocator(Ice.LocatorPrxHelper.uncheckedCast(loc)); _multicastAdapter.activate(); _replyAdapter.activate(); _locatorAdapter.activate(); }
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); ILocatorRegistryPrx locatorRegistryPrx = _locatorAdapter.Add(locatorRegistry); ILookupPrx lookupPrx = ILookupPrx.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(ILookupReplyPrx.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(); }