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


Python RuleManager.read_from方法代码示例

本文整理汇总了Python中carbon.aggregator.rules.RuleManager.read_from方法的典型用法代码示例。如果您正苦于以下问题:Python RuleManager.read_from方法的具体用法?Python RuleManager.read_from怎么用?Python RuleManager.read_from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在carbon.aggregator.rules.RuleManager的用法示例。


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

示例1: createAggregatorService

# 需要导入模块: from carbon.aggregator.rules import RuleManager [as 别名]
# 或者: from carbon.aggregator.rules.RuleManager 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
开发者ID:laiwei,项目名称:carbon,代码行数:32,代码来源:service.py

示例2: createRelayService

# 需要导入模块: from carbon.aggregator.rules import RuleManager [as 别名]
# 或者: from carbon.aggregator.rules.RuleManager import read_from [as 别名]
def createRelayService(config):
    from carbon.routers import RelayRulesRouter, ConsistentHashingRouter, AggregatedConsistentHashingRouter
    from carbon.client import CarbonClientManager
    from carbon.conf import settings
    from carbon import events

    root_service = createBaseService(config)

    # Configure application components
    if settings.RELAY_METHOD == 'rules':
      router = RelayRulesRouter(settings["relay-rules"])
    elif settings.RELAY_METHOD == 'consistent-hashing':
      router = ConsistentHashingRouter(settings.REPLICATION_FACTOR)
    elif settings.RELAY_METHOD == 'aggregated-consistent-hashing':
      from carbon.aggregator.rules import RuleManager
      RuleManager.read_from(settings["aggregation-rules"])
      router = AggregatedConsistentHashingRouter(RuleManager, settings.REPLICATION_FACTOR)

    client_manager = CarbonClientManager(router)
    client_manager.setServiceParent(root_service)

    events.metricReceived.addHandler(client_manager.sendDatapoint)
    events.metricGenerated.addHandler(client_manager.sendDatapoint)
    events.specialMetricReceived.addHandler(client_manager.sendHighPriorityDatapoint)
    events.specialMetricGenerated.addHandler(client_manager.sendHighPriorityDatapoint)

    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,代码行数:35,代码来源:service.py

示例3: setupReceivers

# 需要导入模块: from carbon.aggregator.rules import RuleManager [as 别名]
# 或者: from carbon.aggregator.rules.RuleManager import read_from [as 别名]
def setupReceivers(root_service, settings):
  from carbon.protocols import MetricLineReceiver, MetricPickleReceiver, MetricDatagramReceiver

  for protocol, interface, port in [
      (MetricLineReceiver, settings.LINE_RECEIVER_INTERFACE, settings.LINE_RECEIVER_PORT),
      (MetricPickleReceiver, settings.PICKLE_RECEIVER_INTERFACE, settings.PICKLE_RECEIVER_PORT)
    ]:
    if port:
      factory = ServerFactory()
      factory.protocol = protocol
      service = TCPServer(port, factory, interface=interface)
      service.setServiceParent(root_service)

  if settings.ENABLE_UDP_LISTENER:
      service = UDPServer(int(settings.UDP_RECEIVER_PORT),
                          MetricDatagramReceiver(),
                          interface=settings.UDP_RECEIVER_INTERFACE)
      service.setServiceParent(root_service)

  if settings.ENABLE_AMQP:
    from carbon import amqp_listener
    amqp_host = settings.AMQP_HOST
    amqp_port = settings.AMQP_PORT
    amqp_user = settings.AMQP_USER
    amqp_password = settings.AMQP_PASSWORD
    amqp_verbose = settings.AMQP_VERBOSE
    amqp_vhost = settings.AMQP_VHOST
    amqp_spec = settings.AMQP_SPEC
    amqp_exchange_name = settings.AMQP_EXCHANGE

    factory = amqp_listener.createAMQPListener(
      amqp_user,
      amqp_password,
      vhost=amqp_vhost,
      spec=amqp_spec,
      exchange_name=amqp_exchange_name,
      verbose=amqp_verbose)
    service = TCPClient(amqp_host, amqp_port, factory)
    service.setServiceParent(root_service)

  if settings.ENABLE_MANHOLE:
    from carbon import manhole

    # Configure application components
    if settings.RELAY_METHOD == 'rules':
      router = RelayRulesRouter(settings["relay-rules"])
    elif settings.RELAY_METHOD == 'consistent-hashing':
      router = ConsistentHashingRouter(settings.REPLICATION_FACTOR)
    elif settings.RELAY_METHOD == 'aggregated-consistent-hashing':
      from carbon.aggregator.rules import RuleManager
      RuleManager.read_from(settings["aggregation-rules"])
      router = AggregatedConsistentHashingRouter(RuleManager, settings.REPLICATION_FACTOR)
    elif settings.RELAY_METHOD == 'remove-node-consistent-hashing':
      router = RemoveNodeConsistentHashingRouter(settings.REPLICATION_FACTOR, settings.REMOVE_NODE_INDEX)
    factory = manhole.createManholeListener()
    service = TCPServer(
      settings.MANHOLE_PORT,
      factory,
      interface=settings.MANHOLE_INTERFACE)
    service.setServiceParent(root_service)
