diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-10-11 07:50:31 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-10-11 07:50:31 +0000 |
commit | 8e9b12de541e2a641c7e450df16e5a78bef20ec1 (patch) | |
tree | 66236a42905eec0c913479ba406f6688fd879e05 /cpp/src | |
parent | file policy.3.1.iceboxcs was initially added on branch R3_1_branch. (diff) | |
download | ice-8e9b12de541e2a641c7e450df16e5a78bef20ec1.tar.bz2 ice-8e9b12de541e2a641c7e450df16e5a78bef20ec1.tar.xz ice-8e9b12de541e2a641c7e450df16e5a78bef20ec1.zip |
Bug fixes, replication test.
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceGrid/AdminI.cpp | 1 | ||||
-rw-r--r-- | cpp/src/IceGrid/Database.cpp | 5 | ||||
-rw-r--r-- | cpp/src/IceGrid/Database.h | 2 | ||||
-rw-r--r-- | cpp/src/IceGrid/DescriptorParser.cpp | 6 | ||||
-rw-r--r-- | cpp/src/IceGrid/RegistryI.cpp | 20 | ||||
-rw-r--r-- | cpp/src/IceGrid/ReplicaSessionI.cpp | 24 | ||||
-rw-r--r-- | cpp/src/IceGrid/Topics.cpp | 40 | ||||
-rw-r--r-- | cpp/src/IceGrid/Topics.h | 4 | ||||
-rw-r--r-- | cpp/src/IceGrid/WellKnownObjectsManager.cpp | 2 |
9 files changed, 69 insertions, 35 deletions
diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp index 43e6de3cd2a..7e3934a88d6 100644 --- a/cpp/src/IceGrid/AdminI.cpp +++ b/cpp/src/IceGrid/AdminI.cpp @@ -800,7 +800,6 @@ AdminI::getNodeHostname(const string& name, const Current&) const throw NodeUnreachableException(name, os.str()); return ""; // Keep the compiler happy. } - return ""; // Keep the compiler happy. } diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp index 683bf379d52..82d16f884b3 100644 --- a/cpp/src/IceGrid/Database.cpp +++ b/cpp/src/IceGrid/Database.cpp @@ -338,7 +338,7 @@ Database::syncAdapters(const AdapterInfoSeq& adapters) Freeze::TransactionHolder txHolder(_connection); _adapters.clear(); - for(AdapterInfoSeq::const_iterator r = adapters.end(); r != adapters.end(); ++r) + for(AdapterInfoSeq::const_iterator r = adapters.begin(); r != adapters.end(); ++r) { _adapters.put(StringAdapterInfoDict::value_type(r->id, *r)); } @@ -1243,7 +1243,7 @@ Database::updateObject(const Ice::ObjectPrx& proxy) } } -void +int Database::addOrUpdateObjectsInDatabase(const ObjectInfoSeq& objects) { int serial; @@ -1261,6 +1261,7 @@ Database::addOrUpdateObjectsInDatabase(const ObjectInfoSeq& objects) } _objectObserverTopic->objectsAddedOrUpdated(serial, objects); + return serial; } void diff --git a/cpp/src/IceGrid/Database.h b/cpp/src/IceGrid/Database.h index 9c027cab800..5e23eea25bf 100644 --- a/cpp/src/IceGrid/Database.h +++ b/cpp/src/IceGrid/Database.h @@ -115,7 +115,7 @@ public: void removeObject(const Ice::Identity&); void updateObject(const Ice::ObjectPrx&); - void addOrUpdateObjectsInDatabase(const ObjectInfoSeq&); + int addOrUpdateObjectsInDatabase(const ObjectInfoSeq&); void removeObjectsInDatabase(const ObjectInfoSeq&); void allocateObject(const Ice::Identity&, const ObjectAllocationRequestPtr&); diff --git a/cpp/src/IceGrid/DescriptorParser.cpp b/cpp/src/IceGrid/DescriptorParser.cpp index acdc992d2ab..ea7d672fe32 100644 --- a/cpp/src/IceGrid/DescriptorParser.cpp +++ b/cpp/src/IceGrid/DescriptorParser.cpp @@ -206,7 +206,7 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at { if(!_currentApplication.get()) { - error("the <server> element can only be a child of an <application> element"); + error("the <node> element can only be a child of an <application> element"); } _currentNode.reset(_currentApplication->createNode(attributes)); } @@ -252,7 +252,7 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at } else if(name == "server-template") { - if(_currentTemplate.get() || _currentNode.get()) + if(!_currentApplication.get() || _currentTemplate.get() || _currentNode.get()) { error("the <server-template> element can only be a child of an <application> element"); } @@ -285,7 +285,7 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at } else if(name == "service-template") { - if(_currentNode.get() || _currentTemplate.get()) + if(!_currentApplication.get() || _currentNode.get() || _currentTemplate.get()) { error("the <service-template> element can only be a child of an <application> element"); } diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp index 6bfd2bad9c6..f4790311f6b 100644 --- a/cpp/src/IceGrid/RegistryI.cpp +++ b/cpp/src/IceGrid/RegistryI.cpp @@ -671,7 +671,10 @@ RegistryI::createSession(const string& user, const string& password, const Curre SessionIPtr session = _clientSessionFactory->createSessionServant(user, 0); session->setServantLocator(_sessionServantLocator); SessionPrx proxy = SessionPrx::uncheckedCast(_sessionServantLocator->add(session, current.con)); - _reaper->add(new SessionReapable(current.adapter, session, proxy->ice_getIdentity()), _sessionTimeout); + if(_sessionTimeout > 0) + { + _reaper->add(new SessionReapable(current.adapter, session, proxy->ice_getIdentity()), _sessionTimeout); + } return proxy; } @@ -724,7 +727,10 @@ RegistryI::createAdminSession(const string& user, const string& password, const session->setAdmin(AdminPrx::uncheckedCast(admin)); session->setServantLocator(_sessionServantLocator); AdminSessionPrx proxy = AdminSessionPrx::uncheckedCast(_sessionServantLocator->add(session, current.con)); - _reaper->add(new SessionReapable(current.adapter, session, proxy->ice_getIdentity()), _sessionTimeout); + if(_sessionTimeout > 0) + { + _reaper->add(new SessionReapable(current.adapter, session, proxy->ice_getIdentity()), _sessionTimeout); + } return proxy; } @@ -784,7 +790,10 @@ RegistryI::createSessionFromSecureConnection(const Current& current) SessionIPtr session = _clientSessionFactory->createSessionServant(userDN, 0); session->setServantLocator(_sessionServantLocator); SessionPrx proxy = SessionPrx::uncheckedCast(_sessionServantLocator->add(session, current.con)); - _reaper->add(new SessionReapable(current.adapter, session, proxy->ice_getIdentity()), _sessionTimeout); + if(_sessionTimeout > 0) + { + _reaper->add(new SessionReapable(current.adapter, session, proxy->ice_getIdentity()), _sessionTimeout); + } return proxy; } @@ -835,7 +844,10 @@ RegistryI::createAdminSessionFromSecureConnection(const Current& current) session->setAdmin(AdminPrx::uncheckedCast(admin)); session->setServantLocator(_sessionServantLocator); AdminSessionPrx proxy = AdminSessionPrx::uncheckedCast(_sessionServantLocator->add(session, current.con)); - _reaper->add(new SessionReapable(current.adapter, session, proxy->ice_getIdentity()), _sessionTimeout); + if(_sessionTimeout > 0) + { + _reaper->add(new SessionReapable(current.adapter, session, proxy->ice_getIdentity()), _sessionTimeout); + } return proxy; } diff --git a/cpp/src/IceGrid/ReplicaSessionI.cpp b/cpp/src/IceGrid/ReplicaSessionI.cpp index 26da8a7138d..dc432499f85 100644 --- a/cpp/src/IceGrid/ReplicaSessionI.cpp +++ b/cpp/src/IceGrid/ReplicaSessionI.cpp @@ -100,13 +100,17 @@ ReplicaSessionI::setEndpoints(const StringObjectProxyDict& endpoints, const Ice: void ReplicaSessionI::registerWellKnownObjects(const ObjectInfoSeq& objects, const Ice::Current& current) { - Lock sync(*this); - if(_destroy) + int serial; { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + Lock sync(*this); + if(_destroy) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + _replicaWellKnownObjects = objects; + serial = _database->addOrUpdateObjectsInDatabase(objects); } - _replicaWellKnownObjects = objects; - _database->addOrUpdateObjectsInDatabase(objects); + _database->getObserverTopic(ObjectObserverTopicName)->waitForSyncedSubscribers(serial, _name); } void @@ -156,13 +160,15 @@ ReplicaSessionI::destroy(const Ice::Current& current) } } - _database->removeReplica(_name, this, shutdown); - if(!shutdown) { + cerr << "updating well known objects " << _name << endl; _wellKnownObjects->updateReplicatedWellKnownObjects(); // No need to update these if we're shutting down. } + cerr << "removing replica " << _name << endl; + _database->removeReplica(_name, this, shutdown); + if(current.adapter) { try @@ -190,6 +196,10 @@ Ice::ObjectPrx ReplicaSessionI::getEndpoint(const std::string& name) { Lock sync(*this); + if(_destroy) + { + return 0; + } return _replicaEndpoints[name]; } diff --git a/cpp/src/IceGrid/Topics.cpp b/cpp/src/IceGrid/Topics.cpp index cbb3f7766dc..20159fe4ec6 100644 --- a/cpp/src/IceGrid/Topics.cpp +++ b/cpp/src/IceGrid/Topics.cpp @@ -59,7 +59,7 @@ ObserverTopic::subscribe(const Ice::ObjectPrx& obsv, const string& name) { assert(_syncSubscribers.find(name) == _syncSubscribers.end()); _syncSubscribers.insert(name); - waitForSyncedSubscribers(_serial, name); + waitForSyncedSubscribersNoSync(_serial, name); } } @@ -138,6 +138,13 @@ ObserverTopic::receivedUpdate(const string& name, int serial, const string& fail void ObserverTopic::waitForSyncedSubscribers(int serial, const string& name) { + Lock sync(*this); + waitForSyncedSubscribersNoSync(serial, name); +} + +void +ObserverTopic::waitForSyncedSubscribersNoSync(int serial, const string& name) +{ if(_syncSubscribers.empty() && name.empty()) { return; @@ -150,6 +157,10 @@ ObserverTopic::waitForSyncedSubscribers(int serial, const string& name) } else { + if(_syncSubscribers.find(name) == _syncSubscribers.end()) + { + return; // Not subscribed anymore. + } _waitForUpdates[serial].insert(name); } @@ -519,7 +530,7 @@ ApplicationObserverTopic::applicationAdded(int serial, const ApplicationInfo& in Ice::Warning out(_logger); out << "unexpected exception while publishing `applicationAdded' update:\n" << ex; } - waitForSyncedSubscribers(serial); + waitForSyncedSubscribersNoSync(serial); } void @@ -541,7 +552,7 @@ ApplicationObserverTopic::applicationRemoved(int serial, const string& name) Ice::Warning out(_logger); out << "unexpected exception while publishing `applicationRemoved' update:\n" << ex; } - waitForSyncedSubscribers(serial); + waitForSyncedSubscribersNoSync(serial); } void @@ -594,7 +605,7 @@ ApplicationObserverTopic::applicationUpdated(int serial, const ApplicationUpdate Ice::Warning out(_logger); out << "unexpected exception while publishing `applicationUpdated' update:\n" << ex; } - waitForSyncedSubscribers(serial); + waitForSyncedSubscribersNoSync(serial); } void @@ -661,7 +672,7 @@ AdapterObserverTopic::adapterAdded(int serial, const AdapterInfo& info) Ice::Warning out(_logger); out << "unexpected exception while publishing `adapterAdded' update:\n" << ex; } - waitForSyncedSubscribers(serial); + waitForSyncedSubscribersNoSync(serial); } void @@ -683,7 +694,7 @@ AdapterObserverTopic::adapterUpdated(int serial, const AdapterInfo& info) Ice::Warning out(_logger); out << "unexpected exception while publishing `adapterUpdated' update:\n" << ex; } - waitForSyncedSubscribers(serial); + waitForSyncedSubscribersNoSync(serial); } void @@ -705,7 +716,7 @@ AdapterObserverTopic::adapterRemoved(int serial, const string& id) Ice::Warning out(_logger); out << "unexpected exception while publishing `adapterRemoved' update:\n" << ex; } - waitForSyncedSubscribers(serial); + waitForSyncedSubscribersNoSync(serial); } void @@ -772,7 +783,7 @@ ObjectObserverTopic::objectAdded(int serial, const ObjectInfo& info) Ice::Warning out(_logger); out << "unexpected exception while publishing `objectAdded' update:\n" << ex; } - waitForSyncedSubscribers(serial); + waitForSyncedSubscribersNoSync(serial); } void @@ -794,7 +805,7 @@ ObjectObserverTopic::objectUpdated(int serial, const ObjectInfo& info) Ice::Warning out(_logger); out << "unexpected exception while publishing `objectUpdated' update:\n" << ex; } - waitForSyncedSubscribers(serial); + waitForSyncedSubscribersNoSync(serial); } void @@ -816,7 +827,7 @@ ObjectObserverTopic::objectRemoved(int serial, const Ice::Identity& id) Ice::Warning out(_logger); out << "unexpected exception while publishing `objectRemoved' update:\n" << ex; } - waitForSyncedSubscribers(serial); + waitForSyncedSubscribersNoSync(serial); } void @@ -861,11 +872,10 @@ ObjectObserverTopic::objectsAddedOrUpdated(int serial, const ObjectInfoSeq& info } // - // We don't need to wait for the update to be received by the - // replicas here. This operation is only called internaly by - // IceGrid. + // We don't wait for the update to be received by the replicas + // here. This operation is called by ReplicaSessionI. // - //waitForSyncedSubscribers(serial); + //waitForSyncedSubscribersNoSync(serial); } void @@ -897,7 +907,7 @@ ObjectObserverTopic::objectsRemoved(int serial, const ObjectInfoSeq& infos) // replicas here. This operation is only called internaly by // IceGrid. // - //waitForSyncedSubscribers(serial); + //waitForSyncedSubscribersNoSync(serial); } void diff --git a/cpp/src/IceGrid/Topics.h b/cpp/src/IceGrid/Topics.h index 56554537ce9..13a75970b56 100644 --- a/cpp/src/IceGrid/Topics.h +++ b/cpp/src/IceGrid/Topics.h @@ -36,9 +36,11 @@ public: virtual void initObserver(const Ice::ObjectPrx&) = 0; + void waitForSyncedSubscribers(int, const std::string& = std::string()); + protected: - void waitForSyncedSubscribers(int, const std::string& = std::string()); + void waitForSyncedSubscribersNoSync(int, const std::string& = std::string()); void updateSerial(int); Ice::Context getContext(int) const; diff --git a/cpp/src/IceGrid/WellKnownObjectsManager.cpp b/cpp/src/IceGrid/WellKnownObjectsManager.cpp index fde27fc5bdb..d09bdde2f65 100644 --- a/cpp/src/IceGrid/WellKnownObjectsManager.cpp +++ b/cpp/src/IceGrid/WellKnownObjectsManager.cpp @@ -90,7 +90,7 @@ WellKnownObjectsManager::updateReplicatedWellKnownObjects() id.category = _database->getInstanceName(); ObjectInfo info; ObjectInfoSeq objects; - + Lock sync(*this); Ice::ObjectPrx replicatedClientProxy = _database->getReplicatedEndpoints("Client", _endpoints["Client"]); |