From 17203692ae4b4e9ae003bfb6613440e40c6ddd4d Mon Sep 17 00:00:00 2001 From: Joe George Date: Tue, 12 Nov 2024 14:36:33 -0500 Subject: [PATCH] Use `getIceProperty` where possible in IceGrid (#3136) --- cpp/src/IceGrid/AdminI.cpp | 2 +- cpp/src/IceGrid/Database.cpp | 6 ++-- cpp/src/IceGrid/IceGridNode.cpp | 40 +++++++++++++-------------- cpp/src/IceGrid/IceGridRegistry.cpp | 6 ++-- cpp/src/IceGrid/InternalRegistryI.cpp | 4 +-- cpp/src/IceGrid/NodeI.cpp | 4 +-- cpp/src/IceGrid/RegistryI.cpp | 34 +++++++++++------------ cpp/src/IceGrid/ReplicaSessionI.cpp | 2 +- cpp/src/IceGrid/ServerI.cpp | 8 +++--- cpp/src/IceGrid/SessionI.cpp | 2 +- 10 files changed, 53 insertions(+), 55 deletions(-) diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp index d2ebd0a609a..ba63c064098 100644 --- a/cpp/src/IceGrid/AdminI.cpp +++ b/cpp/src/IceGrid/AdminI.cpp @@ -232,7 +232,7 @@ ApplicationDescriptor AdminI::getDefaultApplicationDescriptor(const Current& current) const { auto properties = current.adapter->getCommunicator()->getProperties(); - string path = properties->getProperty("IceGrid.Registry.DefaultTemplates"); + string path = properties->getIceProperty("IceGrid.Registry.DefaultTemplates"); if (path.empty()) { throw DeploymentException("no default templates configured, you need to set " diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp index d582a86da76..00034d9de89 100644 --- a/cpp/src/IceGrid/Database.cpp +++ b/cpp/src/IceGrid/Database.cpp @@ -211,11 +211,11 @@ Database::Database( _objectCache(_communicator), _allocatableObjectCache(_communicator), _serverCache(_communicator, _instanceName, _nodeCache, _adapterCache, _objectCache, _allocatableObjectCache), - _dbLock(_communicator->getProperties()->getProperty("IceGrid.Registry.LMDB.Path") + "/icedb.lock"), + _dbLock(_communicator->getProperties()->getIceProperty("IceGrid.Registry.LMDB.Path") + "/icedb.lock"), _env( - _communicator->getProperties()->getProperty("IceGrid.Registry.LMDB.Path"), + _communicator->getProperties()->getIceProperty("IceGrid.Registry.LMDB.Path"), 8, - IceDB::getMapSize(_communicator->getProperties()->getPropertyAsInt("IceGrid.Registry.LMDB.MapSize"))), + IceDB::getMapSize(_communicator->getProperties()->getIcePropertyAsInt("IceGrid.Registry.LMDB.MapSize"))), _pluginFacade(dynamic_pointer_cast(getRegistryPluginFacade())), _lock(nullptr) { diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp index 0bc32c270eb..72a55498cd6 100644 --- a/cpp/src/IceGrid/IceGridNode.cpp +++ b/cpp/src/IceGrid/IceGridNode.cpp @@ -243,7 +243,7 @@ NodeService::startImpl(int argc, char* argv[], int& status) auto properties = communicator()->getProperties(); - string name = properties->getProperty("IceGrid.Node.Name"); + string name = properties->getIceProperty("IceGrid.Node.Name"); if (name.empty()) { error("property `IceGrid.Node.Name' is not set"); @@ -282,7 +282,7 @@ NodeService::startImpl(int argc, char* argv[], int& status) // // Collocate the IceGrid registry if we need to. // - if (properties->getPropertyAsInt("IceGrid.Node.CollocateRegistry") > 0) + if (properties->getIcePropertyAsInt("IceGrid.Node.CollocateRegistry") > 0) { _registry = make_shared(communicator(), _activator, nowarn, readonly, initFromReplica, name); @@ -299,7 +299,7 @@ NodeService::startImpl(int argc, char* argv[], int& status) // activated server). The default locator is also needed by // the node session manager. // - if (properties->getProperty("Ice.Default.Locator").empty()) + if (properties->getIceProperty("Ice.Default.Locator").empty()) { properties->setProperty("Ice.Default.Locator", communicator()->getDefaultLocator()->ice_toString()); } @@ -313,7 +313,7 @@ NodeService::startImpl(int argc, char* argv[], int& status) // // Initialize the database environment (first setup the directory structure if needed). // - string dataPath = properties->getProperty("IceGrid.Node.Data"); + string dataPath = properties->getIceProperty("IceGrid.Node.Data"); if (dataPath.empty()) { error("property `IceGrid.Node.Data' is not set"); @@ -366,7 +366,7 @@ NodeService::startImpl(int argc, char* argv[], int& status) // // Check that required properties are set and valid. // - if (properties->getProperty("IceGrid.Node.Endpoints").empty()) + if (properties->getIceProperty("IceGrid.Node.Endpoints").empty()) { error("property `IceGrid.Node.Endpoints' is not set"); return false; @@ -381,7 +381,7 @@ NodeService::startImpl(int argc, char* argv[], int& status) // Setup the user account mapper if configured. // string mapperProperty = "IceGrid.Node.UserAccountMapper"; - string mapperPropertyValue = properties->getProperty(mapperProperty); + string mapperPropertyValue = properties->getIceProperty(mapperProperty); optional mapper; if (!mapperPropertyValue.empty()) { @@ -398,7 +398,7 @@ NodeService::startImpl(int argc, char* argv[], int& status) } else { - string userAccountFileProperty = properties->getProperty("IceGrid.Node.UserAccounts"); + string userAccountFileProperty = properties->getIceProperty("IceGrid.Node.UserAccounts"); if (!userAccountFileProperty.empty()) { try @@ -419,9 +419,7 @@ NodeService::startImpl(int argc, char* argv[], int& status) // _timer = make_shared(); - // - // The IceGrid instance name. - // + // The IceGrid instance name. We can't use getIceProperty as we don't want to get any default values. string instanceName = properties->getProperty("IceGrid.InstanceName"); if (instanceName.empty()) { @@ -483,7 +481,7 @@ NodeService::startImpl(int argc, char* argv[], int& status) // // Create Admin unless there is a collocated registry with its own Admin // - if (!_registry && properties->getPropertyAsInt("Ice.Admin.Enabled") > 0) + if (!_registry && properties->getIcePropertyAsInt("Ice.Admin.Enabled") > 0) { // Replace Admin facet auto origProcess = dynamic_pointer_cast(communicator()->removeAdminFacet("Process")); @@ -507,7 +505,7 @@ NodeService::startImpl(int argc, char* argv[], int& status) // _sessions->activate(); - string bundleName = properties->getProperty("IceGrid.Node.PrintServersReady"); + string bundleName = properties->getIceProperty("IceGrid.Node.PrintServersReady"); if (!bundleName.empty() || !desc.empty()) { enableInterrupt(); @@ -540,14 +538,14 @@ NodeService::startImpl(int argc, char* argv[], int& status) registry = registry->ice_preferSecure(true); // Use SSL if available. optional session; - if (communicator()->getProperties()->getPropertyAsInt("IceGridAdmin.AuthenticateUsingSSL")) + if (communicator()->getProperties()->getIcePropertyAsInt("IceGridAdmin.AuthenticateUsingSSL")) { session = registry->createAdminSessionFromSecureConnection(); } else { - string username = communicator()->getProperties()->getProperty("IceGridAdmin.Username"); - string password = communicator()->getProperties()->getProperty("IceGridAdmin.Password"); + string username = communicator()->getProperties()->getIceProperty("IceGridAdmin.Username"); + string password = communicator()->getProperties()->getIceProperty("IceGridAdmin.Password"); while (username.empty()) { consoleOut << "user id: " << flush; @@ -737,9 +735,9 @@ NodeService::initializeCommunicator(int& argc, char* argv[], const Initializatio { string verifier = "IceGrid.Registry." + type + "PermissionsVerifier"; - if (initData.properties->getProperty(verifier).empty()) + if (initData.properties->getIceProperty(verifier).empty()) { - string cryptPasswords = initData.properties->getProperty("IceGrid.Registry." + type + "CryptPasswords"); + string cryptPasswords = initData.properties->getIceProperty("IceGrid.Registry." + type + "CryptPasswords"); if (!cryptPasswords.empty()) { @@ -760,9 +758,9 @@ NodeService::initializeCommunicator(int& argc, char* argv[], const Initializatio initData.properties->setProperty("Ice.Admin.Endpoints", ""); // - // Enable Admin unless explicitely disabled (or enabled) in configuration + // Enable Admin unless explicitly disabled (or enabled) in configuration // - if (initData.properties->getProperty("Ice.Admin.Enabled").empty()) + if (initData.properties->getIceProperty("Ice.Admin.Enabled").empty()) { initData.properties->setProperty("Ice.Admin.Enabled", "1"); } @@ -813,8 +811,8 @@ main(int argc, char* argv[]) #endif { NodeService svc; - // Initialize the service with a Properties object with the correct property prefix enabled. + // Initialize the service with a Properties object with the correct property prefixes enabled. Ice::InitializationData initData; - initData.properties = make_shared(vector{"IceGrid"}); + initData.properties = make_shared(vector{"IceGrid", "IceGridAdmin"}); return svc.main(argc, argv, initData); } diff --git a/cpp/src/IceGrid/IceGridRegistry.cpp b/cpp/src/IceGrid/IceGridRegistry.cpp index 57a12fd61e5..f8a8ddd3eda 100644 --- a/cpp/src/IceGrid/IceGridRegistry.cpp +++ b/cpp/src/IceGrid/IceGridRegistry.cpp @@ -157,7 +157,7 @@ RegistryService::initializeCommunicator(int& argc, char* argv[], const Initializ if (initData.properties->getProperty(verifier).empty()) { - string cryptPasswords = initData.properties->getProperty("IceGrid.Registry." + *p + "CryptPasswords"); + string cryptPasswords = initData.properties->getIceProperty("IceGrid.Registry." + *p + "CryptPasswords"); if (!cryptPasswords.empty()) { @@ -180,7 +180,7 @@ RegistryService::initializeCommunicator(int& argc, char* argv[], const Initializ // // Enable Admin unless explicitly disabled (or enabled) in configuration // - if (initData.properties->getProperty("Ice.Admin.Enabled").empty()) + if (initData.properties->getIceProperty("Ice.Admin.Enabled").empty()) { initData.properties->setProperty("Ice.Admin.Enabled", "1"); } @@ -188,7 +188,7 @@ RegistryService::initializeCommunicator(int& argc, char* argv[], const Initializ // Turn-off the inactivity timeout for the IceGrid.Registry.Client object adapter unless the application sets this // property. That's because the IceGrid.Registry.Client object adapter hosts connection-bound sessions // (admin sessions and resource allocation sessions). - if (initData.properties->getProperty("IceGrid.Registry.Client.Connection.InactivityTimeout").empty()) + if (initData.properties->getIceProperty("IceGrid.Registry.Client.Connection.InactivityTimeout").empty()) { initData.properties->setProperty("IceGrid.Registry.Client.Connection.InactivityTimeout", "0"); } diff --git a/cpp/src/IceGrid/InternalRegistryI.cpp b/cpp/src/IceGrid/InternalRegistryI.cpp index c7768f81001..267703e8a25 100644 --- a/cpp/src/IceGrid/InternalRegistryI.cpp +++ b/cpp/src/IceGrid/InternalRegistryI.cpp @@ -202,7 +202,7 @@ InternalRegistryI::getFilePath(const string& filename) const string file; if (filename == "stderr") { - file = _database->getCommunicator()->getProperties()->getProperty("Ice.StdErr"); + file = _database->getCommunicator()->getProperties()->getIceProperty("Ice.StdErr"); if (file.empty()) { throw FileNotAvailableException("Ice.StdErr configuration property is not set"); @@ -210,7 +210,7 @@ InternalRegistryI::getFilePath(const string& filename) const } else if (filename == "stdout") { - file = _database->getCommunicator()->getProperties()->getProperty("Ice.StdOut"); + file = _database->getCommunicator()->getProperties()->getIceProperty("Ice.StdOut"); if (file.empty()) { throw FileNotAvailableException("Ice.StdOut configuration property is not set"); diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp index 800c2609703..50d87a12522 100644 --- a/cpp/src/IceGrid/NodeI.cpp +++ b/cpp/src/IceGrid/NodeI.cpp @@ -780,7 +780,7 @@ NodeI::getFilePath(const string& filename) const string file; if (filename == "stderr") { - file = _communicator->getProperties()->getProperty("Ice.StdErr"); + file = _communicator->getProperties()->getIceProperty("Ice.StdErr"); if (file.empty()) { throw FileNotAvailableException("Ice.StdErr configuration property is not set"); @@ -788,7 +788,7 @@ NodeI::getFilePath(const string& filename) const } else if (filename == "stdout") { - file = _communicator->getProperties()->getProperty("Ice.StdOut"); + file = _communicator->getProperties()->getIceProperty("Ice.StdOut"); if (file.empty()) { throw FileNotAvailableException("Ice.StdOut configuration property is not set"); diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp index 05849b27ee6..5009a87c6b0 100644 --- a/cpp/src/IceGrid/RegistryI.cpp +++ b/cpp/src/IceGrid/RegistryI.cpp @@ -182,47 +182,47 @@ RegistryI::startImpl() // // Check that required properties are set and valid. // - if (properties->getProperty("IceGrid.Registry.Client.Endpoints").empty()) + if (properties->getIceProperty("IceGrid.Registry.Client.Endpoints").empty()) { Error out(_communicator->getLogger()); out << "property `IceGrid.Registry.Client.Endpoints' is not set"; return false; } - if (properties->getProperty("IceGrid.Registry.Server.Endpoints").empty()) + if (properties->getIceProperty("IceGrid.Registry.Server.Endpoints").empty()) { Error out(_communicator->getLogger()); out << "property `IceGrid.Registry.Server.Endpoints' is not set"; return false; } - if (properties->getProperty("IceGrid.Registry.Internal.Endpoints").empty()) + if (properties->getIceProperty("IceGrid.Registry.Internal.Endpoints").empty()) { Error out(_communicator->getLogger()); out << "property `IceGrid.Registry.Internal.Endpoints' is not set"; return false; } - if (!properties->getProperty("IceGrid.Registry.SessionManager.Endpoints").empty()) + if (!properties->getIceProperty("IceGrid.Registry.SessionManager.Endpoints").empty()) { if (!_nowarn) { Warning out(_communicator->getLogger()); out << "session manager endpoints `IceGrid.Registry.SessionManager.Endpoints' enabled"; - if (properties->getPropertyAsInt("IceGrid.Registry.SessionFilters") <= 0) + if (properties->getIcePropertyAsInt("IceGrid.Registry.SessionFilters") <= 0) { out << " (with Glacier2 filters disabled)"; } } } - if (!properties->getProperty("IceGrid.Registry.AdminSessionManager.Endpoints").empty()) + if (!properties->getIceProperty("IceGrid.Registry.AdminSessionManager.Endpoints").empty()) { if (!_nowarn) { Warning out(_communicator->getLogger()); out << "administrative session manager endpoints `IceGrid.Registry.AdminSessionManager.Endpoints' enabled"; - if (properties->getPropertyAsInt("IceGrid.Registry.AdminSessionFilters") <= 0) + if (properties->getIcePropertyAsInt("IceGrid.Registry.AdminSessionFilters") <= 0) { out << " (with Glacier2 filters disabled)"; } @@ -241,7 +241,7 @@ RegistryI::startImpl() properties->setProperty("IceGrid.Registry.AdminSessionManager.AdapterId", ""); properties->setProperty("IceGrid.Registry.Internal.AdapterId", ""); - if (properties->getProperty("IceGrid.Registry.Internal.MessageSizeMax").empty()) + if (properties->getIceProperty("IceGrid.Registry.Internal.MessageSizeMax").empty()) { properties->setProperty("IceGrid.Registry.Internal.MessageSizeMax", "0"); // No limit on internal data exchanged } @@ -298,7 +298,7 @@ RegistryI::startImpl() // // Create the registry database. // - string dbPath = _communicator->getProperties()->getProperty("IceGrid.Registry.LMDB.Path"); + string dbPath = _communicator->getProperties()->getIceProperty("IceGrid.Registry.LMDB.Path"); if (dbPath.empty()) { Ice::Error out(_communicator->getLogger()); @@ -323,7 +323,7 @@ RegistryI::startImpl() // try { - string endpoints = properties->getProperty("IceGrid.Registry.Client.Endpoints"); + string endpoints = properties->getIceProperty("IceGrid.Registry.Client.Endpoints"); string strPrx = _instanceName + "/Locator:" + endpoints; _communicator->stringToProxy(strPrx)->ice_invocationTimeout(5s)->ice_ping(); @@ -494,7 +494,7 @@ RegistryI::startImpl() // // Setup file user account mapper object if the property is set. // - string userAccountFileProperty = properties->getProperty("IceGrid.Registry.UserAccounts"); + string userAccountFileProperty = properties->getIceProperty("IceGrid.Registry.UserAccounts"); if (!userAccountFileProperty.empty()) { try @@ -598,7 +598,7 @@ RegistryI::startImpl() } int port = properties->getIcePropertyAsInt("IceGrid.Registry.Discovery.Port"); string interface = properties->getIceProperty("IceGrid.Registry.Discovery.Interface"); - if (properties->getProperty("IceGrid.Registry.Discovery.Endpoints").empty()) + if (properties->getIceProperty("IceGrid.Registry.Discovery.Endpoints").empty()) { ostringstream os; os << "udp -h \"" << address << "\" -p " << port; @@ -621,7 +621,7 @@ RegistryI::startImpl() { Warning out(_communicator->getLogger()); out << "failed to join the multicast group for IceGrid discovery:\n"; - out << "endpoints = " << properties->getProperty("IceGrid.Registry.Discovery.Endpoints") << "\n"; + out << "endpoints = " << properties->getIceProperty("IceGrid.Registry.Discovery.Endpoints") << "\n"; out << ex; } } @@ -652,7 +652,7 @@ RegistryI::startImpl() void RegistryI::setupLocatorRegistry() { - const bool dynReg = _communicator->getProperties()->getPropertyAsInt("IceGrid.Registry.DynamicRegistration") > 0; + const bool dynReg = _communicator->getProperties()->getIcePropertyAsInt("IceGrid.Registry.DynamicRegistration") > 0; Identity locatorRegId = {"LocatorRegistry", _instanceName}; _serverAdapter->add(make_shared(_database, dynReg, _master, *_session), locatorRegId); } @@ -703,7 +703,7 @@ RegistryI::setupInternalRegistry() // // Create Admin // - if (_communicator->getProperties()->getPropertyAsInt("Ice.Admin.Enabled") > 0) + if (_communicator->getProperties()->getIcePropertyAsInt("Ice.Admin.Enabled") > 0) { // Replace Admin facet auto origProcess = dynamic_pointer_cast(_communicator->removeAdminFacet("Process")); @@ -722,7 +722,7 @@ RegistryI::setupClientSessionFactory(const IceGrid::LocatorPrx& locator) ObjectAdapterPtr adapter; shared_ptr servantManager; - if (!properties->getProperty("IceGrid.Registry.SessionManager.Endpoints").empty()) + if (!properties->getIceProperty("IceGrid.Registry.SessionManager.Endpoints").empty()) { adapter = _communicator->createObjectAdapter("IceGrid.Registry.SessionManager"); servantManager = make_shared< @@ -770,7 +770,7 @@ RegistryI::setupAdminSessionFactory( ObjectAdapterPtr adapter; shared_ptr servantManager; - if (!properties->getProperty("IceGrid.Registry.AdminSessionManager.Endpoints").empty()) + if (!properties->getIceProperty("IceGrid.Registry.AdminSessionManager.Endpoints").empty()) { adapter = _communicator->createObjectAdapter("IceGrid.Registry.AdminSessionManager"); servantManager = make_shared( diff --git a/cpp/src/IceGrid/ReplicaSessionI.cpp b/cpp/src/IceGrid/ReplicaSessionI.cpp index 9d0c647e87b..4e18f41475d 100644 --- a/cpp/src/IceGrid/ReplicaSessionI.cpp +++ b/cpp/src/IceGrid/ReplicaSessionI.cpp @@ -226,7 +226,7 @@ ReplicaSessionI::setAdapterDirectProxy( optional proxy, const Ice::Current&) { - if (_database->getCommunicator()->getProperties()->getPropertyAsInt("IceGrid.Registry.DynamicRegistration") <= 0) + if (_database->getCommunicator()->getProperties()->getIcePropertyAsInt("IceGrid.Registry.DynamicRegistration") <= 0) { throw AdapterNotExistException(); } diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index 3d146c4b50f..c4276c4369e 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -2403,8 +2403,8 @@ ServerI::checkAndUpdateUser(const shared_ptr& desc, bo throw runtime_error("node has insufficient privileges to load server under user account `" + user + "'"); } - if (pw->pw_uid == 0 && - _node->getCommunicator()->getProperties()->getPropertyAsInt("IceGrid.Node.AllowRunningServersAsRoot") <= 0) + if (pw->pw_uid == 0 && _node->getCommunicator()->getProperties()->getIcePropertyAsInt( + "IceGrid.Node.AllowRunningServersAsRoot") <= 0) { throw runtime_error("running server as `root' is not allowed"); } @@ -2960,13 +2960,13 @@ ServerI::getProperties(const shared_ptr& desc) { auto properties = _node->getCommunicator()->getProperties(); - string locator = properties->getProperty("Ice.Default.Locator"); + string locator = properties->getIceProperty("Ice.Default.Locator"); if (!locator.empty()) { p->second.push_back(createProperty("Ice.Default.Locator", locator)); } - string discoveryPlugin = properties->getProperty("Ice.Plugin.IceLocatorDiscovery"); + string discoveryPlugin = properties->getIceProperty("Ice.Plugin.IceLocatorDiscovery"); if (!discoveryPlugin.empty()) { p->second.push_back(createProperty("Ice.Plugin.IceLocatorDiscovery", discoveryPlugin)); diff --git a/cpp/src/IceGrid/SessionI.cpp b/cpp/src/IceGrid/SessionI.cpp index dd64df81f98..a4fbd00aef3 100644 --- a/cpp/src/IceGrid/SessionI.cpp +++ b/cpp/src/IceGrid/SessionI.cpp @@ -271,7 +271,7 @@ ClientSessionFactory::ClientSessionFactory( if (_servantManager) // Not set if Glacier2 session manager adapter not enabled { auto properties = _database->getCommunicator()->getProperties(); - const_cast(_filters) = properties->getPropertyAsInt("IceGrid.Registry.SessionFilters") > 0; + const_cast(_filters) = properties->getIcePropertyAsInt("IceGrid.Registry.SessionFilters") > 0; } }