You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by iv...@apache.org on 2012/05/04 20:11:44 UTC
svn commit: r1334107 - in /zookeeper/bookkeeper/trunk: CHANGES.txt
bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java
bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java
Author: ivank
Date: Fri May 4 18:11:43 2012
New Revision: 1334107
URL: http://svn.apache.org/viewvc?rev=1334107&view=rev
Log:
BOOKKEEPER-228: Fix the bugs in BK benchmark (umamaheswararao via ivank)
Modified:
zookeeper/bookkeeper/trunk/CHANGES.txt
zookeeper/bookkeeper/trunk/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java
zookeeper/bookkeeper/trunk/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java
Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1334107&r1=1334106&r2=1334107&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Fri May 4 18:11:43 2012
@@ -114,6 +114,8 @@ Trunk (unreleased changes)
BOOKKEEPER-207: BenchBookie doesn't run correctly (ivank via fpj)
+ BOOKKEEPER-228: Fix the bugs in BK benchmark (umamaheswararao via ivank)
+
IMPROVEMENTS:
bookkeeper-server/
Modified: zookeeper/bookkeeper/trunk/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java?rev=1334107&r1=1334106&r2=1334107&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchThroughputLatency.java Fri May 4 18:11:43 2012
@@ -20,7 +20,6 @@
package org.apache.bookkeeper.benchmark;
import java.io.BufferedOutputStream;
-import java.io.DataInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -34,12 +33,16 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.bookkeeper.client.BKException;
-import org.apache.bookkeeper.conf.ClientConfiguration;
import org.apache.bookkeeper.client.BookKeeper;
import org.apache.bookkeeper.client.LedgerHandle;
import org.apache.bookkeeper.client.AsyncCallback.AddCallback;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.bookkeeper.conf.ClientConfiguration;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
@@ -48,14 +51,8 @@ import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
-
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.PosixParser;
-import org.apache.commons.cli.ParseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class BenchThroughputLatency implements AddCallback, Runnable {
static Logger LOG = LoggerFactory.getLogger(BenchThroughputLatency.class);
@@ -70,14 +67,13 @@ public class BenchThroughputLatency impl
int numberOfLedgers = 1;
final String servers;
- class Context {
+ static class Context {
long localStartTime;
- long globalStartTime;
long id;
Context(long id, long time){
this.id = id;
- this.localStartTime = this.globalStartTime = time;
+ this.localStartTime = time;
}
}
@@ -85,7 +81,6 @@ public class BenchThroughputLatency impl
int throttle, int numberOfLedgers, String servers)
throws KeeperException, IOException, InterruptedException {
this.sem = new Semaphore(throttle);
- this.pace = pace;
this.throttle = throttle;
ClientConfiguration conf = new ClientConfiguration();
@@ -148,7 +143,6 @@ public class BenchThroughputLatency impl
LOG.info("Running...");
long start = previous = System.currentTimeMillis();
- byte messageCount = 0;
int sent = 0;
Thread reporter = new Thread() {
@@ -193,8 +187,9 @@ public class BenchThroughputLatency impl
LOG.info("Sent: " + sent);
try {
synchronized (this) {
- while(this.counter.get() > 0)
- Thread.sleep(1000);
+ while (this.counter.get() > 0) {
+ waitFor(1000);
+ }
}
} catch(InterruptedException e) {
LOG.error("Interrupted while waiting", e);
@@ -202,7 +197,7 @@ public class BenchThroughputLatency impl
synchronized(this) {
duration = System.currentTimeMillis() - start;
}
- throughput = sent*1000/duration;
+ throughput = sent*1000/getDuration();
reporter.interrupt();
try {
@@ -210,7 +205,11 @@ public class BenchThroughputLatency impl
} catch (InterruptedException ie) {
// ignore
}
- LOG.info("Finished processing in ms: " + duration + " tp = " + throughput);
+ LOG.info("Finished processing in ms: " + getDuration() + " tp = " + throughput);
+ }
+
+ private void waitFor(int waitTime) throws InterruptedException {
+ Thread.sleep(waitTime);
}
long throughput = -1;
@@ -291,11 +290,8 @@ public class BenchThroughputLatency impl
byte data[] = new byte[entrysize];
Arrays.fill(data, (byte)'x');
- while(lastWarmUpTP < (throughput = warmUp(servers, data, ledgers, ensemble, quorum, passwd, throttle))) {
+ if(lastWarmUpTP < (throughput = warmUp(servers, data, ledgers, ensemble, quorum, passwd, throttle))) {
LOG.info("Warmup tp: " + throughput);
- lastWarmUpTP = throughput;
- // we will just run once, so lets break
- break;
}
LOG.info("Warmup phase finished");
Modified: zookeeper/bookkeeper/trunk/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java?rev=1334107&r1=1334106&r2=1334107&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/TestClient.java Fri May 4 18:11:43 2012
@@ -1,4 +1,3 @@
-package org.apache.bookkeeper.benchmark;
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,7 +18,7 @@ package org.apache.bookkeeper.benchmark;
* under the License.
*
*/
-
+package org.apache.bookkeeper.benchmark;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -173,8 +172,9 @@ public class TestClient
}
LOG.debug("Finished " + times + " async writes in ms: " + (System.currentTimeMillis() - start));
synchronized (map) {
- if(map.size() != 0)
- map.wait();
+ while (map.size() != 0) {
+ map.wait(100);
+ }
}
LOG.debug("Finished processing in ms: " + (System.currentTimeMillis() - start));
@@ -194,15 +194,16 @@ public class TestClient
}
LOG.debug("Finished " + times + " async writes in ms: " + (System.currentTimeMillis() - start));
synchronized (map) {
- if(map.size() != 0)
- map.wait();
+ while (map.size() != 0) {
+ map.wait(100);
+ }
}
LOG.debug("Finished processing writes (ms): " + (System.currentTimeMillis() - start));
- Integer mon = Integer.valueOf(0);
- synchronized(mon) {
- lh.asyncReadEntries(1, times - 1, this, mon);
- mon.wait();
+ Object syncObj = new Object();
+ synchronized(syncObj) {
+ lh.asyncReadEntries(1, times - 1, this, syncObj);
+ syncObj.wait();
}
LOG.error("Ended computation");
}