kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 09d548c3199c83196d5acf98c3c945474c4e7934096719eacca658b763307493 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2015-08-04 19:15 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-08-04 19:32 +02:00 |
| Parents | c89149fa6140 |
1 file changed
modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +5 −16
| @@ -19,14 +19,12 @@ | ||
| 19 | 19 | import java.net.InetSocketAddress; |
| 20 | 20 | import java.util.HashSet; |
| 21 | 21 | import java.util.Iterator; |
| 22 | -import java.util.List; | |
| 23 | 22 | import java.util.Queue; |
| 24 | 23 | import java.util.concurrent.*; |
| 25 | 24 | import java.util.concurrent.atomic.AtomicBoolean; |
| 26 | 25 | import java.util.concurrent.atomic.AtomicInteger; |
| 27 | 26 | import java.util.concurrent.atomic.AtomicReference; |
| 28 | 27 | |
| 29 | -import com.google.common.collect.Lists; | |
| 30 | 28 | import com.google.common.collect.MapMaker; |
| 31 | 29 | import com.google.common.util.concurrent.*; |
| 32 | 30 | import io.netty.bootstrap.Bootstrap; |
| @@ -827,8 +825,6 @@ | ||
| 827 | 825 | final Queue<FlushItem> queued = new ConcurrentLinkedQueue<FlushItem>(); |
| 828 | 826 | final AtomicBoolean running = new AtomicBoolean(false); |
| 829 | 827 | final HashSet<Channel> channels = new HashSet<Channel>(); |
| 830 | - final List<FlushItem> flushed = Lists.newArrayListWithExpectedSize(50); | |
| 831 | - int runsSinceFlush = 0; | |
| 832 | 828 | int runsWithNoWork = 0; |
| 833 | 829 | |
| 834 | 830 | private Flusher(EventLoop eventLoop) { |
| @@ -851,20 +847,13 @@ | ||
| 851 | 847 | while (null != (flush = queued.poll())) { |
| 852 | 848 | channels.add(flush.channel); |
| 853 | 849 | flush.channel.write(flush.request).addListener(flush.listener); |
| 854 | - flushed.add(flush); | |
| 855 | 850 | doneWork = true; |
| 856 | 851 | } |
| 857 | 852 | |
| 858 | - runsSinceFlush++; | |
| 859 | - | |
| 860 | - if (!doneWork || runsSinceFlush > 2 || flushed.size() > 50) { | |
| 861 | - for (Channel channel : channels) | |
| 862 | - channel.flush(); | |
| 863 | - | |
| 864 | - channels.clear(); | |
| 865 | - flushed.clear(); | |
| 866 | - runsSinceFlush = 0; | |
| 867 | - } | |
| 853 | + // Always flush what we have (don't artificially delay to try to coalesce more messages) | |
| 854 | + for (Channel channel : channels) | |
| 855 | + channel.flush(); | |
| 856 | + channels.clear(); | |
| 868 | 857 | |
| 869 | 858 | if (doneWork) { |
| 870 | 859 | runsWithNoWork = 0; |
| @@ -878,7 +867,7 @@ | ||
| 878 | 867 | } |
| 879 | 868 | |
| 880 | 869 | EventLoop eventLoop = eventLoopRef.get(); |
| 881 | - if(eventLoop != null) { | |
| 870 | + if (eventLoop != null) { | |
| 882 | 871 | eventLoop.schedule(this, 10000, TimeUnit.NANOSECONDS); |
| 883 | 872 | } |
| 884 | 873 | } |