当前位置: 首页>>代码示例>>Java>>正文


Java KafkaConfig.fromProps方法代码示例

本文整理汇总了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());
}
 
开发者ID:apache,项目名称:incubator-pirk,代码行数:22,代码来源:KafkaStormIntegrationTest.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:18,代码来源:KafkaNotification.java

示例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());
  }
}
 
开发者ID:confluentinc,项目名称:support-metrics-client,代码行数:32,代码来源:SupportedServerStartable.java

示例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:");
}
 
开发者ID:confluentinc,项目名称:support-metrics-common,代码行数:13,代码来源:BaseSupportConfigTest.java

示例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);
}
 
开发者ID:sakserv,项目名称:hadoop-mini-clusters,代码行数:11,代码来源:KafkaLocalBroker.java

示例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());
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:12,代码来源:SentryKafkaAuthorizerTest.java

示例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);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:7,代码来源:KafkaLocal.java


注:本文中的kafka.server.KafkaConfig.fromProps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。