setLookupReply(ILookupReplyPrx lookupReply) { // // Use a lookup reply proxy whose adress matches the interface used to send multicast datagrams. // var single = new Endpoint[1]; foreach (var key in new List <ILookupPrx>(_lookups.Keys)) { var info = (UDPEndpointInfo)key.Endpoints[0].getInfo(); if (info.mcastInterface.Length > 0) { foreach (var q in lookupReply.Endpoints) { var r = q.getInfo(); if (r is IPEndpointInfo && ((IPEndpointInfo)r).host.Equals(info.mcastInterface)) { single[0] = q; _lookups[key] = lookupReply.Clone(endpoints: single); } } } if (_lookups[key] == null) { // Fallback: just use the given lookup reply proxy if no matching endpoint found. _lookups[key] = lookupReply; } } }
public void SetLookupReply(ILookupReplyPrx lookupReply) { // // Use a lookup reply proxy whose address matches the interface used to send multicast datagrams. // var single = new Endpoint[1]; foreach (ILookupPrx key in new List<ILookupPrx>(_lookups.Keys)) { var endpoint = (UdpEndpoint)key.Endpoints[0]; if (endpoint.McastInterface.Length > 0) { foreach (Endpoint q in lookupReply.Endpoints) { if (q is IPEndpoint && ((IPEndpoint)q).Host.Equals(endpoint.McastInterface)) { single[0] = q; _lookups[key] = lookupReply.Clone(endpoints: single); } } } if (_lookups[key] == null) { // Fallback: just use the given lookup reply proxy if no matching endpoint found. _lookups[key] = lookupReply; } } }
public void SetLookupReply(ILookupReplyPrx lookupReply) { // Use a lookup reply proxy whose address matches the interface used to send multicast datagrams. var single = new Endpoint[1]; foreach (ILookupPrx key in _lookups.Keys.ToArray()) { var endpoint = (UdpEndpoint)key.Endpoints[0]; if (endpoint.McastInterface.Length > 0) { Endpoint?q = lookupReply.Endpoints.FirstOrDefault(e => e is IPEndpoint ipEndpoint && ipEndpoint.Host.Equals(endpoint.McastInterface)); if (q != null) { single[0] = q; _lookups[key] = lookupReply.Clone(endpoints: single); } } if (_lookups[key] == null) { // Fallback: just use the given lookup reply proxy if no matching endpoint found. _lookups[key] = lookupReply; } } }
internal Lookup( LocatorRegistry registry, ILookupPrx lookup, Communicator communicator, ObjectAdapter replyAdapter) { _replyAdapter = replyAdapter; _registry = registry; _lookup = lookup; _timeout = communicator.GetPropertyAsTimeSpan("IceDiscovery.Timeout") ?? TimeSpan.FromMilliseconds(300); if (_timeout == Timeout.InfiniteTimeSpan) { _timeout = TimeSpan.FromMilliseconds(300); } _retryCount = communicator.GetPropertyAsInt("IceDiscovery.RetryCount") ?? 3; _latencyMultiplier = communicator.GetPropertyAsInt("IceDiscovery.LatencyMultiplier") ?? 1; if (_latencyMultiplier < 1) { throw new InvalidConfigurationException( "The value of `IceDiscovery.LatencyMultiplier' must be a positive integer greater than 0"); } _domainId = communicator.GetProperty("IceDiscovery.DomainId") ?? ""; // Create one lookup proxy per endpoint from the given proxy. We want to send a multicast // datagram on each endpoint. ILookupReplyPrx lookupReply = _replyAdapter.CreateProxy( "dummy", ILookupReplyPrx.Factory).Clone(invocationMode: InvocationMode.Datagram); var single = new Endpoint[1]; foreach (Endpoint endpoint in lookup.Endpoints) { // lookup's invocation mode is Datagram Debug.Assert(endpoint.Transport == Transport.UDP); single[0] = endpoint; ILookupPrx?key = lookup.Clone(endpoints: single); if (endpoint["interface"] is string mcastInterface && mcastInterface.Length > 0) { Endpoint?q = lookupReply.Endpoints.FirstOrDefault(e => e.Host == mcastInterface); if (q != null) { single[0] = q; _lookups[key] = lookupReply.Clone(endpoints: single); } } if (!_lookups.ContainsKey(key)) { // Fallback: just use the given lookup reply proxy if no matching endpoint found. _lookups[key] = lookupReply; } } Debug.Assert(_lookups.Count > 0); }
internal Locator( string name, ILookupPrx lookup, Communicator communicator, string instanceName, ILocatorPrx voidLocator, ILookupReplyPrx lookupReply) { _lookup = lookup; _timeout = communicator.GetPropertyAsTimeSpan($"{name}.Timeout") ?? TimeSpan.FromMilliseconds(300); if (_timeout == System.Threading.Timeout.InfiniteTimeSpan) { _timeout = TimeSpan.FromMilliseconds(300); } _retryCount = Math.Max(communicator.GetPropertyAsInt($"{name}.RetryCount") ?? 3, 1); _retryDelay = communicator.GetPropertyAsTimeSpan($"{name}.RetryDelay") ?? TimeSpan.FromMilliseconds(2000); _traceLevel = communicator.GetPropertyAsInt($"{name}.Trace.Lookup") ?? 0; _instanceName = instanceName; _warned = false; _locator = lookup.Communicator.DefaultLocator; _voidLocator = voidLocator; // 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 (Endpoint endpoint in lookup.Endpoints) { // lookup's invocation mode is Datagram Debug.Assert(endpoint.Transport == Transport.UDP); single[0] = endpoint; ILookupPrx key = lookup.Clone(endpoints: single); if (endpoint["interface"] is string mcastInterface && mcastInterface.Length > 0) { Endpoint?q = lookupReply.Endpoints.FirstOrDefault(e => e.Host == mcastInterface); if (q != null) { single[0] = q; _lookups[key] = lookupReply.Clone(endpoints: single); } } if (!_lookups.ContainsKey(key)) { // Fallback: just use the given lookup reply proxy if no matching endpoint found. _lookups[key] = lookupReply; } } Debug.Assert(_lookups.Count > 0); }
internal Locator( string name, ILookupPrx lookup, Communicator communicator, string instanceName, ILocatorPrx voidLocator, ILookupReplyPrx lookupReply) { _lookup = lookup; _timeout = communicator.GetPropertyAsInt($"{name}.Timeout") ?? 300; if (_timeout < 0) { _timeout = 300; } _retryCount = Math.Max(communicator.GetPropertyAsInt($"{name}.RetryCount") ?? 3, 1); _retryDelay = Math.Max(communicator.GetPropertyAsInt($"{name}.RetryDelay") ?? 2000, 0); _traceLevel = communicator.GetPropertyAsInt($"{name}.Trace.Lookup") ?? 0; _instanceName = instanceName; _warned = false; _locator = lookup.Communicator.DefaultLocator; _voidLocator = voidLocator; // 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 (UdpEndpoint endpoint in lookup.Endpoints.Cast <UdpEndpoint>()) { single[0] = endpoint; ILookupPrx key = lookup.Clone(endpoints: single); if (endpoint.McastInterface.Length > 0) { IPEndpoint?q = lookupReply.Endpoints.Cast <IPEndpoint>().FirstOrDefault( e => e is IPEndpoint ipEndpoint && ipEndpoint.Host.Equals(endpoint.McastInterface)); if (q != null) { single[0] = q; _lookups[key] = lookupReply.Clone(endpoints: single); } } if (!_lookups.ContainsKey(key)) { // Fallback: just use the given lookup reply proxy if no matching endpoint found. _lookups[key] = lookupReply; } } Debug.Assert(_lookups.Count > 0); }
internal Lookup(LocatorRegistry registry, ILookupPrx lookup, Communicator communicator, ObjectAdapter replyAdapter) { _replyAdapter = replyAdapter; _registry = registry; _lookup = lookup; _timeout = communicator.GetPropertyAsTimeSpan("IceDiscovery.Timeout") ?? TimeSpan.FromMilliseconds(300); if (_timeout == System.Threading.Timeout.InfiniteTimeSpan) { _timeout = TimeSpan.FromMilliseconds(300); } _retryCount = communicator.GetPropertyAsInt("IceDiscovery.RetryCount") ?? 3; _latencyMultiplier = communicator.GetPropertyAsInt("IceDiscovery.LatencyMultiplier") ?? 1; _domainId = communicator.GetProperty("IceDiscovery.DomainId") ?? ""; // Create one lookup proxy per endpoint from the given proxy. We want to send a multicast // datagram on each endpoint. ILookupReplyPrx lookupReply = _replyAdapter.CreateProxy( "dummy", ILookupReplyPrx.Factory).Clone(invocationMode: InvocationMode.Datagram); var single = new Endpoint[1]; foreach (UdpEndpoint endpoint in lookup.Endpoints.Cast <UdpEndpoint>()) { single[0] = endpoint; ILookupPrx?key = lookup.Clone(endpoints: single); if (endpoint.McastInterface.Length > 0) { Endpoint?q = lookupReply.Endpoints.FirstOrDefault( e => e is IPEndpoint ipEndpoint && ipEndpoint.Host.Equals(endpoint.McastInterface)); if (q != null) { single[0] = q; _lookups[key] = lookupReply.Clone(endpoints: single); } } if (!_lookups.ContainsKey(key)) { // Fallback: just use the given lookup reply proxy if no matching endpoint found. _lookups[key] = lookupReply; } } Debug.Assert(_lookups.Count > 0); }