當前位置: 首頁>>代碼示例>>Python>>正文


Python rules.RuleManager類代碼示例

本文整理匯總了Python中carbon.aggregator.rules.RuleManager的典型用法代碼示例。如果您正苦於以下問題:Python RuleManager類的具體用法?Python RuleManager怎麽用?Python RuleManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了RuleManager類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: 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

示例2: createRelayService

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,代碼行數:33,代碼來源:service.py

示例3: setupReceivers

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,代碼行數:60,代碼來源:service.py

示例4: setupAggregatorProcessor

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,代碼行數:8,代碼來源:service.py

示例5: __init__

  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,代碼行數:8,代碼來源:routers.py

示例6: __init__

    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,代碼行數:17,代碼來源:cluster.py

示例7: setupRelayProcessor

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,代碼行數:20,代碼來源:service.py

示例8: 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

示例9: tearDown

 def tearDown(self):
   instrumentation.stats.clear()
   BufferManager.clear()
   RuleManager.clear()
開發者ID:graphite-project,項目名稱:carbon,代碼行數:4,代碼來源:test_aggregator_processor.py

示例10: join

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,代碼行數:30,代碼來源:carbon-aggregator.py


注:本文中的carbon.aggregator.rules.RuleManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。