diff options
author | Michal Vaner <michal.vaner@nic.cz> | 2010-12-08 12:34:52 +0100 |
---|---|---|
committer | Michal Vaner <michal.vaner@nic.cz> | 2010-12-08 12:34:52 +0100 |
commit | 2d7e8185d4d72b1351b477b6f4dea4fb873b2f19 (patch) | |
tree | c7e198208ee89f5591fe9f9fd8cede7cf2af0a45 /src/lib/nsas/nameserver_entry.h | |
parent | First part of sync with #356 (diff) | |
parent | Add process and unite tests code for the condition that all the servers are u... (diff) | |
download | kea-2d7e8185d4d72b1351b477b6f4dea4fb873b2f19.tar.xz kea-2d7e8185d4d72b1351b477b6f4dea4fb873b2f19.zip |
Hmm, subversion works locally to subdir. Commit the rest of the tree as well
git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac408@3764 e5f2f494-b856-4b98-b285-d166d9295462
Diffstat (limited to 'src/lib/nsas/nameserver_entry.h')
-rw-r--r-- | src/lib/nsas/nameserver_entry.h | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/src/lib/nsas/nameserver_entry.h b/src/lib/nsas/nameserver_entry.h index c3a5cce671..1d466c726f 100644 --- a/src/lib/nsas/nameserver_entry.h +++ b/src/lib/nsas/nameserver_entry.h @@ -28,16 +28,19 @@ #include "address_entry.h" #include "asiolink.h" -#include "nsas_entry.h" #include "nsas_types.h" #include "hash_key.h" #include "lru_list.h" #include "fetchable.h" #include "resolver_interface.h" +#include "nsas_entry.h" +#include "random_number_generator.h" namespace isc { namespace nsas { +class NameserverAddress; + /// \brief Inconsistent Owner Names /// /// Thrown if a NameserverEntry is constructed from both an A and AAAA RRset @@ -49,6 +52,16 @@ public: {} }; +/// \brief RTT is zero +/// +/// Thrown if a RTT related with an address is 0. +class RTTIsZero : public Exception { +public: + RTTIsZero(const char* file, size_t line, const char* what) : + isc::Exception(file, line, what) + {} +}; + /// \brief Inconsistent Class /// /// Thrown if a NameserverEntry is constructed from both an A and AAAA RRset @@ -87,9 +100,7 @@ class ResolverInterface; /// /// It uses shared_from_this in its methods. It must live inside a shared_ptr. -class NameserverEntry : public NsasEntry<NameserverEntry>, public Fetchable, - public boost::enable_shared_from_this<NameserverEntry> -{ +class NameserverEntry : public NsasEntry<NameserverEntry>, public Fetchable { public: /// List of addresses associated with this nameserver typedef std::vector<AddressEntry> AddressVector; @@ -130,11 +141,19 @@ public: NameserverEntry::AddressVector& addresses, AddressFamily family = ANY_OK, bool expired_ok = false); - // TODO Is this one of any use at all? + /// \brief Return one address + /// + /// Return one address corresponding to this nameserver + /// \param address NameserverAddress object used to receive the address + /// \param family The family of user request, AF_INET or AF_INET6 + /// \return true if one address is found, false otherwise + virtual bool getAddress(NameserverAddress& address, short family); + /// \brief Return Address that corresponding to the index /// /// \param index The address index in the address vector - asiolink::IOAddress getAddressAtIndex(uint32_t index) const; + /// \param family The address family, AF_INET or AF_INET6 + asiolink::IOAddress getAddressAtIndex(uint32_t index, short family) const; /// \brief Update RTT /// @@ -148,7 +167,8 @@ public: /// /// \param rtt Round-Trip Time /// \param index The address's index in address vector - void updateAddressRTTAtIndex(uint32_t rtt, uint32_t index); + /// \param family The address family, AF_INET or AF_INET6 + void updateAddressRTTAtIndex(uint32_t rtt, uint32_t index, short family); /// \brief Set Address Unreachable /// @@ -241,6 +261,18 @@ private: /// Call unlocked. void askIP(boost::shared_ptr<ResolverInterface> resolver, const isc::dns::RRType&, AddressFamily); + /// \brief Update the address selector according to the RTTs of addresses + /// + /// \param addresses The address list + /// \param selector Weighted random generator + void updateAddressSelector(std::vector<AddressEntry>& addresses, + WeightedRandomIntegerGenerator& selector); + + // TODO Unite address_ and v?_addresses_ + std::vector<AddressEntry> v4_addresses_; ///< Set of V4 addresses + std::vector<AddressEntry> v6_addresses_; ///< Set of V6 addresses + WeightedRandomIntegerGenerator v4_address_selector_; ///< Generate one integer according to different probability + WeightedRandomIntegerGenerator v6_address_selector_; ///< Generate one integer according to different probability }; } // namespace dns |