diff --git a/benchmark.conf b/benchmark.conf index d3e285f..d6f3204 100644 --- a/benchmark.conf +++ b/benchmark.conf @@ -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 diff --git a/src/main/java/edu/brown/cs/zkbenchmark/ZooKeeperBenchmark.java b/src/main/java/edu/brown/cs/zkbenchmark/ZooKeeperBenchmark.java index 3016e53..af92cab 100644 --- a/src/main/java/edu/brown/cs/zkbenchmark/ZooKeeperBenchmark.java +++ b/src/main/java/edu/brown/cs/zkbenchmark/ZooKeeperBenchmark.java @@ -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; @@ -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(); + _dataSizeInBytes = conf.getInt("dataSize", 100); + _running = new HashMap(); _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(); @@ -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() { @@ -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);