Merge lp:~tmm1/graphite/udp-receiver into lp:~graphite-dev/graphite/main

Proposed by Aman Gupta
Status: Merged
Merge reported by: chrismd
Merged at revision: not available
Proposed branch: lp:~tmm1/graphite/udp-receiver
Merge into: lp:~graphite-dev/graphite/main
Diff against target: 103 lines (+29/-3)
5 files modified
carbon/conf/carbon.amqp.conf.example (+3/-0)
carbon/conf/carbon.conf.example (+3/-0)
carbon/lib/carbon/conf.py (+2/-0)
carbon/lib/carbon/listeners.py (+14/-1)
carbon/lib/carbon/service.py (+7/-2)
To merge this branch: bzr merge lp:~tmm1/graphite/udp-receiver
Reviewer Review Type Date Requested Status
chrismd Needs Fixing
Review via email: mp+68622@code.launchpad.net
To post a comment you must log in.
lp:~tmm1/graphite/udp-receiver updated
434. By Aman Gupta

Only show remote hostname on invalid datagrams

Revision history for this message
chrismd (chrismd) wrote :

tmm1 this change looks good except I think the datagram receiver should allow for multiple lines. This will make the data format the same as the current tcp port 2003 receiver, and also the udp listener should use udp port 2003 by default as well since it will use the data format.

review: Needs Fixing
Revision history for this message
Aman Gupta (tmm1) wrote :

Good call on both points.

Is it worth having UDP_RECEIVER_* configuration, or should I re-use LINE_RECEIVER_* for both TCP/UDP. I suppose it could be useful to listen for datagrams on a separate ip/port.

lp:~tmm1/graphite/udp-receiver updated
435. By Aman Gupta

Listen for datagrams on the same port as the line receiver by default

436. By Aman Gupta

