diff options
author | Benoit Foucher <benoit@zeroc.com> | 2008-03-12 17:56:56 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2008-03-12 17:56:56 +0100 |
commit | ddf655a37d5d62a3b89adbf4d7ad9d23da65756c (patch) | |
tree | 0930dab75fd5b5153ddfde972d5d7a946ef55541 /cpp/src | |
parent | SLES fixes (diff) | |
download | ice-ddf655a37d5d62a3b89adbf4d7ad9d23da65756c.tar.bz2 ice-ddf655a37d5d62a3b89adbf4d7ad9d23da65756c.tar.xz ice-ddf655a37d5d62a3b89adbf4d7ad9d23da65756c.zip |
Fixed bug 2738
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceGrid/AdminI.cpp | 26 | ||||
-rw-r--r-- | cpp/src/IceGrid/AdminI.h | 2 | ||||
-rw-r--r-- | cpp/src/IceGrid/Database.cpp | 6 | ||||
-rw-r--r-- | cpp/src/IceGrid/Database.h | 5 | ||||
-rw-r--r-- | cpp/src/IceGrid/IceGridNode.cpp | 17 | ||||
-rw-r--r-- | cpp/src/IceGrid/IceGridRegistry.cpp | 8 | ||||
-rw-r--r-- | cpp/src/IceGrid/NodeCache.cpp | 13 | ||||
-rw-r--r-- | cpp/src/IceGrid/NodeSessionI.cpp | 11 | ||||
-rw-r--r-- | cpp/src/IceGrid/RegistryI.cpp | 8 | ||||
-rw-r--r-- | cpp/src/IceGrid/RegistryI.h | 3 | ||||
-rw-r--r-- | cpp/src/IceGrid/ReplicaSessionI.cpp | 9 | ||||
-rw-r--r-- | cpp/src/IceGrid/ReplicaSessionManager.cpp | 3 |
12 files changed, 77 insertions, 34 deletions
diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp index 6edfab038f4..e43421726c1 100644 --- a/cpp/src/IceGrid/AdminI.cpp +++ b/cpp/src/IceGrid/AdminI.cpp @@ -164,7 +164,7 @@ AdminI::~AdminI() void AdminI::addApplication(const ApplicationDescriptor& descriptor, const Current&) { - checkIsMaster(); + checkIsReadOnly(); ApplicationInfo info; info.createTime = info.updateTime = IceUtil::Time::now().toMilliSeconds(); @@ -179,14 +179,14 @@ AdminI::addApplication(const ApplicationDescriptor& descriptor, const Current&) void AdminI::syncApplication(const ApplicationDescriptor& descriptor, const Current&) { - checkIsMaster(); + checkIsReadOnly(); _database->syncApplicationDescriptor(descriptor, _session.get()); } void AdminI::updateApplication(const ApplicationUpdateDescriptor& descriptor, const Current&) { - checkIsMaster(); + checkIsReadOnly(); ApplicationUpdateInfo update; update.updateTime = IceUtil::Time::now().toMilliSeconds(); @@ -199,14 +199,14 @@ AdminI::updateApplication(const ApplicationUpdateDescriptor& descriptor, const C void AdminI::removeApplication(const string& name, const Current&) { - checkIsMaster(); + checkIsReadOnly(); _database->removeApplication(name, _session.get()); } void AdminI::instantiateServer(const string& app, const string& node, const ServerInstanceDescriptor& desc, const Current&) { - checkIsMaster(); + checkIsReadOnly(); _database->instantiateServer(app, node, desc, _session.get()); } @@ -613,7 +613,7 @@ AdminI::getAdapterInfo(const string& id, const Current&) const void AdminI::removeAdapter(const string& adapterId, const Ice::Current&) { - checkIsMaster(); + checkIsReadOnly(); _database->removeAdapter(adapterId); } @@ -626,7 +626,7 @@ AdminI::getAllAdapterIds(const Current&) const void AdminI::addObject(const Ice::ObjectPrx& proxy, const ::Ice::Current& current) { - checkIsMaster(); + checkIsReadOnly(); if(!proxy) { @@ -650,7 +650,7 @@ AdminI::addObject(const Ice::ObjectPrx& proxy, const ::Ice::Current& current) void AdminI::updateObject(const Ice::ObjectPrx& proxy, const ::Ice::Current& current) { - checkIsMaster(); + checkIsReadOnly(); if(!proxy) { @@ -672,7 +672,7 @@ AdminI::updateObject(const Ice::ObjectPrx& proxy, const ::Ice::Current& current) void AdminI::addObjectWithType(const Ice::ObjectPrx& proxy, const string& type, const ::Ice::Current& current) { - checkIsMaster(); + checkIsReadOnly(); if(!proxy) { @@ -697,7 +697,7 @@ AdminI::addObjectWithType(const Ice::ObjectPrx& proxy, const string& type, const void AdminI::removeObject(const Ice::Identity& id, const Ice::Current& current) { - checkIsMaster(); + checkIsReadOnly(); if(id.category == _database->getInstanceName()) { DeploymentException ex; @@ -903,12 +903,12 @@ AdminI::getSliceChecksums(const Current&) const } void -AdminI::checkIsMaster() const +AdminI::checkIsReadOnly() const { - if(!_database->isMaster()) + if(_database->isReadOnly()) { DeploymentException ex; - ex.reason = "this operation is only allowed on the master registry."; + ex.reason = "this operation is only allowed on a slave or read-only master registry."; throw ex; } } diff --git a/cpp/src/IceGrid/AdminI.h b/cpp/src/IceGrid/AdminI.h index 314688a3479..b704e07d4f6 100644 --- a/cpp/src/IceGrid/AdminI.h +++ b/cpp/src/IceGrid/AdminI.h @@ -90,7 +90,7 @@ public: private: - void checkIsMaster() const; + void checkIsReadOnly() const; const DatabasePtr _database; const RegistryIPtr _registry; diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp index 3ac2f85eb3e..f6ec1d0f58c 100644 --- a/cpp/src/IceGrid/Database.cpp +++ b/cpp/src/IceGrid/Database.cpp @@ -48,7 +48,8 @@ Database::Database(const Ice::ObjectAdapterPtr& registryAdapter, const IceStorm::TopicManagerPrx& topicManager, const string& instanceName, const TraceLevelsPtr& traceLevels, - const RegistryInfo& info) : + const RegistryInfo& info, + bool readonly) : _communicator(registryAdapter->getCommunicator()), _internalAdapter(registryAdapter), _topicManager(topicManager), @@ -56,8 +57,9 @@ Database::Database(const Ice::ObjectAdapterPtr& registryAdapter, _instanceName(instanceName), _traceLevels(traceLevels), _master(info.name == "Master"), + _readonly(readonly || !_master), _replicaCache(_communicator, topicManager), - _nodeCache(_communicator, _replicaCache, info.name), + _nodeCache(_communicator, _replicaCache, _readonly && _master ? string("Master (read-only)") : info.name), _adapterCache(_communicator), _objectCache(_communicator), _allocatableObjectCache(_communicator), diff --git a/cpp/src/IceGrid/Database.h b/cpp/src/IceGrid/Database.h index 2f26a834fd0..dd49f5c4431 100644 --- a/cpp/src/IceGrid/Database.h +++ b/cpp/src/IceGrid/Database.h @@ -51,11 +51,11 @@ class Database : public IceUtil::Shared, public IceUtil::Monitor<IceUtil::Mutex> public: Database(const Ice::ObjectAdapterPtr&, const IceStorm::TopicManagerPrx&, const std::string&, const TraceLevelsPtr&, - const RegistryInfo&); + const RegistryInfo&, bool); virtual ~Database(); std::string getInstanceName() const; - bool isMaster() const { return _master; } + bool isReadOnly() const { return _readonly; } const TraceLevelsPtr& getTraceLevels() const { return _traceLevels; } const Ice::CommunicatorPtr& getCommunicator() const { return _communicator; } const Ice::ObjectAdapterPtr& getInternalAdapter() { return _internalAdapter; } @@ -158,6 +158,7 @@ private: const std::string _instanceName; const TraceLevelsPtr _traceLevels; const bool _master; + const bool _readonly; ReplicaCache _replicaCache; NodeCache _nodeCache; diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp index 90cba70148b..1cfef3fab8e 100644 --- a/cpp/src/IceGrid/IceGridNode.cpp +++ b/cpp/src/IceGrid/IceGridNode.cpp @@ -97,7 +97,7 @@ class CollocatedRegistry : public RegistryI { public: - CollocatedRegistry(const CommunicatorPtr&, const ActivatorPtr&, bool); + CollocatedRegistry(const CommunicatorPtr&, const ActivatorPtr&, bool, bool); virtual void shutdown(); private: @@ -135,8 +135,11 @@ private: } -CollocatedRegistry::CollocatedRegistry(const CommunicatorPtr& com, const ActivatorPtr& activator, bool nowarn) : - RegistryI(com, new TraceLevels(com, "IceGrid.Registry"), nowarn), +CollocatedRegistry::CollocatedRegistry(const CommunicatorPtr& com, + const ActivatorPtr& activator, + bool nowarn, + bool readonly) : + RegistryI(com, new TraceLevels(com, "IceGrid.Registry"), nowarn, readonly), _activator(activator) { } @@ -182,6 +185,7 @@ bool NodeService::start(int argc, char* argv[]) { bool nowarn = false; + bool readonly = false; string desc; vector<string> targets; for(int i = 1; i < argc; ++i) @@ -200,6 +204,10 @@ NodeService::start(int argc, char* argv[]) { nowarn = true; } + else if(strcmp(argv[i], "--readonly") == 0) + { + readonly = true; + } else if(strcmp(argv[i], "--deploy") == 0) { if(i + 1 >= argc) @@ -300,7 +308,7 @@ NodeService::start(int argc, char* argv[]) // if(properties->getPropertyAsInt("IceGrid.Node.CollocateRegistry") > 0) { - _registry = new CollocatedRegistry(communicator(), _activator, nowarn); + _registry = new CollocatedRegistry(communicator(), _activator, nowarn, readonly); if(!_registry->start()) { return false; @@ -770,6 +778,7 @@ NodeService::usage(const string& appName) "-h, --help Show this message.\n" "-v, --version Display the Ice version.\n" "--nowarn Don't print any security warnings.\n" + "--readonly Start the collocated master registry in read-only mode." "\n" "--deploy DESCRIPTOR [TARGET1 [TARGET2 ...]]\n" " Add or update descriptor in file DESCRIPTOR, with\n" diff --git a/cpp/src/IceGrid/IceGridRegistry.cpp b/cpp/src/IceGrid/IceGridRegistry.cpp index af8320582cf..c3a681e99bd 100644 --- a/cpp/src/IceGrid/IceGridRegistry.cpp +++ b/cpp/src/IceGrid/IceGridRegistry.cpp @@ -66,11 +66,13 @@ bool RegistryService::start(int argc, char* argv[]) { bool nowarn; + bool readonly; IceUtilInternal::Options opts; opts.addOpt("h", "help"); opts.addOpt("v", "version"); opts.addOpt("", "nowarn"); + opts.addOpt("", "readonly"); vector<string> args; try @@ -95,6 +97,7 @@ RegistryService::start(int argc, char* argv[]) return false; } nowarn = opts.isSet("nowarn"); + readonly = opts.isSet("readonly"); if(!args.empty()) { @@ -117,7 +120,7 @@ RegistryService::start(int argc, char* argv[]) TraceLevelsPtr traceLevels = new TraceLevels(communicator(), "IceGrid.Registry"); - _registry = new RegistryI(communicator(), traceLevels, nowarn); + _registry = new RegistryI(communicator(), traceLevels, nowarn, readonly); if(!_registry->start()) { return false; @@ -167,7 +170,8 @@ RegistryService::usage(const string& appName) "Options:\n" "-h, --help Show this message.\n" "-v, --version Display the Ice version.\n" - "--nowarn Don't print any security warnings."; + "--nowarn Don't print any security warnings." + "--readonly Start the master registry in read-only mode."; #ifndef _WIN32 options.append( "\n" diff --git a/cpp/src/IceGrid/NodeCache.cpp b/cpp/src/IceGrid/NodeCache.cpp index b950bef3913..40d38788a6d 100644 --- a/cpp/src/IceGrid/NodeCache.cpp +++ b/cpp/src/IceGrid/NodeCache.cpp @@ -87,10 +87,17 @@ struct ToInternalServerDescriptor : std::unary_function<CommunicatorDescriptorPt { props.push_back(createProperty(q->name + ".ReplicaGroupId", q->replicaGroupId)); } - if(q->registerProcess) + + // + // Ignore the register process attribute if the server is using Ice > 3.3.0 + // + if(_iceVersion != 0 && _iceVersion < 30300) { - props.push_back(createProperty(q->name + ".RegisterProcess", "1")); - _desc->processRegistered = true; + if(q->registerProcess) + { + props.push_back(createProperty(q->name + ".RegisterProcess", "1")); + _desc->processRegistered = true; + } } } diff --git a/cpp/src/IceGrid/NodeSessionI.cpp b/cpp/src/IceGrid/NodeSessionI.cpp index d12267b4725..34cae9c8084 100644 --- a/cpp/src/IceGrid/NodeSessionI.cpp +++ b/cpp/src/IceGrid/NodeSessionI.cpp @@ -244,8 +244,15 @@ NodeSessionI::loadServers_async(const AMD_NodeSession_loadServersPtr& amdCB, con // // Get the server proxies to load them on the node. // - ServerEntrySeq servers = _database->getNode(_info->name)->getServers(); - for_each(servers.begin(), servers.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait)); + try + { + ServerEntrySeq servers = _database->getNode(_info->name)->getServers(); + for_each(servers.begin(), servers.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait)); + } + catch(const DeploymentException&) + { + // Ignore. + } } Ice::StringSeq diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp index bd0d94b508e..529afa59c16 100644 --- a/cpp/src/IceGrid/RegistryI.cpp +++ b/cpp/src/IceGrid/RegistryI.cpp @@ -148,10 +148,14 @@ private: } -RegistryI::RegistryI(const CommunicatorPtr& communicator, const TraceLevelsPtr& traceLevels, bool nowarn) : +RegistryI::RegistryI(const CommunicatorPtr& communicator, + const TraceLevelsPtr& traceLevels, + bool nowarn, + bool readonly) : _communicator(communicator), _traceLevels(traceLevels), _nowarn(nowarn), + _readonly(readonly), _platform("IceGrid.Registry", communicator, traceLevels) { } @@ -337,7 +341,7 @@ RegistryI::start() // // Create the registry database. // - _database = new Database(registryAdapter, topicManager, _instanceName, _traceLevels, getInfo()); + _database = new Database(registryAdapter, topicManager, _instanceName, _traceLevels, getInfo(), _readonly); _wellKnownObjects = new WellKnownObjectsManager(_database); // diff --git a/cpp/src/IceGrid/RegistryI.h b/cpp/src/IceGrid/RegistryI.h index 060dd405103..9b81da5fe8e 100644 --- a/cpp/src/IceGrid/RegistryI.h +++ b/cpp/src/IceGrid/RegistryI.h @@ -48,7 +48,7 @@ class RegistryI : public Registry { public: - RegistryI(const Ice::CommunicatorPtr&, const TraceLevelsPtr&, bool); + RegistryI(const Ice::CommunicatorPtr&, const TraceLevelsPtr&, bool, bool); ~RegistryI(); bool start(); @@ -99,6 +99,7 @@ private: const Ice::CommunicatorPtr _communicator; const TraceLevelsPtr _traceLevels; const bool _nowarn; + const bool _readonly; DatabasePtr _database; Ice::ObjectAdapterPtr _clientAdapter; diff --git a/cpp/src/IceGrid/ReplicaSessionI.cpp b/cpp/src/IceGrid/ReplicaSessionI.cpp index 8e51f9561a4..c14855168ad 100644 --- a/cpp/src/IceGrid/ReplicaSessionI.cpp +++ b/cpp/src/IceGrid/ReplicaSessionI.cpp @@ -97,6 +97,15 @@ ReplicaSessionI::getTimeout(const Ice::Current& current) const void ReplicaSessionI::setDatabaseObserver(const DatabaseObserverPrx& observer, const Ice::Current& current) { + // + // If it's a read only master, we don't setup the observer to not + // modify the replica database. + // + if(_database->isReadOnly()) + { + return; + } + int serialApplicationObserver; int serialAdapterObserver; int serialObjectObserver; diff --git a/cpp/src/IceGrid/ReplicaSessionManager.cpp b/cpp/src/IceGrid/ReplicaSessionManager.cpp index 0f0f99ac942..665a8a4f08e 100644 --- a/cpp/src/IceGrid/ReplicaSessionManager.cpp +++ b/cpp/src/IceGrid/ReplicaSessionManager.cpp @@ -254,7 +254,6 @@ private: const ReplicaSessionPrx _session; }; - }; ReplicaSessionManager::ReplicaSessionManager() @@ -540,7 +539,7 @@ ReplicaSessionManager::createSessionImpl(const InternalRegistryPrx& registry, Ic // returns once the observer is subscribed and initialized. // DatabaseObserverPtr servant = new MasterDatabaseObserverI(_thread, _database, session); - _observer = DatabaseObserverPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(servant)); + _observer = DatabaseObserverPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(servant)); session->setDatabaseObserver(_observer); return session; } |