From: Michal 'vorner' Vaner Date: Thu, 19 Jul 2012 09:27:53 +0000 (+0200) Subject: [1976] Remove more unused code X-Git-Tag: trac2351_base~97^2~7^2~2^2~21^2^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=64d096e98b2f1803e0e5f5f36986a59c4cd90dff;p=thirdparty%2Fkea.git [1976] Remove more unused code This one is mostly the hot-spot cache. The new data source model does not use it at all. Also, the parameters to tune it were removed. --- diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc index dbba26f174..a6e59966c2 100644 --- a/src/bin/auth/auth_srv.cc +++ b/src/bin/auth/auth_srv.cc @@ -221,10 +221,9 @@ private: AuthSrvImpl(const AuthSrvImpl& source); AuthSrvImpl& operator=(const AuthSrvImpl& source); public: - AuthSrvImpl(const bool use_cache, AbstractXfroutClient& xfrout_client, + AuthSrvImpl(AbstractXfroutClient& xfrout_client, BaseSocketSessionForwarder& ddns_forwarder); ~AuthSrvImpl(); - isc::data::ConstElementPtr setDbFile(isc::data::ConstElementPtr config); bool processNormalQuery(const IOMessage& io_message, Message& message, OutputBuffer& buffer, @@ -247,10 +246,6 @@ public: ModuleCCSession* config_session_; AbstractSession* xfrin_session_; - /// In-memory data source. Currently class IN only for simplicity. - /// Hot spot cache - isc::datasrc::HotCache cache_; - /// Interval timer for periodic submission of statistics counters. IntervalTimer statistics_timer_; @@ -313,8 +308,7 @@ private: auth::Query query_; }; -AuthSrvImpl::AuthSrvImpl(const bool use_cache, - AbstractXfroutClient& xfrout_client, +AuthSrvImpl::AuthSrvImpl(AbstractXfroutClient& xfrout_client, BaseSocketSessionForwarder& ddns_forwarder) : config_session_(NULL), xfrin_session_(NULL), @@ -324,10 +318,7 @@ AuthSrvImpl::AuthSrvImpl(const bool use_cache, xfrout_connected_(false), xfrout_client_(xfrout_client), ddns_forwarder_("update", ddns_forwarder) -{ - // enable or disable the cache - cache_.setEnabled(use_cache); -} +{} AuthSrvImpl::~AuthSrvImpl() { if (xfrout_connected_) { @@ -386,11 +377,10 @@ private: AuthSrv* server_; }; -AuthSrv::AuthSrv(const bool use_cache, - isc::xfr::AbstractXfroutClient& xfrout_client, +AuthSrv::AuthSrv(isc::xfr::AbstractXfroutClient& xfrout_client, isc::util::io::BaseSocketSessionForwarder& ddns_forwarder) { - impl_ = new AuthSrvImpl(use_cache, xfrout_client, ddns_forwarder); + impl_ = new AuthSrvImpl(xfrout_client, ddns_forwarder); checkin_ = new ConfigChecker(this); dns_lookup_ = new MessageLookup(this); dns_answer_ = new MessageAnswer(this); @@ -469,16 +459,6 @@ AuthSrv::getIOService() { return (impl_->io_service_); } -void -AuthSrv::setCacheSlots(const size_t slots) { - impl_->cache_.setSlots(slots); -} - -size_t -AuthSrv::getCacheSlots() const { - return (impl_->cache_.getSlots()); -} - void AuthSrv::setXfrinSession(AbstractSession* xfrin_session) { impl_->xfrin_session_ = xfrin_session; diff --git a/src/bin/auth/auth_srv.h b/src/bin/auth/auth_srv.h index ef2f121562..3d0c5fb0b8 100644 --- a/src/bin/auth/auth_srv.h +++ b/src/bin/auth/auth_srv.h @@ -92,13 +92,11 @@ private: public: /// The constructor. /// - /// \param use_cache Whether to enable hot spot cache for lookup results. /// \param xfrout_client Communication interface with a separate xfrout /// process. It's normally a reference to an xfr::XfroutClient object, /// but can refer to a local mock object for testing (or other /// experimental) purposes. - AuthSrv(const bool use_cache, - isc::xfr::AbstractXfroutClient& xfrout_client, + AuthSrv(isc::xfr::AbstractXfroutClient& xfrout_client, isc::util::io::BaseSocketSessionForwarder& ddns_forwarder); ~AuthSrv(); //@} @@ -187,26 +185,6 @@ public: /// \brief Return pointer to the Checkin callback function isc::asiolink::SimpleCallback* getCheckinProvider() const { return (checkin_); } - /// \brief Set or update the size (number of slots) of hot spot cache. - /// - /// If the specified size is 0, it means the size will be unlimited. - /// The specified size is recorded even if the cache is disabled; the - /// new size will be effective when the cache is enabled. - /// - /// This method never throws an exception. - /// - /// \param slots The number of cache slots. - void setCacheSlots(const size_t slots); - - /// \brief Get the current size (number of slots) of hot spot cache. - /// - /// It always returns the recorded size regardless of the cache is enabled. - /// - /// This method never throws an exception. - /// - /// \return The current number of cache slots. - size_t getCacheSlots() const; - /// \brief Set the communication session with a separate process for /// outgoing zone transfers. /// diff --git a/src/bin/auth/b10-auth.xml b/src/bin/auth/b10-auth.xml index 44c036f040..37843e3de8 100644 --- a/src/bin/auth/b10-auth.xml +++ b/src/bin/auth/b10-auth.xml @@ -44,7 +44,6 @@ b10-auth - @@ -79,18 +78,6 @@ The arguments are as follows: - - - - Do not cache answers in memory. - The default is to use the cache for faster responses. - The cache keeps the most recent 30,000 answers (positive - and negative) in memory for 30 seconds (instead of querying - the data source, such as SQLite3 database, each time). - - - - diff --git a/src/bin/auth/benchmarks/query_bench.cc b/src/bin/auth/benchmarks/query_bench.cc index 2e705e4f2b..6314ab9311 100644 --- a/src/bin/auth/benchmarks/query_bench.cc +++ b/src/bin/auth/benchmarks/query_bench.cc @@ -77,10 +77,9 @@ protected: private: typedef boost::shared_ptr IOEndpointPtr; protected: - QueryBenchMark(const bool enable_cache, - const BenchQueries& queries, Message& query_message, + QueryBenchMark(const BenchQueries& queries, Message& query_message, OutputBuffer& buffer) : - server_(new AuthSrv(enable_cache, xfrout_client, ddns_forwarder)), + server_(new AuthSrv(xfrout_client, ddns_forwarder)), queries_(queries), query_message_(query_message), buffer_(buffer), @@ -119,17 +118,12 @@ private: class Sqlite3QueryBenchMark : public QueryBenchMark { public: - Sqlite3QueryBenchMark(const int cache_slots, - const char* const datasrc_file, + Sqlite3QueryBenchMark(const char* const datasrc_file, const BenchQueries& queries, Message& query_message, OutputBuffer& buffer) : - QueryBenchMark(cache_slots >= 0 ? true : false, queries, - query_message, buffer) + QueryBenchMark(queries, query_message, buffer) { - if (cache_slots >= 0) { - server_->setCacheSlots(cache_slots); - } server_->updateConfig(Element::fromJSON("{\"database_file\": \"" + string(datasrc_file) + "\"}")); } @@ -142,7 +136,7 @@ public: const BenchQueries& queries, Message& query_message, OutputBuffer& buffer) : - QueryBenchMark(false, queries, query_message, buffer) + QueryBenchMark(queries, query_message, buffer) { configureAuthServer(*server_, Element::fromJSON( @@ -274,27 +268,9 @@ main(int argc, char* argv[]) { switch (datasrc_type) { case SQLITE3: - cout << "Benchmark enabling Hot Spot Cache with unlimited slots " - << endl; - BenchMark( - iteration, Sqlite3QueryBenchMark(0, datasrc_file, queries, - message, buffer)); - - cout << "Benchmark enabling Hot Spot Cache with 10*#queries slots " - << endl; - BenchMark( - iteration, Sqlite3QueryBenchMark(10 * queries.size(), datasrc_file, - queries, message, buffer)); - - cout << "Benchmark enabling Hot Spot Cache with #queries/2 slots " - << endl; - BenchMark( - iteration, Sqlite3QueryBenchMark(queries.size() / 2, datasrc_file, - queries, message, buffer)); - - cout << "Benchmark disabling Hot Spot Cache" << endl; + cout << "Benchmark with SQLite3" << endl; BenchMark( - iteration, Sqlite3QueryBenchMark(-1, datasrc_file, queries, + iteration, Sqlite3QueryBenchMark(datasrc_file, queries, message, buffer)); break; case MEMORY: diff --git a/src/bin/auth/main.cc b/src/bin/auth/main.cc index be854c97ac..0abb5b27f1 100644 --- a/src/bin/auth/main.cc +++ b/src/bin/auth/main.cc @@ -85,9 +85,8 @@ my_command_handler(const string& command, ConstElementPtr args) { void usage() { - cerr << "Usage: b10-auth [-u user] [-nv]" + cerr << "Usage: b10-auth [-v]" << endl; - cerr << "\t-n: do not cache answers in memory" << endl; cerr << "\t-v: verbose logging (debug-level)" << endl; exit(1); } @@ -97,14 +96,10 @@ usage() { int main(int argc, char* argv[]) { int ch; - bool cache = true; bool verbose = false; while ((ch = getopt(argc, argv, ":nu:v")) != -1) { switch (ch) { - case 'n': - cache = false; - break; case 'v': verbose = true; break; @@ -143,7 +138,7 @@ main(int argc, char* argv[]) { specfile = string(AUTH_SPECFILE_LOCATION); } - auth_server = new AuthSrv(cache, xfrout_client, ddns_forwarder); + auth_server = new AuthSrv(xfrout_client, ddns_forwarder); LOG_INFO(auth_logger, AUTH_SERVER_CREATED); SimpleCallback* checkin = auth_server->getCheckinProvider(); diff --git a/src/bin/auth/tests/auth_srv_unittest.cc b/src/bin/auth/tests/auth_srv_unittest.cc index c8b870a70b..1db152772e 100644 --- a/src/bin/auth/tests/auth_srv_unittest.cc +++ b/src/bin/auth/tests/auth_srv_unittest.cc @@ -91,7 +91,7 @@ class AuthSrvTest : public SrvTestBase { protected: AuthSrvTest() : dnss_(), - server(true, xfrout, ddns_forwarder), + server(xfrout, ddns_forwarder), // The empty string is expected value of the parameter of // requestSocket, not the app_name (there's no fallback, it checks // the empty string is passed). @@ -1032,16 +1032,6 @@ TEST_F(AuthSrvTest, opcode.getCode(), QR_FLAG | AA_FLAG, 1, 1, 1, 0); } -TEST_F(AuthSrvTest, cacheSlots) { - // simple check for the get/set operations - server.setCacheSlots(10); // 10 = arbitrary choice - EXPECT_EQ(10, server.getCacheSlots()); - - // 0 is a valid size - server.setCacheSlots(0); - EXPECT_EQ(00, server.getCacheSlots()); -} - // Submit UDP normal query and check query counter TEST_F(AuthSrvTest, queryCounterUDPNormal) { // The counter should be initialized to 0. @@ -1677,7 +1667,7 @@ TEST_F(AuthSrvTest, DDNSForwardPushFail) { } TEST_F(AuthSrvTest, DDNSForwardClose) { - scoped_ptr tmp_server(new AuthSrv(true, xfrout, ddns_forwarder)); + scoped_ptr tmp_server(new AuthSrv(xfrout, ddns_forwarder)); UnitTestUtil::createRequestMessage(request_message, Opcode::UPDATE(), default_qid, Name("example.com"), RRClass::IN(), RRType::SOA()); diff --git a/src/bin/auth/tests/command_unittest.cc b/src/bin/auth/tests/command_unittest.cc index a679aa73af..bb2e7c37af 100644 --- a/src/bin/auth/tests/command_unittest.cc +++ b/src/bin/auth/tests/command_unittest.cc @@ -63,7 +63,7 @@ namespace { class AuthCommandTest : public ::testing::Test { protected: AuthCommandTest() : - server_(false, xfrout_, ddns_forwarder_), + server_(xfrout_, ddns_forwarder_), rcode_(-1), expect_rcode_(0), itimer_(server_.getIOService()) diff --git a/src/bin/auth/tests/config_unittest.cc b/src/bin/auth/tests/config_unittest.cc index 748e63b46e..c4d1db7080 100644 --- a/src/bin/auth/tests/config_unittest.cc +++ b/src/bin/auth/tests/config_unittest.cc @@ -54,7 +54,7 @@ protected: AuthConfigTest() : dnss_(), rrclass(RRClass::IN()), - server(true, xfrout, ddns_forwarder), + server(xfrout, ddns_forwarder), // The empty string is expected value of the parameter of // requestSocket, not the app_name (there's no fallback, it checks // the empty string is passed). diff --git a/src/bin/bind10/bind10.xml b/src/bin/bind10/bind10.xml index 40537830ec..cfd5b524ef 100644 --- a/src/bin/bind10/bind10.xml +++ b/src/bin/bind10/bind10.xml @@ -47,7 +47,6 @@ - @@ -57,7 +56,6 @@ config-filename directory - filename @@ -168,15 +166,6 @@ - - , - - Disables the hot-spot caching used by the - b10-auth8 - daemon. - - - , diff --git a/src/bin/bind10/bind10_src.py.in b/src/bin/bind10/bind10_src.py.in index b9dbc3656d..7b71737f7b 100755 --- a/src/bin/bind10/bind10_src.py.in +++ b/src/bin/bind10/bind10_src.py.in @@ -168,7 +168,7 @@ class BoB: """Boss of BIND class.""" def __init__(self, msgq_socket_file=None, data_path=None, - config_filename=None, clear_config=False, nocache=False, + config_filename=None, clear_config=False, verbose=False, nokill=False, setuid=None, setgid=None, username=None, cmdctl_port=None, wait_time=10): """ @@ -192,7 +192,6 @@ class BoB: self.ccs = None self.curproc = None self.msgq_socket_file = msgq_socket_file - self.nocache = nocache self.component_config = {} # Some time in future, it may happen that a single component has # multple processes (like a pipeline-like component). If so happens, @@ -568,8 +567,6 @@ class BoB: if self.uid is not None and self.__started: logger.warn(BIND10_START_AS_NON_ROOT_AUTH) authargs = ['b10-auth'] - if self.nocache: - authargs += ['-n'] if self.verbose: authargs += ['-v'] @@ -1052,8 +1049,6 @@ def parse_args(args=sys.argv[1:], Parser=OptionParser): parser.add_option("-m", "--msgq-socket-file", dest="msgq_socket_file", type="string", default=None, help="UNIX domain socket file the b10-msgq daemon will use") - parser.add_option("-n", "--no-cache", action="store_true", dest="nocache", - default=False, help="disable hot-spot cache in authoritative DNS server") parser.add_option("-i", "--no-kill", action="store_true", dest="nokill", default=False, help="do not send SIGTERM and SIGKILL signals to modules during shutdown") parser.add_option("-u", "--user", dest="user", type="string", default=None, @@ -1208,7 +1203,7 @@ def main(): # Go bob! boss_of_bind = BoB(options.msgq_socket_file, options.data_path, options.config_file, options.clear_config, - options.nocache, options.verbose, options.nokill, + options.verbose, options.nokill, setuid, setgid, username, options.cmdctl_port, options.wait_time) startup_result = boss_of_bind.startup() diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in index 6ed7411050..0a17230881 100644 --- a/src/bin/bind10/tests/bind10_test.py.in +++ b/src/bin/bind10/tests/bind10_test.py.in @@ -349,7 +349,6 @@ class TestBoB(unittest.TestCase): self.assertEqual(bob.runnable, False) self.assertEqual(bob.uid, None) self.assertEqual(bob.username, None) - self.assertEqual(bob.nocache, False) self.assertIsNone(bob._socket_cache) def test_set_creator(self): @@ -377,7 +376,6 @@ class TestBoB(unittest.TestCase): self.assertEqual(bob.runnable, False) self.assertEqual(bob.uid, None) self.assertEqual(bob.username, None) - self.assertEqual(bob.nocache, False) def test_command_handler(self): class DummySession(): diff --git a/tests/lettuce/features/terrain/bind10_control.py b/tests/lettuce/features/terrain/bind10_control.py index a08a887ca4..c0370a9bc2 100644 --- a/tests/lettuce/features/terrain/bind10_control.py +++ b/tests/lettuce/features/terrain/bind10_control.py @@ -52,7 +52,7 @@ def start_bind10(step, config_file, cmdctl_port, msgq_sockfile, process_name): It will also fail if there is a running process with the given process_name already. """ - args = [ 'bind10', '-n', '-v' ] + args = [ 'bind10', '-v' ] if config_file is not None: args.append('-p') args.append("configurations/")