UDP Reciever can accept multiple lines per datagram

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'carbon/conf/carbon.amqp.conf.example'
--- carbon/conf/carbon.amqp.conf.example 2011-04-01 06:01:35 +0000
+++ carbon/conf/carbon.amqp.conf.example 2011-07-21 03:08:32 +0000
@@ -32,6 +32,9 @@
32LINE_RECEIVER_INTERFACE = 0.0.0.032LINE_RECEIVER_INTERFACE = 0.0.0.0
33LINE_RECEIVER_PORT = 200333LINE_RECEIVER_PORT = 2003
3434
35UDP_RECEIVER_INTERFACE = 0.0.0.0
36UDP_RECEIVER_PORT = 2003
37
35PICKLE_RECEIVER_INTERFACE = 0.0.0.038PICKLE_RECEIVER_INTERFACE = 0.0.0.0
36PICKLE_RECEIVER_PORT = 200439PICKLE_RECEIVER_PORT = 2004
3740
3841
=== modified file 'carbon/conf/carbon.conf.example'
--- carbon/conf/carbon.conf.example 2011-04-05 21:42:51 +0000
+++ carbon/conf/carbon.conf.example 2011-07-21 03:08:32 +0000
@@ -30,6 +30,9 @@
30LINE_RECEIVER_INTERFACE = 0.0.0.030LINE_RECEIVER_INTERFACE = 0.0.0.0
31LINE_RECEIVER_PORT = 200331LINE_RECEIVER_PORT = 2003
3232
33UDP_RECEIVER_INTERFACE = 0.0.0.0
34UDP_RECEIVER_PORT = 2003
35
33PICKLE_RECEIVER_INTERFACE = 0.0.0.036PICKLE_RECEIVER_INTERFACE = 0.0.0.0
34PICKLE_RECEIVER_PORT = 200437PICKLE_RECEIVER_PORT = 2004
3538
3639
=== modified file 'carbon/lib/carbon/conf.py'
--- carbon/lib/carbon/conf.py 2011-07-20 23:15:06 +0000
+++ carbon/lib/carbon/conf.py 2011-07-21 03:08:32 +0000
@@ -35,6 +35,8 @@
35 MAX_CREATES_PER_MINUTE='inf',35 MAX_CREATES_PER_MINUTE='inf',
36 LINE_RECEIVER_INTERFACE='0.0.0.0',36 LINE_RECEIVER_INTERFACE='0.0.0.0',
37 LINE_RECEIVER_PORT=2003,37 LINE_RECEIVER_PORT=2003,
38 UDP_RECEIVER_INTERFACE='0.0.0.0',
39 UDP_RECEIVER_PORT=2003,
38 PICKLE_RECEIVER_INTERFACE='0.0.0.0',40 PICKLE_RECEIVER_INTERFACE='0.0.0.0',
39 PICKLE_RECEIVER_PORT=2004,41 PICKLE_RECEIVER_PORT=2004,
40 CACHE_QUERY_INTERFACE='0.0.0.0',42 CACHE_QUERY_INTERFACE='0.0.0.0',
4143
=== modified file 'carbon/lib/carbon/listeners.py'
--- carbon/lib/carbon/listeners.py 2010-06-06 16:24:30 +0000
+++ carbon/lib/carbon/listeners.py 2011-07-21 03:08:32 +0000
@@ -1,5 +1,5 @@
1from twisted.internet import reactor1from twisted.internet import reactor
2from twisted.internet.protocol import Factory2from twisted.internet.protocol import Factory, DatagramProtocol
3from twisted.internet.error import ConnectionDone3from twisted.internet.error import ConnectionDone
4from twisted.protocols.basic import LineOnlyReceiver, Int32StringReceiver4from twisted.protocols.basic import LineOnlyReceiver, Int32StringReceiver
5from carbon.cache import MetricCache5from carbon.cache import MetricCache
@@ -42,6 +42,19 @@
42 metricReceived(metric, datapoint)42 metricReceived(metric, datapoint)
4343
4444
45class MetricDatagramReceiver(LoggingMixin, DatagramProtocol):
46 def datagramReceived(self, data, (host, port)):
47 for line in data.splitlines():
48 try:
49 metric, value, timestamp = line.strip().split()
50 datapoint = ( float(timestamp), float(value) )
51
52 increment('metricsReceived')
53 metricReceived(metric, datapoint)
54 except:
55 log.listener('invalid line received from client %s, ignoring' % host)
56
57
45class MetricPickleReceiver(LoggingMixin, Int32StringReceiver):58class MetricPickleReceiver(LoggingMixin, Int32StringReceiver):
46 MAX_LENGTH = 2 ** 2059 MAX_LENGTH = 2 ** 20
4760
4861
=== modified file 'carbon/lib/carbon/service.py'
--- carbon/lib/carbon/service.py 2011-07-08 20:25:00 +0000
+++ carbon/lib/carbon/service.py 2011-07-21 03:08:32 +0000
@@ -16,13 +16,13 @@
16from os.path import exists16from os.path import exists
1717
18from twisted.application.service import MultiService18from twisted.application.service import MultiService
19from twisted.application.internet import TCPServer, TCPClient19from twisted.application.internet import TCPServer, TCPClient, UDPServer
20from twisted.internet.protocol import ServerFactory20from twisted.internet.protocol import ServerFactory
2121
2222
23def createBaseService(config):23def createBaseService(config):
24 from carbon.conf import settings24 from carbon.conf import settings
25 from carbon.listeners import MetricLineReceiver, MetricPickleReceiver25 from carbon.listeners import MetricLineReceiver, MetricPickleReceiver, MetricDatagramReceiver
2626
27 root_service = MultiService()27 root_service = MultiService()
28 root_service.setName(settings.program)28 root_service.setName(settings.program)
@@ -52,6 +52,11 @@
52 service = TCPServer(int(port), factory, interface=interface)52 service = TCPServer(int(port), factory, interface=interface)
53 service.setServiceParent(root_service)53 service.setServiceParent(root_service)
5454
55 service = UDPServer(int(settings.UDP_RECEIVER_PORT),
56 MetricDatagramReceiver(),
57 interface=settings.UDP_RECEIVER_INTERFACE)
58 service.setServiceParent(root_service)
59
55 if use_amqp:60 if use_amqp:
56 factory = amqp_listener.createAMQPListener(61 factory = amqp_listener.createAMQPListener(
57 amqp_user, amqp_password,62 amqp_user, amqp_password,

Subscribers

People subscribed via source and target branches