BIND 10 trac2856, updated. 724e39ef6eaba76229a8208d2bf33449f16f3c01 [2856] Use deque instead of a list to store events

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Jul 24 09:42:11 UTC 2013


The branch, trac2856 has been updated
       via  724e39ef6eaba76229a8208d2bf33449f16f3c01 (commit)
       via  941c1d8bfc0468b585039c92eba3165e20f6d08d (commit)
       via  40471d97b2dbe22189147f2f46f5956c587fa34f (commit)
      from  1f09795960479dcbe6e53ae9ead9f969c0705107 (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 724e39ef6eaba76229a8208d2bf33449f16f3c01
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Jul 24 15:09:54 2013 +0530

    [2856] Use deque instead of a list to store events
    
    ... for faster pops from position 0 of the list.

commit 941c1d8bfc0468b585039c92eba3165e20f6d08d
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Jul 24 15:00:52 2013 +0530

    [2856] Fix copyright year

commit 40471d97b2dbe22189147f2f46f5956c587fa34f
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Jul 24 14:59:59 2013 +0530

    [2856] Rename memmgr module mes file to libmemmgr to avoid conflict

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

Summary of changes:
 src/lib/python/isc/log_messages/Makefile.am        |    2 ++
 .../python/isc/log_messages/libmemmgr_messages.py  |    1 +
 src/lib/python/isc/memmgr/Makefile.am              |   14 +++++++-------
 src/lib/python/isc/memmgr/builder.py               |   10 +++++-----
 src/lib/python/isc/memmgr/datasrc_info.py          |    9 ++++-----
 ...{memmgr_messages.mes => libmemmgr_messages.mes} |    8 ++++----
 src/lib/python/isc/memmgr/logger.py                |    4 ++--
 7 files changed, 25 insertions(+), 23 deletions(-)
 create mode 100644 src/lib/python/isc/log_messages/libmemmgr_messages.py
 rename src/lib/python/isc/memmgr/{memmgr_messages.mes => libmemmgr_messages.mes} (79%)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/log_messages/Makefile.am b/src/lib/python/isc/log_messages/Makefile.am
index caf1e3b..3e265d7 100644
--- a/src/lib/python/isc/log_messages/Makefile.am
+++ b/src/lib/python/isc/log_messages/Makefile.am
@@ -4,6 +4,7 @@ EXTRA_DIST = __init__.py
 EXTRA_DIST += init_messages.py
 EXTRA_DIST += cmdctl_messages.py
 EXTRA_DIST += ddns_messages.py
+EXTRA_DIST += libmemmgr_messages.py
 EXTRA_DIST += memmgr_messages.py
 EXTRA_DIST += stats_messages.py
 EXTRA_DIST += stats_httpd_messages.py
@@ -25,6 +26,7 @@ CLEANFILES = __init__.pyc
 CLEANFILES += init_messages.pyc
 CLEANFILES += cmdctl_messages.pyc
 CLEANFILES += ddns_messages.pyc
+CLEANFILES += libmemmgr_messages.pyc
 CLEANFILES += memmgr_messages.pyc
 CLEANFILES += stats_messages.pyc
 CLEANFILES += stats_httpd_messages.pyc
diff --git a/src/lib/python/isc/log_messages/libmemmgr_messages.py b/src/lib/python/isc/log_messages/libmemmgr_messages.py
new file mode 100644
index 0000000..3aedc3f
--- /dev/null
+++ b/src/lib/python/isc/log_messages/libmemmgr_messages.py
@@ -0,0 +1 @@
+from work.libmemmgr_messages import *
diff --git a/src/lib/python/isc/memmgr/Makefile.am b/src/lib/python/isc/memmgr/Makefile.am
index a2919e5..5529570 100644
--- a/src/lib/python/isc/memmgr/Makefile.am
+++ b/src/lib/python/isc/memmgr/Makefile.am
@@ -4,20 +4,20 @@ python_PYTHON = __init__.py builder.py datasrc_info.py logger.py
 
 pythondir = $(pyexecdir)/isc/memmgr
 
-BUILT_SOURCES = $(PYTHON_LOGMSGPKG_DIR)/work/memmgr_messages.py
+BUILT_SOURCES = $(PYTHON_LOGMSGPKG_DIR)/work/libmemmgr_messages.py
 
-nodist_pylogmessage_PYTHON = $(PYTHON_LOGMSGPKG_DIR)/work/memmgr_messages.py
+nodist_pylogmessage_PYTHON = $(PYTHON_LOGMSGPKG_DIR)/work/libmemmgr_messages.py
 
 pylogmessagedir = $(pyexecdir)/isc/log_messages/
 
-CLEANFILES = $(PYTHON_LOGMSGPKG_DIR)/work/memmgr_messages.py
-CLEANFILES += $(PYTHON_LOGMSGPKG_DIR)/work/memmgr_messages.pyc
+CLEANFILES = $(PYTHON_LOGMSGPKG_DIR)/work/libmemmgr_messages.py
+CLEANFILES += $(PYTHON_LOGMSGPKG_DIR)/work/libmemmgr_messages.pyc
 
-EXTRA_DIST = memmgr_messages.mes
+EXTRA_DIST = libmemmgr_messages.mes
 
-$(PYTHON_LOGMSGPKG_DIR)/work/memmgr_messages.py : memmgr_messages.mes
+$(PYTHON_LOGMSGPKG_DIR)/work/libmemmgr_messages.py : libmemmgr_messages.mes
 	$(top_builddir)/src/lib/log/compiler/message \
-	-d $(PYTHON_LOGMSGPKG_DIR)/work -p $(srcdir)/memmgr_messages.mes
+	-d $(PYTHON_LOGMSGPKG_DIR)/work -p $(srcdir)/libmemmgr_messages.mes
 
 CLEANDIRS = __pycache__
 
diff --git a/src/lib/python/isc/memmgr/builder.py b/src/lib/python/isc/memmgr/builder.py
index 0b27006..9c3738e 100644
--- a/src/lib/python/isc/memmgr/builder.py
+++ b/src/lib/python/isc/memmgr/builder.py
@@ -17,7 +17,7 @@ import json
 from isc.datasrc import ConfigurableClientList
 from isc.memmgr.datasrc_info import SegmentInfo
 
-from isc.log_messages.memmgr_messages import *
+from isc.log_messages.libmemmgr_messages import *
 from isc.memmgr.logger import logger
 
 class MemorySegmentBuilder:
@@ -69,7 +69,7 @@ class MemorySegmentBuilder:
         # in this case as we are likely running in a different thread
         # from the main thread which would need to be notified. Instead
         # return this in the response queue.
-        logger.error(MEMMGR_BUILDER_BAD_COMMAND_ERROR, bad_command)
+        logger.error(LIBMEMMGR_BUILDER_BAD_COMMAND_ERROR, bad_command)
         self._response_queue.append(('bad_command',))
         self._shutdown = True
 
@@ -110,16 +110,16 @@ class MemorySegmentBuilder:
             result, writer = clist.get_cached_zone_writer(zone_name, catch_load_error,
                                                           dsrc_name)
             if result != ConfigurableClientList.CACHE_STATUS_ZONE_SUCCESS:
-                logger.error(MEMMGR_BUILDER_GET_ZONE_WRITER_ERROR, zone_name, dsrc_name)
+                logger.error(LIBMEMMGR_BUILDER_GET_ZONE_WRITER_ERROR, zone_name, dsrc_name)
                 continue
 
             try:
                 error = writer.load()
                 if error is not None:
-                    logger.error(MEMMGR_BUILDER_ZONE_WRITER_LOAD_1_ERROR, zone_name, dsrc_name, error)
+                    logger.error(LIBMEMMGR_BUILDER_ZONE_WRITER_LOAD_1_ERROR, zone_name, dsrc_name, error)
                     continue
             except Exception as e:
-                logger.error(MEMMGR_BUILDER_ZONE_WRITER_LOAD_2_ERROR, zone_name, dsrc_name, str(e))
+                logger.error(LIBMEMMGR_BUILDER_ZONE_WRITER_LOAD_2_ERROR, zone_name, dsrc_name, str(e))
                 continue
             writer.install()
             writer.cleanup()
diff --git a/src/lib/python/isc/memmgr/datasrc_info.py b/src/lib/python/isc/memmgr/datasrc_info.py
index 65502e3..84d8bb4 100644
--- a/src/lib/python/isc/memmgr/datasrc_info.py
+++ b/src/lib/python/isc/memmgr/datasrc_info.py
@@ -14,6 +14,7 @@
 # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 import os
+from collections import deque
 
 class SegmentInfoError(Exception):
     """An exception raised for general errors in the SegmentInfo class."""
@@ -83,7 +84,7 @@ class SegmentInfo:
         # READY state. This maintains such pending events in the order
         # they arrived. SegmentInfo doesn't have to know the details of
         # the stored data; it only matters for the memmgr.
-        self.__events = []
+        self.__events = deque()
 
     def get_state(self):
         """Returns the state of SegmentInfo (UPDATING, SYNCHRONIZING,
@@ -104,7 +105,7 @@ class SegmentInfo:
 
     def get_events(self):
         """Returns a list of pending events in the order they arrived."""
-        return self.__events
+        return list(self.__events)
 
     # Helper method used in complete_update(), sync_reader() and
     # remove_reader().
@@ -112,9 +113,7 @@ class SegmentInfo:
         if not self.__old_readers:
             self.__state = new_state
             if self.__events:
-                e = self.__events[0]
-                del self.__events[0]
-                return e
+                return self.__events.popleft()
 
         return None
 
diff --git a/src/lib/python/isc/memmgr/libmemmgr_messages.mes b/src/lib/python/isc/memmgr/libmemmgr_messages.mes
new file mode 100644
index 0000000..c8fcf05
--- /dev/null
+++ b/src/lib/python/isc/memmgr/libmemmgr_messages.mes
@@ -0,0 +1,35 @@
+# Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+# No namespace declaration - these constants go in the global namespace
+# of the config_messages python module.
+
+% LIBMEMMGR_BUILDER_BAD_COMMAND_ERROR MemorySegmentBuilder received bad command '%1'
+The MemorySegmentBuilder has received a bad command in its input command
+queue. This is likely a programming error. If the builder runs in a
+separate thread, this would cause it to exit the thread.
+
+% LIBMEMMGR_BUILDER_GET_ZONE_WRITER_ERROR Unable to get zone writer for zone '%1', data source '%2'. Skipping.
+The MemorySegmentBuilder was unable to get a ZoneWriter for the
+specified zone when handling the load command. This zone will be
+skipped.
+
+% LIBMEMMGR_BUILDER_ZONE_WRITER_LOAD_1_ERROR Error loading zone '%1', data source '%2': '%3'
+The MemorySegmentBuilder failed to load the specified zone when handling
+the load command. This zone will be skipped.
+
+% LIBMEMMGR_BUILDER_ZONE_WRITER_LOAD_2_ERROR Error loading zone '%1', data source '%2': '%3'
+An exception occured when the MemorySegmentBuilder tried to load the
+specified zone when handling the load command. This zone will be
+skipped.
diff --git a/src/lib/python/isc/memmgr/logger.py b/src/lib/python/isc/memmgr/logger.py
index 804d58f..eb324cf 100644
--- a/src/lib/python/isc/memmgr/logger.py
+++ b/src/lib/python/isc/memmgr/logger.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
 #
 # Permission to use, copy, modify, and distribute this software for any
 # purpose with or without fee is hereby granted, provided that the above
@@ -17,4 +17,4 @@
 
 import isc.log
 
-logger = isc.log.Logger("memmgr")
+logger = isc.log.Logger("libmemmgr")
diff --git a/src/lib/python/isc/memmgr/memmgr_messages.mes b/src/lib/python/isc/memmgr/memmgr_messages.mes
deleted file mode 100644
index 3625b01..0000000
--- a/src/lib/python/isc/memmgr/memmgr_messages.mes
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-# PERFORMANCE OF THIS SOFTWARE.
-
-# No namespace declaration - these constants go in the global namespace
-# of the config_messages python module.
-
-% MEMMGR_BUILDER_BAD_COMMAND_ERROR MemorySegmentBuilder received bad command '%1'
-The MemorySegmentBuilder has received a bad command in its input command
-queue. This is likely a programming error. If the builder runs in a
-separate thread, this would cause it to exit the thread.
-
-% MEMMGR_BUILDER_GET_ZONE_WRITER_ERROR Unable to get zone writer for zone '%1', data source '%2'. Skipping.
-The MemorySegmentBuilder was unable to get a ZoneWriter for the
-specified zone when handling the load command. This zone will be
-skipped.
-
-% MEMMGR_BUILDER_ZONE_WRITER_LOAD_1_ERROR Error loading zone '%1', data source '%2': '%3'
-The MemorySegmentBuilder failed to load the specified zone when handling
-the load command. This zone will be skipped.
-
-% MEMMGR_BUILDER_ZONE_WRITER_LOAD_2_ERROR Error loading zone '%1', data source '%2': '%3'
-An exception occured when the MemorySegmentBuilder tried to load the
-specified zone when handling the load command. This zone will be
-skipped.



More information about the bind10-changes mailing list