+
+void DatabaseConfigurationImpl::checkAndApplySentinelPorts(const std::string& portsEnvStr)
+{
+ std::vector<std::string> ports;
+ boost::split(ports, portsEnvStr, boost::is_any_of(","));
+
+ for (auto port : ports)
+ {
+ try {
+ sentinelPorts.push_back(htons(boost::lexical_cast<uint16_t>(port)));
+ }
+ catch (boost::bad_lexical_cast const &) {
+ continue;
+ }
+ }
+}
+
+boost::optional<HostAndPort> DatabaseConfigurationImpl::getSentinelAddress(const boost::optional<std::size_t>& addressIndex) const
+{
+ std::size_t index(addressIndex ? *addressIndex : 0);
+ uint16_t port((sentinelPorts.size() > 0 && index < sentinelPorts.size()) ? sentinelPorts.at(index) : htons(DEFAULT_SENTINEL_PORT));
+
+ if (!(serverAddresses.size() > 0))
+ return {};
+
+ return { HostAndPort(serverAddresses.at(index).getHost(), port) };
+}
+
+void DatabaseConfigurationImpl::checkAndApplySentinelMasterNames(const std::string& sentinelMasterNamesEnvStr)
+{
+ boost::split(sentinelMasterNames, sentinelMasterNamesEnvStr, boost::is_any_of(","));
+}
+
+std::string DatabaseConfigurationImpl::getSentinelMasterName(const boost::optional<std::size_t>& addressIndex) const
+{
+ std::size_t index(addressIndex ? *addressIndex : 0);
+ return ((sentinelMasterNames.size() > 0 && index < sentinelMasterNames.size()) ? sentinelMasterNames.at(index) : DEFAULT_SENTINEL_MASTER_GROUP_NAME);
+}