Parcourir la source

[2835] Revise the MemorySegmentState

* Don't base it on the type of segment (eg. remove MSS_LOCAL).
* Use a SEGMENT_ prefix instead of MSS_ (MSS reportedly usually refers
  to something else).
Michal 'vorner' Vaner il y a 12 ans
Parent
commit
8377d0dcf3

+ 4 - 3
src/lib/datasrc/client_list.cc

@@ -479,9 +479,10 @@ vector<DataSourceStatus>
 ConfigurableClientList::getStatus() const {
     vector<DataSourceStatus> result;
     BOOST_FOREACH(const DataSourceInfo& info, data_sources_) {
-        // TODO: Once we support mapped cache, provide the correct MSS_ value
-        result.push_back(DataSourceStatus(info.name_, info.cache_ ? MSS_LOCAL :
-                                          MSS_UNUSED));
+        // 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));
     }
     return (result);
 }

+ 9 - 6
src/lib/datasrc/client_list.h

@@ -51,15 +51,18 @@ class ZoneWriter;
 /// Describes the status in which the memory segment of given data source
 /// is.
 enum MemorySegmentState {
-    /// \brief The segment is local one.
-    MSS_LOCAL,
     /// \brief No segment used for this data source.
-    MSS_UNUSED,
+    ///
+    /// 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
     ///     it.
-    MSS_WAITING,
-    /// \brief A mapped segment and in active use.
-    MSS_MAPPED
+    SEGMENT_WAITING,
+
+    /// \brief The segment is ready to be used.
+    SEGMENT_MAPPED
 };
 
 /// \brief Status of one data source.

+ 4 - 4
src/lib/datasrc/tests/client_list_unittest.cc

@@ -575,9 +575,9 @@ TEST_F(ListTest, status) {
     const vector<DataSourceStatus> statuses(list_->getStatus());
     ASSERT_EQ(2, statuses.size());
     EXPECT_EQ("type1", statuses[0].getName());
-    EXPECT_EQ(MSS_UNUSED, statuses[0].getSegmentState());
+    EXPECT_EQ(SEGMENT_UNUSED, statuses[0].getSegmentState());
     EXPECT_EQ("Test name", statuses[1].getName());
-    EXPECT_EQ(MSS_LOCAL, statuses[1].getSegmentState());
+    EXPECT_EQ(SEGMENT_MAPPED, statuses[1].getSegmentState());
 }
 
 TEST_F(ListTest, wrongConfig) {
@@ -1163,9 +1163,9 @@ TYPED_TEST(ReloadTest, reloadMasterFile) {
 
 // Check the status holds data and can change the segment state
 TEST(DataSourceStatus, status) {
-    DataSourceStatus status("Test", MSS_UNUSED);
+    DataSourceStatus status("Test", SEGMENT_UNUSED);
     EXPECT_EQ("Test", status.getName());
-    EXPECT_EQ(MSS_UNUSED, status.getSegmentState());
+    EXPECT_EQ(SEGMENT_UNUSED, status.getSegmentState());
 }
 
 }