void Ice::ObjectAdapterI::setPublishedEndpoints(const EndpointSeq& newEndpoints) { vector<EndpointIPtr> newPublishedEndpoints; transform(newEndpoints.begin(), newEndpoints.end(), back_inserter(newPublishedEndpoints), toEndpointI); LocatorInfoPtr locatorInfo; vector<EndpointIPtr> oldPublishedEndpoints; { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); checkForDeactivation(); oldPublishedEndpoints = _publishedEndpoints; _publishedEndpoints = newPublishedEndpoints; locatorInfo = _locatorInfo; } try { Ice::Identity dummy; dummy.name = "dummy"; updateLocatorRegistry(locatorInfo, createDirectProxy(dummy)); } catch(const Ice::LocalException&) { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); // // Restore the old published endpoints. // _publishedEndpoints = oldPublishedEndpoints; throw; } }
ObjectPrxPtr ICE_OBJECT_PRX::ice_endpoints(const EndpointSeq& newEndpoints) const { vector<EndpointIPtr> endpoints; for(EndpointSeq::const_iterator p = newEndpoints.begin(); p != newEndpoints.end(); ++p) { endpoints.push_back(ICE_DYNAMIC_CAST(EndpointI, *p)); } if(endpoints == _reference->getEndpoints()) { return CONST_POINTER_CAST_OBJECT_PRX; } else { ObjectPrxPtr proxy = __newInstance(); proxy->setup(_reference->changeEndpoints(endpoints)); return proxy; } }
void ObjectAdapterI::updateLocatorRegistry(const IceInternal::LocatorInfoPtr& locatorInfo, const Ice::ObjectPrx& proxy, bool registerProcess) { if(!registerProcess && _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(); string serverId; if(registerProcess) { assert(_instance); serverId = _instance->initializationData().properties->getProperty("Ice.ServerId"); if(!locatorRegistry) { Warning out(_instance->initializationData().logger); out << "object adapter `" << getName() << "' cannot register the process without a locator registry"; } else if(serverId.empty()) { Warning out(_instance->initializationData().logger); out << "object adapter `" << getName() << "' cannot register the process without a value for Ice.ServerId"; } } 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; } 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 = "; if(proxy) { EndpointSeq endpts = proxy ? proxy->ice_getEndpoints() : EndpointSeq(); ostringstream o; transform(endpts.begin(), endpts.end(), ostream_iterator<string>(o, endpts.size() > 1 ? ":" : ""), Ice::constMemFun(&Endpoint::toString)); out << o.str(); } } } if(registerProcess && !serverId.empty()) { { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); if(_processId.name == "") { ProcessPtr servant = new ProcessI(_communicator); _processId = addWithUUID(servant)->ice_getIdentity(); } } try { locatorRegistry->setServerProcessProxy(serverId, ProcessPrx::uncheckedCast(createDirectProxy(_processId))); } catch(const ServerNotFoundException&) { if(_instance->traceLevels()->location >= 1) { Trace out(_instance->initializationData().logger, _instance->traceLevels()->locationCat); out << "couldn't register server `" + serverId + "' with the locator registry:\n"; out << "the server is not known to the locator registry"; } NotRegisteredException ex(__FILE__, __LINE__); ex.kindOfObject = "server"; ex.id = serverId; throw ex; } catch(const Ice::LocalException& ex) { if(_instance->traceLevels()->location >= 1) { Trace out(_instance->initializationData().logger, _instance->traceLevels()->locationCat); out << "couldn't register server `" + serverId + "' with the locator registry:\n" << ex; } 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 << "registered server `" + serverId + "' with the locator registry"; } } }
void ObjectAdapterI::updateLocatorRegistry(const IceInternal::LocatorInfoPtr& locatorInfo, const Ice::ObjectPrxPtr& proxy) { if(_id.empty() || !locatorInfo) { return; // Nothing to update. } LocatorRegistryPrxPtr locatorRegistry = locatorInfo->getLocatorRegistry(); if(!locatorRegistry) { return; } 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"; } throw NotRegisteredException(__FILE__, __LINE__, "object adapter", _id); } 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"; } throw NotRegisteredException(__FILE__, __LINE__, "replica group", _replicaGroupId); } 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"; } throw ObjectAdapterIdInUseException(__FILE__, __LINE__, _id); } catch(const ObjectAdapterDeactivatedException&) { // Expected if collocated call and OA is deactivated, ignore. } catch(const CommunicatorDestroyedException&) { // Ignore. } 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; } 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 = "; if(proxy) { EndpointSeq endpts = proxy ? proxy->ice_getEndpoints() : EndpointSeq(); ostringstream o; transform(endpts.begin(), endpts.end(), ostream_iterator<string>(o, endpts.size() > 1 ? ":" : ""), Ice::constMemFun(&Endpoint::toString)); out << o.str(); } } }