當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。