X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fasyncstorageimpl.cpp;h=0d6d683ab5019acaf1fb105ce94fef31504e4738;hb=refs%2Fchanges%2F25%2F9925%2F1;hp=d9478c2a3766949fc5effd13fa8ba899cbcbd9bf;hpb=ece67088ea6c4f67b9d0db74477a9d5c614d7763;p=ric-plt%2Fsdl.git diff --git a/src/asyncstorageimpl.cpp b/src/asyncstorageimpl.cpp index d9478c2..0d6d683 100644 --- a/src/asyncstorageimpl.cpp +++ b/src/asyncstorageimpl.cpp @@ -96,16 +96,17 @@ AsyncStorageImpl::AsyncStorageImpl(std::shared_ptr engine, { } -void AsyncStorageImpl::setAsyncRedisStorageHandlers(const std::string& ns) +void AsyncStorageImpl::setAsyncRedisStorageHandlersForCluster(const std::string& ns) { - for (std::size_t i = 0; i < databaseConfiguration->getServerAddresses().size(); i++) + static auto serverCount = databaseConfiguration->getServerAddresses().size(); + for (std::size_t addrIndex = 0; addrIndex < serverCount; addrIndex++) { auto redisHandler = std::make_shared(engine, asyncDatabaseDiscoveryCreator( engine, ns, std::ref(*databaseConfiguration), - i, + addrIndex, logger), publisherId, namespaceConfigurations, @@ -114,10 +115,32 @@ void AsyncStorageImpl::setAsyncRedisStorageHandlers(const std::string& ns) } } +void AsyncStorageImpl::setAsyncRedisStorageHandlers(const std::string& ns) +{ + if (DatabaseConfiguration::DbType::SDL_STANDALONE_CLUSTER == databaseConfiguration->getDbType() || + DatabaseConfiguration::DbType::SDL_SENTINEL_CLUSTER == databaseConfiguration->getDbType()) + { + setAsyncRedisStorageHandlersForCluster(ns); + return; + } + auto redisHandler = std::make_shared(engine, + asyncDatabaseDiscoveryCreator( + engine, + ns, + std::ref(*databaseConfiguration), + boost::none, + logger), + publisherId, + namespaceConfigurations, + logger); + asyncStorages.push_back(redisHandler); +} + AsyncStorage& AsyncStorageImpl::getAsyncRedisStorageHandler(const std::string& ns) { std::size_t handlerIndex{0}; - if (DatabaseConfiguration::DbType::SDL_CLUSTER == databaseConfiguration->getDbType()) + if (DatabaseConfiguration::DbType::SDL_STANDALONE_CLUSTER == databaseConfiguration->getDbType() || + DatabaseConfiguration::DbType::SDL_SENTINEL_CLUSTER == databaseConfiguration->getDbType()) handlerIndex = getClusterHashIndex(ns, databaseConfiguration->getServerAddresses().size()); return *asyncStorages.at(handlerIndex); } @@ -125,7 +148,6 @@ AsyncStorage& AsyncStorageImpl::getAsyncRedisStorageHandler(const std::string& n AsyncStorage& AsyncStorageImpl::getRedisHandler(const std::string& ns) { #if HAVE_REDIS - auto serverAddresses(databaseConfiguration->getServerAddresses()); if (asyncStorages.empty()) setAsyncRedisStorageHandlers(ns); @@ -219,6 +241,13 @@ void AsyncStorageImpl::findKeysAsync(const Namespace& ns, getOperationHandler(ns).findKeysAsync(ns, keyPrefix, findKeysAck); } +void AsyncStorageImpl::listKeys(const Namespace& ns, + const std::string& pattern, + const FindKeysAck& findKeysAck) +{ + getOperationHandler(ns).listKeys(ns, pattern, findKeysAck); +} + void AsyncStorageImpl::removeAllAsync(const Namespace& ns, const ModifyAck& modifyAck) {