Search in sources :

Example 1 with KafkaProducer

use of com.mozilla.bagheera.producer.KafkaProducer in project bagheera by mozilla-metrics.

the class Bagheera method main.

/**
     * A simple front-end that configures a new server from properties files,
     * waiting until runtime shutdown to clean up.
     */
public static void main(String[] args) throws Exception {
    final int port = Integer.parseInt(System.getProperty("server.port", "8080"));
    final boolean tcpNoDelay = Boolean.parseBoolean(System.getProperty("server.tcpnodelay", "false"));
    // Initalize properties and producer.
    final WildcardProperties props = getDefaultProperties();
    final Properties kafkaProps = getDefaultKafkaProperties();
    final Producer producer = new KafkaProducer(kafkaProps);
    final MetricsManager manager = MetricsManager.getDefaultMetricsManager();
    final BagheeraServerState server = startServer(port, tcpNoDelay, props, producer, getChannelFactory(), Bagheera.class.getName(), manager);
    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            server.close();
            server.channelFactory.releaseExternalResources();
        }
    });
}
Also used : KafkaProducer(com.mozilla.bagheera.producer.KafkaProducer) Producer(com.mozilla.bagheera.producer.Producer) KafkaProducer(com.mozilla.bagheera.producer.KafkaProducer) MetricsManager(com.mozilla.bagheera.metrics.MetricsManager) WildcardProperties(com.mozilla.bagheera.util.WildcardProperties) Properties(java.util.Properties) WildcardProperties(com.mozilla.bagheera.util.WildcardProperties)

Aggregations

MetricsManager (com.mozilla.bagheera.metrics.MetricsManager)1 KafkaProducer (com.mozilla.bagheera.producer.KafkaProducer)1 Producer (com.mozilla.bagheera.producer.Producer)1 WildcardProperties (com.mozilla.bagheera.util.WildcardProperties)1 Properties (java.util.Properties)1