示例#1
0
            public LocatorKey(Ice.LocatorPrx prx)
            {
                Reference r = prx.IceReference;

                _id       = r.getIdentity();
                _encoding = r.getEncoding();
            }
示例#2
0
 foundLocator(Ice.LocatorPrx locator, Ice.Current current)
 {
     _locator.foundLocator(locator);
 }
示例#3
0
文件: LocatorInfo.cs 项目: motuii/ice
 internal LocatorInfo(Ice.LocatorPrx locator, LocatorTable table, bool background)
 {
     _locator    = locator;
     _table      = table;
     _background = background;
 }
示例#4
0
文件: PluginI.cs 项目: motuii/ice
        invoke(Ice.LocatorPrx locator, Request request)
        {
            lock (this)
            {
                if (request != null && _locator != null && _locator != locator)
                {
                    request.invoke(_locator);
                }
                else if (request != null && IceInternal.Time.currentMonotonicTimeMillis() < _nextRetry)
                {
                    request.invoke(_voidLocator); // Don't retry to find a locator before the retry delay expires
                }
                else
                {
                    _locator = null;

                    if (request != null)
                    {
                        _pendingRequests.Add(request);
                    }

                    if (!_pending) // No request in progress
                    {
                        _pending           = true;
                        _pendingRetryCount = _retryCount;
                        _failureCount      = 0;
                        try
                        {
                            if (_traceLevel > 1)
                            {
                                StringBuilder s = new StringBuilder("looking up locator:\nlookup = ");
                                s.Append(_lookup);
                                if (_instanceName.Length == 0)
                                {
                                    s.Append("\ninstance name = ").Append(_instanceName);
                                }
                                _lookup.Communicator.getLogger().trace("Lookup", s.ToString());
                            }

                            foreach (var l in _lookups)
                            {
                                l.Key.findLocatorAsync(_instanceName, l.Value).ContinueWith(t =>
                                {
                                    try
                                    {
                                        t.Wait();
                                    }
                                    catch (AggregateException ex)
                                    {
                                        exception(ex.InnerException);
                                    }
                                }, l.Key.Scheduler); // Send multicast request.
                            }
                            _timer.schedule(this, _timeout);
                        }
                        catch (Ice.LocalException ex)
                        {
                            if (_traceLevel > 0)
                            {
                                StringBuilder s = new StringBuilder("locator lookup failed:\nlookup = ");
                                s.Append(_lookup);
                                if (_instanceName.Length == 0)
                                {
                                    s.Append("\ninstance name = ").Append(_instanceName);
                                }
                                s.Append("\n").Append(ex);
                                _lookup.Communicator.getLogger().trace("Lookup", s.ToString());
                            }

                            foreach (Request req in _pendingRequests)
                            {
                                req.invoke(_voidLocator);
                            }
                            _pendingRequests.Clear();
                            _pendingRetryCount = 0;
                            _pending           = false;
                        }
                    }
                }
            }
        }
示例#5
0
文件: PluginI.cs 项目: motuii/ice
        foundLocator(Ice.LocatorPrx locator)
        {
            lock (this)
            {
                if (locator == null ||
                    (_instanceName.Length > 0 && !locator.Identity.category.Equals(_instanceName)))
                {
                    if (_traceLevel > 2)
                    {
                        StringBuilder s = new StringBuilder("ignoring locator reply: instance name doesn't match\n");
                        s.Append("expected = ").Append(_instanceName);
                        s.Append("received = ").Append(locator.Identity.category);
                        _lookup.Communicator.getLogger().trace("Lookup", s.ToString());
                    }
                    return;
                }

                //
                // If we already have a locator assigned, ensure the given locator
                // has the same identity, otherwise ignore it.
                //
                if (_pendingRequests.Count > 0 &&
                    _locator != null && !locator.Identity.category.Equals(_locator.Identity.category))
                {
                    if (!_warned)
                    {
                        _warned = true; // Only warn once

                        locator.Communicator.getLogger().warning(
                            "received Ice locator with different instance name:\n" +
                            "using = `" + _locator.Identity.category + "'\n" +
                            "received = `" + locator.Identity.category + "'\n" +
                            "This is typically the case if multiple Ice locators with different " +
                            "instance names are deployed and the property `IceLocatorDiscovery.InstanceName'" +
                            "is not set.");
                    }
                    return;
                }

                if (_pending) // No need to continue, we found a locator
                {
                    _timer.cancel(this);
                    _pendingRetryCount = 0;
                    _pending           = false;
                }

                if (_traceLevel > 0)
                {
                    StringBuilder s = new StringBuilder("locator lookup succeeded:\nlocator = ");
                    s.Append(locator);
                    if (_instanceName.Length == 0)
                    {
                        s.Append("\ninstance name = ").Append(_instanceName);
                    }
                    _lookup.Communicator.getLogger().trace("Lookup", s.ToString());
                }

                Ice.LocatorPrx l = null;
                if (_pendingRequests.Count == 0)
                {
                    _locators.TryGetValue(locator.Identity.category, out _locator);
                }
                else
                {
                    l = _locator;
                }
                if (l != null)
                {
                    //
                    // We found another locator replica, append its endpoints to the
                    // current locator proxy endpoints.
                    //
                    List <Endpoint> newEndpoints = new List <Endpoint>(l.Endpoints);
                    foreach (Endpoint p in locator.Endpoints)
                    {
                        //
                        // Only add endpoints if not already in the locator proxy endpoints
                        //
                        bool found = false;
                        foreach (Endpoint q in newEndpoints)
                        {
                            if (p.Equals(q))
                            {
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            newEndpoints.Add(p);
                        }
                    }
                    l = l.Clone(endpoints: newEndpoints.ToArray());
                }
                else
                {
                    l = locator;
                }

                if (_pendingRequests.Count == 0)
                {
                    _locators[locator.Identity.category] = l;
                    Monitor.Pulse(this);
                }
                else
                {
                    _locator = l;
                    if (_instanceName.Length == 0)
                    {
                        _instanceName = _locator.Identity.category; // Stick to the first locator
                    }

                    //
                    // Send pending requests if any.
                    //
                    foreach (Request req in _pendingRequests)
                    {
                        req.invoke(_locator);
                    }
                    _pendingRequests.Clear();
                }
            }
        }