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