Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions benchmark.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ lowerbound=8000
# Can also be set on the command-line.
sync=true

# Size of znode data (in bytes)
dataSize=1024

# List of ZooKeeper servers to connect to.
server.1=host1:2181
server.2=host2:2181
Expand Down
23 changes: 14 additions & 9 deletions src/main/java/edu/brown/cs/zkbenchmark/ZooKeeperBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class ZooKeeperBenchmark {
private long _lastCpuTime;
private long _currentCpuTime;
private long _startCpuTime;
private int _dataSizeInBytes;
private TestType _currentTest;
private String _data;
private BufferedWriter _rateFile;
Expand Down Expand Up @@ -70,20 +71,16 @@ public ZooKeeperBenchmark(Configuration conf) throws IOException {
int totaltime = conf.getInt("totalTime");
_totalTimeSeconds = Math.round((double) totaltime / 1000.0);
boolean sync = conf.getBoolean("sync");

_running = new HashMap<Integer,Thread>();
_dataSizeInBytes = conf.getInt("dataSize", 100);
_running = new HashMap<Integer,Thread>();
_clients = new BenchmarkClient[serverList.size()];
_barrier = new CyclicBarrier(_clients.length+1);
_deadline = totaltime / _interval;

LOG.info("benchmark set with: interval: " + _interval + " total number: " + _totalOps +
" threshold: " + _lowerbound + " time: " + totaltime + " sync: " + (sync?"SYNC":"ASYNC"));

_data = "";
" threshold: " + _lowerbound + " time: " + totaltime + " sync: " + (sync?"SYNC":"ASYNC") + " data size: " + _dataSizeInBytes + " bytes");

for (int i = 0; i < 20; i++) { // 100 bytes of important data
_data += "!!!!!";
}
_data = genZNodeData(_dataSizeInBytes);

int avgOps = _totalOps / serverList.size();

Expand All @@ -96,6 +93,14 @@ public ZooKeeperBenchmark(Configuration conf) throws IOException {
}

}

private String genZNodeData(int len){
StringBuilder sb = new StringBuilder(len);
for(int i = 0; i < len; i++) {
sb.append("!");
}
return sb.toString();
}

public void runBenchmark() {

Expand Down Expand Up @@ -329,7 +334,7 @@ private static PropertiesConfiguration initConfiguration(String[] args) {
Integer lowerbound = (Integer) options.valueOf("lbound");
Integer time = (Integer) options.valueOf("time");
Boolean sync = (Boolean) options.valueOf("sync");

// Load and parse the configuration file
String configFile = (String) options.valueOf("conf");
LOG.info("Loading benchmark from configuration file: " + configFile);
Expand Down