You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/08/15 18:54:04 UTC
[GitHub] merlimat closed pull request #2351: Avoid double executor on
non-persistent topic send operation
merlimat closed pull request #2351: Avoid double executor on non-persistent topic send operation
URL: https://github.com/apache/incubator-pulsar/pull/2351
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentTopic.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentTopic.java
index e13549e7a6..281d8438db 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentTopic.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentTopic.java
@@ -188,32 +188,24 @@ public NonPersistentTopic(String topic, BrokerService brokerService) {
@Override
public void publishMessage(ByteBuf data, PublishContext callback) {
- AtomicInteger msgDeliveryCount = new AtomicInteger(2);
+ callback.completed(null, 0L, 0L);
ENTRIES_ADDED_COUNTER_UPDATER.incrementAndGet(this);
- // retain data for sub/replication because io-thread will release actual payload
- data.retain(2);
- this.executor.executeOrdered(topic, SafeRun.safeRun(() -> {
- subscriptions.forEach((name, subscription) -> {
- ByteBuf duplicateBuffer = data.retainedDuplicate();
- Entry entry = create(0L, 0L, duplicateBuffer);
- // entry internally retains data so, duplicateBuffer should be release here
- duplicateBuffer.release();
- if (subscription.getDispatcher() != null) {
- subscription.getDispatcher().sendMessages(Lists.newArrayList(entry));
- } else {
- // it happens when subscription is created but dispatcher is not created as consumer is not added
- // yet
- entry.release();
- }
- });
- data.release();
- if (msgDeliveryCount.decrementAndGet() == 0) {
- callback.completed(null, 0L, 0L);
+ subscriptions.forEach((name, subscription) -> {
+ ByteBuf duplicateBuffer = data.retainedDuplicate();
+ Entry entry = create(0L, 0L, duplicateBuffer);
+ // entry internally retains data so, duplicateBuffer should be release here
+ duplicateBuffer.release();
+ if (subscription.getDispatcher() != null) {
+ subscription.getDispatcher().sendMessages(Collections.singletonList(entry));
+ } else {
+ // it happens when subscription is created but dispatcher is not created as consumer is not added
+ // yet
+ entry.release();
}
- }));
+ });
- this.executor.executeOrdered(topic, SafeRun.safeRun(() -> {
+ if (!replicators.isEmpty()) {
replicators.forEach((name, replicator) -> {
ByteBuf duplicateBuffer = data.retainedDuplicate();
Entry entry = create(0L, 0L, duplicateBuffer);
@@ -221,11 +213,7 @@ public void publishMessage(ByteBuf data, PublishContext callback) {
duplicateBuffer.release();
((NonPersistentReplicator) replicator).sendMessage(entry);
});
- data.release();
- if (msgDeliveryCount.decrementAndGet() == 0) {
- callback.completed(null, 0L, 0L);
- }
- }));
+ }
}
@Override
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services