Commit b4471621 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[1198] proposed further refactor 7: recovered logs, with defining new

ones for each subcase of find().
parent c05dc709
......@@ -612,6 +612,24 @@ DatabaseClient::Finder::findNoNameResult(const Name& name, const RRType& type,
}
}
ZoneFinder::FindResult
DatabaseClient::Finder::logAndCreateResult(const Name& name,
const RRType& type,
ZoneFinder::Result code,
ConstRRsetPtr rrset,
const isc::log::MessageID& log_id)
{
if (rrset) {
LOG_DEBUG(logger, DBG_TRACE_DETAILED, log_id).
arg(accessor_->getDBName()).arg(name).arg(getClass()).
arg(type).arg(*rrset);
} else {
LOG_DEBUG(logger, DBG_TRACE_DETAILED, log_id).
arg(accessor_->getDBName()).arg(name).arg(type).arg(getClass());
}
return (ZoneFinder::FindResult(code, rrset));
}
ZoneFinder::FindResult
DatabaseClient::Finder::find(const isc::dns::Name& name,
const isc::dns::RRType& type,
......@@ -643,19 +661,19 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
if (!is_origin && (options & FIND_GLUE_OK) == 0 &&
nsi != found.second.end()) { // delegation at the exact node
LOG_DEBUG(logger, DBG_TRACE_DETAILED,
DATASRC_DATABASE_FOUND_DELEGATION_EXACT).
arg(accessor_->getDBName()).arg(name);
return (FindResult(DELEGATION, nsi->second));
return (logAndCreateResult(name, type, DELEGATION, nsi->second,
DATASRC_DATABASE_FOUND_DELEGATION_EXACT));
} else if (type != RRType::CNAME() && cni != found.second.end()) { // CNAME
if (cni->second->getRdataCount() != 1) {
isc_throw(DataSourceError, "CNAME with " <<
cni->second->getRdataCount() <<
" rdata at " << name << ", expected 1");
}
return (FindResult(CNAME, cni->second));
return (logAndCreateResult(name, type, CNAME, cni->second,
DATASRC_DATABASE_FOUND_CNAME));
} else if (wti != found.second.end()) { // normal answer
return (FindResult(SUCCESS, wti->second));
return (logAndCreateResult(name, type, SUCCESS, wti->second,
DATASRC_DATABASE_FOUND_RRSET));
} else if (!found.first) { // NXDOMAIN, empty name, wildcard
return (findNoNameResult(name, type, options, dresult));
} else {
......@@ -664,10 +682,12 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
if ((options & FIND_DNSSEC) != 0) {
const FoundIterator nci(found.second.find(RRType::NSEC()));
if (nci != found.second.end()) {
return (FindResult(NXRRSET, nci->second));
return (logAndCreateResult(name, type, NXRRSET, nci->second,
DATASRC_DATABASE_FOUND_NXRRSET_NSEC));
}
}
return (FindResult(NXRRSET, ConstRRsetPtr()));
return (logAndCreateResult(name, type, NXRRSET, ConstRRsetPtr(),
DATASRC_DATABASE_FOUND_NXRRSET));
}
}
......
......@@ -25,6 +25,7 @@
#include <dns/rrtype.h>
#include <datasrc/client.h>
#include <datasrc/logger.h>
#include <dns/name.h>
#include <exceptions/exceptions.h>
......@@ -981,6 +982,14 @@ public:
const isc::dns::RRType& type,
FindOptions options,
const DelegationSearchResult& dresult);
// To be documented.
FindResult logAndCreateResult(const isc::dns::Name& name,
const isc::dns::RRType& type,
ZoneFinder::Result code,
isc::dns::ConstRRsetPtr rrset,
const isc::log::MessageID& log_id);
/**
* \brief Checks if something lives below this domain.
*
......
......@@ -110,6 +110,12 @@ The data returned by the database backend contained data for the given domain
name, and it either matches the type or has a relevant type. The RRset that is
returned is printed.
% DATASRC_DATABASE_FOUND_CNAME search in datasource %1 for %2/%3/%4 resulted in CNAME %5
(TBD)
% DATASRC_DATABASE_FOUND_NXRRSET_NSEC search in datasource %1 for %2/%3/%4 resulted in RRset %5
(TBD)
% DATASRC_DATABASE_ITERATE iterating zone %1
The program is reading the whole zone, eg. not searching for data, but going
through each of the RRsets there.
......
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