示例#1
0
        public void clearCache(Reference rf)
        {
            Debug.Assert(rf.isIndirect());
            if(!rf.isWellKnown())
            {
                EndpointI[] endpoints = _table.removeAdapterEndpoints(rf.getAdapterId());

                if(endpoints != null && rf.getInstance().traceLevels().location >= 2)
                {
                    trace("removed endpoints from locator table\n", rf, endpoints);
                }
            }
            else
            {
                Reference r = _table.removeObjectReference(rf.getIdentity());
                if(r != null)
                {
                    if(!r.isIndirect())
                    {
                        if(rf.getInstance().traceLevels().location >= 2)
                        {
                            trace("removed endpoints from locator table", rf, r.getEndpoints());
                        }
                    }
                    else if(!r.isWellKnown())
                    {
                        clearCache(r);
                    }
                }
            }
        }
示例#2
0
 public Reference copy(Reference r)
 {
     Ice.Identity ident = r.getIdentity();
     if(ident.name.Length == 0 && ident.category.Length == 0)
     {
         return null;
     }
     return (Reference)r.Clone();
 }
示例#3
0
 public void clearCache(Reference @ref)
 {
     lock(this)
     {
         _identities.Remove(@ref.getIdentity());
     }
 }
示例#4
0
        finishRequest(Reference @ref, List<Reference> wellKnownRefs, Ice.ObjectPrx proxy, bool notRegistered)
        {
            Ice.ObjectPrxHelperBase @base = proxy as Ice.ObjectPrxHelperBase;
            if(proxy == null || @base.reference__().isIndirect())
            {
                //
                // Remove the cached references of well-known objects for which we tried
                // to resolved the endpoints if these endpoints are empty.
                //
                foreach(Reference r in wellKnownRefs)
                {
                    _table.removeObjectReference(r.getIdentity());
                }
            }
    
            if([email protected]())
            {
                if(proxy != null && [email protected]__().isIndirect())
                {
                    // Cache the adapter endpoints.
                    _table.addAdapterEndpoints(@ref.getAdapterId(), @base.reference__().getEndpoints());
                }
                else if(notRegistered) // If the adapter isn't registered anymore, remove it from the cache.
                {
                    _table.removeAdapterEndpoints(@ref.getAdapterId());
                }
            
                lock(this)
                {
                    Debug.Assert(_adapterRequests.ContainsKey(@ref.getAdapterId()));
                    _adapterRequests.Remove(@ref.getAdapterId());
                }
            }
            else
            {
                if(proxy != null && [email protected]__().isWellKnown()) 
                {
                    // Cache the well-known object reference.
                    _table.addObjectReference(@ref.getIdentity(), @base.reference__());
                }
                else if(notRegistered) // If the well-known object isn't registered anymore, remove it from the cache.
                {
                    _table.removeObjectReference(@ref.getIdentity());
                }

                lock(this)
                {
                    Debug.Assert(_objectRequests.ContainsKey(@ref.getIdentity()));
                    _objectRequests.Remove(@ref.getIdentity());
                }
            }
        }
示例#5
0
        getObjectRequest(Reference @ref)
        {
            if(@ref.getInstance().traceLevels().location >= 1)
            {
                Instance instance = @ref.getInstance();
                System.Text.StringBuilder s = new System.Text.StringBuilder();
                s.Append("searching for object by id\nobject = ");
                s.Append(instance.identityToString(@ref.getIdentity()));
                instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString());
            }

            lock(this)
            {
                Request request;
                if(_objectRequests.TryGetValue(@ref.getIdentity(), out request))
                {
                    return request;
                }
                
                request = new ObjectRequest(this, @ref);
                _objectRequests.Add(@ref.getIdentity(), request);
                return request;
            }
        }
示例#6
0
 private void getEndpointsTrace(Reference @ref, EndpointI[] endpoints, bool cached)
 {
     if(endpoints != null && endpoints.Length > 0)
     {
         if(cached)
         {
             trace("found endpoints in locator table", @ref, endpoints);
         }
         else
         {
             trace("retrieved endpoints from locator, adding to locator table", @ref, endpoints);
         }
     }
     else
     {
         Instance instance = @ref.getInstance();
         System.Text.StringBuilder s = new System.Text.StringBuilder();
         s.Append("no endpoints configured for ");
         if(@ref.getAdapterId().Length > 0)
         {
             s.Append("adapter\n");
             s.Append("adapter = " + @ref.getAdapterId());
         }
         else
         {
             s.Append("object\n");
             s.Append("object = " + instance.identityToString(@ref.getIdentity()));
         }
         instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString());
     }
 }