开发者ID:zhpn,项目名称:carbon,代码行数:62,代码来源:service.py

示例4: setupAggregatorProcessor

# 需要导入模块: from carbon.aggregator.rules import RuleManager [as 别名]
# 或者: from carbon.aggregator.rules.RuleManager import read_from [as 别名]
def setupAggregatorProcessor(root_service, settings):
  from carbon.aggregator.processor import AggregationProcessor  # Register the plugin class
  from carbon.aggregator.rules import RuleManager

  aggregation_rules_path = settings["aggregation-rules"]
  if not exists(aggregation_rules_path):
    raise CarbonConfigException("aggregation processor: file does not exist {0}".format(aggregation_rules_path))
  RuleManager.read_from(aggregation_rules_path)
开发者ID:zhpn,项目名称:carbon,代码行数:10,代码来源:service.py

示例5: __init__

# 需要导入模块: from carbon.aggregator.rules import RuleManager [as 别名]
# 或者: from carbon.aggregator.rules.RuleManager import read_from [as 别名]
  def __init__(self, settings):
    from carbon.aggregator.rules import RuleManager
    aggregation_rules_path = settings["aggregation-rules"]
    if aggregation_rules_path:
      RuleManager.read_from(aggregation_rules_path)

    self.hash_router = ConsistentHashingRouter(settings)
    self.agg_rules_manager = RuleManager
开发者ID:NixM0nk3y,项目名称:carbon,代码行数:10,代码来源:routers.py

示例6: __init__

# 需要导入模块: from carbon.aggregator.rules import RuleManager [as 别名]
# 或者: from carbon.aggregator.rules.RuleManager import read_from [as 别名]
    def __init__(self, config, cluster='main', aggregation_rules=None):
        relay_method = config.relay_method(cluster=cluster)
        if relay_method == "consistent-hashing":
            self.ring = ConsistentHashingRouter(config.replication_factor(cluster))
        elif relay_method == "aggregated-consistent-hashing":
            if aggregation_rules:
                RuleManager.read_from(aggregation_rules)
            self.ring = AggregatedConsistentHashingRouter(RuleManager, config.replication_factor(cluster))

        try:
            dest_list = config.destinations(cluster)
            self.destinations = util.parseDestinations(dest_list)
        except ValueError as e:
            raise SystemExit("Unable to parse destinations!" + str(e))

        for d in self.destinations:
            self.ring.addDestination(d)
开发者ID:klynch,项目名称:carbonate,代码行数:19,代码来源:cluster.py

示例7: setupRelayProcessor

# 需要导入模块: from carbon.aggregator.rules import RuleManager [as 别名]
# 或者: from carbon.aggregator.rules.RuleManager import read_from [as 别名]
def setupRelayProcessor(root_service, settings):
  from carbon.routers import AggregatedConsistentHashingRouter, \
      ConsistentHashingRouter, RelayRulesRouter
  from carbon.client import CarbonClientManager

  if settings.RELAY_METHOD == 'consistent-hashing':
    router = ConsistentHashingRouter(settings.REPLICATION_FACTOR)
  elif settings.RELAY_METHOD == 'aggregated-consistent-hashing':
    from carbon.aggregator.rules import RuleManager
    aggregation_rules_path = settings["aggregation-rules"]
    RuleManager.read_from(aggregation_rules_path)
    router = AggregatedConsistentHashingRouter(RuleManager, settings.REPLICATION_FACTOR)
  elif settings.RELAY_METHOD == 'rules':
    router = RelayRulesRouter(settings["relay-rules"])

  state.client_manager = CarbonClientManager(router)
  state.client_manager.setServiceParent(root_service)

  for destination in util.parseDestinations(settings.DESTINATIONS):
    state.client_manager.startClient(destination)
开发者ID:zhpn,项目名称:carbon,代码行数:22,代码来源:service.py

示例8: createAggregatorService

# 需要导入模块: from carbon.aggregator.rules import RuleManager [as 别名]
# 或者: from carbon.aggregator.rules.RuleManager 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
开发者ID:mtodd,项目名称:graphite,代码行数:22,代码来源:service.py

示例9: join

# 需要导入模块: from carbon.aggregator.rules import RuleManager [as 别名]
# 或者: from carbon.aggregator.rules.RuleManager import read_from [as 别名]
from carbon.conf import settings
settings.readFrom(options.config, 'aggregator')


# 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()
开发者ID:katzj,项目名称:graphite,代码行数:32,代码来源:carbon-aggregator.py


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