Search in sources :

Example 1 with KafkaMetricsReporter

use of kafka.metrics.KafkaMetricsReporter in project opennms by OpenNMS.

the class JUnitKafkaServer method before.

@Override
public void before() throws Exception {
    zkServer = new TestingServer();
    // Start ZooKeeper, this method will block until the service has started
    zkServer.start();
    getAvailablePort(kafkaPort, 9192);
    // Delete any existing Kafka log directory
    FileUtils.deleteDirectory(new File("target/kafka-log"));
    localhost = getLocalhost();
    final Properties properties = new Properties();
    properties.put("broker.id", "1");
    properties.put("auto.create.topics.enable", "true");
    properties.put("num.partitions", "100");
    properties.put("enable.zookeeper", "true");
    properties.put("host.name", localhost);
    properties.put("log.dir", "target/kafka-log");
    properties.put("port", String.valueOf(kafkaPort.get()));
    properties.put("zookeeper.connect", zkServer.getConnectString());
    properties.put("listeners", "PLAINTEXT://" + "localhost:" + String.valueOf(kafkaPort.get()));
    System.err.println("Kafka server properties: " + properties);
    kafkaConfig = new KafkaConfig(properties);
    final List<KafkaMetricsReporter> kmrList = new ArrayList<>();
    final Buffer<KafkaMetricsReporter> metricsList = scala.collection.JavaConversions.asScalaBuffer(kmrList);
    kafkaServer = new KafkaServer(kafkaConfig, new SystemTime(), Option.<String>empty(), metricsList);
    kafkaServer.startup();
    await().atMost(1, MINUTES).until(this::getBrokerMetadatas, hasSize(greaterThanOrEqualTo(1)));
    System.err.println("Kafka Address: " + getKafkaConnectString());
    System.err.println("Zookeeper Address: " + getZookeeperConnectString());
}
Also used : TestingServer(org.apache.curator.test.TestingServer) KafkaServer(kafka.server.KafkaServer) ArrayList(java.util.ArrayList) Properties(java.util.Properties) File(java.io.File) KafkaMetricsReporter(kafka.metrics.KafkaMetricsReporter) KafkaConfig(kafka.server.KafkaConfig)

Example 2 with KafkaMetricsReporter

use of kafka.metrics.KafkaMetricsReporter in project deeplearning4j by deeplearning4j.

the class EmbeddedKafkaCluster method startBroker.

private KafkaServer startBroker(Properties props) {
    List<KafkaMetricsReporter> kmrList = new ArrayList<>();
    Buffer<KafkaMetricsReporter> metricsList = scala.collection.JavaConversions.asScalaBuffer(kmrList);
    KafkaServer server = new KafkaServer(new KafkaConfig(props), new SystemTime(), Option.<String>empty(), metricsList);
    server.startup();
    return server;
}
Also used : KafkaServer(kafka.server.KafkaServer) ArrayList(java.util.ArrayList) KafkaMetricsReporter(kafka.metrics.KafkaMetricsReporter) KafkaConfig(kafka.server.KafkaConfig)

Example 3 with KafkaMetricsReporter

use of kafka.metrics.KafkaMetricsReporter in project camel by apache.

the class EmbeddedKafkaBroker method startBroker.

private KafkaServer startBroker(Properties props) {
    List<KafkaMetricsReporter> kmrList = new ArrayList<>();
    Buffer<KafkaMetricsReporter> metricsList = scala.collection.JavaConversions.asScalaBuffer(kmrList);
    KafkaServer server = new KafkaServer(new KafkaConfig(props), new SystemTime(), Option.<String>empty(), metricsList);
    server.startup();
    return server;
}
Also used : KafkaServer(kafka.server.KafkaServer) ArrayList(java.util.ArrayList) KafkaMetricsReporter(kafka.metrics.KafkaMetricsReporter) KafkaConfig(kafka.server.KafkaConfig)

Example 4 with KafkaMetricsReporter

use of kafka.metrics.KafkaMetricsReporter in project atlas by apache.

the class EmbeddedKafkaServer method startKafka.

private void startKafka() throws IOException, URISyntaxException {
    String kafkaValue = properties.getProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG);
    LOG.info("Starting kafka at {}", kafkaValue);
    URL kafkaAddress = getURL(kafkaValue);
    Properties brokerConfig = properties;
    brokerConfig.setProperty("broker.id", "1");
    brokerConfig.setProperty("host.name", kafkaAddress.getHost());
    brokerConfig.setProperty("port", String.valueOf(kafkaAddress.getPort()));
    brokerConfig.setProperty("log.dirs", constructDir("kafka").getAbsolutePath());
    brokerConfig.setProperty("log.flush.interval.messages", String.valueOf(1));
    List<KafkaMetricsReporter> metrics = new ArrayList<>();
    Buffer<KafkaMetricsReporter> metricsReporters = scala.collection.JavaConversions.asScalaBuffer(metrics);
    kafkaServer = new KafkaServer(KafkaConfig.fromProps(brokerConfig), new SystemTime(), Option.apply(this.getClass().getName()), metricsReporters);
    kafkaServer.startup();
    LOG.info("Embedded kafka server started with broker config {}", brokerConfig);
}
Also used : KafkaServer(kafka.server.KafkaServer) ApplicationProperties(org.apache.atlas.ApplicationProperties) URL(java.net.URL) KafkaMetricsReporter(kafka.metrics.KafkaMetricsReporter)

Example 5 with KafkaMetricsReporter

use of kafka.metrics.KafkaMetricsReporter in project wildfly-camel by wildfly-extras.

the class EmbeddedKafkaBroker method startBroker.

private KafkaServer startBroker(Properties props) {
    List<KafkaMetricsReporter> kmrList = new ArrayList<>();
    Buffer<KafkaMetricsReporter> metricsList = scala.collection.JavaConversions.asScalaBuffer(kmrList);
    KafkaServer server = new KafkaServer(new KafkaConfig(props), new SystemTime(), Option.<String>empty(), metricsList);
    server.startup();
    return server;
}
Also used : KafkaServer(kafka.server.KafkaServer) ArrayList(java.util.ArrayList) KafkaMetricsReporter(kafka.metrics.KafkaMetricsReporter) KafkaConfig(kafka.server.KafkaConfig)

Aggregations

KafkaMetricsReporter (kafka.metrics.KafkaMetricsReporter)5 KafkaServer (kafka.server.KafkaServer)5 ArrayList (java.util.ArrayList)4 KafkaConfig (kafka.server.KafkaConfig)4 File (java.io.File)1 URL (java.net.URL)1 Properties (java.util.Properties)1 ApplicationProperties (org.apache.atlas.ApplicationProperties)1 TestingServer (org.apache.curator.test.TestingServer)1