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


Java TestUtils.createServer方法代码示例

本文整理汇总了Java中kafka.utils.TestUtils.createServer方法的典型用法代码示例。如果您正苦于以下问题:Java TestUtils.createServer方法的具体用法?Java TestUtils.createServer怎么用?Java TestUtils.createServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kafka.utils.TestUtils的用法示例。


在下文中一共展示了TestUtils.createServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startup

import kafka.utils.TestUtils; //导入方法依赖的package包/类
/**
 * Starts the Embedded Kafka and Zookeeper Servers.
 * @throws Exception - If an exeption occurs during startup.
 */
protected void startup() throws Exception {
    // Setup the embedded zookeeper
    logger.info("Starting up Embedded Zookeeper...");
    zkServer = new EmbeddedZookeeper();
    zookeperConnect = ZKHOST + ":" + zkServer.port();
    logger.info("Embedded Zookeeper started at: {}", zookeperConnect);

    // setup Broker
    logger.info("Starting up Embedded Kafka...");
    brokerPort = Integer.toString(PortUtils.getRandomFreePort());
    final Properties brokerProps = new Properties();
    brokerProps.setProperty(KafkaConfig$.MODULE$.BrokerIdProp(), "0");
    brokerProps.setProperty(KafkaConfig$.MODULE$.HostNameProp(), BROKERHOST);
    brokerProps.setProperty(KafkaConfig$.MODULE$.PortProp(), brokerPort);
    brokerProps.setProperty(KafkaConfig$.MODULE$.ZkConnectProp(), zookeperConnect);
    brokerProps.setProperty(KafkaConfig$.MODULE$.LogDirsProp(), Files.createTempDirectory(getClass().getSimpleName() + "-").toAbsolutePath().toString());
    final KafkaConfig config = new KafkaConfig(brokerProps);
    final Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);
    logger.info("Embedded Kafka Server started at: {}:{}", BROKERHOST, brokerPort);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:26,代码来源:EmbeddedKafkaInstance.java

示例2: setupKafka

import kafka.utils.TestUtils; //导入方法依赖的package包/类
/**
 * setup mini kafka and call the super to setup mini fluo
 */
@Before
public void setupKafka() throws Exception {
    // Install an instance of Rya on the Accumulo cluster.
    installRyaInstance();

    // Setup Kafka.
    zkServer = new EmbeddedZookeeper();
    final String zkConnect = ZKHOST + ":" + zkServer.port();
    zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$);
    zkUtils = ZkUtils.apply(zkClient, false);

    // setup Broker
    final 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", "PLAINTEXT://" + BROKERHOST + ":" + BROKERPORT);
    final KafkaConfig config = new KafkaConfig(brokerProps);
    final Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:25,代码来源:KafkaExportITBase.java

示例3: startServer

