本文整理汇总了Java中kafka.utils.TestUtils.waitUntilMetadataIsPropagated方法的典型用法代码示例。如果您正苦于以下问题:Java TestUtils.waitUntilMetadataIsPropagated方法的具体用法?Java TestUtils.waitUntilMetadataIsPropagated怎么用?Java TestUtils.waitUntilMetadataIsPropagated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kafka.utils.TestUtils
的用法示例。
在下文中一共展示了TestUtils.waitUntilMetadataIsPropagated方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpClass
import kafka.utils.TestUtils; //导入方法依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
int zkConnectionTimeout = 6000;
int zkSessionTimeout = 6000;
zookeeper = new EmbeddedZookeeper();
zkConnect = String.format("127.0.0.1:%d", zookeeper.port());
zkUtils = ZkUtils.apply(
zkConnect, zkSessionTimeout, zkConnectionTimeout,
JaasUtils.isZkSecurityEnabled());
port = NetworkUtils.getRandomPort();
kafkaServer = TestUtil09.createKafkaServer(port, zkConnect);
for (int i = 0; i < topics.length; i++) {
topics[i] = UUID.randomUUID().toString();
AdminUtils.createTopic(zkUtils, topics[i], 1, 1, new Properties());
TestUtils.waitUntilMetadataIsPropagated(
scala.collection.JavaConversions.asScalaBuffer(Arrays.asList(kafkaServer)),
topics[i], 0, 5000);
}
}
示例2: setUp
import kafka.utils.TestUtils; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
sdcKafkaTestUtil.startZookeeper();
sdcKafkaTestUtil.startKafkaBrokers(3);
// create topic
sdcKafkaTestUtil.createTopic(TOPIC1, PARTITIONS, REPLICATION_FACTOR);
for (int i = 1; i <= 1 ; i++) {
for (int j = 0; j < PARTITIONS; j++) {
TestUtils.waitUntilMetadataIsPropagated(
scala.collection.JavaConversions.asScalaBuffer(sdcKafkaTestUtil.getKafkaServers()),
"TestUDPToKafkaSource" + String.valueOf(i), j, 5000);
}
}
kafkaStreams1 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC1, PARTITIONS);
}
示例3: setUp
import kafka.utils.TestUtils; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
randomPort = NetworkUtils.getRandomPort();
sdcKafkaTestUtil.startZookeeper();
sdcKafkaTestUtil.startKafkaBrokers(3);
// create topic
sdcKafkaTestUtil.createTopic(TOPIC1, PARTITIONS, REPLICATION_FACTOR);
for (int i = 1; i <= 1 ; i++) {
for (int j = 0; j < PARTITIONS; j++) {
TestUtils.waitUntilMetadataIsPropagated(
scala.collection.JavaConversions.asScalaBuffer(sdcKafkaTestUtil.getKafkaServers()),
"TestSdcIpcToKafka" + String.valueOf(i), j, 5000);
}
}
kafkaStreams1 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC1, PARTITIONS);
}
示例4: createTopic
import kafka.utils.TestUtils; //导入方法依赖的package包/类
private void createTopic(String topic) {
final ZkClient zkClient = new ZkClient(zookeeper.getConnectString(), 30000, 30000, ZKStringSerializer$.MODULE$);
final ZkConnection connection = new ZkConnection(zookeeper.getConnectString());
final ZkUtils zkUtils = new ZkUtils(zkClient, connection, false);
AdminUtils.createTopic(zkUtils, topic, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$);
TestUtils.waitUntilMetadataIsPropagated(JavaConversions.asScalaBuffer(Lists.newArrayList(kafkaServer)), topic, 0, 10000);
zkClient.close();
}
示例5: createTopic
import kafka.utils.TestUtils; //导入方法依赖的package包/类
public void createTopic(String topic, int numPartitions, long timeout) {
ensureInitialized();
TopicCommand.createTopic(zkClient, new TopicCommand.TopicCommandOptions(
new String[] {"--topic", topic, "--partitions", String.valueOf(numPartitions),"--replication-factor", "1"}
));
List<KafkaServer> servers = new ArrayList<>();
servers.add(kafkaServer);
for (int partitionId = 0; partitionId < numPartitions; partitionId++) {
TestUtils.waitUntilMetadataIsPropagated(asScalaBuffer(servers), topic, partitionId, timeout);
}
}
示例6: KafkaTestBase
import kafka.utils.TestUtils; //导入方法依赖的package包/类
public KafkaTestBase(String topic) throws InterruptedException, RuntimeException {
startServer();
this.topic = topic;
AdminUtils.createTopic(zkClient, topic, 1, 1, new Properties());
List<KafkaServer> servers = new ArrayList<KafkaServer>();
servers.add(kafkaServer);
TestUtils.waitUntilMetadataIsPropagated(scala.collection.JavaConversions.asScalaBuffer(servers), topic, 0, 5000);
Properties consumeProps = new Properties();
consumeProps.put("zookeeper.connect", zkConnect);
consumeProps.put("group.id", "testConsumer");
consumeProps.put("zookeeper.session.timeout.ms", "10000");
consumeProps.put("zookeeper.sync.time.ms", "10000");
consumeProps.put("auto.commit.interval.ms", "10000");
consumeProps.put("consumer.timeout.ms", "10000");
consumer = Consumer.createJavaConsumerConnector(new ConsumerConfig(consumeProps));
Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
topicCountMap.put(this.topic, 1);
Map<String, List<KafkaStream<byte[], byte[]>>> consumerMap = consumer.createMessageStreams(topicCountMap);
List<KafkaStream<byte[],byte[]>> streams = consumerMap.get(this.topic);
stream = streams.get(0);
iterator = stream.iterator();
}
示例7: KafkaTestBase
import kafka.utils.TestUtils; //导入方法依赖的package包/类
public KafkaTestBase(String topic) throws InterruptedException, RuntimeException {
startServer();
this.topic = topic;
AdminUtils.createTopic(zkClient, topic, 1, 1, new Properties());
List<KafkaServer> servers = new ArrayList<>();
servers.add(kafkaServer);
TestUtils.waitUntilMetadataIsPropagated(scala.collection.JavaConversions.asScalaBuffer(servers), topic, 0, 5000);
Properties consumeProps = new Properties();
consumeProps.put("zookeeper.connect", zkConnect);
consumeProps.put("group.id", "testConsumer");
consumeProps.put("zookeeper.session.timeout.ms", "10000");
consumeProps.put("zookeeper.sync.time.ms", "10000");
consumeProps.put("auto.commit.interval.ms", "10000");
consumeProps.put("consumer.timeout.ms", "10000");
consumer = Consumer.createJavaConsumerConnector(new ConsumerConfig(consumeProps));
Map<String, Integer> topicCountMap = new HashMap<>();
topicCountMap.put(this.topic, 1);
Map<String, List<KafkaStream<byte[], byte[]>>> consumerMap = consumer.createMessageStreams(topicCountMap);
List<KafkaStream<byte[], byte[]>> streams = consumerMap.get(this.topic);
stream = streams.get(0);
iterator = stream.iterator();
}
示例8: createTopic
import kafka.utils.TestUtils; //导入方法依赖的package包/类
public void createTopic(String topic, int numberOfPartitions, int replicationFactor) {
if (!AdminUtils.topicExists(zkClient, topic)) {
logger.info(String.format("Topic '%s' not found, creating...", topic));
AdminUtils.createTopic(zkClient, topic, numberOfPartitions,
replicationFactor, new Properties());
for (int i = 0; i < numberOfPartitions; i++) {
TestUtils.waitUntilMetadataIsPropagated(JavaConversions.asScalaBuffer(getBrokers()), topic, i, 5000);
TestUtils.waitUntilLeaderIsElectedOrChanged(zkClient, topic, i, 500, Option.empty(), Option.empty());
}
} else {
logger.info(String.format("Topic '%s' already exists", topic));
}
}
示例9: waitForTopic
import kafka.utils.TestUtils; //导入方法依赖的package包/类
protected void waitForTopic(String topic) {
TestUtils.waitUntilMetadataIsPropagated(scala.collection.JavaConversions.asScalaBuffer(kafkaServers), topic, 0,
30000);
}
示例10: setUp
import kafka.utils.TestUtils; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws IOException, InterruptedException {
sdcKafkaTestUtil.startZookeeper();
sdcKafkaTestUtil.startKafkaBrokers(1);
// create topic
sdcKafkaTestUtil.createTopic(TOPIC1, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC2, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC3, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC4, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC5, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC6, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC7, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC8, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC9, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC10, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC11, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC12, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC13, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC14, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC15, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC16, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC17, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC18, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC19, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC20, PARTITIONS, REPLICATION_FACTOR);
sdcKafkaTestUtil.createTopic(TOPIC21, PARTITIONS, REPLICATION_FACTOR);
for (int i = 1; i <= 21 ; i++) {
TestUtils.waitUntilMetadataIsPropagated(
scala.collection.JavaConversions.asScalaBuffer(sdcKafkaTestUtil.getKafkaServers()),
"TestKafkaTargetSinglePartition" + String.valueOf(i), 0, 5000);
}
kafkaStreams1 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC1, PARTITIONS);
kafkaStreams2 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC2, PARTITIONS);
kafkaStreams3 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC3, PARTITIONS);
kafkaStreams4 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC4, PARTITIONS);
kafkaStreams5 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC5, PARTITIONS);
kafkaStreams6 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC6, PARTITIONS);
kafkaStreams7 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC7, PARTITIONS);
kafkaStreams8 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC8, PARTITIONS);
kafkaStreams9 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC9, PARTITIONS);
kafkaStreams10 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC10, PARTITIONS);
kafkaStreams11 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC11, PARTITIONS);
kafkaStreams12 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC12, PARTITIONS);
kafkaStreams13 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC13, PARTITIONS);
kafkaStreams14 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC14, PARTITIONS);
kafkaStreams15 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC15, PARTITIONS);
kafkaStreams16 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC16, PARTITIONS);
kafkaStreams17 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC17, PARTITIONS);
kafkaStreams18 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC18, PARTITIONS);
kafkaStreams19 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC19, PARTITIONS);
kafkaStreams20 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC20, PARTITIONS);
kafkaStreams21 = sdcKafkaTestUtil.createKafkaStream(sdcKafkaTestUtil.getZkConnect(), TOPIC21, PARTITIONS);
}
示例11: 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);
}
示例12: 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
示例13: 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 = 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);
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,代码来源:KafkaMessageNewReceiverPoolTest.java
示例14: 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);
}
示例15: 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 = 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);
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,代码行数:43,代码来源:KafkaMessageNewSenderPoolTest.java