本文整理汇总了Python中carbon.rewrite.RewriteRuleManager.read_from方法的典型用法代码示例。如果您正苦于以下问题:Python RewriteRuleManager.read_from方法的具体用法?Python RewriteRuleManager.read_from怎么用?Python RewriteRuleManager.read_from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类carbon.rewrite.RewriteRuleManager
的用法示例。
在下文中一共展示了RewriteRuleManager.read_from方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createAggregatorService
# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_from [as 别名]
def createAggregatorService(config):
from carbon.aggregator import receiver
from carbon.aggregator.rules import RuleManager
from carbon.routers import ConsistentHashingRouter
from carbon.client import CarbonClientManager
from carbon.rewrite import RewriteRuleManager
from carbon.conf import settings
from carbon import events
root_service = createBaseService(config)
# Configure application components
router = ConsistentHashingRouter()
client_manager = CarbonClientManager(router)
client_manager.setServiceParent(root_service)
events.metricReceived.addHandler(receiver.process)
events.metricGenerated.addHandler(client_manager.sendDatapoint)
RuleManager.read_from(settings["aggregation-rules"])
if exists(settings["rewrite-rules"]):
RewriteRuleManager.read_from(settings["rewrite-rules"])
if not settings.DESTINATIONS:
raise CarbonConfigException("Required setting DESTINATIONS is missing from carbon.conf")
for destination in util.parseDestinations(settings.DESTINATIONS):
client_manager.startClient(destination)
return root_service
示例2: createAggregatorService
# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_from [as 别名]
def createAggregatorService(config):
from carbon.events import metricReceived
from carbon.aggregator import receiver
from carbon.aggregator.rules import RuleManager
from carbon.aggregator import client
from carbon.rewrite import RewriteRuleManager
from carbon.conf import settings
root_service = createBaseService(config)
# Configure application components
metricReceived.installHandler(receiver.process)
RuleManager.read_from(settings["aggregation-rules"])
if exists(settings["rewrite-rules"]):
RewriteRuleManager.read_from(settings["rewrite-rules"])
client.connect(settings["DESTINATION_HOST"],
int(settings["DESTINATION_PORT"]))
return root_service
示例3: setupRewriterProcessor
# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_from [as 别名]
def setupRewriterProcessor(root_service, settings):
from carbon.rewrite import RewriteRuleManager
rewrite_rules_path = settings["rewrite-rules"]
RewriteRuleManager.read_from(rewrite_rules_path)
示例4: join
# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_from [as 别名]
# Import application components
from carbon.log import logToStdout, logToDir
from carbon.instrumentation import startRecording
from carbon.listeners import MetricLineReceiver, MetricPickleReceiver, startListener
from carbon.aggregator.rules import RuleManager
from carbon.aggregator import receiver
from carbon.aggregator import client
from carbon.rewrite import RewriteRuleManager
from carbon.events import metricReceived
from carbon.util import daemonize
RuleManager.read_from(options.rules)
rewrite_rules_conf = join(CONF_DIR, 'rewrite-rules.conf')
if exists(rewrite_rules_conf):
RewriteRuleManager.read_from(rewrite_rules_conf)
# --debug
if options.debug:
logToStdout()
else:
if not isdir(options.logdir):
os.makedirs(options.logdir)
daemonize()
pidfile = open(options.pidfile, 'w')
pidfile.write( str(os.getpid()) )
pidfile.close()
示例5: test_read_from_starts_task
# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_from [as 别名]
def test_read_from_starts_task(self):
with patch.object(RewriteRuleManager, 'read_rules'):
with patch.object(RewriteRuleManager.read_task, 'start') as task_start_mock:
RewriteRuleManager.read_from('foo.conf')
task_start_mock.assert_called_once()
示例6: test_read_from_starts_task
# 需要导入模块: from carbon.rewrite import RewriteRuleManager [as 别名]
# 或者: from carbon.rewrite.RewriteRuleManager import read_from [as 别名]
def test_read_from_starts_task(self):
with patch.object(RewriteRuleManager, 'read_rules'):
with patch.object(RewriteRuleManager.read_task, 'start') as task_start_mock:
RewriteRuleManager.read_from('foo.conf')
self.assertEqual(1, task_start_mock.call_count)