BIND 10 trac2835, updated. 946126b36db6b9cd21c194a84a61417dd6bd567c [2835] Use string for segment type

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Mar 22 10:14:12 UTC 2013


The branch, trac2835 has been updated
       via  946126b36db6b9cd21c194a84a61417dd6bd567c (commit)
       via  8c6afd880d47f33174b656ed12a2e5e4c821e14b (commit)
       via  22407c48db5999e77a6fbd6e4f42ba2a3fe36762 (commit)
       via  bc87d1113832e7900d3627663c0a1203c3e7b2da (commit)
       via  6fadd98cb5a9beeb79c58ba0a2768d9ad895c210 (commit)
      from  e1c60036dfd2d4e1fcd372807e4a3f0f201028cb (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 946126b36db6b9cd21c194a84a61417dd6bd567c
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Mar 22 11:13:11 2013 +0100

    [2835] Use string for segment type
    
    Instead of hard-coded enum type. The data source should be agnostic to
    the type.

commit 8c6afd880d47f33174b656ed12a2e5e4c821e14b
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Mar 22 10:38:37 2013 +0100

    [2835] Fix comment

commit 22407c48db5999e77a6fbd6e4f42ba2a3fe36762
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Mar 22 10:37:17 2013 +0100

    [2835] Throw a more appropriate exception

commit bc87d1113832e7900d3627663c0a1203c3e7b2da
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Mar 22 10:20:13 2013 +0100

    [2835] Clarification of doxygen
    
    Saying the segments are for in-memory cache. Also adding note about
    future extending and exceptions.

commit 6fadd98cb5a9beeb79c58ba0a2768d9ad895c210
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Mar 22 10:03:24 2013 +0100

    [2835] Rename enum item
    
    SEGMENT_MAPPED may be misleading in case of locally-allocated memory.
    Using SEGMENT_INUSE.

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

Summary of changes:
 src/lib/datasrc/client_list.cc                |    4 +--
 src/lib/datasrc/client_list.h                 |   42 ++++++++++++-------------
 src/lib/datasrc/tests/client_list_unittest.cc |   17 +++++-----
 3 files changed, 31 insertions(+), 32 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/client_list.cc b/src/lib/datasrc/client_list.cc
index 03f2ace..eb60a96 100644
--- a/src/lib/datasrc/client_list.cc
+++ b/src/lib/datasrc/client_list.cc
@@ -482,8 +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_LOCAL));
+                                          SEGMENT_INUSE : SEGMENT_UNUSED,
+                                          "local"));
     }
     return (result);
 }
diff --git a/src/lib/datasrc/client_list.h b/src/lib/datasrc/client_list.h
index d457872..25ebee4 100644
--- a/src/lib/datasrc/client_list.h
+++ b/src/lib/datasrc/client_list.h
@@ -48,8 +48,8 @@ class ZoneWriter;
 
 /// \brief Segment status of the cache
 ///
-/// Describes the status in which the memory segment of given data source
-/// is.
+/// Describes the status in which the memory segment for the in-memory cache of
+// /given data source is.
 enum MemorySegmentState {
     /// \brief No segment used for this data source.
     ///
@@ -61,16 +61,7 @@ enum MemorySegmentState {
     SEGMENT_WAITING,
 
     /// \brief The segment is ready to be used.
-    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
+    SEGMENT_INUSE
 };
 
 /// \brief Status of one data source.
@@ -78,6 +69,9 @@ enum MemorySegmentType {
 /// This indicates the status a data soure is in. It is used with segment
 /// and cache management, to discover the data sources that need external
 /// mapping or local loading.
+///
+/// In future, it may be extended for other purposes, such as performing an
+/// operation on named data source.
 class DataSourceStatus {
 public:
     /// \brief Constructor
@@ -85,35 +79,36 @@ public:
     /// 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) :
+                     const std::string& type) :
         name_(name),
-        state_(state),
-        type_(type)
+        type_(type),
+        state_(state)
     {}
 
-    /// \brief Get the current segment state
+    /// \brief Get the segment state
     MemorySegmentState getSegmentState() const {
         return (state_);
     }
 
-    /// \brief Get the current segment type
+    /// \brief Get the segment type
     ///
-    /// \throw isc::BadValue if called and state is SEGMENT_UNUSED.
-    MemorySegmentType getSegmentType() const {
+    /// \throw isc::InvalidOperation if called and state is SEGMENT_UNUSED.
+    const std::string& getSegmentType() const {
         if (getSegmentState() == SEGMENT_UNUSED) {
-            isc_throw(isc::BadValue, "No segment used, no type therefore.");
+            isc_throw(isc::InvalidOperation,
+                      "No segment used, no type therefore.");
         }
         return (type_);
     }
 
-    /// \brief Get the current name.
+    /// \brief Get the name.
     const std::string& getName() const {
         return (name_);
     }
 private:
     std::string name_;
+    std::string type_;
     MemorySegmentState state_;
-    MemorySegmentType type_;
 };
 
 /// \brief The list of data source clients.
@@ -456,6 +451,9 @@ public:
     ///
     /// Get a DataSourceStatus for current state of each data source client
     /// in this list.
+    ///
+    /// This may throw standad exceptions, such as std::bad_alloc. Otherwise,
+    /// it is exception free.
     std::vector<DataSourceStatus> getStatus() const;
 public:
     /// \brief Access to the data source clients.
diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc
index 8b30319..b7cdfc2 100644
--- a/src/lib/datasrc/tests/client_list_unittest.cc
+++ b/src/lib/datasrc/tests/client_list_unittest.cc
@@ -576,10 +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_THROW(statuses[0].getSegmentType(), isc::InvalidOperation);
     EXPECT_EQ("Test name", statuses[1].getName());
-    EXPECT_EQ(SEGMENT_MAPPED, statuses[1].getSegmentState());
-    EXPECT_EQ(SEGMENT_LOCAL, statuses[1].getSegmentType());
+    EXPECT_EQ(SEGMENT_INUSE, statuses[1].getSegmentState());
+    EXPECT_EQ("local", statuses[1].getSegmentType());
 }
 
 TEST_F(ListTest, wrongConfig) {
@@ -1165,14 +1165,15 @@ TYPED_TEST(ReloadTest, reloadMasterFile) {
 
 // Check the status holds data and can change the segment state
 TEST(DataSourceStatus, status) {
-    const DataSourceStatus status("Test", SEGMENT_MAPPED, SEGMENT_LOCAL);
+    const DataSourceStatus status("Test", SEGMENT_INUSE, "local");
     EXPECT_EQ("Test", status.getName());
-    EXPECT_EQ(SEGMENT_MAPPED, status.getSegmentState());
-    EXPECT_EQ(SEGMENT_LOCAL, status.getSegmentType());
-    const DataSourceStatus statusUnused("Unused", SEGMENT_UNUSED, SEGMENT_FILE);
+    EXPECT_EQ(SEGMENT_INUSE, status.getSegmentState());
+    EXPECT_EQ("local", status.getSegmentType());
+    const DataSourceStatus statusUnused("Unused", SEGMENT_UNUSED,
+                                        "");
     EXPECT_EQ("Unused", statusUnused.getName());
     EXPECT_EQ(SEGMENT_UNUSED, statusUnused.getSegmentState());
-    EXPECT_THROW(statusUnused.getSegmentType(), isc::BadValue);
+    EXPECT_THROW(statusUnused.getSegmentType(), isc::InvalidOperation);
 }
 
 }



More information about the bind10-changes mailing list