use of kafka.server.KafkaConfig in project storm by apache.
the class KafkaUnit method setUp.
public void setUp() throws IOException {
// setup ZK
zkServer = new EmbeddedZookeeper();
String zkConnect = ZK_HOST + ":" + zkServer.port();
ZkClient zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$);
zkUtils = ZkUtils.apply(zkClient, false);
// setup Broker
Properties brokerProps = new Properties();
brokerProps.setProperty("zookeeper.connect", zkConnect);
brokerProps.setProperty("broker.id", "0");
brokerProps.setProperty("log.dirs", Files.createTempDirectory("kafka-").toAbsolutePath().toString());
brokerProps.setProperty("listeners", String.format("PLAINTEXT://%s:%d", KAFKA_HOST, KAFKA_PORT));
KafkaConfig config = new KafkaConfig(brokerProps);
MockTime mock = new MockTime();
kafkaServer = TestUtils.createServer(config, mock);
// setup default Producer
createProducer();
}
use of kafka.server.KafkaConfig in project storm by apache.
the class KafkaTestBroker method buildKafkaConfig.
private kafka.server.KafkaConfig buildKafkaConfig(String zookeeperConnectionString) {
Properties p = new Properties();
p.setProperty("zookeeper.connect", zookeeperConnectionString);
p.setProperty("broker.id", "0");
p.setProperty("port", "" + port);
p.setProperty("log.dirs", logDir.getAbsolutePath());
return new KafkaConfig(p);
}
use of kafka.server.KafkaConfig in project pinot by linkedin.
the class KafkaStarterUtils method startServer.
public static KafkaServerStartable startServer(final int port, final int brokerId, final String zkStr, final String logDirPath, final Properties configuration) {
// Create the ZK nodes for Kafka, if needed
int indexOfFirstSlash = zkStr.indexOf('/');
if (indexOfFirstSlash != -1) {
String bareZkUrl = zkStr.substring(0, indexOfFirstSlash);
String zkNodePath = zkStr.substring(indexOfFirstSlash);
ZkClient client = new ZkClient(bareZkUrl);
client.createPersistent(zkNodePath, true);
client.close();
}
File logDir = new File(logDirPath);
logDir.mkdirs();
configureKafkaPort(configuration, port);
configureZkConnectionString(configuration, zkStr);
configureBrokerId(configuration, brokerId);
configureKafkaLogDirectory(configuration, logDir);
configuration.put("zookeeper.session.timeout.ms", "60000");
KafkaConfig config = new KafkaConfig(configuration);
KafkaServerStartable serverStartable = new KafkaServerStartable(config);
serverStartable.startup();
return serverStartable;
}
use of kafka.server.KafkaConfig in project bagheera by mozilla-metrics.
the class ProducerTest method startServer.
private void startServer() {
stopServer();
Properties props = new Properties();
props.setProperty("hostname", "localhost");
props.setProperty("port", String.valueOf(KAFKA_BROKER_PORT));
props.setProperty("brokerid", String.valueOf(KAFKA_BROKER_ID));
props.setProperty("log.dir", KAFKA_DIR);
props.setProperty("enable.zookeeper", "false");
// flush every message.
props.setProperty("log.flush.interval", "1");
// flush every 1ms
props.setProperty("log.default.flush.scheduler.interval.ms", "1");
server = new KafkaServer(new KafkaConfig(props));
server.startup();
}
use of kafka.server.KafkaConfig 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());
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(() -> getBrokerMetadatas(), hasSize(greaterThanOrEqualTo(1)));
System.err.println("Kafka Address: " + getKafkaConnectString());
System.err.println("Zookeeper Address: " + getZookeeperConnectString());
}
Aggregations