diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/config/Makefile | 2 | ||||
-rw-r--r-- | cpp/config/Makefile.mak | 2 | ||||
-rw-r--r-- | cpp/config/icegrid-slice.3.1.ice.gz | bin | 2943 -> 2943 bytes | |||
-rw-r--r-- | cpp/config/icegrid-slice.3.2.ice.gz | bin | 0 -> 3641 bytes | |||
-rw-r--r-- | cpp/config/icegrid-slice.3.3.ice.gz | bin | 0 -> 3758 bytes | |||
-rwxr-xr-x | cpp/config/upgradeicegrid.py | 218 | ||||
-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 |
18 files changed, 225 insertions, 108 deletions
diff --git a/cpp/config/Makefile b/cpp/config/Makefile index 0918e93a773..41311e5d13d 100644 --- a/cpp/config/Makefile +++ b/cpp/config/Makefile @@ -24,4 +24,6 @@ install:: $(call installdata,convertssl.py,$(prefix)/config) $(call installdata,upgradeicegrid.py,$(prefix)/config) $(call installdata,icegrid-slice.3.1.ice.gz,$(prefix)/config) + $(call installdata,icegrid-slice.3.2.ice.gz,$(prefix)/config) + $(call installdata,icegrid-slice.3.3.ice.gz,$(prefix)/config) diff --git a/cpp/config/Makefile.mak b/cpp/config/Makefile.mak index 5c3d3bc32e6..09ba5aac35a 100644 --- a/cpp/config/Makefile.mak +++ b/cpp/config/Makefile.mak @@ -24,3 +24,5 @@ install:: copy icegridnode.cfg $(prefix)\config copy glacier2router.cfg $(prefix)\config copy icegrid-slice.3.1.ice.gz $(prefix)\config + copy icegrid-slice.3.2.ice.gz $(prefix)\config + copy icegrid-slice.3.3.ice.gz $(prefix)\config diff --git a/cpp/config/icegrid-slice.3.1.ice.gz b/cpp/config/icegrid-slice.3.1.ice.gz Binary files differindex 4f25fa3786b..a2972541939 100644 --- a/cpp/config/icegrid-slice.3.1.ice.gz +++ b/cpp/config/icegrid-slice.3.1.ice.gz diff --git a/cpp/config/icegrid-slice.3.2.ice.gz b/cpp/config/icegrid-slice.3.2.ice.gz Binary files differnew file mode 100644 index 00000000000..6c297f650be --- /dev/null +++ b/cpp/config/icegrid-slice.3.2.ice.gz diff --git a/cpp/config/icegrid-slice.3.3.ice.gz b/cpp/config/icegrid-slice.3.3.ice.gz Binary files differnew file mode 100644 index 00000000000..390a34c0c78 --- /dev/null +++ b/cpp/config/icegrid-slice.3.3.ice.gz diff --git a/cpp/config/upgradeicegrid.py b/cpp/config/upgradeicegrid.py index d04ce809ddb..6f924227527 100755 --- a/cpp/config/upgradeicegrid.py +++ b/cpp/config/upgradeicegrid.py @@ -27,7 +27,7 @@ # the script to perform the database transformation. # -import sys, os, gzip, time +import sys, os, gzip, time, shutil, getopt olddbenv = None newdbenv = None @@ -42,6 +42,7 @@ def usage(): print print "Options:" print "-h Show this message." + sys.exit(2) def printOutputFromPipe(pipe): while 1: @@ -55,51 +56,150 @@ def error(message): print "error: " + message sys.exit(1) -def transformdb(db, desc): - global olddbenv, newdbenv, slicedir, bindir +def transformdb(olddbenv, newdbenv, db, desc, oldslice, newslice): + global bindir - oldslice = os.path.join(newdbenv, "icegrid-slice.3.1.ice") - oldslicefile = open(oldslice, "w+") - oldslicefile.write(gzip.GzipFile(os.path.join(os.path.dirname(sys.argv[0]), "icegrid-slice.3.1.ice.gz")).read()) + oldslicefile = open(os.path.join(newdbenv, oldslice), "w+") + oldslicefile.write(gzip.GzipFile(os.path.join(os.path.dirname(__file__), oldslice + ".gz")).read()) oldslicefile.close() + newslicefile = open(os.path.join(newdbenv, newslice), "w+") + newslicefile.write(gzip.GzipFile(os.path.join(os.path.dirname(__file__), newslice + ".gz")).read()) + newslicefile.close() + tmpdesc = os.path.join(newdbenv, "tmpdesc.xml") tmpfile = open(tmpdesc, "w+") tmpfile.write(desc) tmpfile.close() - transformdb = os.path.join(bindir, "transformdb") + \ - " -i --old " + oldslice + \ - " --include-new " + slicedir + " --new " + os.path.join(slicedir, "IceGrid", "Admin.ice") + transformdb = os.path.join(bindir, "transformdb") + " -i" + \ + " --old " + os.path.join(newdbenv, oldslice) + \ + " --new " + os.path.join(newdbenv, newslice) pipe = os.popen(transformdb + " -f " + tmpdesc + " " + olddbenv + " " + db + " " + newdbenv + " 2>&1" ) printOutputFromPipe(pipe) os.remove(tmpdesc) - os.remove(oldslice) + os.remove(os.path.join(newdbenv, oldslice)) + os.remove(os.path.join(newdbenv, newslice)) + if pipe.close(): + sys.exit(1) + +def upgrade31(olddbenv, newdbenv): + desc = \ + '<transformdb>' + \ + ' ' + \ + ' <database name="applications" ' + \ + ' key="string" ' + \ + ' value="::IceGrid::ApplicationDescriptor,::IceGrid::ApplicationInfo">' + \ + ' <record>' + \ + ' <set target="newvalue.revision" value="1"/>' + \ + ' <set target="newvalue.uuid" value="generateUUID()"/>' + \ + ' <set target="newvalue.createUser" value="\'IceGrid Registry (database upgrade)\'"/>' + \ + ' <set target="newvalue.updateUser" value="\'IceGrid Registry (database upgrade)\'"/>' + \ + ' <set target="newvalue.createTime" value="' + str(int(time.time() * 1000)) + '"/>' + \ + ' <set target="newvalue.updateTime" value="' + str(int(time.time() * 1000)) + '"/>' + \ + ' <set target="newvalue.descriptor" value="oldvalue"/>' + \ + ' </record>' + \ + ' </database>' + \ + ' <database name="objects" key="::Ice::Identity" value="::IceGrid::ObjectInfo"><record/></database>' + \ + ' <database name="adapters" key="string" value="::IceGrid::AdapterInfo"><record/></database>' + \ + '' + \ + ' <transform type="::IceGrid::AdapterDescriptor">' + \ + ' <set target="new.serverLifetime" value="old.waitForActivation"/>' + \ + ' </transform>' + \ + '' + \ + ' <transform type="::IceGrid::ReplicaGroupDescriptor">' + \ + ' <if test="old.loadBalancing == nil">' + \ + ' <set target="new.loadBalancing" type="::IceGrid::RandomLoadBalancingPolicy"/>' + \ + ' <set target="new.loadBalancing.nReplicas" value="\'0\'"/>' + \ + ' </if>' + \ + ' <if test="old.loadBalancing != nil and old.loadBalancing.nReplicas == \'0\'">' + \ + ' <set target="new.loadBalancing.nReplicas" value="\'1\'"/>' + \ + ' </if>' + \ + ' </transform>' + \ + ' ' + \ + '</transformdb>' + + transformdb(olddbenv, newdbenv, "objects", desc, "icegrid-slice.3.1.ice", "icegrid-slice.3.2.ice") + transformdb(olddbenv, newdbenv, "adapters", desc, "icegrid-slice.3.1.ice", "icegrid-slice.3.2.ice") + transformdb(olddbenv, newdbenv, "applications", desc, "icegrid-slice.3.1.ice", "icegrid-slice.3.2.ice") + +def upgrade32(olddbenv, newdbenv, iceServerVersion): + + databases = \ + '<database name="adapters" key="string" value="::IceGrid::AdapterInfo"><record/></database>' + \ + '<database name="applications" key="string" value="::IceGrid::ApplicationInfo"><record/></database>' + \ + '<database name="internal-objects" key="::Ice::Identity" value="::IceGrid::ObjectInfo">' + \ + '<record/></database>' + \ + '<database name="objects" key="::Ice::Identity" value="::IceGrid::ObjectInfo"><record/></database>' + + if not iceServerVersion.startswith("3.3"): + desc = \ + '<transformdb>' + \ + databases + \ + ' <transform type="::IceGrid::ServerDescriptor">' + \ + ' <set target="new.iceVersion" value="\'' + iceServerVersion + '\'"/>' + \ + ' </transform>' + \ + '</transformdb>' + else: + desc = \ + '<transformdb>' + \ + databases + \ + ' <transform type="::IceGrid::AdapterDescriptor">' + \ + ' <set target="new.registerProcess" value="false"/>' + \ + ' </transform>' + \ + ' <transform type="::IceGrid::ServerDescriptor">' + \ + ' <define name="adminEndpointProp" type="::IceGrid::PropertyDescriptor"/>' + \ + ' <set target="adminEndpointProp.name" value="\'Ice.Admin.Endpoints\'"/>' + \ + ' <set target="adminEndpointProp.value" value="\'tcp -h 127.0.0.1\'"/>' + \ + ' <add target="new.propertySet.properties" index="0" value="adminEndpointProp"/>' + \ + ' </transform>' + \ + '</transformdb>' + + transformdb(olddbenv, newdbenv, "objects", desc, "icegrid-slice.3.2.ice", "icegrid-slice.3.3.ice") + transformdb(olddbenv, newdbenv, "adapters", desc, "icegrid-slice.3.2.ice", "icegrid-slice.3.3.ice") + transformdb(olddbenv, newdbenv, "applications", desc, "icegrid-slice.3.2.ice", "icegrid-slice.3.3.ice") + if os.path.exists(os.path.join(olddbenv, "internal-objects")): + transformdb(olddbenv, newdbenv, "internal-objects", desc, "icegrid-slice.3.2.ice", "icegrid-slice.3.3.ice") + +def getIceGridEnvVersion(dbenv): + global bindir + + pipe = os.popen(os.path.join(bindir, "dumpdb") + " -c " + dbenv + " 2>&1") + ver = None + for line in pipe.readlines(): + if line.find("value type = ::IceGrid::ApplicationDescriptor") > 0: + ver = "3.1" + break + elif line.find("value type = ::IceGrid::ApplicationInfo") > 0: + ver = "3.2" + break + if pipe.close(): sys.exit(1) + return ver + # # Check arguments # -olddbenv = "" -newdbenv = "" -for x in sys.argv[1:]: - if x == "-h": - usage() - sys.exit(0) - elif x.startswith("-"): - print sys.argv[0] + ": unknown option `" + x + "'" - print - usage() - sys.exit(1) - elif olddbenv == "": - olddbenv = x - elif newdbenv == "": - newdbenv = x - else: + +try: + opts, args = getopt.getopt(sys.argv[1:], "hs:", ["help", "server-version="]) +except getopt.GetoptError: + usage() + +if not args or len(args) != 2: + print sys.argv[0] + ": missing database environment arguments" + usage() +olddbenv = args[0] +newdbenv = args[1] + +for o, a in opts: + if o in ("-h", "--help"): usage() - sys.exit(0) + if o in ("-s", "--server-version"): + serverVersion = a if not os.path.exists(olddbenv): error("database environment `" + olddbenv + "' doesn't exist") @@ -108,60 +208,30 @@ if not os.path.exists(newdbenv): error("database environment `" + newdbenv + "' doesn't exist") elif os.path.exists(os.path.join(newdbenv, "applications")) or \ os.path.exists(os.path.join(newdbenv, "adapters")) or \ + os.path.exists(os.path.join(newdbenv, "internal-objects")) or \ os.path.exists(os.path.join(newdbenv, "objects")): error("database environment `" + newdbenv + "' already has databases") -icedir = os.getenv("ICE_HOME") -if icedir == None: - icedir = os.path.join(os.path.dirname(sys.argv[0]), "..") - -for bindir in [os.path.join(icedir, "bin"), "/usr/bin"]: +for bindir in [os.path.join(os.path.dirname(__file__), "..", "bin"), "/usr/bin"]: bindir = os.path.normpath(bindir) if os.path.exists(os.path.join(bindir, "transformdb")): break else: error("can't locate the `transformdb' executable") -for slicedir in [os.path.join(icedir, "slice"), "/usr/share/slice"]: - slicedir = os.path.normpath(slicedir) - if os.path.exists(os.path.join(slicedir, "IceGrid", "Admin.ice")): - break +dbEnvVersion = getIceGridEnvVersion(olddbenv) +if dbEnvVersion == "3.1": + print "upgrading 3.1 database environment...", + sys.stdout.flush() + os.mkdir(os.path.join(newdbenv, "3.2")) + upgrade31(olddbenv, os.path.join(newdbenv, "3.2")) + upgrade32(os.path.join(newdbenv, "3.2"), newdbenv, "3.3") + shutil.rmtree(os.path.join(newdbenv, "3.2")) + print "ok" +elif dbEnvVersion == "3.2": + print "upgrading 3.2 database environment...", + sys.stdout.flush() + upgrade32(olddbenv, newdbenv, serverVersion) + print "ok" else: - error("can't locate the IceGrid slice files") - -desc = \ -'<transformdb>' + \ -' ' + \ -' <database name="applications" key="string" value="::IceGrid::ApplicationDescriptor,::IceGrid::ApplicationInfo">' + \ -' <record>' + \ -' <set target="newvalue.revision" value="1"/>' + \ -' <set target="newvalue.uuid" value="generateUUID()"/>' + \ -' <set target="newvalue.createUser" value="\'IceGrid Registry (database upgrade)\'"/>' + \ -' <set target="newvalue.updateUser" value="\'IceGrid Registry (database upgrade)\'"/>' + \ -' <set target="newvalue.createTime" value="' + str(int(time.time() * 1000)) + '"/>' + \ -' <set target="newvalue.updateTime" value="' + str(int(time.time() * 1000)) + '"/>' + \ -' <set target="newvalue.descriptor" value="oldvalue"/>' + \ -' </record>' + \ -' </database>' + \ -' <database name="objects" key="::Ice::Identity" value="::IceGrid::ObjectInfo"/>' + \ -' <database name="adapters" key="string" value="::IceGrid::AdapterInfo"/>' + \ -'' + \ -' <transform type="::IceGrid::AdapterDescriptor">' + \ -' <set target="new.serverLifetime" value="old.waitForActivation"/>' + \ -' </transform>' + \ -'' + \ -' <transform type="::IceGrid::ReplicaGroupDescriptor">' + \ -' <if test="old.loadBalancing == nil">' + \ -' <set target="new.loadBalancing" type="::IceGrid::RandomLoadBalancingPolicy"/>' + \ -' <set target="new.loadBalancing.nReplicas" value="\'0\'"/>' + \ -' </if>' + \ -' <if test="old.loadBalancing != nil and old.loadBalancing.nReplicas == \'0\'">' + \ -' <set target="new.loadBalancing.nReplicas" value="\'1\'"/>' + \ -' </if>' + \ -' </transform>' + \ -' ' + \ -'</transformdb>' - -transformdb("objects", desc) -transformdb("adapters", desc) -transformdb("applications", desc) + error("can't figure out the version of the IceGrid database environment " + olddbenv) 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; } |