BIND 10 trac2835, updated. 6e0725b08ad12bafcc939622daa5a2f7b734ecbe [2835] Include the segment type

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Mar 19 09:28:16 UTC 2013


The branch, trac2835 has been updated
       via  6e0725b08ad12bafcc939622daa5a2f7b734ecbe (commit)
      from  8377d0dcf3c758cc50111a98a7a9dafdc3237c44 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6e0725b08ad12bafcc939622daa5a2f7b734ecbe
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Tue Mar 19 10:26:29 2013 +0100

    [2835] Include the segment type
    
    Specify the segment type used. This is SEGMENT_LOCAL for now with every
    segment used, but it is ready for when we have different kinds of
    segments too.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/datasrc/client_list.cc                |    3 ++-
 src/lib/datasrc/client_list.h                 |   32 ++++++++++++++++++++-----
 src/lib/datasrc/tests/client_list_unittest.cc |   11 +++++++--
 3 files changed, 37 insertions(+), 9 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/client_list.cc b/src/lib/datasrc/client_list.cc
index a05f26a..03f2ace 100644
--- a/src/lib/datasrc/client_list.cc
+++ b/src/lib/datasrc/client_list.cc
@@ -482,7 +482,8 @@ ConfigurableClientList::getStatus() const {
         // TODO: Once we support mapped cache, decide when we need the
         // SEGMENT_WAITING.
         result.push_back(DataSourceStatus(info.name_, info.cache_ ?
-                                          SEGMENT_MAPPED : SEGMENT_UNUSED));
+                                          SEGMENT_MAPPED : SEGMENT_UNUSED,
+                                          SEGMENT_LOCAL));
     }
     return (result);
 }
diff --git a/src/lib/datasrc/client_list.h b/src/lib/datasrc/client_list.h
index c584e60..d457872 100644
--- a/src/lib/datasrc/client_list.h
+++ b/src/lib/datasrc/client_list.h
@@ -54,7 +54,6 @@ enum MemorySegmentState {
     /// \brief No segment used for this data source.
     ///
     /// This is usually a result of the cache being disabled.
-
     SEGMENT_UNUSED,
 
     /// \brief It is a mapped segment and we wait for information how to map
@@ -65,6 +64,15 @@ enum MemorySegmentState {
     SEGMENT_MAPPED
 };
 
+/// \brief The type of the memory segment in cache
+enum MemorySegmentType {
+    /// \brief A locally loaded, unshared cache. Normal memory.
+    SEGMENT_LOCAL,
+
+    /// \brief A file image mapped into memory
+    SEGMENT_FILE
+};
+
 /// \brief Status of one data source.
 ///
 /// This indicates the status a data soure is in. It is used with segment
@@ -74,10 +82,13 @@ class DataSourceStatus {
 public:
     /// \brief Constructor
     ///
-    /// Sets initial values.
-    DataSourceStatus(const std::string& name, MemorySegmentState state) :
+    /// Sets initial values. It doesn't matter what is provided for the type
+    /// if state is SEGMENT_UNUSED, the value is effectively ignored.
+    DataSourceStatus(const std::string& name, MemorySegmentState state,
+                     MemorySegmentType type) :
         name_(name),
-        state_(state)
+        state_(state),
+        type_(type)
     {}
 
     /// \brief Get the current segment state
@@ -85,15 +96,24 @@ public:
         return (state_);
     }
 
-    /// \brief Get the current name.
+    /// \brief Get the current segment type
     ///
-    /// \note The name may not be changed once the object is constructed.
+    /// \throw isc::BadValue if called and state is SEGMENT_UNUSED.
+    MemorySegmentType getSegmentType() const {
+        if (getSegmentState() == SEGMENT_UNUSED) {
+            isc_throw(isc::BadValue, "No segment used, no type therefore.");
+        }
+        return (type_);
+    }
+
+    /// \brief Get the current name.
     const std::string& getName() const {
         return (name_);
     }
 private:
     std::string name_;
     MemorySegmentState state_;
+    MemorySegmentType type_;
 };
 
 /// \brief The list of data source clients.
diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc
index d764264..8d4257f 100644
--- a/src/lib/datasrc/tests/client_list_unittest.cc
+++ b/src/lib/datasrc/tests/client_list_unittest.cc
@@ -576,8 +576,10 @@ TEST_F(ListTest, status) {
     ASSERT_EQ(2, statuses.size());
     EXPECT_EQ("type1", statuses[0].getName());
     EXPECT_EQ(SEGMENT_UNUSED, statuses[0].getSegmentState());
+    EXPECT_THROW(statuses[0].getSegmentType(), isc::BadValue);
     EXPECT_EQ("Test name", statuses[1].getName());
     EXPECT_EQ(SEGMENT_MAPPED, statuses[1].getSegmentState());
+    EXPECT_EQ(SEGMENT_LOCAL, statuses[1].getSegmentType());
 }
 
 TEST_F(ListTest, wrongConfig) {
@@ -1163,9 +1165,14 @@ TYPED_TEST(ReloadTest, reloadMasterFile) {
 
 // Check the status holds data and can change the segment state
 TEST(DataSourceStatus, status) {
-    DataSourceStatus status("Test", SEGMENT_UNUSED);
+    DataSourceStatus status("Test", SEGMENT_MAPPED, SEGMENT_LOCAL);
     EXPECT_EQ("Test", status.getName());
-    EXPECT_EQ(SEGMENT_UNUSED, status.getSegmentState());
+    EXPECT_EQ(SEGMENT_MAPPED, status.getSegmentState());
+    EXPECT_EQ(SEGMENT_LOCAL, status.getSegmentType());
+    DataSourceStatus statusUnused("Unused", SEGMENT_UNUSED, SEGMENT_FILE);
+    EXPECT_EQ("Unused", statusUnused.getName());
+    EXPECT_EQ(SEGMENT_UNUSED, statusUnused.getSegmentState());
+    EXPECT_THROW(statusUnused.getSegmentType(), isc::BadValue);
 }
 
 }



More information about the bind10-changes mailing list