本文整理匯總了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);
}