当前位置: 首页>>代码示例>>Python>>正文


Python rewrite.RewriteRuleManager类代码示例

本文整理汇总了Python中carbon.rewrite.RewriteRuleManager的典型用法代码示例。如果您正苦于以下问题:Python RewriteRuleManager类的具体用法?Python RewriteRuleManager怎么用?Python RewriteRuleManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RewriteRuleManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process

  def process(self, metric, datapoint):
    increment('datapointsReceived')

    for rule in RewriteRuleManager.rules(PRE):
      metric = rule.apply(metric)

    aggregate_metrics = set()

    for rule in RuleManager.rules:
      aggregate_metric = rule.get_aggregate_metric(metric)

      if aggregate_metric is None:
        continue
      else:
        aggregate_metrics.add(aggregate_metric)

      values_buffer = BufferManager.get_buffer(aggregate_metric)

      if not values_buffer.configured:
        values_buffer.configure_aggregation(rule.frequency, rule.aggregation_func)

      values_buffer.input(datapoint)

    for rule in RewriteRuleManager.rules(POST):
      metric = rule.apply(metric)

    if metric not in aggregate_metrics:
      yield (metric, datapoint)
开发者ID:Akulatraxas,项目名称:carbon,代码行数:28,代码来源:processor.py

示例2: process

  def process(self, metric, datapoint):
    increment('datapointsReceived')

    for rule in RewriteRuleManager.rules(PRE):
      metric = rule.apply(metric)

    aggregate_metrics = set()

    for rule in RuleManager.rules:
      aggregate_metric = rule.get_aggregate_metric(metric)

      if aggregate_metric is None:
        continue
      else:
        aggregate_metrics.add(aggregate_metric)

      values_buffer = BufferManager.get_buffer(aggregate_metric)

      if not values_buffer.configured:
        values_buffer.configure_aggregation(rule.frequency, rule.aggregation_func)

      values_buffer.input(datapoint)

    for rule in RewriteRuleManager.rules(POST):
      metric = rule.apply(metric)

    if settings.FORWARD_ALL and metric not in aggregate_metrics:
      if settings.LOG_AGGREGATOR_MISSES and len(aggregate_metrics) == 0:
        log.msg(
          "Couldn't match metric %s with any aggregation rule. Passing on un-aggregated." % metric)
      yield (metric, datapoint)
开发者ID:NixM0nk3y,项目名称:carbon,代码行数:31,代码来源:processor.py

示例3: createAggregatorService

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
开发者ID:laiwei,项目名称:carbon,代码行数:30,代码来源:service.py

示例4: test_read_clears_if_no_file

  def test_read_clears_if_no_file(self):
    import carbon.rewrite
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'exists', Mock(return_value=False)):
      with patch.object(RewriteRuleManager, 'clear') as clear_mock:
        RewriteRuleManager.read_rules()
        clear_mock.assert_called_once_with()
开发者ID:Akulatraxas,项目名称:carbon,代码行数:8,代码来源:test_rewrite.py

示例5: test_read_records_mtime

  def test_read_records_mtime(self):
    import carbon.rewrite
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'open', mock_open(), create=True):
      with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
        with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=1234)):
          RewriteRuleManager.read_rules()
    self.assertEqual(1234, RewriteRuleManager.rules_last_read)
开发者ID:Akulatraxas,项目名称:carbon,代码行数:9,代码来源:test_rewrite.py

示例6: test_read_opens_file_if_mtime_newer

  def test_read_opens_file_if_mtime_newer(self):
    import carbon.rewrite
    RewriteRuleManager.rules_last_read = 1234
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'open', mock_open(), create=True) as open_mock:
      with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
        with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=5678)):
          RewriteRuleManager.read_rules()
          self.assertTrue(open_mock.called)
开发者ID:Akulatraxas,项目名称:carbon,代码行数:10,代码来源:test_rewrite.py

示例7: test_comments_ignored

  def test_comments_ignored(self):
    import carbon.rewrite

    open_mock = Mock(return_value=iter(self.commented_config.splitlines()))
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'open', open_mock, create=True):
      with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
        with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=1234)):
          RewriteRuleManager.read_rules()
    self.assertEqual(1, len(RewriteRuleManager.rules('pre')))
开发者ID:Akulatraxas,项目名称:carbon,代码行数:11,代码来源:test_rewrite.py

示例8: test_section_parsed_into_ruleset

  def test_section_parsed_into_ruleset(self):
    import carbon.rewrite

    open_mock = Mock(return_value=iter(self.sample_config.splitlines()))
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'open', open_mock, create=True):
      with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
        with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=1234)):
          RewriteRuleManager.read_rules()
    self.assertTrue('pre' in RewriteRuleManager.rulesets)
开发者ID:Akulatraxas,项目名称:carbon,代码行数:11,代码来源:test_rewrite.py

示例9: test_read_doesnt_open_file_if_mtime_unchanged

  def test_read_doesnt_open_file_if_mtime_unchanged(self):
    import carbon.rewrite
    mtime = 1234
    RewriteRuleManager.rules_last_read = mtime
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'open', mock_open(), create=True) as open_mock:
      with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
        with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=1234)):
          RewriteRuleManager.read_rules()
          self.assertFalse(open_mock.called)
开发者ID:Akulatraxas,项目名称:carbon,代码行数:11,代码来源:test_rewrite.py

示例10: test_rules_unchanged_if_mtime_unchanged

  def test_rules_unchanged_if_mtime_unchanged(self):
    import carbon.rewrite
    mtime = 1234
    rulesets = {'pre': [Mock(RewriteRule)]}
    RewriteRuleManager.rules_last_read = mtime
    RewriteRuleManager.rulesets.update(rulesets)
    RewriteRuleManager.rules_file = 'foo.conf'

    with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
      with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=mtime)):
        RewriteRuleManager.read_rules()

    self.assertEqual(rulesets, RewriteRuleManager.rulesets)
开发者ID:Akulatraxas,项目名称:carbon,代码行数:13,代码来源:test_rewrite.py

示例11: createAggregatorService

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
开发者ID:mtodd,项目名称:graphite,代码行数:20,代码来源:service.py

示例12: test_request_for_nonexistent_rules_returns_iterable

 def test_request_for_nonexistent_rules_returns_iterable(self):
   try:
     iter(RewriteRuleManager.rules('foo'))
   except TypeError:
     self.fail("RewriteRuleManager.rules() returned a non-iterable type")
开发者ID:Akulatraxas,项目名称:carbon,代码行数:5,代码来源:test_rewrite.py

示例13: tearDown

 def tearDown(self):
   instrumentation.stats.clear()
   BufferManager.clear()
   RuleManager.clear()
   RewriteRuleManager.clear()
开发者ID:Akulatraxas,项目名称:carbon,代码行数:5,代码来源:test_aggregator_processor.py

示例14: setupRewriterProcessor

def setupRewriterProcessor(root_service, settings):
  from carbon.rewrite import RewriteRuleManager

  rewrite_rules_path = settings["rewrite-rules"]
  RewriteRuleManager.read_from(rewrite_rules_path)
开发者ID:zhpn,项目名称:carbon,代码行数:5,代码来源:service.py

示例15: tearDown

 def tearDown(self):
   RewriteRuleManager.rules_file = None
   RewriteRuleManager.rules_last_read = 0.0
   RewriteRuleManager.clear()
开发者ID:Akulatraxas,项目名称:carbon,代码行数:4,代码来源:test_rewrite.py


注:本文中的carbon.rewrite.RewriteRuleManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。