本文整理汇总了Java中kafka.server.KafkaConfig.fromProps方法的典型用法代码示例。如果您正苦于以下问题:Java KafkaConfig.fromProps方法的具体用法?Java KafkaConfig.fromProps怎么用?Java KafkaConfig.fromProps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kafka.server.KafkaConfig
的用法示例。
在下文中一共展示了KafkaConfig.fromProps方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startKafka
import kafka.server.KafkaConfig; //导入方法依赖的package包/类
private void startKafka() throws Exception
{
FileUtils.deleteDirectory(new File(kafkaTmpDir));
Properties props = new Properties();
props.setProperty("zookeeper.session.timeout.ms", "100000");
props.put("advertised.host.name", "localhost");
props.put("port", 11111);
// props.put("broker.id", "0");
props.put("log.dir", kafkaTmpDir);
props.put("enable.zookeeper", "true");
props.put("zookeeper.connect", zookeeperLocalCluster.getConnectString());
KafkaConfig kafkaConfig = KafkaConfig.fromProps(props);
kafkaLocalBroker = new KafkaServer(kafkaConfig, new SystemTime(), scala.Option.apply("kafkaThread"));
kafkaLocalBroker.startup();
zkClient = new ZkClient(zookeeperLocalCluster.getConnectString(), 60000, 60000, ZKStringSerializer$.MODULE$);
ZkUtils zkUtils = new ZkUtils(zkClient, new ZkConnection(zookeeperLocalCluster.getConnectString()), false);
// ZkUtils zkUtils = ZkUtils.apply(zookeeperLocalCluster.getConnectString(), 60000, 60000, false);
AdminUtils.createTopic(zkUtils, topic, 1, 1, new Properties());
}
示例2: startKafka
import kafka.server.KafkaConfig; //导入方法依赖的package包/类
private void startKafka() throws IOException, URISyntaxException {
String kafkaValue = properties.getProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG);
LOG.debug("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));
kafkaServer = new KafkaServer(KafkaConfig.fromProps(brokerConfig), new SystemTime(),
Option.apply(this.getClass().getName()));
kafkaServer.startup();
LOG.debug("Embedded kafka server started with broker config {}", brokerConfig);
}
示例3: SupportedServerStartable
import kafka.server.KafkaConfig; //导入方法依赖的package包/类
public SupportedServerStartable(Properties brokerConfiguration) {
Seq<KafkaMetricsReporter>
reporters =
KafkaMetricsReporter$.MODULE$.startReporters(new VerifiableProperties(brokerConfiguration));
KafkaConfig serverConfig = KafkaConfig.fromProps(brokerConfiguration);
Option<String> noThreadNamePrefix = Option.empty();
server = new KafkaServer(serverConfig, Time.SYSTEM, noThreadNamePrefix, reporters);
KafkaSupportConfig kafkaSupportConfig = new KafkaSupportConfig(brokerConfiguration);
if (kafkaSupportConfig.isProactiveSupportEnabled()) {
try {
Runtime serverRuntime = Runtime.getRuntime();
metricsReporter =
new MetricsReporter(server, kafkaSupportConfig, serverRuntime);
metricsReporter.init();
metricsThread = newThread("ConfluentProactiveSupportMetricsAgent", metricsReporter, true);
long reportIntervalMs = kafkaSupportConfig.getReportIntervalMs();
long reportIntervalHours = reportIntervalMs / (60 * 60 * 1000);
// We log at WARN level to increase the visibility of this information.
log.warn(legalDisclaimerProactiveSupportEnabled(reportIntervalHours));
} catch (Exception e) {
// We catch any exceptions to prevent collateral damage to the more important broker
// threads that are running in the same JVM.
log.error("Failed to start Proactive Support Metrics agent: {}", e.getMessage());
}
} else {
// We log at WARN level to increase the visibility of this information.
log.warn(legalDisclaimerProactiveSupportDisabled());
}
}
示例4: proactiveSupportConfigIsValidKafkaConfig
import kafka.server.KafkaConfig; //导入方法依赖的package包/类
@Test
public void proactiveSupportConfigIsValidKafkaConfig() throws IOException {
// Given
Properties brokerConfiguration = defaultBrokerConfiguration();
// When
KafkaConfig cfg = KafkaConfig.fromProps(brokerConfiguration);
// Then
assertThat(cfg.brokerId()).isEqualTo(0);
assertThat(cfg.zkConnect()).startsWith("localhost:");
}
示例5: configure
import kafka.server.KafkaConfig; //导入方法依赖的package包/类
@Override
public void configure() throws Exception {
kafkaProperties.put("advertised.host.name", kafkaHostname);
kafkaProperties.put("port", kafkaPort+"");
kafkaProperties.put("broker.id", kafkaBrokerId+"");
kafkaProperties.put("log.dir", kafkaTempDir);
kafkaProperties.put("enable.zookeeper", "true");
kafkaProperties.put("zookeeper.connect", zookeeperConnectionString);
kafkaConfig = KafkaConfig.fromProps(kafkaProperties);
}
示例6: setUp
import kafka.server.KafkaConfig; //导入方法依赖的package包/类
@Before
public void setUp() {
Properties props = new Properties();
String sentry_site_path = SentryKafkaAuthorizerTest.class.getClassLoader().getResource(KafkaAuthConf.AUTHZ_SITE_FILE).getPath();
// Kafka check this prop when creating a config instance
props.put("zookeeper.connect", "test");
props.put("sentry.kafka.site.url", "file://" + sentry_site_path);
config = KafkaConfig.fromProps(props);
authorizer.configure(config.originals());
}
示例7: KafkaLocal
import kafka.server.KafkaConfig; //导入方法依赖的package包/类
public KafkaLocal(Properties kafkaProperties) throws IOException, InterruptedException {
KafkaConfig kafkaConfig = KafkaConfig.fromProps(kafkaProperties);
// start local kafka broker
kafka = new KafkaServerStartable(kafkaConfig);
}