Commit c94995ad authored by zhanglikun's avatar zhanglikun
Browse files

Add the local zone data class

parent fca9cd2a
......@@ -27,5 +27,7 @@ libcache_la_SOURCES += message_entry.h message_entry.cc
libcache_la_SOURCES += rrset_cache.h rrset_cache.cc
libcache_la_SOURCES += rrset_entry.h rrset_entry.cc
libcache_la_SOURCES += cache_entry_key.h cache_entry_key.cc
libcache_la_SOURCES += rrset_copy.h rrset_copy.cc
libcache_la_SOURCES += local_zone_data.h local_zone_data.cc
CLEANFILES = *.gcno *.gcda
......@@ -20,7 +20,7 @@
#include <string>
using namespace isc::dns;
using namespace std;
using namespace std;
namespace isc {
namespace cache {
......@@ -31,24 +31,24 @@ RecursorCache::RecursorCache(std::vector<CacheSizeInfo> caches_size) {
for (; index < size; index++) {
CacheSizeInfo* infop = &caches_size[index];
uint16_t klass = infop->class_;
rrsets_cache1_[klass] = RRsetCachePtr(new
rrsets_cache1_[klass] = RRsetCachePtr(new
RRsetCache(infop->rrset_cache_size, klass));
rrsets_cache2_[klass] = RRsetCachePtr(new
rrsets_cache2_[klass] = RRsetCachePtr(new
RRsetCache(infop->rrset_cache_size, klass));
messages_cache_[klass] = MessageCachePtr(new MessageCache(rrsets_cache2_[klass],
infop->message_cache_size,
messages_cache_[klass] = MessageCachePtr(new MessageCache(rrsets_cache2_[klass],
infop->message_cache_size,
klass));
}
}
bool
RecursorCache::lookup(const isc::dns::Name& qname,
RecursorCache::lookup(const isc::dns::Name& qname,
const isc::dns::RRType& qtype,
const isc::dns::RRClass& qclass,
isc::dns::Message& response) const
{
// First, query in rrsets_cache1_, if the rrset(qname, qtype, qclass) can be
// found in rrsets_cache1_, generated reply message with only the rrset in
// First, query in rrsets_cache1_, if the rrset(qname, qtype, qclass) can be
// found in rrsets_cache1_, generated reply message with only the rrset in
// answer section.
RRsetCacheMap::const_iterator cache_iter = rrsets_cache1_.find(qclass.getCode());
if (cache_iter != rrsets_cache1_.end()) {
......@@ -70,7 +70,7 @@ RecursorCache::lookup(const isc::dns::Name& qname,
}
isc::dns::RRsetPtr
RecursorCache::lookup_in_rrset_cache(const isc::dns::Name& qname,
RecursorCache::lookup_in_rrset_cache(const isc::dns::Name& qname,
const isc::dns::RRType& qtype,
const isc::dns::RRClass& qclass,
const RRsetCacheMap& rrsets_cache) const
......@@ -88,12 +88,12 @@ RecursorCache::lookup_in_rrset_cache(const isc::dns::Name& qname,
}
isc::dns::RRsetPtr
RecursorCache::lookup(const isc::dns::Name& qname,
RecursorCache::lookup(const isc::dns::Name& qname,
const isc::dns::RRType& qtype,
const isc::dns::RRClass& qclass) const
{
// Algorithm:
// 1. Search in rrsets_cache1_ first,
// 1. Search in rrsets_cache1_ first,
// 2. Then do search in rrsets_cache2_.
RRsetPtr rrset_ptr = lookup_in_rrset_cache(qname, qtype, qclass, rrsets_cache1_);
if (rrset_ptr) {
......@@ -119,7 +119,7 @@ RecursorCache::update(const isc::dns::Message& msg) {
bool
RecursorCache::updateRRsetCache(const isc::dns::RRset& rrset,
RRsetCacheMap& rrset_cache_map)
RRsetCacheMap& rrset_cache_map)
{
uint16_t klass = rrset.getClass().getCode();
RRsetCacheMap::iterator cache_iter = rrset_cache_map.find(klass);
......
......@@ -32,7 +32,7 @@ typedef std::map<uint16_t, MessageCachePtr> MessageCacheMap;
typedef std::map<uint16_t, RRsetCachePtr> RRsetCacheMap;
//TODO a better proper default cache size
#define MESSAGE_CACHE_DEFAULT_SIZE 1000000
#define MESSAGE_CACHE_DEFAULT_SIZE 1000000
#define RRSET_CACHE_DEFAULT_SIZE 10000
/// \brief Cache Size Information.
......@@ -44,7 +44,7 @@ struct CacheSizeInfo
uint32_t rrset_cache_size; // The size for rrset cache.
};
///
///
/// \brief Recursor Cache
/// The object of RecursorCache represents the cache of the recursor. It holds
/// a list of message cache and rrset cache.
......@@ -52,7 +52,7 @@ struct CacheSizeInfo
class RecursorCache {
public:
/// \brief Construct Function
/// \param caches_size cache size information for each
/// \param caches_size cache size information for each
/// messages/rrsets.
RecursorCache(std::vector<CacheSizeInfo> caches_size);
......@@ -65,26 +65,26 @@ public:
/// will be added to different sections.
///
/// \return return true if the message can be found, or else, return false.
bool lookup(const isc::dns::Name& qname,
bool lookup(const isc::dns::Name& qname,
const isc::dns::RRType& qtype,
const isc::dns::RRClass& qclass,
isc::dns::Message& response) const;
/// \brief Look up rrset in cache.
/// \return return the shared_ptr of rrset if it can be found,
/// or else, return NULL. When looking up, cache1(localzone) will
/// \return return the shared_ptr of rrset if it can be found,
/// or else, return NULL. When looking up, cache1(localzone) will
/// be searched first, if not found, then search in cache2.
///
/// \overload
///
isc::dns::RRsetPtr lookup(const isc::dns::Name& qname,
isc::dns::RRsetPtr lookup(const isc::dns::Name& qname,
const isc::dns::RRType& qtype,
const isc::dns::RRClass& qclass) const;
//@}
/// \brief Update the message in the cache with the new one.
/// \return return true if the message is updated into the cache,
/// or else, return false.
/// or else, return false.
///
/// \note, the function doesn't do any message
/// validation check, the user should make sure the message is valid.
......@@ -96,8 +96,8 @@ public:
/// will be added into both of them.
/// \return return false, if the class of the parameter rrset is
/// allowed to be cached.
///
/// \overload
///
/// \overload
///
bool update(const isc::dns::RRset& rrset);
......@@ -112,13 +112,13 @@ public:
void load(const std::string& file_name);
//@}
protected:
protected:
/// \brief Look up rrset in one specified rrset cache.
/// This function is used internally by lookup()
/// \param rrsets_cache the cache for looking up rrset.
/// \return return the shared_ptr of the rrset if it can be
/// found in the cache.
isc::dns::RRsetPtr lookup_in_rrset_cache(const isc::dns::Name& qname,
isc::dns::RRsetPtr lookup_in_rrset_cache(const isc::dns::Name& qname,
const isc::dns::RRType& qtype,
const isc::dns::RRClass& qclass,
const RRsetCacheMap& rrsets_cache) const;
......@@ -137,11 +137,11 @@ protected:
/// \brief the list of message cache for configured classes(message cache
/// is class-specific)
MessageCacheMap messages_cache_;
/// \name rrset caches
//@{
/// \brief the list of rrset cache for configured classes.
/// rrsets_cache1_ is used to cache the configured rrsets in localzone, rrsets
/// rrsets_cache1_ is used to cache the configured rrsets in localzone, rrsets
/// in it will never expire.
RRsetCacheMap rrsets_cache1_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment