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


Java TestUtils.createBrokerConfig方法代码示例

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


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

示例1: initialize

import kafka.utils.TestUtils; //导入方法依赖的package包/类
public void initialize() {
    if (initialized) {
        throw new IllegalStateException("Context has been already initialized");
    }
    zkServer = new EmbeddedZookeeper(TestZKUtils.zookeeperConnect());
    zkClient = new ZkClient(zkServer.connectString(), 10000, 10000, ZKStringSerializer$.MODULE$);

    port = TestUtils.choosePort();

    KafkaConfig config = new KafkaConfig(TestUtils.createBrokerConfig(brokerId, port, true));
    Time mock = new MockTime();

    kafkaServer = new KafkaServer(config, mock);
    kafkaServer.startup();

    initialized = true;
}
 
开发者ID:researchgate,项目名称:kafka-metamorph,代码行数:18,代码来源:Kafka08TestContext.java

示例2: startKafkaBrokers

import kafka.utils.TestUtils; //导入方法依赖的package包/类
public static void startKafkaBrokers(int numberOfBrokers) {
  kafkaServers = new ArrayList<>(numberOfBrokers);
  kafkaProps = new HashMap<>();
  // setup Broker
  StringBuilder sb = new StringBuilder();
  for(int i = 0; i < numberOfBrokers; i ++) {
    int port = TestUtils.choosePort();
    Properties props = TestUtils.createBrokerConfig(i, port);
    props.put("auto.create.topics.enable", "false");
    kafkaServers.add(TestUtils.createServer(new KafkaConfig(props), new MockTime()));
    sb.append("localhost:").append(port).append(",");
  }
  metadataBrokerURI = sb.deleteCharAt(sb.length()-1).toString();
  LOG.info("Setting metadataBrokerList and auto.offset.reset for test case");
  kafkaProps.put("auto.offset.reset", "smallest");
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:17,代码来源:KafkaTestUtil.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:Hanmourang,项目名称:Gobblin,代码行数:19,代码来源:KafkaTestBase.java

示例4: start

import kafka.utils.TestUtils; //导入方法依赖的package包/类
public void start() throws IOException {

        String zkConnect = TestZKUtils.zookeeperConnect();
        zkServer = new EmbeddedZookeeper(zkConnect);
        zkClient =
                new ZkClient(zkServer.connectString(), 30000, 30000, ZKStringSerializer$.MODULE$);
        brokerPort = TestUtils.choosePort();
        logger.info("{}", brokerPort);;
        Properties props = TestUtils.createBrokerConfig(BROKER_ID, brokerPort, true);
        // props.setProperty("zookeeper.connect", String.valueOf(zkPort));
        props.setProperty("zookeeper.session.timeout.ms", "30000");
        props.setProperty("zookeeper.connection.timeout.ms", "30000");
        logger.info("{}", props);
        KafkaConfig config = new KafkaConfig(props);
        Time mock = new MockTime();
        kafkaServer = TestUtils.createServer(config, mock);
    }
 
开发者ID:trustedanalytics,项目名称:data-acquisition,代码行数:18,代码来源:KafkaEmbeded.java

示例5: createKafkaConfig

import kafka.utils.TestUtils; //导入方法依赖的package包/类
public static Properties createKafkaConfig(int port, String zkConnect, boolean autoCreateTopic, int numPartitions) {
  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<String> rack = scala.Option.apply(RackAwareMode.Enforced$.MODULE$.toString());

  Properties props = TestUtils.createBrokerConfig(
      0, 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", String.valueOf(autoCreateTopic));
  props.setProperty("num.partitions", String.valueOf(numPartitions));
  props.setProperty("offsets.topic.replication.factor", "1");
  return props;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:17,代码来源:TestUtil1_0.java

示例6: createKafkaConfig

import kafka.utils.TestUtils; //导入方法依赖的package包/类
public static Properties createKafkaConfig(int port, String zkConnect, boolean autoCreateTopic, int numPartitions) {
  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<String> rack = scala.Option.apply(RackAwareMode.Enforced$.MODULE$.toString());

  Properties props = TestUtils.createBrokerConfig(
      0, zkConnect, false, false, port, noInterBrokerSecurityProtocol,
      noFile, saslProperties, true, false, TestUtils.RandomPort(), false, TestUtils.RandomPort(), false,
      TestUtils.RandomPort(), rack);
  props.setProperty("auto.create.topics.enable", String.valueOf(autoCreateTopic));
  props.setProperty("num.partitions", String.valueOf(numPartitions));
  props.setProperty("offsets.topic.replication.factor", "1");
  return props;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:17,代码来源:TestUtil11.java

示例7: 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);
  Properties props = TestUtils.createBrokerConfig(
      brokerId,
      zkConnect,
      false,
      false,
      port,
      noInterBrokerSecurityProtocol,
      noFile,
      true,
      false,
      TestUtils.RandomPort(),
      false,
      TestUtils.RandomPort(),
      false,
      TestUtils.RandomPort()
  );
  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,代码行数:26,代码来源:KafkaTestUtil09.java

示例8: createKafkaConfig

import kafka.utils.TestUtils; //导入方法依赖的package包/类
public static Properties createKafkaConfig(int port, String zkConnect, boolean autoCreateTopic, int numPartitions) {
  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<String> rack = scala.Option.apply(RackAwareMode.Enforced$.MODULE$.toString());

  Properties props = TestUtils.createBrokerConfig(
      0, zkConnect, false, false, port, noInterBrokerSecurityProtocol,
      noFile, saslProperties, true, false, TestUtils.RandomPort(), false, TestUtils.RandomPort(), false,
      TestUtils.RandomPort(), rack);
  props.setProperty("auto.create.topics.enable", String.valueOf(autoCreateTopic));
  props.setProperty("num.partitions", String.valueOf(numPartitions));
  props.setProperty("offsets.topic.replication.factor", "1");
  props.setProperty("message.max.bytes", "500");
  return props;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:18,代码来源:TestUtil10.java

示例9: 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

示例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: setUp

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

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

    final Option<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);

    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", "2"});

    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,代码行数:43,代码来源:KafkaMessageNewReceiverPoolTest3.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 = scala.Option.apply(null);
    final Option<SecurityProtocol> noInterBrokerSecurityProtocol = scala.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,代码来源:ReceiverTest.java


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