public Request(LocatorInfo locatorInfo, Reference @ref) { _locatorInfo = locatorInfo; _ref = @ref; _sent = false; _response = false; }
public override bool Equals(object obj) { if (ReferenceEquals(this, obj)) { return(true); } LocatorInfo rhs = obj as LocatorInfo; return(rhs == null ? false : _locator.Equals(rhs._locator)); }
exception(LocatorInfo locatorInfo, Ice.Exception exc) { try { locatorInfo.getEndpointsException(_ref, exc); // This throws. } catch (Ice.LocalException ex) { if (_callback != null) { _callback.setException(ex); } } }
exception(LocatorInfo locatorInfo, Ice.Exception exc) { try { locatorInfo.getEndpointsException(_ref, exc); // This throws. } catch(Ice.LocalException ex) { if(_callback != null) { _callback.setException(ex); } } }
response(LocatorInfo locatorInfo, Ice.ObjectPrx proxy) { EndpointI[] endpoints = null; if (proxy != null) { Reference r = ((Ice.ObjectPrxHelperBase)proxy).iceReference(); if (_ref.isWellKnown() && !Protocol.isSupported(_ref.getEncoding(), r.getEncoding())) { // // If a well-known proxy and the returned // proxy encoding isn't supported, we're done: // there's no compatible endpoint we can use. // } else if (!r.isIndirect()) { endpoints = r.getEndpoints(); } else if (_ref.isWellKnown() && !r.isWellKnown()) { // // We're resolving the endpoints of a well-known object and the proxy returned // by the locator is an indirect proxy. We now need to resolve the endpoints // of this indirect proxy. // if (_ref.getInstance().traceLevels().location >= 1) { locatorInfo.trace("retrieved adapter for well-known object from locator, " + "adding to locator cache", _ref, r); } locatorInfo.getEndpoints(r, _ref, _ttl, _callback); return; } } if (_ref.getInstance().traceLevels().location >= 1) { locatorInfo.getEndpointsTrace(_ref, endpoints, false); } if (_callback != null) { _callback.setEndpoints(endpoints == null ? new EndpointI[0] : endpoints, false); } }
// // Returns locator info for a given locator. Automatically creates // the locator info if it doesn't exist yet. // public LocatorInfo get(Ice.LocatorPrx loc) { if (loc == null) { return(null); } // // The locator can't be located. // Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(loc.ice_locator(null)); // // TODO: reap unused locator info objects? // lock (this) { LocatorInfo info = null; if (!_table.TryGetValue(locator, out info)) { // // Rely on locator identity for the adapter table. We want to // have only one table per locator (not one per locator // proxy). // LocatorTable table = null; LocatorKey key = new LocatorKey(locator); if (!_locatorTables.TryGetValue(key, out table)) { table = new LocatorTable(); _locatorTables[key] = table; } info = new LocatorInfo(locator, table, _background); _table[locator] = info; } return(info); } }
// // Returns locator info for a given locator. Automatically creates // the locator info if it doesn't exist yet. // public LocatorInfo get(ILocatorPrx loc) { if (loc == null) { throw new System.ArgumentNullException(nameof(loc)); } // // The locator can't be located. // ILocatorPrx locator = loc.Clone(clearLocator: true); // // TODO: reap unused locator info objects? // lock (this) { LocatorInfo info; if (!_table.TryGetValue(locator, out info)) { // // Rely on locator identity for the adapter table. We want to // have only one table per locator (not one per locator // proxy). // LocatorTable?table = null; LocatorKey key = new LocatorKey(locator); if (!_locatorTables.TryGetValue(key, out table)) { table = new LocatorTable(); _locatorTables[key] = table; } info = new LocatorInfo(locator, table, _background); _table[locator] = info; } return(info); } }
response(LocatorInfo locatorInfo, Ice.ObjectPrx proxy) { EndpointI[] endpoints = null; if(proxy != null) { Reference r = ((Ice.ObjectPrxHelperBase)proxy).reference__(); if(_ref.isWellKnown() && !Protocol.isSupported(_ref.getEncoding(), r.getEncoding())) { // // If a well-known proxy and the returned // proxy encoding isn't supported, we're done: // there's no compatible endpoint we can use. // } else if(!r.isIndirect()) { endpoints = r.getEndpoints(); } else if(_ref.isWellKnown() && !r.isWellKnown()) { // // We're resolving the endpoints of a well-known object and the proxy returned // by the locator is an indirect proxy. We now need to resolve the endpoints // of this indirect proxy. // locatorInfo.getEndpoints(r, _ref, _ttl, _callback); return; } } if(_ref.getInstance().traceLevels().location >= 1) { locatorInfo.getEndpointsTrace(_ref, endpoints, false); } if(_callback != null) { _callback.setEndpoints(endpoints == null ? new EndpointI[0] : endpoints, false); } }
public ObjectRequest(LocatorInfo locatorInfo, Reference reference) : base(locatorInfo, reference) { }
public ObjectRequest(LocatorInfo locatorInfo, Reference @ref) : base(locatorInfo, @ref) { }
public AdapterRequest(LocatorInfo locatorInfo, Reference @ref) : base(locatorInfo, @ref) { }
public int checkRetryAfterException(Ice.LocalException ex, Reference @ref, bool sleep, ref int cnt) { TraceLevels traceLevels = instance_.traceLevels(); Ice.Logger logger = instance_.initializationData().logger; // // We don't retry batch requests because the exception might have caused // the all the requests batched with the connection to be aborted and we // want the application to be notified. // if (@ref.getMode() == Reference.Mode.ModeBatchOneway || @ref.getMode() == Reference.Mode.ModeBatchDatagram) { throw ex; } Ice.ObjectNotExistException one = ex as Ice.ObjectNotExistException; if (one != null) { if (@ref.getRouterInfo() != null && one.operation.Equals("ice_add_proxy")) { // // If we have a router, an ObjectNotExistException with an // operation name "ice_add_proxy" indicates to the client // that the router isn't aware of the proxy (for example, // because it was evicted by the router). In this case, we // must *always* retry, so that the missing proxy is added // to the router. // @ref.getRouterInfo().clearCache(@ref); if (traceLevels.retry >= 1) { string s = "retrying operation call to add proxy to router\n" + ex; logger.trace(traceLevels.retryCat, s); } return(0); // We must always retry, so we don't look at the retry count. } else if (@ref.isIndirect()) { // // We retry ObjectNotExistException if the reference is // indirect. // if (@ref.isWellKnown()) { LocatorInfo li = @ref.getLocatorInfo(); if (li != null) { li.clearCache(@ref); } } } else { // // For all other cases, we don't retry ObjectNotExistException. // throw ex; } } else if (ex is Ice.RequestFailedException) { throw ex; } // // There is no point in retrying an operation that resulted in a // MarshalException. This must have been raised locally (because if // it happened in a server it would result in an UnknownLocalException // instead), which means there was a problem in this process that will // not change if we try again. // // The most likely cause for a MarshalException is exceeding the // maximum message size, which is represented by the subclass // MemoryLimitException. For example, a client can attempt to send a // message that exceeds the maximum memory size, or accumulate enough // batch requests without flushing that the maximum size is reached. // // This latter case is especially problematic, because if we were to // retry a batch request after a MarshalException, we would in fact // silently discard the accumulated requests and allow new batch // requests to accumulate. If the subsequent batched requests do not // exceed the maximum message size, it appears to the client that all // of the batched requests were accepted, when in reality only the // last few are actually sent. // if (ex is Ice.MarshalException) { throw ex; } ++cnt; Debug.Assert(cnt > 0); int interval; if (cnt == (_retryIntervals.Length + 1) && ex is Ice.CloseConnectionException) { // // A close connection exception is always retried at least once, even if the retry // limit is reached. // interval = 0; } else if (cnt > _retryIntervals.Length) { if (traceLevels.retry >= 1) { string s = "cannot retry operation call because retry limit has been exceeded\n" + ex; logger.trace(traceLevels.retryCat, s); } throw ex; } else { interval = _retryIntervals[cnt - 1]; } if (traceLevels.retry >= 1) { string s = "retrying operation call"; if (interval > 0) { s += " in " + interval + "ms"; } s += " because of exception\n" + ex; logger.trace(traceLevels.retryCat, s); } if (sleep && interval > 0) { // // Sleep before retrying. // System.Threading.Thread.Sleep(interval); } return(interval); }
public AdapterRequest(LocatorInfo locatorInfo, Reference reference) : base(locatorInfo, reference) { }
private void updateLocatorRegistry(LocatorInfo locatorInfo, ObjectPrx proxy) { if(_id.Length == 0 || locatorInfo == null) { return; // Nothing to update. } // // Call on the locator registry outside the synchronization to // blocking other threads that need to lock this OA. // LocatorRegistryPrx locatorRegistry = locatorInfo.getLocatorRegistry(); if(locatorRegistry == null) { return; } try { if(_replicaGroupId.Length == 0) { locatorRegistry.setAdapterDirectProxy(_id, proxy); } else { locatorRegistry.setReplicatedAdapterDirectProxy(_id, _replicaGroupId, proxy); } } catch(AdapterNotFoundException) { if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); s.Append("the object adapter is not known to the locator registry"); instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } NotRegisteredException ex1 = new NotRegisteredException(); ex1.kindOfObject = "object adapter"; ex1.id = _id; throw ex1; } catch(InvalidReplicaGroupIdException) { if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); s.Append("the replica group `" + _replicaGroupId + "' is not known to the locator registry"); instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } NotRegisteredException ex1 = new NotRegisteredException(); ex1.kindOfObject = "replica group"; ex1.id = _replicaGroupId; throw ex1; } catch(AdapterAlreadyActiveException) { if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); s.Append("the object adapter endpoints are already set"); instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } ObjectAdapterIdInUseException ex1 = new ObjectAdapterIdInUseException(); ex1.id = _id; throw; } catch(ObjectAdapterDeactivatedException) { // Expected if collocated call and OA is deactivated, ignore. } catch(CommunicatorDestroyedException) { // Ignore } catch(LocalException e) { if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); s.Append(e.ToString()); instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } throw; // TODO: Shall we raise a special exception instead of a non obvious local exception? } if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("updated object adapter `" + _id + "' endpoints with the locator registry\n"); s.Append("endpoints = "); if(proxy != null) { Ice.Endpoint[] endpoints = proxy.ice_getEndpoints(); for(int i = 0; i < endpoints.Length; i++) { s.Append(endpoints[i].ToString()); if(i + 1 < endpoints.Length) { s.Append(":"); } } } instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } }
public void destroy() { // // Deactivate and wait for completion. // deactivate(); waitForDeactivate(); lock(this) { // // Only a single thread is allowed to destroy the object // adapter. Other threads wait for the destruction to be // completed. // while(state_ == StateDestroying) { System.Threading.Monitor.Wait(this); } if(state_ == StateDestroyed) { return; } state_ = StateDestroying; } // // Now it's also time to clean up our servants and servant // locators. // _servantManager.destroy(); // // Destroy the thread pool. // if(_threadPool != null) { _threadPool.destroy(); _threadPool.joinWithAllThreads(); } if(_objectAdapterFactory != null) { _objectAdapterFactory.removeObjectAdapter(this); } lock(this) { // // We're done, now we can throw away all incoming connection // factories. // _incomingConnectionFactories.Clear(); // // Remove object references (some of them cyclic). // instance_ = null; _threadPool = null; _routerEndpoints = null; _routerInfo = null; _publishedEndpoints = null; _locatorInfo = null; _reference = null; _objectAdapterFactory = null; state_ = StateDestroyed; System.Threading.Monitor.PulseAll(this); } }
// // Returns locator info for a given locator. Automatically creates // the locator info if it doesn't exist yet. // public LocatorInfo get(Ice.LocatorPrx loc) { if(loc == null) { return null; } // // The locator can't be located. // Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(loc.ice_locator(null)); // // TODO: reap unused locator info objects? // lock(this) { LocatorInfo info = null; if(!_table.TryGetValue(locator, out info)) { // // Rely on locator identity for the adapter table. We want to // have only one table per locator (not one per locator // proxy). // LocatorTable table = null; LocatorKey key = new LocatorKey(locator); if(!_locatorTables.TryGetValue(key, out table)) { table = new LocatorTable(); _locatorTables[key] = table; } info = new LocatorInfo(locator, table, _background); _table[locator] = info; } return info; } }
public void setLocator(LocatorPrx locator) { lock(this) { checkForDeactivation(); _locatorInfo = instance_.locatorManager().get(locator); } }
private int _timeout; // Only used if _overrideTimeout == true #endregion Fields #region Constructors public RoutableReference(Instance instance, Ice.Communicator communicator, Ice.Identity identity, string facet, Reference.Mode mode, bool secure, EndpointI[] endpoints, string adapterId, LocatorInfo locatorInfo, RouterInfo routerInfo, bool collocationOptimized, bool cacheConnection, bool preferSecure, Ice.EndpointSelectionType endpointSelection, int locatorCacheTimeout) : base(instance, communicator, identity, facet, mode, secure) { _endpoints = endpoints; _adapterId = adapterId; _locatorInfo = locatorInfo; _routerInfo = routerInfo; _collocationOptimized = collocationOptimized; _cacheConnection = cacheConnection; _preferSecure = preferSecure; _endpointSelection = endpointSelection; _locatorCacheTimeout = locatorCacheTimeout; _overrideTimeout = false; _timeout = -1; if(_endpoints == null) { _endpoints = _emptyEndpoints; } if(_adapterId == null) { _adapterId = ""; } Debug.Assert(_adapterId.Length == 0 || _endpoints.Length == 0); }
public void response(LocatorInfo locatorInfo, Ice.ObjectPrx proxy) { EndpointI[] endpoints = null; if(proxy != null) { Reference r = ((Ice.ObjectPrxHelperBase)proxy).reference__(); if(!r.isIndirect()) { endpoints = r.getEndpoints(); } else if(_ref.isWellKnown() && !r.isWellKnown()) { // // We're resolving the endpoints of a well-known object and the proxy returned // by the locator is an indirect proxy. We now need to resolve the endpoints // of this indirect proxy. // locatorInfo.getEndpoints(r, _ref, _ttl, _callback); return; } } if(_ref.getInstance().traceLevels().location >= 1) { locatorInfo.getEndpointsTrace(_ref, endpoints, false); } if(_callback != null) { _callback.setEndpoints(endpoints == null ? new EndpointI[0] : endpoints, false); } }
// // Returns locator info for a given locator. Automatically creates // the locator info if it doesn't exist yet. // public LocatorInfo get(Ice.LocatorPrx loc) { if(loc == null) { return null; } // // The locator can't be located. // Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(loc.ice_locator(null)); // // TODO: reap unused locator info objects? // lock(this) { LocatorInfo info = (LocatorInfo)_table[locator]; if(info == null) { // // Rely on locator identity for the adapter table. We want to // have only one table per locator (not one per locator // proxy). // LocatorTable table = (LocatorTable)_locatorTables[locator.ice_getIdentity()]; if(table == null) { table = new LocatorTable(); _locatorTables[locator.ice_getIdentity()] = table; } info = new LocatorInfo(locator, table, _background); _table[locator] = info; } return info; } }
private Reference create(Ice.Identity ident, string facet, Reference.Mode mode, bool secure, Ice.ProtocolVersion protocol, Ice.EncodingVersion encoding, EndpointI[] endpoints, string adapterId, string propertyPrefix) { DefaultsAndOverrides defaultsAndOverrides = instance_.defaultsAndOverrides(); // // Default local proxy options. // LocatorInfo locatorInfo = null; if (_defaultLocator != null) { if (!((Ice.ObjectPrxHelperBase)_defaultLocator).reference__().getEncoding().Equals(encoding)) { locatorInfo = instance_.locatorManager().get( (Ice.LocatorPrx)_defaultLocator.ice_encodingVersion(encoding)); } else { locatorInfo = instance_.locatorManager().get(_defaultLocator); } } RouterInfo routerInfo = instance_.routerManager().get(_defaultRouter); bool collocOptimized = defaultsAndOverrides.defaultCollocationOptimization; bool cacheConnection = true; bool preferSecure = defaultsAndOverrides.defaultPreferSecure; Ice.EndpointSelectionType endpointSelection = defaultsAndOverrides.defaultEndpointSelection; int locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout; int invocationTimeout = defaultsAndOverrides.defaultInvocationTimeout; Dictionary <string, string> context = null; // // Override the defaults with the proxy properties if a property prefix is defined. // if (propertyPrefix != null && propertyPrefix.Length > 0) { Ice.Properties properties = instance_.initializationData().properties; // // Warn about unknown properties. // if (properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0) { checkForUnknownProperties(propertyPrefix); } string property; property = propertyPrefix + ".Locator"; Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)); if (locator != null) { if (!((Ice.ObjectPrxHelperBase)locator).reference__().getEncoding().Equals(encoding)) { locatorInfo = instance_.locatorManager().get( (Ice.LocatorPrx)locator.ice_encodingVersion(encoding)); } else { locatorInfo = instance_.locatorManager().get(locator); } } property = propertyPrefix + ".Router"; Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)); if (router != null) { if (propertyPrefix.EndsWith(".Router", StringComparison.Ordinal)) { string s = "`" + property + "=" + properties.getProperty(property) + "': cannot set a router on a router; setting ignored"; instance_.initializationData().logger.warning(s); } else { routerInfo = instance_.routerManager().get(router); } } property = propertyPrefix + ".CollocationOptimized"; collocOptimized = properties.getPropertyAsIntWithDefault(property, collocOptimized ? 1 : 0) > 0; property = propertyPrefix + ".ConnectionCached"; cacheConnection = properties.getPropertyAsIntWithDefault(property, cacheConnection ? 1 : 0) > 0; property = propertyPrefix + ".PreferSecure"; preferSecure = properties.getPropertyAsIntWithDefault(property, preferSecure ? 1 : 0) > 0; property = propertyPrefix + ".EndpointSelection"; if (properties.getProperty(property).Length > 0) { string type = properties.getProperty(property); if (type.Equals("Random")) { endpointSelection = Ice.EndpointSelectionType.Random; } else if (type.Equals("Ordered")) { endpointSelection = Ice.EndpointSelectionType.Ordered; } else { throw new Ice.EndpointSelectionTypeParseException("illegal value `" + type + "'; expected `Random' or `Ordered'"); } } property = propertyPrefix + ".LocatorCacheTimeout"; string val = properties.getProperty(property); if (val.Length > 0) { locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout); if (locatorCacheTimeout < -1) { locatorCacheTimeout = -1; StringBuilder msg = new StringBuilder("invalid value for "); msg.Append(property); msg.Append(" `"); msg.Append(properties.getProperty(property)); msg.Append("': defaulting to -1"); instance_.initializationData().logger.warning(msg.ToString()); } } property = propertyPrefix + ".InvocationTimeout"; val = properties.getProperty(property); if (val.Length > 0) { invocationTimeout = properties.getPropertyAsIntWithDefault(property, invocationTimeout); if (invocationTimeout < 1 && invocationTimeout != -1) { invocationTimeout = -1; StringBuilder msg = new StringBuilder("invalid value for "); msg.Append(property); msg.Append(" `"); msg.Append(properties.getProperty(property)); msg.Append("': defaulting to -1"); instance_.initializationData().logger.warning(msg.ToString()); } } property = propertyPrefix + ".Context."; Dictionary <string, string> contexts = properties.getPropertiesForPrefix(property); if (contexts.Count != 0) { context = new Dictionary <string, string>(); foreach (KeyValuePair <string, string> e in contexts) { context.Add(e.Key.Substring(property.Length), e.Value); } } } // // Create new reference // return(new RoutableReference(instance_, _communicator, ident, facet, mode, secure, protocol, encoding, endpoints, adapterId, locatorInfo, routerInfo, collocOptimized, cacheConnection, preferSecure, endpointSelection, locatorCacheTimeout, invocationTimeout, context)); }
private void updateLocatorRegistry(LocatorInfo locatorInfo, ObjectPrx proxy, bool registerProcess) { if(!registerProcess && _id.Length == 0) { return; // Nothing to update. } // // Call on the locator registry outside the synchronization to // blocking other threads that need to lock this OA. // LocatorRegistryPrx locatorRegistry = locatorInfo != null ? locatorInfo.getLocatorRegistry() : null; string serverId = ""; if(registerProcess) { Debug.Assert(instance_ != null); serverId = instance_.initializationData().properties.getProperty("Ice.ServerId"); if(locatorRegistry == null) { instance_.initializationData().logger.warning( "object adapter `" + getName() + "' cannot register the process without a locator registry"); } else if(serverId.Length == 0) { instance_.initializationData().logger.warning( "object adapter `" + getName() + "' cannot register the process without a value for Ice.ServerId"); } } if(locatorRegistry == null) { return; } if(_id.Length > 0) { try { if(_replicaGroupId.Length == 0) { locatorRegistry.setAdapterDirectProxy(_id, proxy); } else { locatorRegistry.setReplicatedAdapterDirectProxy(_id, _replicaGroupId, proxy); } } catch(AdapterNotFoundException) { if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); s.Append("the object adapter is not known to the locator registry"); instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } NotRegisteredException ex1 = new NotRegisteredException(); ex1.kindOfObject = "object adapter"; ex1.id = _id; throw ex1; } catch(InvalidReplicaGroupIdException) { if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); s.Append("the replica group `" + _replicaGroupId + "' is not known to the locator registry"); instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } NotRegisteredException ex1 = new NotRegisteredException(); ex1.kindOfObject = "replica group"; ex1.id = _replicaGroupId; throw ex1; } catch(AdapterAlreadyActiveException) { if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); s.Append("the object adapter endpoints are already set"); instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } ObjectAdapterIdInUseException ex1 = new ObjectAdapterIdInUseException(); ex1.id = _id; throw; } catch(LocalException e) { if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); s.Append(e.ToString()); instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } throw; // TODO: Shall we raise a special exception instead of a non obvious local exception? } if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("updated object adapter `" + _id + "' endpoints with the locator registry\n"); s.Append("endpoints = "); if(proxy != null) { Ice.Endpoint[] endpoints = proxy.ice_getEndpoints(); for(int i = 0; i < endpoints.Length; i++) { s.Append(endpoints[i].ToString()); if(i + 1 < endpoints.Length) { s.Append(":"); } } } instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } } if(registerProcess && serverId.Length > 0) { lock(this) { if(_processId == null) { Process servant = new ProcessI(_communicator); _processId = addWithUUID(servant).ice_getIdentity(); } } try { locatorRegistry.setServerProcessProxy(serverId, ProcessPrxHelper.uncheckedCast(createDirectProxy(_processId))); } catch(ServerNotFoundException) { if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("couldn't register server `" + serverId + "' with the locator registry:\n"); s.Append("the server is not known to the locator registry"); instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } NotRegisteredException ex1 = new NotRegisteredException(); ex1.id = serverId; ex1.kindOfObject = "server"; throw ex1; } catch(LocalException ex) { if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("couldn't register server `" + serverId + "' with the locator registry:\n" + ex); instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } throw; // TODO: Shall we raise a special exception instead of a non obvious local exception? } if(instance_.traceLevels().location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("registered server `" + serverId + "' with the locator registry"); instance_.initializationData().logger.trace(instance_.traceLevels().locationCat, s.ToString()); } } }
public int checkRetryAfterException(Ice.LocalException ex, Reference @ref, ref int cnt) { TraceLevels traceLevels = _instance.traceLevels(); Ice.Logger logger = _instance.initializationData().logger; if (@ref.getMode() == Reference.Mode.ModeBatchOneway || @ref.getMode() == Reference.Mode.ModeBatchDatagram) { Debug.Assert(false); // batch no longer implemented anyway throw ex; } Ice.ObjectNotExistException one = ex as Ice.ObjectNotExistException; if (one != null) { if (@ref.getRouterInfo() != null && one.operation.Equals("ice_add_proxy")) { // // If we have a router, an ObjectNotExistException with an // operation name "ice_add_proxy" indicates to the client // that the router isn't aware of the proxy (for example, // because it was evicted by the router). In this case, we // must *always* retry, so that the missing proxy is added // to the router. // @ref.getRouterInfo().clearCache(@ref); if (traceLevels.retry >= 1) { string s = "retrying operation call to add proxy to router\n" + ex; logger.trace(traceLevels.retryCat, s); } return(0); // We must always retry, so we don't look at the retry count. } else if (@ref.isIndirect()) { // // We retry ObjectNotExistException if the reference is // indirect. // if (@ref.isWellKnown()) { LocatorInfo li = @ref.getLocatorInfo(); if (li != null) { li.clearCache(@ref); } } } else { // // For all other cases, we don't retry ObjectNotExistException. // throw ex; } } else if (ex is Ice.RequestFailedException) { throw ex; } // // There is no point in retrying an operation that resulted in a // MarshalException. This must have been raised locally (because if // it happened in a server it would result in an UnknownLocalException // instead), which means there was a problem in this process that will // not change if we try again. // if (ex is Ice.MarshalException) { throw ex; } // // Don't retry if the communicator is destroyed, object adapter is deactivated, // or connection is manually closed. // if (ex is Ice.CommunicatorDestroyedException || ex is Ice.ObjectAdapterDeactivatedException || ex is Ice.ConnectionManuallyClosedException) { throw ex; } // // Don't retry invocation timeouts. // if (ex is Ice.InvocationTimeoutException || ex is Ice.InvocationCanceledException) { throw ex; } ++cnt; Debug.Assert(cnt > 0); int interval; if (cnt == (_retryIntervals.Length + 1) && ex is Ice.CloseConnectionException) { // // A close connection exception is always retried at least once, even if the retry // limit is reached. // interval = 0; } else if (cnt > _retryIntervals.Length) { if (traceLevels.retry >= 1) { string s = "cannot retry operation call because retry limit has been exceeded\n" + ex; logger.trace(traceLevels.retryCat, s); } throw ex; } else { interval = _retryIntervals[cnt - 1]; } if (traceLevels.retry >= 1) { string s = "retrying operation call"; if (interval > 0) { s += " in " + interval + "ms"; } s += " because of exception\n" + ex; logger.trace(traceLevels.retryCat, s); } return(interval); }