summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2010-06-04 19:20:21 +0000
committerSol Jerome <solj@ices.utexas.edu>2010-06-07 08:42:52 -0500
commit20f1d3918ecbb22a3452c705ee0139a1ebe1265e (patch)
tree3817814ab8c44e9759e450736443291d8f8c24ac /src
parent8c4089d7e33a3eae0a53613b1fe491d7808a9ba3 (diff)
downloadbcfg2-20f1d3918ecbb22a3452c705ee0139a1ebe1265e.tar.gz
bcfg2-20f1d3918ecbb22a3452c705ee0139a1ebe1265e.tar.bz2
bcfg2-20f1d3918ecbb22a3452c705ee0139a1ebe1265e.zip
Switching Statistics.py to ThreadedStatistics
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5890 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Plugins/Statistics.py25
1 files changed, 6 insertions, 19 deletions
diff --git a/src/lib/Server/Plugins/Statistics.py b/src/lib/Server/Plugins/Statistics.py
index cbd602d8c..74e676243 100644
--- a/src/lib/Server/Plugins/Statistics.py
+++ b/src/lib/Server/Plugins/Statistics.py
@@ -114,33 +114,20 @@ class StatisticsStore(object):
class Statistics(Bcfg2.Server.Plugin.Plugin,
- Bcfg2.Server.Plugin.Statistics,
+ Bcfg2.Server.Plugin.ThreadedStatistics,
Bcfg2.Server.Plugin.PullSource):
name = 'Statistics'
__version__ = '$Id$'
def __init__(self, core, datastore):
Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore)
- Bcfg2.Server.Plugin.Statistics.__init__(self)
+ Bcfg2.Server.Plugin.ThreadedStatistics.__init__(self, core, datastore)
Bcfg2.Server.Plugin.PullSource.__init__(self)
- self.fpath = "%s/etc/statistics.xml" % datastore
- # Event from the core signaling an exit
- self.terminate = core.terminate
- self.work_queue = Queue.Queue()
- self.worker = threading.Thread(target=self.process_statistics_loop)
- self.worker.start()
-
- def process_statistics_loop(self):
- self.data_file = StatisticsStore(self.fpath)
- while not (self.terminate.isSet() and self.work_queue.empty()):
- try:
- (xdata, hostname) = self.work_queue.get(block=True, timeout=5)
- except:
- continue
- self.data_file.updateStats(xdata, hostname)
+ fpath = "%s/etc/statistics.xml" % datastore
+ self.data_file = StatisticsStore(fpath)
- def process_statistics(self, client, xdata):
- self.work_queue.put((copy.deepcopy(xdata), client.hostname))
+ def handle_statistic(self, metadata, data):
+ self.data_file.updateStats(data, metadata.hostname)
def FindCurrent(self, client):
rt = self.data_file.element.xpath('//Node[@name="%s"]' % client)[0]