public void refreshPublishedEndpoints() { LocatorInfo locatorInfo = null; List <EndpointI> oldPublishedEndpoints; lock (this) { checkForDeactivation(); oldPublishedEndpoints = _publishedEndpoints; _publishedEndpoints = parsePublishedEndpoints(); locatorInfo = _locatorInfo; } try { Ice.Identity dummy = new Ice.Identity(); dummy.name = "dummy"; updateLocatorRegistry(locatorInfo, createDirectProxy(dummy)); } catch (Ice.LocalException) { lock (this) { // // Restore the old published endpoints. // _publishedEndpoints = oldPublishedEndpoints; throw; } } }
internal Request(LocatorInfo locatorInfo, Reference reference) { LocatorInfo = locatorInfo; Ref = reference; _sent = false; _response = false; }
// Returns locator info for a given locator. Automatically creates // the locator info if it doesn't exist yet. internal LocatorInfo GetLocatorInfo(ILocatorPrx loc) { // The locator can't be located. ILocatorPrx locator = loc.Clone(clearLocator: true); // TODO: reap unused locator info objects? lock (_locatorInfoMap) { if (!_locatorInfoMap.TryGetValue(locator, out LocatorInfo? info)) { // Rely on locator identity for the adapter table. We want to // have only one table per locator (not one per locator // proxy). var key = new LocatorKey(locator); if (!_locatorTableMap.TryGetValue(key, out LocatorTable? table)) { table = new LocatorTable(); _locatorTableMap[key] = table; } info = new LocatorInfo(locator, table, _backgroundLocatorCacheUpdates); _locatorInfoMap[locator] = info; } return(info); } }
public void Exception(LocatorInfo locatorInfo, Exception exc) { try { locatorInfo.GetEndpointsException(_ref, exc); // This throws. } catch (LocalException ex) { if (_callback != null) { _callback.SetException(ex); } } }
public void Response(LocatorInfo locatorInfo, IObjectPrx?proxy) { Endpoint[]? endpoints = null; if (proxy != null) { Reference r = 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.GetCommunicator().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.GetCommunicator().TraceLevels.location >= 1) { locatorInfo.GetEndpointsTrace(_ref, endpoints, false); } if (_callback != null) { _callback.SetEndpoints(endpoints ?? Array.Empty <Endpoint>(), false); } }
public void Response(LocatorInfo locatorInfo, IObjectPrx?proxy) { IReadOnlyList <Endpoint>?endpoints = null; if (proxy != null) { Reference r = proxy.IceReference; if (_ref.IsWellKnown && _ref.Encoding != r.Encoding) { // If a well-known proxy and the returned proxy encoding don't match we're done: // there's no compatible endpoint we can use. } else if (!r.IsIndirect) { endpoints = r.Endpoints; } 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.Communicator.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.Communicator.TraceLevels.Location >= 1) { locatorInfo.GetEndpointsTrace(_ref, endpoints, false); } if (_callback != null) { _callback.SetEndpoints(endpoints ?? Array.Empty <Endpoint>(), false); } }
public void setPublishedEndpoints(Endpoint[] newEndpoints) { List <EndpointI> newPublishedEndpoints = new List <EndpointI>(newEndpoints.Length); foreach (Endpoint e in newEndpoints) { newPublishedEndpoints.Add((EndpointI)e); } LocatorInfo locatorInfo = null; List <EndpointI> oldPublishedEndpoints; lock (this) { checkForDeactivation(); oldPublishedEndpoints = _publishedEndpoints; _publishedEndpoints = newPublishedEndpoints; locatorInfo = _locatorInfo; } try { Identity dummy = new Identity(); dummy.name = "dummy"; updateLocatorRegistry(locatorInfo, createDirectProxy(dummy)); } catch (LocalException) { lock (this) { // // Restore the old published endpoints. // _publishedEndpoints = oldPublishedEndpoints; throw; } } }
public void setPublishedEndpoints(Endpoint[] newEndpoints) { LocatorInfo locatorInfo = null; EndpointI[] oldPublishedEndpoints; lock (this) { checkForDeactivation(); if (_routerInfo != null) { throw new ArgumentException( "can't set published endpoints on object adapter associated with a router"); } oldPublishedEndpoints = _publishedEndpoints; _publishedEndpoints = Array.ConvertAll(newEndpoints, endpt => (EndpointI)endpt); locatorInfo = _locatorInfo; } try { Identity dummy = new Identity(); dummy.name = "dummy"; updateLocatorRegistry(locatorInfo, createDirectProxy(dummy)); } catch (LocalException) { lock (this) { // // Restore the old published endpoints. // _publishedEndpoints = oldPublishedEndpoints; throw; } } }
public void activate() { LocatorInfo locatorInfo = null; bool printAdapterReady = false; lock (this) { checkForDeactivation(); // // If we've previously been initialized we just need to activate the // incoming connection factories and we're done. // if (state_ != StateUninitialized) { foreach (IncomingConnectionFactory icf in _incomingConnectionFactories) { icf.activate(); } return; } // // One off initializations of the adapter: update the // locator registry and print the "adapter ready" // message. We set set state to StateActivating to prevent // deactivation from other threads while these one off // initializations are done. // state_ = StateActivating; locatorInfo = _locatorInfo; if (!_noConfig) { Properties properties = instance_.initializationData().properties; printAdapterReady = properties.getPropertyAsInt("Ice.PrintAdapterReady") > 0; } } try { Ice.Identity dummy = new Ice.Identity(); dummy.name = "dummy"; updateLocatorRegistry(locatorInfo, createDirectProxy(dummy)); } catch (Ice.LocalException) { // // If we couldn't update the locator registry, we let the // exception go through and don't activate the adapter to // allow to user code to retry activating the adapter // later. // lock (this) { state_ = StateUninitialized; System.Threading.Monitor.PulseAll(this); } throw; } if (printAdapterReady) { Console.Out.WriteLine(_name + " ready"); } lock (this) { Debug.Assert(state_ == StateActivating); foreach (IncomingConnectionFactory icf in _incomingConnectionFactories) { icf.activate(); } state_ = StateActive; System.Threading.Monitor.PulseAll(this); } }
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()); } }
internal AdapterRequest(LocatorInfo locatorInfo, Reference reference) : base(locatorInfo, reference) { }
internal ObjectRequest(LocatorInfo locatorInfo, Reference reference) : base(locatorInfo, reference) { }