Skip to content

Commit

Permalink
TransferQueueBundler: increased default capacity to 200'000 and switc…
Browse files Browse the repository at this point in the history
…h from ms to ns
  • Loading branch information
belaban committed Jan 3, 2012
1 parent 8c71eec commit bbd3c81
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/org/jgroups/protocols/TP.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import java.io.IOException;
import java.io.InterruptedIOException;
import java.lang.management.ManagementFactory;
import java.net.*;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.text.NumberFormat;
import java.util.*;
import java.util.concurrent.*;
Expand Down Expand Up @@ -248,7 +249,7 @@ public abstract class TP extends Protocol {

@Experimental
@Property(description="The max number of elements in a bundler if the bundler supports size limitations")
protected int bundler_capacity=20000;
protected int bundler_capacity=200000;


@Property(name="max_bundle_size", description="Maximum number of bytes for messages to be queued until they are sent")
Expand Down Expand Up @@ -1932,24 +1933,26 @@ public int getBufferSize() {


public void run() {
next_bundle_time=System.currentTimeMillis() + max_bundle_timeout;
long max_bundle_timeout_in_nanos=TimeUnit.MILLISECONDS.toNanos(max_bundle_timeout);

next_bundle_time=System.nanoTime() + max_bundle_timeout_in_nanos;
while(running) {
Message msg=null;
long sleep_time=next_bundle_time - System.currentTimeMillis();
long sleep_time=next_bundle_time - System.nanoTime();

try {
if(count == 0)
msg=buffer.take();
else
msg=buffer.poll(sleep_time, TimeUnit.MILLISECONDS);
msg=buffer.poll(sleep_time, TimeUnit.NANOSECONDS);

long size=msg != null? msg.size() : 0;
boolean send_msgs=(msg != null && count + size >= max_bundle_size) ||
buffer.size() >= threshold ||
System.currentTimeMillis() >= next_bundle_time;
System.nanoTime() >= next_bundle_time;

if(send_msgs) {
next_bundle_time=System.currentTimeMillis() + max_bundle_timeout;
next_bundle_time=System.nanoTime() + max_bundle_timeout_in_nanos;
try {
if(!msgs.isEmpty()) {
sendBundledMessages(msgs);
Expand Down

0 comments on commit bbd3c81

Please sign in to comment.