pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] merlimat commented on a change in pull request #2351: Avoid double executor on non-persistent topic send operation
Date Fri, 10 Aug 2018 04:42:22 GMT
merlimat commented on a change in pull request #2351: Avoid double executor on non-persistent
topic send operation
URL: https://github.com/apache/incubator-pulsar/pull/2351#discussion_r209143474
 
 

 ##########
 File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentTopic.java
 ##########
 @@ -188,44 +188,32 @@ 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));
 
 Review comment:
   Yes, that's what I was thinking. We do these non-blocking ops that don't need to be executed
from a particular thread, so IO thread should be already good.

----------------------------------------------------------------
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

Mime
View raw message