X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fdatabaseconfigurationimpl.cpp;h=211c53773370da3798ad0fc5a8afe30284947a25;hb=ece67088ea6c4f67b9d0db74477a9d5c614d7763;hp=f1fb2bedf2447e3d88341c2500029e46147e65cc;hpb=ef2bf51d04aaf01fa0cabdcaf905b23423067662;p=ric-plt%2Fsdl.git diff --git a/src/databaseconfigurationimpl.cpp b/src/databaseconfigurationimpl.cpp index f1fb2be..211c537 100644 --- a/src/databaseconfigurationimpl.cpp +++ b/src/databaseconfigurationimpl.cpp @@ -14,8 +14,14 @@ limitations under the License. */ +/* + * This source code is part of the near-RT RIC (RAN Intelligent Controller) + * platform project (RICP). +*/ + #include "private/databaseconfigurationimpl.hpp" #include +#include using namespace shareddatalayer; @@ -28,6 +34,7 @@ namespace } const uint16_t DEFAULT_PORT(6379U); + const uint16_t DEFAULT_SENTINEL_PORT(26379U); } DatabaseConfigurationImpl::DatabaseConfigurationImpl(): @@ -45,6 +52,10 @@ void DatabaseConfigurationImpl::checkAndApplyDbType(const std::string& type) dbType = DatabaseConfiguration::DbType::REDIS_STANDALONE; else if (type == "redis-cluster") dbType = DatabaseConfiguration::DbType::REDIS_CLUSTER; + else if (type == "redis-sentinel") + dbType = DatabaseConfiguration::DbType::REDIS_SENTINEL; + else if (type == "sdl-cluster") + dbType = DatabaseConfiguration::DbType::SDL_CLUSTER; else throw DatabaseConfiguration::InvalidDbType(type); } @@ -73,3 +84,31 @@ DatabaseConfiguration::Addresses DatabaseConfigurationImpl::getDefaultServerAddr { return { HostAndPort(getDefaultHost(), htons(DEFAULT_PORT)) }; } + +void DatabaseConfigurationImpl::checkAndApplySentinelAddress(const std::string& address) +{ + sentinelAddress = HostAndPort(address, htons(DEFAULT_SENTINEL_PORT)); +} + +boost::optional DatabaseConfigurationImpl::getSentinelAddress() const +{ + return sentinelAddress; +} + +boost::optional DatabaseConfigurationImpl::getSentinelAddress(const boost::optional& addressIndex) const +{ + if (addressIndex) + return { HostAndPort(serverAddresses.at(*addressIndex).getHost(), sentinelAddress->getPort()) }; + + return getSentinelAddress(); +} + +void DatabaseConfigurationImpl::checkAndApplySentinelMasterName(const std::string& name) +{ + sentinelMasterName = name; +} + +std::string DatabaseConfigurationImpl::getSentinelMasterName() const +{ + return sentinelMasterName; +}