Skip to content

Commit

Permalink
plog-stress: Java 6 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Carrier committed May 7, 2014
1 parent dd50ea6 commit 239827f
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import lombok.extern.slf4j.Slf4j;

import java.net.InetSocketAddress;
import java.net.StandardSocketOptions;
import java.nio.channels.DatagramChannel;
import java.util.Random;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -92,15 +91,15 @@ private void run(Config config) {

for (int i = 0; i < threadCount; i++) {
new Thread("stress_" + i) {
private DatagramChannel socket;
private DatagramChannel channel;

@Override
public void run() {
try {
for (int sent = 0; sent < stopAfter; sent++, messageMeter.mark()) {
if (sent % socketRenewRate == 0) {
socket = DatagramChannel.open();
socket.setOption(StandardSocketOptions.SO_SNDBUF, bufferSize);
channel = DatagramChannel.open();
channel.socket().setSendBufferSize(bufferSize);
socketMeter.mark();
}

Expand All @@ -120,7 +119,7 @@ public void run() {
lossMeter.mark();
} else {
final int packetSize = fragment.readableBytes();
socket.send(fragment.nioBuffer(), target);
channel.send(fragment.nioBuffer(), target);

packetSizeHistogram.update(packetSize);
packetMeter.mark();
Expand Down

0 comments on commit 239827f

Please sign in to comment.