|
@@ -26,21 +26,21 @@ using namespace isc::dns;
|
|
namespace isc {
|
|
namespace isc {
|
|
namespace datasrc {
|
|
namespace datasrc {
|
|
|
|
|
|
-/// \brief rbtree color define
|
|
|
|
|
|
+/// \brief Define rbtree color
|
|
enum RBTreeColor {BLACK = 1, RED};
|
|
enum RBTreeColor {BLACK = 1, RED};
|
|
class RBTree;
|
|
class RBTree;
|
|
|
|
|
|
-/// \brief \c RBNode class represent one domain name in the domain space
|
|
|
|
|
|
+/// \brief \c RBNode class represents one domain name in the domain space
|
|
|
|
|
|
-/// It has two roles, the first one is as one node in the \c RBTree the second one
|
|
|
|
|
|
+/// It has two roles, the first one is as one node in the \c RBTree, the second one
|
|
/// is store the data related to DNS. As for the first role, it has left, right, parent and color memebers
|
|
/// is store the data related to DNS. As for the first role, it has left, right, parent and color memebers
|
|
-/// which used to keey the balance of the \c RBTree. As for the second role,
|
|
|
|
-// it stores the rrsets belongs to the domain name and a rbtree which includes all the subdomains of this node
|
|
|
|
-/// the name stored in the node is relative related to its parent node.
|
|
|
|
|
|
+/// which used to keep the balance of the \c RBTree. As for the second role,
|
|
|
|
+// it stores the rrsets belong to the domain name and a rbtree which includes all the subdomains of this node
|
|
|
|
+/// the name stored in the node is relative related to its parent node.
|
|
/// One special kind of node is non-terminal node
|
|
/// One special kind of node is non-terminal node
|
|
-/// which has subdomains with rrset but it self doesn't has any rrset
|
|
|
|
|
|
+/// which has subdomains with rrset but it self doesn't have any rrsets
|
|
///
|
|
///
|
|
-/// \b Note: \c RBNode should create or destroied only by \c RBTree so constructor and destructor function aren't exposed
|
|
|
|
|
|
+/// \b Note: \c RBNode should be created or destroyed only by \c RBTree so constructor and destructor function aren't exposed
|
|
|
|
|
|
|
|
|
|
class RBNode : public boost::noncopyable{
|
|
class RBNode : public boost::noncopyable{
|
|
@@ -56,7 +56,7 @@ class RBNode : public boost::noncopyable{
|
|
bool isDelegate() const { return is_delegate_;}
|
|
bool isDelegate() const { return is_delegate_;}
|
|
|
|
|
|
/// \brief return whether current domain name is non-terminal
|
|
/// \brief return whether current domain name is non-terminal
|
|
- /// A non-terminal domain has no rrsets but at least one its descendant
|
|
|
|
|
|
+ /// A non-terminal domain has no rrsets but at least one of its descendant
|
|
/// domain has rrset
|
|
/// domain has rrset
|
|
bool isNonterminal() const { return is_nonterminal_;}
|
|
bool isNonterminal() const { return is_nonterminal_;}
|
|
|
|
|
|
@@ -75,7 +75,7 @@ class RBNode : public boost::noncopyable{
|
|
|
|
|
|
/// \brief add the rrset to the node
|
|
/// \brief add the rrset to the node
|
|
/// \Note: there is no check whether the node already has the rrset or not
|
|
/// \Note: there is no check whether the node already has the rrset or not
|
|
- /// and no check about whether the name of the rrset is same with the node or not
|
|
|
|
|
|
+ /// and no check about whether the name of the rrset is the same with the node or not
|
|
/// All of above is rely on interface user
|
|
/// All of above is rely on interface user
|
|
int addRRset(RRsetPtr rrset);
|
|
int addRRset(RRsetPtr rrset);
|
|
//@}
|
|
//@}
|
|
@@ -88,15 +88,15 @@ class RBNode : public boost::noncopyable{
|
|
RBNode(const Name& name, RRsetListPtr rrsets = RRsetListPtr(), RBNode* nullnode = NULL);
|
|
RBNode(const Name& name, RRsetListPtr rrsets = RRsetListPtr(), RBNode* nullnode = NULL);
|
|
|
|
|
|
/// the class isn't left to be inherted
|
|
/// the class isn't left to be inherted
|
|
- ~RBNode();
|
|
|
|
|
|
+ ~RBNode();
|
|
//@}
|
|
//@}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
/// \brief copy the DNS related date to another node except the sub domain tree
|
|
/// \brief copy the DNS related date to another node except the sub domain tree
|
|
void cloneDNSData(RBNode& node);
|
|
void cloneDNSData(RBNode& node);
|
|
- /// \brief when copy the DNS data from one node to another, except the rrsets, name etc,
|
|
|
|
|
|
+ /// \brief when copy the DNS data from one node to another, except the rrsets, name etc,
|
|
/// also needs to maintain the down and up relationship, which includes set the down point of current
|
|
/// also needs to maintain the down and up relationship, which includes set the down point of current
|
|
- /// node and up point of sub domain tree
|
|
|
|
|
|
+ /// node and up point of sub domain tree
|
|
void setDownTree(RBTree* down);
|
|
void setDownTree(RBTree* down);
|
|
|
|
|
|
/// data to maintain the rbtree balance
|
|
/// data to maintain the rbtree balance
|
|
@@ -113,13 +113,13 @@ class RBNode : public boost::noncopyable{
|
|
bool is_nonterminal_;
|
|
bool is_nonterminal_;
|
|
};
|
|
};
|
|
|
|
|
|
-/// \brief \c RBTree class represent all the domains with same suffix, so it can be used to store
|
|
|
|
|
|
+/// \brief \c RBTree class represents all the domains with the same suffix, so it can be used to store
|
|
/// the domains in one zone
|
|
/// the domains in one zone
|
|
///
|
|
///
|
|
-/// \c RBTree is a generic red black tree, and contains all the node with same suffix, since each
|
|
|
|
|
|
+/// \c RBTree is a generic red black tree, and contains all the nodes with the same suffix, since each
|
|
/// name may have sub domain names so \c RBTree is a recursive data struct or tree in tree
|
|
/// name may have sub domain names so \c RBTree is a recursive data struct or tree in tree
|
|
-/// So for one zone, severl RBTrees are involved. But from outside, the sub tree is
|
|
|
|
-/// opaque for end user.
|
|
|
|
|
|
+/// So for one zone, several RBTrees are involved. But from outside, the sub tree is
|
|
|
|
+/// opaque for end users.
|
|
class RBTree : public boost::noncopyable{
|
|
class RBTree : public boost::noncopyable{
|
|
friend class RBNode;
|
|
friend class RBNode;
|
|
public:
|
|
public:
|
|
@@ -138,19 +138,19 @@ class RBTree : public boost::noncopyable{
|
|
|
|
|
|
/// \name Inquery methods
|
|
/// \name Inquery methods
|
|
//@{
|
|
//@{
|
|
- /// \brief find the node with the name
|
|
|
|
|
|
+ /// \brief find the node with the name
|
|
/// \param name Target to be found
|
|
/// \param name Target to be found
|
|
/// \param node Point to the node when the return vaule is \c not NOTFOUND, if
|
|
/// \param node Point to the node when the return vaule is \c not NOTFOUND, if
|
|
- /// if the return value is NOTFOUND, the value of node is \c unknown
|
|
|
|
|
|
+ /// the return value is NOTFOUND, the value of node is \c unknown
|
|
FindResult find(const Name& name, RBNode** node)const;
|
|
FindResult find(const Name& name, RBNode** node)const;
|
|
|
|
|
|
- /// \brief Get all the node count in the tree
|
|
|
|
|
|
+ /// \brief Get the total node count in the tree
|
|
int getNodeCount() const;
|
|
int getNodeCount() const;
|
|
//@}
|
|
//@}
|
|
|
|
|
|
/// \name Debug function
|
|
/// \name Debug function
|
|
//@{
|
|
//@{
|
|
- /// \brief print the node in the trees
|
|
|
|
|
|
+ /// \brief print the nodes in the trees
|
|
/// \todo is it better to return one string instead of print to the stdout?
|
|
/// \todo is it better to return one string instead of print to the stdout?
|
|
void printTree(int depth = 0)const;
|
|
void printTree(int depth = 0)const;
|
|
//@}
|
|
//@}
|
|
@@ -159,19 +159,19 @@ class RBTree : public boost::noncopyable{
|
|
//@{
|
|
//@{
|
|
/// \brief insert the domain name into the tree
|
|
/// \brief insert the domain name into the tree
|
|
/// \param name The name want to be inserted into the tree
|
|
/// \param name The name want to be inserted into the tree
|
|
- /// \param inserted_node If no node with the name in the tree,
|
|
|
|
|
|
+ /// \param inserted_node If no node with the name in the tree,
|
|
/// new \c RBNode will be created, otherwise nothing will be done
|
|
/// new \c RBNode will be created, otherwise nothing will be done
|
|
/// anyway the pointer point to the node with the name will be assign to inserted_node
|
|
/// anyway the pointer point to the node with the name will be assign to inserted_node
|
|
/// \return return 0 means no node exists in the tree with the name before insert
|
|
/// \return return 0 means no node exists in the tree with the name before insert
|
|
/// return 1 means already has the node with the given name
|
|
/// return 1 means already has the node with the given name
|
|
//
|
|
//
|
|
/// If want to add rrset into one node, but not sure whether the node already exist
|
|
/// If want to add rrset into one node, but not sure whether the node already exist
|
|
- /// Instead of call \c find, call \c insert and then call the RBNode interface to
|
|
|
|
|
|
+ /// Instead of call \c find, call \c insert and then call the RBNode interface to
|
|
/// add rrset into the node is a better way
|
|
/// add rrset into the node is a better way
|
|
int insert(const Name& name, RBNode** inserted_node);
|
|
int insert(const Name& name, RBNode** inserted_node);
|
|
|
|
|
|
/// \brief erase the node with the domain name
|
|
/// \brief erase the node with the domain name
|
|
- /// \return If no node with the name, return one otherwise return zero
|
|
|
|
|
|
+ /// \return If no node with the name, return 1 otherwise return 0
|
|
int erase(const Name& name);
|
|
int erase(const Name& name);
|
|
//@}
|
|
//@}
|
|
|
|
|
|
@@ -186,7 +186,7 @@ class RBTree : public boost::noncopyable{
|
|
|
|
|
|
/// \name Helper function
|
|
/// \name Helper function
|
|
//@{
|
|
//@{
|
|
- /// All the public function has related recursive helper function
|
|
|
|
|
|
+ /// Each public function has related recursive helper function
|
|
void eraseNode(RBNode* node);
|
|
void eraseNode(RBNode* node);
|
|
FindResult findHelper(const Name& name, RBTree** tree, RBNode** node)const;
|
|
FindResult findHelper(const Name& name, RBTree** tree, RBNode** node)const;
|
|
int getNodeCountHelper(const RBNode* node) const;
|
|
int getNodeCountHelper(const RBNode* node) const;
|
|
@@ -198,7 +198,7 @@ class RBTree : public boost::noncopyable{
|
|
RBNode* NULLNODE;
|
|
RBNode* NULLNODE;
|
|
RBNode* up_;
|
|
RBNode* up_;
|
|
/// the node count of current tree except the sub domain trees
|
|
/// the node count of current tree except the sub domain trees
|
|
- unsigned int node_count_;
|
|
|
|
|
|
+ unsigned int node_count_;
|
|
};
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|