Exemple #1
0
def createRelayService(config):
    from carbon.log import msg
    from carbon.conf import settings
    from carbon.events import metricReceived
    from carbon.hashing import setDestinationHosts
    from carbon.relay import createClientConnections, relay
    from carbon.rules import loadRules, allDestinationServers, parseHostList

    root_service = createBaseService(config)

    # Configure application components
    metricReceived.installHandler(relay)

    if settings["RELAY_METHOD"] == "rules":
        loadRules(settings["relay-rules"])
        createClientConnections(allDestinationServers())
    elif settings["RELAY_METHOD"] == "consistent-hashing":
        hosts = parseHostList(settings["CH_HOST_LIST"])
        msg('consistent-hashing hosts = %s' % str(hosts))
        setDestinationHosts(hosts)
        createClientConnections(hosts)

    return root_service
Exemple #2
0
  atexit.register(shutdown)


# Configure application components
metricReceived.installHandler(relay)
startListener(settings.LINE_RECEIVER_INTERFACE, settings.LINE_RECEIVER_PORT, MetricLineReceiver)
startListener(settings.PICKLE_RECEIVER_INTERFACE, settings.PICKLE_RECEIVER_PORT, MetricPickleReceiver)

if settings.RELAY_METHOD == 'rules':
  loadRules(options.rules)
  createClientConnections( allDestinationServers() )
elif settings.RELAY_METHOD == 'consistent-hashing':
  hosts = parseHostList(settings.CH_HOST_LIST)
  msg('consistent-hashing hosts = %s' % str(hosts))
  setDestinationHosts(hosts)
  createClientConnections(hosts)

startRecording()


# Run the twisted reactor
if options.profile:
  import cProfile

  if exists(options.profile):
    os.unlink(options.profile)

  cProfile.run('reactor.run()', options.profile)

else:
    atexit.register(shutdown)

# Configure application components
metricReceived.installHandler(relay)
startListener(settings.LINE_RECEIVER_INTERFACE, settings.LINE_RECEIVER_PORT,
              MetricLineReceiver)
startListener(settings.PICKLE_RECEIVER_INTERFACE,
              settings.PICKLE_RECEIVER_PORT, MetricPickleReceiver)

if settings.RELAY_METHOD == 'rules':
    loadRules(options.rules)
    createClientConnections(allDestinationServers())
elif settings.RELAY_METHOD == 'consistent-hashing':
    hosts = parseHostList(settings.CH_HOST_LIST)
    msg('consistent-hashing hosts = %s' % str(hosts))
    setDestinationHosts(hosts)
    createClientConnections(hosts)

startRecording()

# Run the twisted reactor
if options.profile:
    import cProfile

    if exists(options.profile):
        os.unlink(options.profile)

    cProfile.run('reactor.run()', options.profile)

else:
    reactor.run()