xiangfu0 commented on code in PR #8691:
URL: https://github.com/apache/pinot/pull/8691#discussion_r871799558
##########
pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/test/java/org/apache/pinot/plugin/stream/pulsar/PulsarConsumerTest.java:
##########
@@ -164,52 +165,70 @@ public void publishRecords()
throws Exception {
for (int p = 0; p < NUM_PARTITION; p++) {
final int partition = p;
- Producer<String> producer =
-
_pulsarClient.newProducer(Schema.STRING).topic(TEST_TOPIC).messageRouter(new
MessageRouter() {
+ try (Producer<String> producer =
_pulsarClient.newProducer(Schema.STRING).topic(TEST_TOPIC)
+ .messageRouter(new MessageRouter() {
@Override
public int choosePartition(Message<?> msg, TopicMetadata metadata)
{
return partition;
}
- }).create();
-
- for (int i = 0; i < NUM_RECORDS_PER_PARTITION; i++) {
- MessageId messageId = producer.send(MESSAGE_PREFIX + "_" + i);
- if (!_partitionToFirstMessageIdMap.containsKey(partition)) {
- _partitionToFirstMessageIdMap.put(partition, messageId);
+ }).create()) {
+ for (int i = 0; i < NUM_RECORDS_PER_PARTITION; i++) {
+ MessageId messageId = producer.send(MESSAGE_PREFIX + "_" + i);
+ if (!_partitionToFirstMessageIdMap.containsKey(partition)) {
+ _partitionToFirstMessageIdMap.put(partition, messageId);
+ }
}
+ producer.flush();
}
-
- producer.flush();
}
}
public void publishRecordsBatch()
throws Exception {
for (int p = 0; p < NUM_PARTITION; p++) {
final int partition = p;
- Producer<String> producer =
+ try (Producer<String> producer =
_pulsarClient.newProducer(Schema.STRING).topic(TEST_TOPIC_BATCH).messageRouter(new
MessageRouter() {
@Override
public int choosePartition(Message<?> msg, TopicMetadata metadata)
{
return partition;
}
- }).batchingMaxMessages(BATCH_SIZE).batchingMaxPublishDelay(1,
TimeUnit.SECONDS).create();
-
- for (int i = 0; i < NUM_RECORDS_PER_PARTITION; i++) {
- CompletableFuture<MessageId> messageIdCompletableFuture =
producer.sendAsync(MESSAGE_PREFIX + "_" + i);
- messageIdCompletableFuture.thenAccept(messageId -> {
-
- List<BatchMessageIdImpl> batchMessageIdList =
_partitionToMessageIdMapping
- .getOrDefault(partition, new ArrayList<>());
- batchMessageIdList.add((BatchMessageIdImpl) messageId);
- _partitionToMessageIdMapping.put(partition, batchMessageIdList);
-
- if (!_partitionToFirstMessageIdMapBatch.containsKey(partition)) {
- _partitionToFirstMessageIdMapBatch.put(partition, messageId);
- }
- });
+ }).batchingMaxMessages(BATCH_SIZE).batchingMaxPublishDelay(1,
TimeUnit.SECONDS).create()) {
+ for (int i = 0; i < NUM_RECORDS_PER_PARTITION; i++) {
+ CompletableFuture<MessageId> messageIdCompletableFuture =
producer.sendAsync(MESSAGE_PREFIX + "_" + i);
+ messageIdCompletableFuture.thenAccept(messageId -> {
+
+ List<BatchMessageIdImpl> batchMessageIdList =
_partitionToMessageIdMapping
+ .getOrDefault(partition, new ArrayList<>());
+ batchMessageIdList.add((BatchMessageIdImpl) messageId);
+ _partitionToMessageIdMapping.put(partition, batchMessageIdList);
+
+ if (!_partitionToFirstMessageIdMapBatch.containsKey(partition)) {
+ _partitionToFirstMessageIdMapBatch.put(partition, messageId);
+ }
+ });
+ }
+ producer.flush();
}
- producer.flush();
+ waitForCondition(input -> validatePartitionMessageCount(partition,
NUM_RECORDS_PER_PARTITION), 5 * 1000L,
Review Comment:
will change to 10 or 30 sec later
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]