def createCacheService(config): from carbon.cache import MetricCache from carbon.conf import settings from carbon.protocols import CacheManagementHandler # Configure application components events.metricReceived.addHandler(MetricCache.store) root_service = createBaseService(config) factory = ServerFactory() factory.protocol = CacheManagementHandler service = TCPServer(int(settings.CACHE_QUERY_PORT), factory, interface=settings.CACHE_QUERY_INTERFACE, backlog=settings.CACHE_QUERY_BACKLOG) service.setServiceParent(root_service) # have to import this *after* settings are defined from carbon.writer import WriterService service = WriterService() service.setServiceParent(root_service) if settings.USE_FLOW_CONTROL: events.cacheFull.addHandler(events.pauseReceivingMetrics) events.cacheSpaceAvailable.addHandler(events.resumeReceivingMetrics) return root_service
def createCacheService(config): from carbon.cache import MetricCache, UDPForward from carbon.conf import settings from carbon.protocols import CacheManagementHandler # Configure application components events.metricReceived.addHandler(MetricCache.store) root_service = createBaseService(config) factory = ServerFactory() factory.protocol = CacheManagementHandler service = TCPServer(int(settings.CACHE_QUERY_PORT), factory, interface=settings.CACHE_QUERY_INTERFACE) service.setServiceParent(root_service) # have to import this *after* settings are defined from carbon.writer import WriterService service = WriterService() service.setServiceParent(root_service) # Turn on UDP forwarding if settings.ENABLE_UDP_FORWARDING: udp_forward = UDPForward() events.metricReceived.addHandler(udp_forward.sendDatapoint) if settings.USE_FLOW_CONTROL: events.cacheFull.addHandler(events.pauseReceivingMetrics) events.cacheSpaceAvailable.addHandler(events.resumeReceivingMetrics) return root_service
def setupWriterProcessor(root_service, settings): from carbon import cache # Register CacheFeedingProcessor from carbon.protocols import CacheManagementHandler from carbon.writer import WriterService from carbon import events factory = ServerFactory() factory.protocol = CacheManagementHandler service = TCPServer(settings.CACHE_QUERY_PORT, factory, interface=settings.CACHE_QUERY_INTERFACE) service.setServiceParent(root_service) writer_service = WriterService() writer_service.setServiceParent(root_service) if settings.USE_FLOW_CONTROL: events.cacheFull.addHandler(events.pauseReceivingMetrics) events.cacheSpaceAvailable.addHandler(events.resumeReceivingMetrics)
def setupWriterProcessor(root_service, settings): from carbon import cache # NOQA Register CacheFeedingProcessor from carbon.protocols import CacheManagementHandler from carbon.writer import WriterService factory = ServerFactory() factory.protocol = CacheManagementHandler service = TCPServer(settings.CACHE_QUERY_PORT, factory, interface=settings.CACHE_QUERY_INTERFACE) service.setServiceParent(root_service) writer_service = WriterService() writer_service.setServiceParent(root_service) if settings.USE_FLOW_CONTROL: events.cacheFull.addHandler(events.pauseReceivingMetrics) events.cacheSpaceAvailable.addHandler(events.resumeReceivingMetrics)