Browse Source

[2207] Rename updater to reloader

This might be less confusing.
Michal 'vorner' Vaner 12 years ago
parent
commit
58c41ea9cd

+ 1 - 1
src/lib/datasrc/memory/Makefile.am

@@ -22,7 +22,7 @@ libdatasrc_memory_la_SOURCES += zone_table.h zone_table.cc
 libdatasrc_memory_la_SOURCES += zone_finder.h zone_finder.cc
 libdatasrc_memory_la_SOURCES += zone_table_segment.h zone_table_segment.cc
 libdatasrc_memory_la_SOURCES += zone_table_segment_local.h zone_table_segment_local.cc
-libdatasrc_memory_la_SOURCES += zone_updater.h zone_updater.cc
+libdatasrc_memory_la_SOURCES += zone_reloader.h zone_reloader.cc
 nodist_libdatasrc_memory_la_SOURCES = memory_messages.h memory_messages.cc
 
 EXTRA_DIST  = rdata_serialization_priv.cc

+ 10 - 10
src/lib/datasrc/memory/zone_updater.cc

@@ -12,7 +12,7 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
-#include "zone_updater.h"
+#include "zone_reloader.h"
 #include "zone_data.h"
 #include "zone_table_segment.h"
 
@@ -24,11 +24,11 @@ namespace isc {
 namespace datasrc {
 namespace memory {
 
-ZoneUpdaterLocal::ZoneUpdaterLocal(ZoneTableSegment* segment,
-                                   const LoadAction& load_action,
-                                   const InstallAction& install_action,
-                                   const dns::Name& origin,
-                                   const dns::RRClass& rrclass) :
+ZoneReloaderLocal::ZoneReloaderLocal(ZoneTableSegment* segment,
+                                     const LoadAction& load_action,
+                                     const InstallAction& install_action,
+                                     const dns::Name& origin,
+                                     const dns::RRClass& rrclass) :
     segment_(segment),
     load_action_(load_action),
     install_action_(install_action),
@@ -39,14 +39,14 @@ ZoneUpdaterLocal::ZoneUpdaterLocal(ZoneTableSegment* segment,
     data_ready_(false)
 {}
 
-ZoneUpdaterLocal::~ZoneUpdaterLocal() {
+ZoneReloaderLocal::~ZoneReloaderLocal() {
     // Clean up everything there might be left if someone forgot, just
     // in case. Or should we assert instead?
     cleanup();
 }
 
 void
-ZoneUpdaterLocal::load() {
+ZoneReloaderLocal::load() {
     if (loaded_) {
         isc_throw(isc::Unexpected, "Trying to load twice");
     }
@@ -60,7 +60,7 @@ ZoneUpdaterLocal::load() {
 }
 
 void
-ZoneUpdaterLocal::install() {
+ZoneReloaderLocal::install() {
     if (!data_ready_) {
         isc_throw(isc::Unexpected, "No data to install");
     }
@@ -75,7 +75,7 @@ ZoneUpdaterLocal::install() {
 }
 
 void
-ZoneUpdaterLocal::cleanup() {
+ZoneReloaderLocal::cleanup() {
     // We eat the data (if any) now.
     data_ready_ = false;
 

+ 8 - 8
src/lib/datasrc/memory/zone_updater.h

@@ -34,7 +34,7 @@ class ZoneTableSegment;
 /// We divide them so the update of zone data can be done asynchronously,
 /// in a different thread. The install() operation is the only one that needs
 /// to be done in a critical section.
-class ZoneUpdater {
+class ZoneReloader {
 public:
     /// \brief Get the zone data into memory.
     ///
@@ -120,13 +120,13 @@ typedef boost::function<void(ZoneData*)> LoadAction;
 typedef boost::function<ZoneData* (const ZoneSegmentID&,
                                    ZoneSegment*)> InstallAction;
 
-/// \brief Updater implementation which loads data locally.
+/// \brief Reloader implementation which loads data locally.
 ///
 /// This implementation prepares a clean zone data and lets one callback
 /// to fill it and another to install it somewhere. The class does mostly
 /// nothing (and delegates the work to the callbacks), just stores little bit
 /// of state between the calls.
-class ZoneUpdaterLocal : public ZoneUpdater {
+class ZoneReloaderLocal : public ZoneReloader {
 public:
     /// \brief Constructor
     ///
@@ -135,12 +135,12 @@ public:
     /// \param install_action The callback used to install the loaded zone.
     /// \param origin The origin name of the zone.
     /// \param rrclass The class of the zone.
-    ZoneUpdaterLocal(ZoneTableSegment* segment, const LoadAction& load_action,
-                     const InstallAction& install_action,
-                     const dns::Name& origin,
-                     const dns::RRClass& rrclass);
+    ZoneReloaderLocal(ZoneTableSegment* segment, const LoadAction& load_action,
+                      const InstallAction& install_action,
+                      const dns::Name& origin,
+                      const dns::RRClass& rrclass);
     /// \brief Destructor
-    ~ZoneUpdaterLocal();
+    ~ZoneReloaderLocal();
     /// \brief Loads the data.
     ///
     /// This prepares an empty ZoneData and calls load_action (passed to

+ 1 - 1
src/lib/datasrc/tests/memory/Makefile.am

@@ -33,7 +33,7 @@ run_unittests_SOURCES += memory_segment_test.h
 run_unittests_SOURCES += segment_object_holder_unittest.cc
 run_unittests_SOURCES += memory_client_unittest.cc
 run_unittests_SOURCES += zone_table_segment_unittest.cc
-run_unittests_SOURCES += zone_updater_unittest.cc
+run_unittests_SOURCES += zone_reloader_unittest.cc
 
 run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 run_unittests_LDFLAGS  = $(AM_LDFLAGS)  $(GTEST_LDFLAGS)

+ 46 - 45
src/lib/datasrc/tests/memory/zone_updater_unittest.cc

@@ -12,7 +12,7 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
-#include <datasrc/memory/zone_updater.h>
+#include <datasrc/memory/zone_reloader.h>
 #include <datasrc/memory/zone_table_segment.h>
 #include <datasrc/memory/zone_data.h>
 
@@ -35,33 +35,34 @@ namespace {
 
 class TestException {};
 
-class ZoneUpdaterLocalTest : public ::testing::Test {
+class ZoneReloaderLocalTest : public ::testing::Test {
 public:
-    ZoneUpdaterLocalTest() :
+    ZoneReloaderLocalTest() :
         // FIXME: The NullElement probably isn't the best one, but we don't
         // know how the config will look, so it just fills the argument
         // (which is currently ignored)
         segment_(ZoneTableSegment::create(isc::data::NullElement())),
-        updater_(new
-            ZoneUpdaterLocal(segment_.get(),
-                             bind(&ZoneUpdaterLocalTest::loadAction, this, _1),
-                             bind(&ZoneUpdaterLocalTest::installAction, this,
-                                  _1, _2),
-                             Name("example.org"), RRClass::IN())),
+        reloader_(new
+            ZoneReloaderLocal(segment_.get(),
+                              bind(&ZoneReloaderLocalTest::loadAction, this,
+                                   _1),
+                              bind(&ZoneReloaderLocalTest::installAction, this,
+                                   _1, _2),
+                              Name("example.org"), RRClass::IN())),
         load_called_(false),
         install_called_(false),
         load_throw_(false),
         install_throw_(false)
     {}
     void TearDown() {
-        // Release the updater
-        updater_.reset();
+        // Release the reloader
+        reloader_.reset();
         // And check we freed all memory
         EXPECT_TRUE(segment_->getMemorySegment().allMemoryDeallocated());
     }
 protected:
     scoped_ptr<ZoneTableSegment> segment_;
-    scoped_ptr<ZoneUpdaterLocal> updater_;
+    scoped_ptr<ZoneReloaderLocal> reloader_;
     bool load_called_;
     bool install_called_;
     bool load_throw_;
@@ -106,83 +107,83 @@ private:
 
 // We call it the way we are supposed to, check every callback is called in the
 // right moment.
-TEST_F(ZoneUpdaterLocalTest, correctCall) {
+TEST_F(ZoneReloaderLocalTest, correctCall) {
     // Nothing called before we call it
     EXPECT_FALSE(load_called_);
     EXPECT_FALSE(install_called_);
 
     // Just the load gets called now
-    EXPECT_NO_THROW(updater_->load());
+    EXPECT_NO_THROW(reloader_->load());
     EXPECT_TRUE(load_called_);
     EXPECT_FALSE(install_called_);
     load_called_ = false;
 
-    EXPECT_NO_THROW(updater_->install());
+    EXPECT_NO_THROW(reloader_->install());
     EXPECT_FALSE(load_called_);
     EXPECT_TRUE(install_called_);
 
     // We don't check explicitly how this works, but call it to free memory. If
     // everything is freed should be checked inside the TearDown.
-    EXPECT_NO_THROW(updater_->cleanup());
+    EXPECT_NO_THROW(reloader_->cleanup());
 }
 
-TEST_F(ZoneUpdaterLocalTest, loadTwice) {
+TEST_F(ZoneReloaderLocalTest, loadTwice) {
     // Load it the first time
-    EXPECT_NO_THROW(updater_->load());
+    EXPECT_NO_THROW(reloader_->load());
     EXPECT_TRUE(load_called_);
     EXPECT_FALSE(install_called_);
     load_called_ = false;
 
     // The second time, it should not be possible
-    EXPECT_THROW(updater_->load(), isc::Unexpected);
+    EXPECT_THROW(reloader_->load(), isc::Unexpected);
     EXPECT_FALSE(load_called_);
     EXPECT_FALSE(install_called_);
 
     // The object should not be damaged, try installing and clearing now
-    EXPECT_NO_THROW(updater_->install());
+    EXPECT_NO_THROW(reloader_->install());
     EXPECT_FALSE(load_called_);
     EXPECT_TRUE(install_called_);
 
     // We don't check explicitly how this works, but call it to free memory. If
     // everything is freed should be checked inside the TearDown.
-    EXPECT_NO_THROW(updater_->cleanup());
+    EXPECT_NO_THROW(reloader_->cleanup());
 }
 
 // Try loading after call to install and call to cleanup. Both is
 // forbidden.
-TEST_F(ZoneUpdaterLocalTest, loadLater) {
+TEST_F(ZoneReloaderLocalTest, loadLater) {
     // Load first, so we can install
-    EXPECT_NO_THROW(updater_->load());
-    EXPECT_NO_THROW(updater_->install());
+    EXPECT_NO_THROW(reloader_->load());
+    EXPECT_NO_THROW(reloader_->install());
     // Reset so we see nothing is called now
     install_called_ = load_called_ = false;
 
-    EXPECT_THROW(updater_->load(), isc::Unexpected);
+    EXPECT_THROW(reloader_->load(), isc::Unexpected);
     EXPECT_FALSE(load_called_);
     EXPECT_FALSE(install_called_);
 
     // Cleanup and try loading again. Still shouldn't work.
-    EXPECT_NO_THROW(updater_->cleanup());
+    EXPECT_NO_THROW(reloader_->cleanup());
 
-    EXPECT_THROW(updater_->load(), isc::Unexpected);
+    EXPECT_THROW(reloader_->load(), isc::Unexpected);
     EXPECT_FALSE(load_called_);
     EXPECT_FALSE(install_called_);
 }
 
 // Try calling install at various bad times
-TEST_F(ZoneUpdaterLocalTest, invalidInstall) {
+TEST_F(ZoneReloaderLocalTest, invalidInstall) {
     // Nothing loaded yet
-    EXPECT_THROW(updater_->install(), isc::Unexpected);
+    EXPECT_THROW(reloader_->install(), isc::Unexpected);
     EXPECT_FALSE(load_called_);
     EXPECT_FALSE(install_called_);
 
-    EXPECT_NO_THROW(updater_->load());
+    EXPECT_NO_THROW(reloader_->load());
     load_called_ = false;
     // This install is OK
-    EXPECT_NO_THROW(updater_->install());
+    EXPECT_NO_THROW(reloader_->install());
     install_called_ = false;
     // But we can't call it second time now
-    EXPECT_THROW(updater_->install(), isc::Unexpected);
+    EXPECT_THROW(reloader_->install(), isc::Unexpected);
     EXPECT_FALSE(load_called_);
     EXPECT_FALSE(install_called_);
 }
@@ -190,47 +191,47 @@ TEST_F(ZoneUpdaterLocalTest, invalidInstall) {
 // We check we can clean without installing first and nothing bad
 // happens. We also misuse the testcase to check we can't install
 // after cleanup.
-TEST_F(ZoneUpdaterLocalTest, cleanWithoutInstall) {
-    EXPECT_NO_THROW(updater_->load());
-    EXPECT_NO_THROW(updater_->cleanup());
+TEST_F(ZoneReloaderLocalTest, cleanWithoutInstall) {
+    EXPECT_NO_THROW(reloader_->load());
+    EXPECT_NO_THROW(reloader_->cleanup());
 
     EXPECT_TRUE(load_called_);
     EXPECT_FALSE(install_called_);
 
     // We cleaned up, no way to install now
-    EXPECT_THROW(updater_->install(), isc::Unexpected);
+    EXPECT_THROW(reloader_->install(), isc::Unexpected);
     EXPECT_FALSE(install_called_);
 }
 
 // Test the case when load callback throws
-TEST_F(ZoneUpdaterLocalTest, loadThrows) {
+TEST_F(ZoneReloaderLocalTest, loadThrows) {
     load_throw_ = true;
-    EXPECT_THROW(updater_->load(), TestException);
+    EXPECT_THROW(reloader_->load(), TestException);
 
     // We can't install now
-    EXPECT_THROW(updater_->install(), isc::Unexpected);
+    EXPECT_THROW(reloader_->install(), isc::Unexpected);
     EXPECT_TRUE(load_called_);
     EXPECT_FALSE(install_called_);
 
     // But we can cleanup
-    EXPECT_NO_THROW(updater_->cleanup());
+    EXPECT_NO_THROW(reloader_->cleanup());
 }
 
 // Test we free all our memory even when we throw from install
-TEST_F(ZoneUpdaterLocalTest, installThrows) {
+TEST_F(ZoneReloaderLocalTest, installThrows) {
     install_throw_ = true;
-    EXPECT_NO_THROW(updater_->load());
+    EXPECT_NO_THROW(reloader_->load());
 
-    EXPECT_THROW(updater_->install(), TestException);
+    EXPECT_THROW(reloader_->install(), TestException);
     EXPECT_TRUE(load_called_);
     EXPECT_TRUE(install_called_);
 
     // We can't try again
     install_throw_ = false;
-    EXPECT_THROW(updater_->install(), isc::Unexpected);
+    EXPECT_THROW(reloader_->install(), isc::Unexpected);
 
     // But it is not completely broken
-    EXPECT_NO_THROW(updater_->cleanup());
+    EXPECT_NO_THROW(reloader_->cleanup());
 }
 
 }