diff options
Diffstat (limited to 'cpp/src/IceGrid/Database.cpp')
-rw-r--r-- | cpp/src/IceGrid/Database.cpp | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp index 0d8fb7888dd..7604f5cd353 100644 --- a/cpp/src/IceGrid/Database.cpp +++ b/cpp/src/IceGrid/Database.cpp @@ -76,15 +76,15 @@ Database::Database(const Ice::ObjectAdapterPtr& registryAdapter, _objectCache(_communicator), _allocatableObjectCache(_communicator), _serverCache(_communicator, _instanceName, _nodeCache, _adapterCache, _objectCache, _allocatableObjectCache), - _databaseCache(plugin->getDatabaseCache()), + _connectionPool(plugin->getConnectionPool()), _databasePlugin(plugin), _lock(0), _applicationSerial(0) { ServerEntrySeq entries; - DatabaseConnectionPtr connection = _databaseCache->getConnection(); - ApplicationsWrapperPtr applicationsWrapper = _databaseCache->getApplications(connection); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); + ApplicationsWrapperPtr applicationsWrapper = _connectionPool->getApplications(connection); map<string, ApplicationInfo> applications = applicationsWrapper->getMap(); for(map<string, ApplicationInfo>::iterator p = applications.begin(); p != applications.end(); ++p) { @@ -110,10 +110,10 @@ Database::Database(const Ice::ObjectAdapterPtr& registryAdapter, _registryObserverTopic = new RegistryObserverTopic(_topicManager); _applicationObserverTopic = new ApplicationObserverTopic(_topicManager, applications); - AdaptersWrapperPtr adaptersWrapper = _databaseCache->getAdapters(connection); + AdaptersWrapperPtr adaptersWrapper = _connectionPool->getAdapters(connection); _adapterObserverTopic = new AdapterObserverTopic(_topicManager, adaptersWrapper->getMap()); - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); _objectObserverTopic = new ObjectObserverTopic(_topicManager, objectsWrapper->getMap()); _registryObserverTopic->registryUp(info); @@ -125,7 +125,7 @@ Database::~Database() // Release first the cache and then the plugin. This must be done in this order // to make sure the plugin is destroyed after the database cache. // - _databaseCache = 0; + _connectionPool = 0; _databasePlugin = 0; } @@ -215,11 +215,11 @@ Database::syncApplications(const ApplicationInfoSeq& newApplications) map<string, ApplicationInfo> oldApplications; for(;;) { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); try { TransactionHolder txHolder(connection); - ApplicationsWrapperPtr applicationsWrapper = _databaseCache->getApplications(connection); + ApplicationsWrapperPtr applicationsWrapper = _connectionPool->getApplications(connection); oldApplications = applicationsWrapper->getMap(); applicationsWrapper->clear(); for(ApplicationInfoSeq::const_iterator p = newApplications.begin(); p != newApplications.end(); ++p) @@ -288,11 +288,11 @@ Database::syncAdapters(const AdapterInfoSeq& adapters) Lock sync(*this); for(;;) { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); try { TransactionHolder txHolder(connection); - AdaptersWrapperPtr adaptersWrapper = _databaseCache->getAdapters(connection); + AdaptersWrapperPtr adaptersWrapper = _connectionPool->getAdapters(connection); adaptersWrapper->clear(); for(AdapterInfoSeq::const_iterator r = adapters.begin(); r != adapters.end(); ++r) { @@ -323,11 +323,11 @@ Database::syncObjects(const ObjectInfoSeq& objects) Lock sync(*this); for(;;) { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); try { TransactionHolder txHolder(connection); - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); objectsWrapper->clear(); for(ObjectInfoSeq::const_iterator q = objects.begin(); q != objects.end(); ++q) { @@ -361,10 +361,10 @@ Database::addApplication(const ApplicationInfo& info, AdminSessionI* session) waitForUpdate(info.descriptor.name); - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); try { - ApplicationsWrapperPtr applicationsWrapper = _databaseCache->getApplications(connection); + ApplicationsWrapperPtr applicationsWrapper = _connectionPool->getApplications(connection); applicationsWrapper->find(info.descriptor.name); throw DeploymentException("application `" + info.descriptor.name + "' already exists"); } @@ -407,7 +407,7 @@ Database::addApplication(const ApplicationInfo& info, AdminSessionI* session) Lock sync(*this); entries.clear(); unload(ApplicationHelper(_communicator, info.descriptor), entries); - removeApplication(info.descriptor.name, _databaseCache->getConnection()); + removeApplication(info.descriptor.name, _connectionPool->getConnection()); } catch(const DeploymentException& ex) { @@ -455,8 +455,8 @@ Database::updateApplication(const ApplicationUpdateInfo& updt, bool noRestart, A waitForUpdate(update.descriptor.name); - DatabaseConnectionPtr connection = _databaseCache->getConnection(); - ApplicationsWrapperPtr applicationsWrapper = _databaseCache->getApplications(connection); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); + ApplicationsWrapperPtr applicationsWrapper = _connectionPool->getApplications(connection); try { oldApp = applicationsWrapper->find(update.descriptor.name); @@ -498,8 +498,8 @@ Database::syncApplicationDescriptor(const ApplicationDescriptor& newDesc, bool n waitForUpdate(newDesc.name); - DatabaseConnectionPtr connection = _databaseCache->getConnection(); - ApplicationsWrapperPtr applicationsWrapper = _databaseCache->getApplications(connection); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); + ApplicationsWrapperPtr applicationsWrapper = _connectionPool->getApplications(connection); try { oldApp = applicationsWrapper->find(newDesc.name); @@ -545,8 +545,8 @@ Database::instantiateServer(const string& application, waitForUpdate(application); - DatabaseConnectionPtr connection = _databaseCache->getConnection(); - ApplicationsWrapperPtr applicationsWrapper = _databaseCache->getApplications(connection); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); + ApplicationsWrapperPtr applicationsWrapper = _connectionPool->getApplications(connection); try { oldApp = applicationsWrapper->find(application); @@ -587,11 +587,11 @@ Database::removeApplication(const string& name, AdminSessionI* session) waitForUpdate(name); - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); ApplicationInfo appInfo; try { - ApplicationsWrapperPtr applicationsWrapper = _databaseCache->getApplications(connection); + ApplicationsWrapperPtr applicationsWrapper = _connectionPool->getApplications(connection); appInfo = applicationsWrapper->find(name); } catch(const NotFoundException&) @@ -656,10 +656,10 @@ Database::removeApplication(const string& name, AdminSessionI* session) ApplicationInfo Database::getApplicationInfo(const std::string& name) { - DatabaseConnectionPtr connection = _databaseCache->newConnection(); + DatabaseConnectionPtr connection = _connectionPool->newConnection(); try { - ApplicationsWrapperPtr applicationsWrapper = _databaseCache->getApplications(connection); + ApplicationsWrapperPtr applicationsWrapper = _connectionPool->getApplications(connection); return applicationsWrapper->find(name); } catch(const NotFoundException&) @@ -671,8 +671,8 @@ Database::getApplicationInfo(const std::string& name) Ice::StringSeq Database::getAllApplications(const string& expression) { - DatabaseConnectionPtr connection = _databaseCache->newConnection(); - ApplicationsWrapperPtr applicationsWrapper = _databaseCache->getApplications(connection); + DatabaseConnectionPtr connection = _connectionPool->newConnection(); + ApplicationsWrapperPtr applicationsWrapper = _connectionPool->getApplications(connection); return getMatchingKeys<map<string, ApplicationInfo> >(applicationsWrapper->getMap(), expression); } @@ -763,9 +763,9 @@ Database::setAdapterDirectProxy(const string& adapterId, const string& replicaGr { try { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); TransactionHolder txHolder(connection); - AdaptersWrapperPtr adaptersWrapper = _databaseCache->getAdapters(connection); + AdaptersWrapperPtr adaptersWrapper = _connectionPool->getAdapters(connection); try { adaptersWrapper->find(adapterId); @@ -828,8 +828,8 @@ Database::setAdapterDirectProxy(const string& adapterId, const string& replicaGr Ice::ObjectPrx Database::getAdapterDirectProxy(const string& id) { - DatabaseConnectionPtr connection = _databaseCache->newConnection(); - AdaptersWrapperPtr adaptersWrapper = _databaseCache->getAdapters(connection); + DatabaseConnectionPtr connection = _connectionPool->newConnection(); + AdaptersWrapperPtr adaptersWrapper = _connectionPool->getAdapters(connection); try { return adaptersWrapper->find(id).proxy; @@ -873,9 +873,9 @@ Database::removeAdapter(const string& adapterId) { try { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); TransactionHolder txHolder(connection); - AdaptersWrapperPtr adaptersWrapper = _databaseCache->getAdapters(connection); + AdaptersWrapperPtr adaptersWrapper = _connectionPool->getAdapters(connection); try { adaptersWrapper->find(adapterId); @@ -976,8 +976,8 @@ Database::getAdapterInfo(const string& id) // Otherwise, we check the adapter endpoint table -- if there's an // entry the adapter is managed by the registry itself. // - DatabaseConnectionPtr connection = _databaseCache->newConnection(); - AdaptersWrapperPtr adaptersWrapper = _databaseCache->getAdapters(connection); + DatabaseConnectionPtr connection = _connectionPool->newConnection(); + AdaptersWrapperPtr adaptersWrapper = _connectionPool->getAdapters(connection); AdapterInfoSeq infos; try { @@ -1007,8 +1007,8 @@ Database::getAllAdapters(const string& expression) result.swap(ids); set<string> groups; - DatabaseConnectionPtr connection = _databaseCache->getConnection(); - AdaptersWrapperPtr adaptersWrapper = _databaseCache->getAdapters(connection); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); + AdaptersWrapperPtr adaptersWrapper = _connectionPool->getAdapters(connection); map<string, AdapterInfo> adapters = adaptersWrapper->getMap(); for(map<string, AdapterInfo>::const_iterator p = adapters.begin(); p != adapters.end(); ++p) { @@ -1050,9 +1050,9 @@ Database::addObject(const ObjectInfo& info) { try { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); TransactionHolder txHolder(connection); - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); try { objectsWrapper->find(id); @@ -1104,9 +1104,9 @@ Database::addOrUpdateObject(const ObjectInfo& info) { try { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); TransactionHolder txHolder(connection); - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); try { objectsWrapper->find(id); @@ -1167,9 +1167,9 @@ Database::removeObject(const Ice::Identity& id) { try { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); TransactionHolder txHolder(connection); - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); try { objectsWrapper->find(id); @@ -1229,9 +1229,9 @@ Database::updateObject(const Ice::ObjectPrx& proxy) { try { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); TransactionHolder txHolder(connection); - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); try { info = objectsWrapper->find(id); @@ -1278,9 +1278,9 @@ Database::addOrUpdateObjectsInDatabase(const ObjectInfoSeq& objects) { try { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); TransactionHolder txHolder(connection); - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p) { objectsWrapper->put(p->proxy->ice_getIdentity(), *p); @@ -1310,9 +1310,9 @@ Database::removeObjectsInDatabase(const ObjectInfoSeq& objects) { try { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); TransactionHolder txHolder(connection); - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p) { objectsWrapper->erase(p->proxy->ice_getIdentity()); @@ -1346,10 +1346,10 @@ Database::getObjectProxy(const Ice::Identity& id) { } - DatabaseConnectionPtr connection = _databaseCache->newConnection(); + DatabaseConnectionPtr connection = _connectionPool->newConnection(); try { - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); return objectsWrapper->find(id).proxy; } catch(const NotFoundException&) @@ -1408,8 +1408,8 @@ Database::getObjectsByType(const string& type) { Ice::ObjectProxySeq proxies = _objectCache.getObjectsByType(type); - DatabaseConnectionPtr connection = _databaseCache->newConnection(); - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + DatabaseConnectionPtr connection = _connectionPool->newConnection(); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); vector<ObjectInfo> infos = objectsWrapper->findByType(type); for(unsigned int i = 0; i < infos.size(); ++i) { @@ -1430,8 +1430,8 @@ Database::getObjectInfo(const Ice::Identity& id) { } - DatabaseConnectionPtr connection = _databaseCache->newConnection(); - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + DatabaseConnectionPtr connection = _connectionPool->newConnection(); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); try { return objectsWrapper->find(id); @@ -1447,8 +1447,8 @@ Database::getAllObjectInfos(const string& expression) { ObjectInfoSeq infos = _objectCache.getAll(expression); - DatabaseConnectionPtr connection = _databaseCache->newConnection(); - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + DatabaseConnectionPtr connection = _connectionPool->newConnection(); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); map<Ice::Identity, ObjectInfo> objects = objectsWrapper->getMap(); for(map<Ice::Identity, ObjectInfo>::const_iterator p = objects.begin(); p != objects.end(); ++p) { @@ -1465,8 +1465,8 @@ Database::getObjectInfosByType(const string& type) { ObjectInfoSeq infos = _objectCache.getAllByType(type); - DatabaseConnectionPtr connection = _databaseCache->newConnection(); - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + DatabaseConnectionPtr connection = _connectionPool->newConnection(); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); ObjectInfoSeq dbInfos = objectsWrapper->findByType(type); for(unsigned int i = 0; i < dbInfos.size(); ++i) { @@ -1485,9 +1485,9 @@ Database::addInternalObject(const ObjectInfo& info, bool replace) { try { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); TransactionHolder txHolder(connection); - ObjectsWrapperPtr internalObjectsWrapper = _databaseCache->getInternalObjects(connection); + ObjectsWrapperPtr internalObjectsWrapper = _connectionPool->getInternalObjects(connection); if(!replace) { try @@ -1523,9 +1523,9 @@ Database::removeInternalObject(const Ice::Identity& id) { try { - DatabaseConnectionPtr connection = _databaseCache->getConnection(); + DatabaseConnectionPtr connection = _connectionPool->getConnection(); TransactionHolder txHolder(connection); - ObjectsWrapperPtr internalObjectsWrapper = _databaseCache->getInternalObjects(connection); + ObjectsWrapperPtr internalObjectsWrapper = _connectionPool->getInternalObjects(connection); try { internalObjectsWrapper->find(id); @@ -1556,8 +1556,8 @@ Database::getInternalObjectsByType(const string& type) { Ice::ObjectProxySeq proxies; - DatabaseConnectionPtr connection = _databaseCache->newConnection(); - ObjectsWrapperPtr internalObjectsWrapper = _databaseCache->getInternalObjects(connection); + DatabaseConnectionPtr connection = _connectionPool->newConnection(); + ObjectsWrapperPtr internalObjectsWrapper = _connectionPool->getInternalObjects(connection); vector<ObjectInfo> infos = internalObjectsWrapper->findByType(type); for(unsigned int i = 0; i < infos.size(); ++i) { @@ -1578,7 +1578,7 @@ Database::checkForAddition(const ApplicationHelper& app, const DatabaseConnectio for_each(serverIds.begin(), serverIds.end(), objFunc(*this, &Database::checkServerForAddition)); if(!adapterIds.empty()) { - AdaptersWrapperPtr adaptersWrapper = _databaseCache->getAdapters(connection); + AdaptersWrapperPtr adaptersWrapper = _connectionPool->getAdapters(connection); for(set<string>::const_iterator p = adapterIds.begin(); p != adapterIds.end(); ++p) { checkAdapterForAddition(*p, adaptersWrapper); @@ -1586,7 +1586,7 @@ Database::checkForAddition(const ApplicationHelper& app, const DatabaseConnectio } if(!objectIds.empty()) { - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); for(set<Ice::Identity>::const_iterator p = objectIds.begin(); p != objectIds.end(); ++p) { checkObjectForAddition(*p, objectsWrapper); @@ -1619,7 +1619,7 @@ Database::checkForUpdate(const ApplicationHelper& origApp, set_difference(newAdpts.begin(), newAdpts.end(), oldAdpts.begin(), oldAdpts.end(), back_inserter(addedAdpts)); if(!addedAdpts.empty()) { - AdaptersWrapperPtr adaptersWrapper = _databaseCache->getAdapters(connection); + AdaptersWrapperPtr adaptersWrapper = _connectionPool->getAdapters(connection); for(Ice::StringSeq::const_iterator p = addedAdpts.begin(); p != addedAdpts.end(); ++p) { checkAdapterForAddition(*p, adaptersWrapper); @@ -1630,7 +1630,7 @@ Database::checkForUpdate(const ApplicationHelper& origApp, set_difference(newObjs.begin(), newObjs.end(), oldObjs.begin(), oldObjs.end(), back_inserter(addedObjs)); if(!addedObjs.empty()) { - ObjectsWrapperPtr objectsWrapper = _databaseCache->getObjects(connection); + ObjectsWrapperPtr objectsWrapper = _connectionPool->getObjects(connection); for(vector<Ice::Identity>::const_iterator p = addedObjs.begin(); p != addedObjs.end(); ++p) { checkObjectForAddition(*p, objectsWrapper); @@ -1982,7 +1982,7 @@ Database::saveApplication(const ApplicationInfo& info, const DatabaseConnectionP { try { - ApplicationsWrapperPtr applicationsWrapper = _databaseCache->getApplications(connection); + ApplicationsWrapperPtr applicationsWrapper = _connectionPool->getApplications(connection); TransactionHolder txHolder(connection); applicationsWrapper->put(info.descriptor.name, info); txHolder.commit(); @@ -2006,7 +2006,7 @@ Database::removeApplication(const string& name, const DatabaseConnectionPtr& con { try { - ApplicationsWrapperPtr applicationsWrapper = _databaseCache->getApplications(connection); + ApplicationsWrapperPtr applicationsWrapper = _connectionPool->getApplications(connection); TransactionHolder txHolder(connection); applicationsWrapper->erase(name); txHolder.commit(); |