本文整理匯總了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)