import kafka.utils.TestUtils; //导入方法依赖的package包/类
public static void startServer() throws RuntimeException {
  if (serverStarted && serverClosed) {
    throw new RuntimeException("Kafka test server has already been closed. Cannot generate Kafka server twice.");
  }
  if (!serverStarted) {
    serverStarted = true;
    zkConnect = TestZKUtils.zookeeperConnect();
    zkServer = new EmbeddedZookeeper(zkConnect);
    zkClient = new ZkClient(zkServer.connectString(), 30000, 30000, ZKStringSerializer$.MODULE$);

    kafkaPort = TestUtils.choosePort();
    Properties props = TestUtils.createBrokerConfig(brokerId, kafkaPort, true);

    KafkaConfig config = new KafkaConfig(props);
    Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:19,代码来源:KafkaTestBase.java

示例4: KafkaEmbedded

import kafka.utils.TestUtils; //导入方法依赖的package包/类
/**
 * Creates and starts an embedded Kafka broker.
 *
 * @param config Broker configuration settings.  Used to modify, for example, on which port the
 *               broker should listen to.  Note that you cannot change the `log.dirs` setting
 *               currently.
 */
public KafkaEmbedded(final Properties config, final MockTime time) throws IOException {
    tmpFolder = new TemporaryFolder();
    tmpFolder.create();
    logDir = tmpFolder.newFolder();
    effectiveConfig = effectiveConfigFrom(config);
    final boolean loggingEnabled = true;
    final KafkaConfig kafkaConfig = new KafkaConfig(effectiveConfig, loggingEnabled);
    log.debug("Starting embedded Kafka broker (with log.dirs={} and ZK ensemble at {}) ...",
        logDir, zookeeperConnect());
    kafka = TestUtils.createServer(kafkaConfig, time);
    log.debug("Startup of embedded Kafka broker at {} completed (with ZK ensemble at {}) ...",
        brokerList(), zookeeperConnect());
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:21,代码来源:KafkaEmbedded.java

示例5: KafkaEmbedded

import kafka.utils.TestUtils; //导入方法依赖的package包/类
/**
 * Creates and starts an embedded Kafka broker.
 *
 * @param config Broker configuration settings.  Used to modify, for example, on which port the
 *               broker should listen to.  Note that you cannot change some settings such as
 *               `log.dirs`, `port`.
 */
public KafkaEmbedded(Properties config) throws IOException {
  tmpFolder = new TemporaryFolder();
  tmpFolder.create();
  logDir = tmpFolder.newFolder();
  effectiveConfig = effectiveConfigFrom(config);
  boolean loggingEnabled = true;

  KafkaConfig kafkaConfig = new KafkaConfig(effectiveConfig, loggingEnabled);
  log.debug("Starting embedded Kafka broker (with log.dirs={} and ZK ensemble at {}) ...",
      logDir, zookeeperConnect());
  kafka = TestUtils.createServer(kafkaConfig, Time.SYSTEM);
  log.debug("Startup of embedded Kafka broker at {} completed (with ZK ensemble at {}) ...",
      brokerList(), zookeeperConnect());
}
 
开发者ID:kaiwaehner,项目名称:kafka-streams-machine-learning-examples,代码行数:22,代码来源:KafkaEmbedded.java

示例6: setup

import kafka.utils.TestUtils; //导入方法依赖的package包/类
@BeforeClass
public static void setup() {
  zkServer = new EmbeddedZookeeper(TestZKUtils.zookeeperConnect());
  zkClient = new ZkClient(zkServer.connectString(), 30000, 30000, ZKStringSerializer$.MODULE$);
  kafkaServer = TestUtils.createServer(new KafkaConfig(TestUtils.createBrokerConfig(0, brokerPort, true)),
      new MockTime());
  kafkaServers = new ArrayList<>();
  kafkaServers.add(kafkaServer);
}
 
开发者ID:FreshetDMS,项目名称:Freshet-Deprecated,代码行数:10,代码来源:AbstractSamzaTest.java

示例7: KafkaEmbedded

import kafka.utils.TestUtils; //导入方法依赖的package包/类
/**
 * Creates and starts an embedded Kafka broker.
 *
 * @param config Broker configuration settings.  Used to modify, for example, on which port the
 *               broker should listen to.  Note that you cannot change the `log.dirs` setting
 *               currently.
 */
public KafkaEmbedded(final Properties config, final MockTime time) throws IOException {
  tmpFolder = new TemporaryFolder();
  tmpFolder.create();
  logDir = tmpFolder.newFolder();
  effectiveConfig = effectiveConfigFrom(config);
  final boolean loggingEnabled = true;
  final KafkaConfig kafkaConfig = new KafkaConfig(effectiveConfig, loggingEnabled);
  log.debug("Starting embedded Kafka broker (with log.dirs={} and ZK ensemble at {}) ...",
      logDir, zookeeperConnect());
  kafka = TestUtils.createServer(kafkaConfig, time);
  log.debug("Startup of embedded Kafka broker at {} completed (with ZK ensemble at {}) ...",
      brokerList(), zookeeperConnect());
}
 
开发者ID:Landoop,项目名称:kafka-testkit,代码行数:21,代码来源:KafkaEmbedded.java

示例8: KafkaEmbedded

import kafka.utils.TestUtils; //导入方法依赖的package包/类
/**
 * Creates and starts an embedded Kafka broker.
 *
 * @param config Broker configuration settings.  Used to modify, for example, on which port the
 *               broker should listen to.  Note that you cannot change some settings such as
 *               `log.dirs`, `port`.
 */
public KafkaEmbedded(Properties config) throws IOException {
  tmpFolder = new TemporaryFolder();
  tmpFolder.create();
  logDir = tmpFolder.newFolder();
  effectiveConfig = effectiveConfigFrom(config);
  boolean loggingEnabled = true;

  KafkaConfig kafkaConfig = new KafkaConfig(effectiveConfig, loggingEnabled);
  log.debug("Starting embedded Kafka broker (with log.dirs={} and ZK ensemble at {}) ...",
      logDir, zookeeperConnect());
  kafka = TestUtils.createServer(kafkaConfig, new SystemTime());
  log.debug("Startup of embedded Kafka broker at {} completed (with ZK ensemble at {}) ...",
      brokerList(), zookeeperConnect());
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:22,代码来源:KafkaEmbedded.java

示例9: setupKafkaServer

import kafka.utils.TestUtils; //导入方法依赖的package包/类
/**
 * Sets up test Kafka broker.
 *
 * @throws IOException If failed.
 */
private void setupKafkaServer() throws IOException {
    kafkaCfg = new KafkaConfig(getKafkaConfig());

    kafkaSrv = TestUtils.createServer(kafkaCfg, SystemTime$.MODULE$);

    kafkaSrv.startup();
}
 
开发者ID:apache,项目名称:ignite,代码行数:13,代码来源:TestKafkaBroker.java

示例10: createKafkaServer

import kafka.utils.TestUtils; //导入方法依赖的package包/类
public static KafkaServer createKafkaServer(int brokerId, int port, String zkConnect) {
  final Option<File> noFile = scala.Option.apply(null);
  final Option<SecurityProtocol> noInterBrokerSecurityProtocol = scala.Option.apply(null);
  // new params for kafka 0.10.0
  Option<Properties> saslProperties = scala.Option.apply(null);
  Option rack = scala.Option.apply(RackAwareMode.Enforced$.MODULE$.toString());
  Properties props = TestUtils.createBrokerConfig(
      brokerId,
      zkConnect,
      false,
      false,
      port,
      noInterBrokerSecurityProtocol,
      noFile,
      saslProperties,
      true,
      false,
      TestUtils.RandomPort(),
      false,
      TestUtils.RandomPort(),
      false,
      TestUtils.RandomPort(),
      rack
  );
  props.setProperty("auto.create.topics.enable", "true");
  props.setProperty("num.partitions", "1");
  props.setProperty("zookeeper.connect", zkConnect);
  KafkaConfig config = new KafkaConfig(props);
  return TestUtils.createServer(config, Time.SYSTEM);
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:31,代码来源:KafkaTestUtil11.java

示例11: createKafkaServer

import kafka.utils.TestUtils; //导入方法依赖的package包/类
public static KafkaServer createKafkaServer(int brokerId, int port, String zkConnect) {
  final Option<File> noFile = scala.Option.apply(null);
  final Option<SecurityProtocol> noInterBrokerSecurityProtocol = scala.Option.apply(null);
  // new params for kafka 0.10.0
  Option<Properties> saslProperties = scala.Option.apply(null);
  Option rack = scala.Option.apply(RackAwareMode.Enforced$.MODULE$.toString());
  Properties props = TestUtils.createBrokerConfig(
      brokerId,
      zkConnect,
      false,
      false,
      port,
      noInterBrokerSecurityProtocol,
      noFile,
      saslProperties,
      true,
      false,
      TestUtils.RandomPort(),
      false,
      TestUtils.RandomPort(),
      false,
      TestUtils.RandomPort(),
      rack
  );
  props.setProperty("auto.create.topics.enable", "true");
  props.setProperty("num.partitions", "1");
  props.setProperty("zookeeper.connect", zkConnect);
  KafkaConfig config = new KafkaConfig(props);
  return TestUtils.createServer(config, SystemTime$.MODULE$);
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:31,代码来源:KafkaTestUtil10.java

示例12: createKafkaServer

import kafka.utils.TestUtils; //导入方法依赖的package包/类
public static KafkaServer createKafkaServer(int brokerId, int port, String zkConnect) {
  final Option<File> noFile = scala.Option.apply(null);
  final Option<SecurityProtocol> noInterBrokerSecurityProtocol = scala.Option.apply(null);
  // new params for kafka 0.10.0
  Option<Properties> saslProperties = scala.Option.apply(null);
  Option rack = scala.Option.apply(RackAwareMode.Enforced$.MODULE$.toString());
  Properties props = TestUtils.createBrokerConfig(
      brokerId,
      zkConnect,
      false,
      false,
      port,
      noInterBrokerSecurityProtocol,
      noFile,
      saslProperties,
      true,
      false,
      TestUtils.RandomPort(),
      false,
      TestUtils.RandomPort(),
      false,
      TestUtils.RandomPort(),
      rack,
      1
  );
  props.setProperty("auto.create.topics.enable", "true");
  props.setProperty("num.partitions", "1");
  props.setProperty("zookeeper.connect", zkConnect);
  KafkaConfig config = new KafkaConfig(props);
  return TestUtils.createServer(config, Time.SYSTEM);
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:32,代码来源:KafkaTestUtil1_0.java

示例13: startKafkaServer

import kafka.utils.TestUtils; //导入方法依赖的package包/类
private KafkaServer startKafkaServer() {
    Properties props = TestUtils.createBrokerConfig(0, zookeeper.getConnectString(), true, true, 9092, Option.<SecurityProtocol>empty(), Option.<File>empty(), Option.<Properties>empty(), true, false, 0, false, 0, false, 0, Option.<String>empty(), 0);
    props.put(KafkaConfig.ZkConnectProp(), zookeeper.getConnectString());
    kafkaServer = TestUtils.createServer(new KafkaConfig(props), new kafka.utils.MockTime());
    return kafkaServer;
}
 
开发者ID:hubrick,项目名称:vertx-kafka-service,代码行数:7,代码来源:KafkaProducerServiceIntegrationTest.java

示例14: createKafkaServer

import kafka.utils.TestUtils; //导入方法依赖的package包/类
public static KafkaServer createKafkaServer(int port, String zkConnect, boolean autoCreateTopic) {
  KafkaConfig config = new KafkaConfig(createKafkaConfig(port, zkConnect, autoCreateTopic, 1));
  return TestUtils.createServer(config, Time.SYSTEM);
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:5,代码来源:TestUtil1_0.java

示例15: before

import kafka.utils.TestUtils; //导入方法依赖的package包/类
@Before
public void before() {

    zkServer = new EmbeddedZookeeper();
    zkConnect = String.format("localhost:%d", zkServer.port());
    ZkUtils zkUtils = ZkUtils.apply(zkConnect, 30000, 30000,
            JaasUtils.isZkSecurityEnabled());
    zkClient = zkUtils.zkClient();

    final Option<java.io.File> noFile = Option.apply(null);
    final Option<SecurityProtocol> noInterBrokerSecurityProtocol = Option
            .apply(null);

    kafkaProps = TestUtils.createBrokerConfig(brokerId, zkConnect, false,
            false, port, noInterBrokerSecurityProtocol, noFile, true,
            false, TestUtils.RandomPort(), false, TestUtils.RandomPort(),
            false, TestUtils.RandomPort());

    kafkaProps.setProperty("auto.create.topics.enable", "true");
    kafkaProps.setProperty("num.partitions", "1");
    // We *must* override this to use the port we allocated (Kafka currently
    // allocates one port
    // that it always uses for ZK
    kafkaProps.setProperty("zookeeper.connect", this.zkConnect);
    kafkaProps.setProperty("host.name", "localhost");
    kafkaProps.setProperty("port", port + "");

    KafkaConfig config = new KafkaConfig(kafkaProps);
    Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);

    // create topic
    TopicCommand.TopicCommandOptions options = new TopicCommand.TopicCommandOptions(
            new String[]{"--create", "--topic", topic,
                    "--replication-factor", "1", "--partitions", "1"});

    TopicCommand.createTopic(zkUtils, options);

    List<KafkaServer> servers = new ArrayList<KafkaServer>();
    servers.add(kafkaServer);
    TestUtils.waitUntilMetadataIsPropagated(
            scala.collection.JavaConversions.asScalaBuffer(servers), topic,
            0, 5000);
}
 
开发者ID:DarkPhoenixs,项目名称:message-queue-client-framework,代码行数:45,代码来源:NewReceiverWithSpringTest.java


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