void IceInternal::LocatorInfo::finishRequest(const ReferencePtr& ref, const vector<ReferencePtr>& wellKnownRefs, const Ice::ObjectPrx& proxy, bool notRegistered) { if(!proxy || proxy->__reference()->isIndirect()) { // // Remove the cached references of well-known objects for which we tried // to resolved the endpoints if these endpoints are empty. // for(vector<ReferencePtr>::const_iterator q = wellKnownRefs.begin(); q != wellKnownRefs.end(); ++q) { _table->removeObjectReference((*q)->getIdentity()); } } if(!ref->isWellKnown()) { if(proxy && !proxy->__reference()->isIndirect()) // Cache the adapter endpoints. { _table->addAdapterEndpoints(ref->getAdapterId(), proxy->__reference()->getEndpoints()); } else if(notRegistered) // If the adapter isn't registered anymore, remove it from the cache. { _table->removeAdapterEndpoints(ref->getAdapterId()); } IceUtil::Mutex::Lock sync(*this); assert(_adapterRequests.find(ref->getAdapterId()) != _adapterRequests.end()); _adapterRequests.erase(ref->getAdapterId()); } else { if(proxy && !proxy->__reference()->isWellKnown()) // Cache the well-known object reference. { _table->addObjectReference(ref->getIdentity(), proxy->__reference()); } else if(notRegistered) // If the well-known object isn't registered anymore, remove it from the cache. { _table->removeObjectReference(ref->getIdentity()); } IceUtil::Mutex::Lock sync(*this); assert(_objectRequests.find(ref->getIdentity()) != _objectRequests.end()); _objectRequests.erase(ref->getIdentity()); } }
vector<EndpointIPtr> IceInternal::RouterInfo::setClientEndpoints(const Ice::ObjectPrx& proxy) { IceUtil::Mutex::Lock sync(*this); if(_clientEndpoints.empty()) { if(!proxy) { // // If getClientProxy() return nil, use router endpoints. // _clientEndpoints = _router->__reference()->getEndpoints(); } else { Ice::ObjectPrx clientProxy = proxy->ice_router(0); // The client proxy cannot be routed. // // In order to avoid creating a new connection to the router, // we must use the same timeout as the already existing // connection. // if(_router->ice_getConnection()) { clientProxy = clientProxy->ice_timeout(_router->ice_getConnection()->timeout()); } _clientEndpoints = clientProxy->__reference()->getEndpoints(); } } return _clientEndpoints; }
void IceInternal::LocatorInfo::RequestCallback::response(const LocatorInfoPtr& locatorInfo, const Ice::ObjectPrx& proxy) { vector<EndpointIPtr> endpoints; if(proxy) { ReferencePtr r = proxy->__reference(); if(_ref->isWellKnown() && !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) { _callback->setEndpoints(endpoints, false); } }
void ObjectAdapter::updateLocatorRegistry(const IceInternal::LocatorInfoPtr& locatorInfo, const Ice::ObjectPrx& proxy) { if(_id.empty()) { 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 ? locatorInfo->getLocatorRegistry() : LocatorRegistryPrx(); if(!locatorRegistry) { return; } if(!_id.empty()) { try { if(_replicaGroupId.empty()) { locatorRegistry->setAdapterDirectProxy(_id, proxy); } else { locatorRegistry->setReplicatedAdapterDirectProxy(_id, _replicaGroupId, proxy); } } catch(const AdapterNotFoundException&) { if(_instance->traceLevels()->location >= 1) { Trace out(_instance->initializationData().logger, _instance->traceLevels()->locationCat); out << "couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"; out << "the object adapter is not known to the locator registry"; } NotRegisteredException ex(__FILE__, __LINE__); ex.kindOfObject = "object adapter"; ex.id = _id; throw ex; } catch(const InvalidReplicaGroupIdException&) { if(_instance->traceLevels()->location >= 1) { Trace out(_instance->initializationData().logger, _instance->traceLevels()->locationCat); out << "couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"; out << "the replica group `" << _replicaGroupId << "' is not known to the locator registry"; } NotRegisteredException ex(__FILE__, __LINE__); ex.kindOfObject = "replica group"; ex.id = _replicaGroupId; throw ex; } catch(const AdapterAlreadyActiveException&) { if(_instance->traceLevels()->location >= 1) { Trace out(_instance->initializationData().logger, _instance->traceLevels()->locationCat); out << "couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"; out << "the object adapter endpoints are already set"; } ObjectAdapterIdInUseException ex(__FILE__, __LINE__); ex.id = _id; throw ex; } catch(const LocalException& ex) { if(_instance->traceLevels()->location >= 1) { Trace out(_instance->initializationData().logger, _instance->traceLevels()->locationCat); out << "couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n" << ex.toString(); } throw; // TODO: Shall we raise a special exception instead of a non obvious local exception? } if(_instance->traceLevels()->location >= 1) { Trace out(_instance->initializationData().logger, _instance->traceLevels()->locationCat); out << "updated object adapter `" + _id + "' endpoints with the locator registry\n"; out << "endpoints = "; vector<EndpointPtr> endpts = proxy ? proxy->__reference()->getEndpoints() : vector<EndpointPtr>(); for(vector<EndpointPtr>::iterator p = endpts.begin(); p != endpts.end(); ++p) { if(p != endpts.begin()) { out << ":"; } out << (*p)->toString(); } } } }