mirror of
https://github.com/EDCD/EDDN.git
synced 2025-06-19 16:23:56 +03:00
Merge branch 'master' of github.com:jamesremuscat/EDDN
This commit is contained in:
commit
f82814231c
@ -213,7 +213,7 @@ class MalformedUploadError(Exception):
|
|||||||
def main():
|
def main():
|
||||||
loadConfig()
|
loadConfig()
|
||||||
configure()
|
configure()
|
||||||
run(host='0.0.0.0', port=Settings.GATEWAY_HTTP_PORT, server='gevent')
|
run(host=Settings.GATEWAY_HTTP_BIND_ADDRESS, port=Settings.GATEWAY_HTTP_PORT, server='gevent')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -31,7 +31,8 @@ class _Settings(object):
|
|||||||
# Gateway settings
|
# Gateway settings
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
GATEWAY_HTTP_PORT = 8080
|
GATEWAY_HTTP_BIND_ADDRESS = "127.0.0.1"
|
||||||
|
GATEWAY_HTTP_PORT = 8081
|
||||||
|
|
||||||
GATEWAY_SENDER_BINDINGS = ["tcp://*:8500"]
|
GATEWAY_SENDER_BINDINGS = ["tcp://*:8500"]
|
||||||
|
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
# coding: utf8
|
# coding: utf8
|
||||||
|
import hashlib
|
||||||
|
import re
|
||||||
|
import simplejson
|
||||||
|
import zlib
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from eddn.conf.Settings import Settings
|
||||||
from threading import Lock, Thread
|
from threading import Lock, Thread
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import hashlib
|
|
||||||
import zlib
|
|
||||||
import re
|
|
||||||
|
|
||||||
import simplejson
|
|
||||||
from eddn.conf.Settings import Settings, loadConfig
|
|
||||||
|
|
||||||
|
|
||||||
class DuplicateMessages(Thread):
|
class DuplicateMessages(Thread):
|
||||||
|
@ -13,18 +13,17 @@ class StatsCollector(Thread):
|
|||||||
you choose, up to one hour.
|
you choose, up to one hour.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
max_minutes = 60
|
|
||||||
|
|
||||||
current = {}
|
|
||||||
history = {}
|
|
||||||
|
|
||||||
lock = Lock()
|
|
||||||
|
|
||||||
starttime = 0
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(StatsCollector, self).__init__()
|
super(StatsCollector, self).__init__()
|
||||||
self.daemon = True
|
self.daemon = True
|
||||||
|
self.max_minutes = 60
|
||||||
|
|
||||||
|
self.current = {}
|
||||||
|
self.history = {}
|
||||||
|
|
||||||
|
self.lock = Lock()
|
||||||
|
|
||||||
|
self.starttime = 0
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.starttime = datetime.utcnow()
|
self.starttime = datetime.utcnow()
|
||||||
@ -44,12 +43,6 @@ class StatsCollector(Thread):
|
|||||||
else:
|
else:
|
||||||
self.current[key] += 1
|
self.current[key] += 1
|
||||||
|
|
||||||
def getInboundCount(self, minutes):
|
|
||||||
return sum(islice(self.inboundHistory, 0, min(minutes, self.max_minutes)))
|
|
||||||
|
|
||||||
def getOutboundCount(self, minutes):
|
|
||||||
return sum(islice(self.outboundHistory, 0, min(minutes, self.max_minutes)))
|
|
||||||
|
|
||||||
def getCount(self, key, minutes):
|
def getCount(self, key, minutes):
|
||||||
if key in self.history:
|
if key in self.history:
|
||||||
return sum(islice(self.history[key], 0, min(minutes, self.max_minutes)))
|
return sum(islice(self.history[key], 0, min(minutes, self.max_minutes)))
|
||||||
|
17
src/eddn/core/tests/TestStatsCollector.py
Normal file
17
src/eddn/core/tests/TestStatsCollector.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
from eddn.core.StatsCollector import StatsCollector
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
|
||||||
|
class Test(unittest.TestCase):
|
||||||
|
|
||||||
|
def testStatsCollectorTally(self):
|
||||||
|
print "This test will take about 60 seconds to run!"
|
||||||
|
statsCollector = StatsCollector()
|
||||||
|
statsCollector.start()
|
||||||
|
|
||||||
|
self.assertEqual(0, statsCollector.getCount("test", 1))
|
||||||
|
statsCollector.tally("test")
|
||||||
|
sleep(61)
|
||||||
|
self.assertEqual(1, statsCollector.getCount("test", 1))
|
0
src/eddn/core/tests/__init__.py
Normal file
0
src/eddn/core/tests/__init__.py
Normal file
Loading…
x
Reference in New Issue
Block a user