/*
- Copyright (c) 2018-2019 Nokia.
+ Copyright (c) 2018-2022 Nokia.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
#include "private/namespaceconfigurations.hpp"
#include "private/namespacevalidator.hpp"
#include "private/system.hpp"
+#include <boost/algorithm/string.hpp>
using namespace shareddatalayer;
parseNsConfiguration(namespaceConfigurations, namespaceConfigurationMapItem.first, namespaceConfigurationMapItem.second.first, namespaceConfigurationMapItem.second.second);
}
+ const std::string DEFAULT_REDIS_PORT("6379");
+
void appendDBPortToAddrList(std::string& addresses, const std::string& port)
{
size_t base(0);
+ std::vector<std::string> portList;
+ boost::split(portList, port, boost::is_any_of(","));
+
+ std::size_t idx(0);
+ auto redisPort((portList.size() > 0 && idx < portList.size()) ? portList.at(idx) : DEFAULT_REDIS_PORT);
auto pos = addresses.find(',', base);
while (std::string::npos != pos)
{
- addresses.insert(pos, ":" + port);
- base = pos + 2 + port.size();
+ addresses.insert(pos, ":" + redisPort);
+ base = pos + 2 + redisPort.size();
pos = addresses.find(',', base);
+ idx++;
}
- addresses.append(":" + port);
+ addresses.append(":" + redisPort);
}
}
if (DatabaseConfiguration::DbType::REDIS_SENTINEL == dbType ||
DatabaseConfiguration::DbType::SDL_SENTINEL_CLUSTER == dbType)
{
- databaseConfiguration.checkAndApplySentinelAddress(dbHostEnvVariableValue + ":" + sentinelPortEnvVariableValue);
- databaseConfiguration.checkAndApplySentinelMasterName(sentinelMasterNameEnvVariableValue);
+ databaseConfiguration.checkAndApplySentinelPorts(sentinelPortEnvVariableValue);
+ databaseConfiguration.checkAndApplySentinelMasterNames(sentinelMasterNameEnvVariableValue);
}
}
else