示例#7
0
        private void getEndpointsException(Reference @ref, System.Exception exc)
        {
            try
            {
                throw exc;
            }
            catch(Ice.AdapterNotFoundException ex)
            {
                Instance instance = @ref.getInstance();
                if(instance.traceLevels().location >= 1)
                {
                    System.Text.StringBuilder s = new System.Text.StringBuilder();
                    s.Append("adapter not found\n");
                    s.Append("adapter = " + @ref.getAdapterId());
                    instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString());
                }

                Ice.NotRegisteredException e = new Ice.NotRegisteredException(ex);
                e.kindOfObject = "object adapter";
                e.id = @ref.getAdapterId();
                throw e;
            }
            catch(Ice.ObjectNotFoundException ex)
            {
                Instance instance = @ref.getInstance();
                if(instance.traceLevels().location >= 1)
                {
                    System.Text.StringBuilder s = new System.Text.StringBuilder();
                    s.Append("object not found\n");
                    s.Append("object = " + instance.identityToString(@ref.getIdentity()));
                    instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString());
                }

                Ice.NotRegisteredException e = new Ice.NotRegisteredException(ex);
                e.kindOfObject = "object";
                e.id = instance.identityToString(@ref.getIdentity());
                throw e;
            }
            catch(Ice.NotRegisteredException)
            {
                throw;
            }
            catch(Ice.LocalException ex)
            {
                Instance instance = @ref.getInstance();
                if(instance.traceLevels().location >= 1)
                {
                    System.Text.StringBuilder s = new System.Text.StringBuilder();
                    s.Append("couldn't contact the locator to retrieve adapter endpoints\n");
                    if(@ref.getAdapterId().Length > 0)
                    {
                        s.Append("adapter = " + @ref.getAdapterId() + "\n");
                    }
                    else
                    {
                        s.Append("object = " + instance.identityToString(@ref.getIdentity()) + "\n");
                    }
                    s.Append("reason = " + ex);
                    instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString());
                }
                throw;
            }
            catch(System.Exception)
            {
                Debug.Assert(false);
            }
        }
示例#8
0
 private void trace(string msg, Reference r, EndpointI[] endpoints)
 {
     System.Text.StringBuilder s = new System.Text.StringBuilder();
     s.Append(msg + "\n");
     if(r.getAdapterId().Length > 0)
     {
         s.Append("adapter = " + r.getAdapterId() + "\n");
     }
     else
     {
         s.Append("object = " + r.getInstance().identityToString(r.getIdentity()) + "\n");
     }
     
     s.Append("endpoints = ");
     int sz = endpoints.Length;
     for (int i = 0; i < sz; i++)
     {
         s.Append(endpoints[i].ToString());
         if(i + 1 < sz)
         {
             s.Append(":");
         }
     }
     
     r.getInstance().initializationData().logger.trace(r.getInstance().traceLevels().locationCat, s.ToString());
 }
示例#9
0
 getEndpoints(Reference @ref, Reference wellKnownRef, int ttl, GetEndpointsCallback callback)
 {
     Debug.Assert(@ref.isIndirect());
     EndpointI[] endpoints = null;
     bool cached = false;
     if([email protected]())
     {
         endpoints = _table.getAdapterEndpoints(@ref.getAdapterId(), ttl, out cached);
         if(!cached)
         {
             if(_background && endpoints != null)
             {
                 getAdapterRequest(@ref).addCallback(@ref, wellKnownRef, ttl, null);
             }
             else
             {
                 getAdapterRequest(@ref).addCallback(@ref, wellKnownRef, ttl, callback);
                 return;
             }
         }
     }
     else
     {
         Reference r = _table.getObjectReference(@ref.getIdentity(), ttl, out cached);
         if(!cached)
         {
             if(_background && r != null)
             {
                 getObjectRequest(@ref).addCallback(@ref, null, ttl, null);
             }
             else
             {
                 getObjectRequest(@ref).addCallback(@ref, null, ttl, callback);
                 return;
             }
         }
         
         if(!r.isIndirect())
         {
             endpoints = r.getEndpoints();
         }
         else if(!r.isWellKnown())
         {
             getEndpoints(r, @ref, ttl, callback);
             return;
         }
     }
     
     Debug.Assert(endpoints != null);
     if(@ref.getInstance().traceLevels().location >= 1)
     {
         getEndpointsTrace(@ref, endpoints, true);
     }
     if(callback != null)
     {
         callback.setEndpoints(endpoints, true);
     }
 }