Author: skabashnyuk
Date: 2010-02-23 03:30:45 -0500 (Tue, 23 Feb 2010)
New Revision: 1941
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/ResultCollector.java
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AbstractAvgResponseTimeTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AbstractTestAgent.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/query/JcrQueryAvgResponseTimeTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/AbstractWebDavTestAgent.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/WebDavAvgResponseTimeTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/WebDavTestAgent.java
Log:
EXOJCR-510 : Counting work time
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AbstractAvgResponseTimeTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AbstractAvgResponseTimeTest.java 2010-02-22
20:08:35 UTC (rev 1940)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AbstractAvgResponseTimeTest.java 2010-02-23
08:30:45 UTC (rev 1941)
@@ -18,8 +18,6 @@
*/
package org.exoplatform.services.jcr.cluster.load;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
@@ -44,7 +42,10 @@
private final int readValue;
- private final DecimalFormat df = new DecimalFormat("#####.##");
+ /**
+ * 10%
+ */
+ private final int WARM_UP_RATIO = 10;
/**
* @param iterationGrowingPoll
@@ -62,7 +63,7 @@
public void testResponce() throws Exception
{
- final List<NodeInfo> nodesPath = new LinkedList<NodeInfo>();
+
//start from 1 thread
int threadCount = initialSize;
@@ -73,39 +74,70 @@
//test init
setUp();
- final List<WorkerResult> responceResults = new
LinkedList<WorkerResult>();
+ final List<NodeInfo> nodesPath = new LinkedList<NodeInfo>();
ExecutorService threadPool = Executors.newFixedThreadPool(threadCount);
CountDownLatch startSignal = new CountDownLatch(1);
AbstractTestAgent[] testAgents = new AbstractTestAgent[threadCount];
-
+ ResultCollector resultCollector = new ResultCollector();
//pool initialization
for (int i = 0; i < threadCount; i++)
{
- testAgents[i] = getAgent(nodesPath, responceResults, startSignal, readValue,
random);
+ testAgents[i] = getAgent(nodesPath, resultCollector, startSignal, readValue,
random);
//init agent
testAgents[i].prepare();
threadPool.execute(testAgents[i]);
}
- responceResults.clear();
+ resultCollector.startIteration();
startSignal.countDown();//let all threads proceed
- Thread.sleep(iterationTime);
+ long warmUpTime = (iterationTime * WARM_UP_RATIO) / 100;
+ Thread.sleep(warmUpTime);
+ //reset result after warm up
+ resultCollector.reset();
+ Thread.sleep(iterationTime - warmUpTime);
+ while (true)
+ {
+ long totalRead = resultCollector.getTotalReadTime();
+ long totalWrite = resultCollector.getTotalWriteTime();
+ long readAndWrite = totalRead + totalWrite;
+ long ratio = (totalRead * 100) / readAndWrite;
+ System.out.println("Ratio =" + ratio);
+ if (ratio >= readValue)
+ {
+ break;
+ }
+ //only read allowed
+ for (int i = 0; i < testAgents.length; i++)
+ {
+ testAgents[i].setBlockWrite(true);
+ }
+ Thread.sleep(1000);
+ }
+
threadPool.shutdown();
for (int i = 0; i < testAgents.length; i++)
{
testAgents[i].setShouldStop(true);
}
+
//wait 10 minutes
threadPool.awaitTermination(60 * 10, TimeUnit.SECONDS);
- dumpResults(responceResults, threadCount, iterationTime);
+ resultCollector.finishIteration();
+ pritResult(threadCount, resultCollector);
threadCount += iterationGrowingPoll;
tearDown();
}
}
+ private void pritResult(int threadCount, ResultCollector resultCollector)
+ {
+ System.out.println("Threads " + threadCount + " Time read " +
resultCollector.getTotalReadTime() + " Time write "
+ + resultCollector.getTotalWriteTime() + " " +
resultCollector.getStatistic());
+ }
+
/**
* Made some actions before iteration run
* @throws Exception
@@ -133,199 +165,7 @@
* @param random
* @return
*/
- protected abstract AbstractTestAgent getAgent(List<NodeInfo> nodesPath,
List<WorkerResult> responceResults,
+ protected abstract AbstractTestAgent getAgent(List<NodeInfo> nodesPath,
ResultCollector resultCollector,
CountDownLatch startSignal, int readValue, Random random);
- private void dumpResults(List<WorkerResult> responceResults, int threadCount,
int iterationTime)
- {
-
- List<Double> readResult = new ArrayList<Double>();
- List<Double> writeResult = new ArrayList<Double>();
-
- for (WorkerResult workerResult : responceResults)
- {
- if (workerResult == null)
- {
- continue;
- }
- if (workerResult.isRead())
- {
- // read++;
- // sum_read += workerResult.getResponceTime();
- readResult.add(new Double(workerResult.getResponceTime()));
- }
- else
- {
- writeResult.add(new Double(workerResult.getResponceTime()));
- }
- }
- ResultInfo readResultInfo = new ResultInfo(readResult);
- readResultInfo.calculate();
-
- ResultInfo writeResultInfo = new ResultInfo(writeResult);
- writeResultInfo.calculate();
-
- StringBuffer result = new StringBuffer();
- result.append("ThreadCount= ").append(threadCount);
- result.append(" TPS = ").append(
- Math.round(((readResultInfo.getResultCount() + writeResultInfo.getResultCount())
* 1000) / iterationTime));
- result.append(" Total read=
").append(df.format(readResultInfo.getResultCount()));
- result.append(" Max= ").append(df.format(readResultInfo.getMaxValue()));
- result.append(" Min= ").append(df.format(readResultInfo.getMinValue()));
- result.append(" Avg= ").append(df.format(readResultInfo.getAvgValue()));
- result.append(" StdDev=
").append(df.format(readResultInfo.getStdDevValue()));
- result.append(" Total write=
").append(writeResultInfo.getResultCount());
- result.append(" Max=
").append(df.format(writeResultInfo.getMaxValue()));
- result.append(" Min=
").append(df.format(writeResultInfo.getMinValue()));
- result.append(" Avg=
").append(df.format(writeResultInfo.getAvgValue()));
- result.append(" StdDev=
").append(df.format(writeResultInfo.getStdDevValue()));
-
- System.out.println(result.toString());
- // long sum_read = 0;
- // long sum_write = 0;
- // long read = 0;
- // long write = 0;
- // for (WorkerResult workerResult : responceResults)
- // {
- // if (workerResult == null)
- // {
- // continue;
- // }
- // if (workerResult.isRead())
- // {
- // read++;
- // sum_read += workerResult.getResponceTime();
- // }
- // else
- // {
- // write++;
- // sum_write += workerResult.getResponceTime();
- // }
- // }
- // if ((read + write) > 0)
- // {
- // StringBuffer result = new StringBuffer();
- // result.append("ThreadCount= ").append(threadCount);
- // result.append(" TPS = ").append(Math.round(((read + write) *
1000) / iterationTime));
- // if (read > 0)
- // {
- // result.append(" Total read = ").append(read);
- //
- // result.append(" Avg read response = ").append((sum_read /
read));
- // }
- // if (write > 0)
- // {
- // result.append(" Total write = ").append(write);
- //
- // result.append(" Avg write response = ").append((sum_write /
write));
- // }
- //
- // System.out.println(result.toString());
- // }
- responceResults.clear();
- }
-
- public class ResultInfo
- {
- private double maxValue;
-
- private double minValue;
-
- private double avgValue;
-
- private double stdDevValue;
-
- private List<Double> data;
-
- /**
- * @param data
- */
- public ResultInfo(List<Double> data)
- {
- super();
- this.data = data;
- }
-
- private void calculate()
- {
- final int n = data.size();
- if (n < 2)
- {
- this.stdDevValue = Double.NaN;
- this.avgValue = data.get(0);
- this.maxValue = data.get(0);
- this.minValue = data.get(0);
- }
- else
- {
- this.avgValue = data.get(0);
- this.maxValue = data.get(0);
- this.minValue = data.get(0);
- double sum = 0;
- for (int i = 1; i < data.size(); i++)
- {
- Double currValue = data.get(i);
- if (currValue > maxValue)
- {
- maxValue = currValue;
- }
- if (currValue < minValue)
- {
- minValue = currValue;
- }
- double newavg = avgValue + (currValue - avgValue) / (i + 1);
- sum += (currValue - avgValue) * (currValue - newavg);
- this.avgValue = newavg;
- }
- // Change to ( n - 1 ) to n if you have complete data instead of a sample.
- this.stdDevValue = Math.sqrt(sum / (n - 1));
- }
- }
-
- /**
- * @return the stdDevValue
- */
- public double getStdDevValue()
- {
- return stdDevValue;
- }
-
- /**
- * @return the maxValue
- */
- public double getMaxValue()
- {
- return maxValue;
- }
-
- /**
- * @return the minValue
- */
- public double getMinValue()
- {
- return minValue;
- }
-
- /**
- * @return the avgValue
- */
- public double getAvgValue()
- {
- return avgValue;
- }
-
- /**
- * @return the data
- */
- public List<Double> getData()
- {
- return data;
- }
-
- public long getResultCount()
- {
- return data.size();
- }
-
- }
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AbstractTestAgent.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AbstractTestAgent.java 2010-02-22
20:08:35 UTC (rev 1940)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AbstractTestAgent.java 2010-02-23
08:30:45 UTC (rev 1941)
@@ -38,18 +38,22 @@
private final List<NodeInfo> nodesPath;
- private final List<WorkerResult> responceResults;
+ private final ResultCollector resultCollector;
private boolean shouldStop = false;
+ private static volatile long LAST_WRITE_START;
+
+ private boolean blockWrite;
+
/**
*
*/
- public AbstractTestAgent(List<NodeInfo> nodesPath, List<WorkerResult>
responceResults, CountDownLatch startSignal,
+ public AbstractTestAgent(List<NodeInfo> nodesPath, ResultCollector
resultCollector, CountDownLatch startSignal,
int readValue, Random random)
{
this.nodesPath = nodesPath;
- this.responceResults = responceResults;
+ this.resultCollector = resultCollector;
this.random = random;
this.startSignal = startSignal;
this.readValue = readValue;
@@ -59,23 +63,15 @@
* Do read
* @return
*/
- public abstract void doRead(List<NodeInfo> nodesPath, List<WorkerResult>
responseResults);
+ public abstract void doRead(List<NodeInfo> nodesPath, ResultCollector
resultCollector);
/**
* Do write
* @return
*/
- public abstract void doWrite(List<NodeInfo> nodesPath, List<WorkerResult>
responseResults);
+ public abstract void doWrite(List<NodeInfo> nodesPath, ResultCollector
resultCollector);
/**
- * Prepare agent
- */
- protected void prepare()
- {
-
- }
-
- /**
* @see java.lang.Runnable#run()
*/
public void run()
@@ -86,15 +82,32 @@
while (!shouldStop)
{
- if (nodesPath.size() < 10 || random.nextInt(100) > readValue)
+ long totalRead = resultCollector.getTotalReadTime();
+ long totalWrite = resultCollector.getTotalWriteTime();
+ long readAndWrite = totalRead + totalWrite;
+ if (blockWrite)
{
-
- doWrite(nodesPath, responceResults);
+ doRead(nodesPath, resultCollector);
}
else
{
- doRead(nodesPath, responceResults);
+ long ratio = 0;
+ if (readAndWrite > 0)
+ {
+ ratio = (totalRead * 100) / readAndWrite;
+ }
+ //prevent to match write
+ if (nodesPath.size() < 2 || (System.currentTimeMillis() -
LAST_WRITE_START > 500 && (ratio > readValue)))
+ {
+ LAST_WRITE_START = System.currentTimeMillis();
+ doWrite(nodesPath, resultCollector);
+ }
+ else
+ {
+ doRead(nodesPath, resultCollector);
+ }
}
+
}
}
catch (InterruptedException e)
@@ -104,6 +117,14 @@
}
/**
+ * @return the blockWrite
+ */
+ protected boolean isBlockWrite()
+ {
+ return blockWrite;
+ }
+
+ /**
* @return the shouldStop
*/
protected boolean isShouldStop()
@@ -112,6 +133,22 @@
}
/**
+ * Prepare agent
+ */
+ protected void prepare()
+ {
+
+ }
+
+ /**
+ * @param blockWrite the blockWrite to set
+ */
+ protected void setBlockWrite(boolean blockWrite)
+ {
+ this.blockWrite = blockWrite;
+ }
+
+ /**
* @param shouldStop the shouldStop to set
*/
protected void setShouldStop(boolean shouldStop)
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/ResultCollector.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/ResultCollector.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/ResultCollector.java 2010-02-23
08:30:45 UTC (rev 1941)
@@ -0,0 +1,281 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.cluster.load;
+
+import java.text.DecimalFormat;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey
Kabashnyuk</a>
+ * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
+ *
+ */
+public class ResultCollector
+{
+ private ResultInfo readResultInfo;
+
+ private ResultInfo writeResultInfo;
+
+ private final DecimalFormat df = new DecimalFormat("#####.##");
+
+ private long iterationStartTime;
+
+ private long iterationTime;
+
+ /**
+ *
+ */
+ public ResultCollector()
+ {
+ super();
+ readResultInfo = new ResultInfo();
+ writeResultInfo = new ResultInfo();
+ }
+
+ /**
+ *
+ * @return return total write time
+ */
+ public long getTotalWriteTime()
+ {
+ return writeResultInfo.getSum();
+ }
+
+ /**
+ * Reset result
+ */
+ public synchronized void reset()
+ {
+ this.readResultInfo = new ResultInfo();
+ this.writeResultInfo = new ResultInfo();
+ this.iterationStartTime = System.currentTimeMillis();
+ }
+
+ /**
+ *
+ * @return total read time.
+ */
+ public long getTotalReadTime()
+ {
+ return readResultInfo.getSum();
+ }
+
+ /**
+ * Total write time
+ * @return
+ */
+ public long getReadCount()
+ {
+ return readResultInfo.getResultCount();
+ }
+
+ /**
+ * Total read times
+ * @return
+ */
+ public long getWriteCount()
+ {
+ return writeResultInfo.getResultCount();
+ }
+
+ public void addResult(boolean isRead, long time)
+ {
+ if (isRead)
+ {
+ readResultInfo.addResult(time);
+ }
+ else
+ {
+ writeResultInfo.addResult(time);
+ }
+ }
+
+ /**
+ * Strt iteration
+ */
+ public void startIteration()
+ {
+ this.iterationStartTime = System.currentTimeMillis();
+ }
+
+ /**
+ * Strt iteration
+ */
+ public void finishIteration()
+ {
+ this.iterationTime = System.currentTimeMillis() - iterationStartTime;
+ }
+
+ public String getStatistic()
+ {
+ readResultInfo.calculateStatistic();
+ writeResultInfo.calculateStatistic();
+
+ StringBuffer result = new StringBuffer();
+ result.append(" TPS total= ").append(
+ Math.round(((readResultInfo.getResultCount() + writeResultInfo.getResultCount())
* 1000) / iterationTime));
+ result.append(" TPS read=
").append(Math.round(((readResultInfo.getResultCount()) * 1000) / iterationTime));
+ result.append(" TPS write=
").append(Math.round(((writeResultInfo.getResultCount()) * 1000) / iterationTime));
+
+ result.append(" Total read=
").append(df.format(readResultInfo.getResultCount()));
+ result.append(" Max= ").append(df.format(readResultInfo.getMaxValue()));
+ result.append(" Min= ").append(df.format(readResultInfo.getMinValue()));
+ result.append(" Avg= ").append(df.format(readResultInfo.getAvgValue()));
+ result.append(" StdDev=
").append(df.format(readResultInfo.getStdDevValue()));
+ result.append(" Total write=
").append(writeResultInfo.getResultCount());
+ result.append(" Max=
").append(df.format(writeResultInfo.getMaxValue()));
+ result.append(" Min=
").append(df.format(writeResultInfo.getMinValue()));
+ result.append(" Avg=
").append(df.format(writeResultInfo.getAvgValue()));
+ result.append(" StdDev=
").append(df.format(writeResultInfo.getStdDevValue()));
+
+ return result.toString();
+ }
+
+ class ResultInfo
+ {
+ private double maxValue;
+
+ private double minValue;
+
+ private double avgValue;
+
+ private double stdDevValue;
+
+ private List<Double> data;
+
+ private AtomicLong sumValue;
+
+ /**
+ * @param data
+ */
+ public ResultInfo()
+ {
+
+ this.data = new LinkedList<Double>();
+ this.sumValue = new AtomicLong(0);
+ }
+
+ public void addResult(long resultTime)
+ {
+ this.data.add(new Double(resultTime));
+ this.sumValue.addAndGet(resultTime);
+ }
+
+ /**
+ *
+ * @return sum of values
+ */
+ public long getSum()
+ {
+ return sumValue.get();
+ }
+
+ public void calculateStatistic()
+ {
+ final int n = data.size();
+ if (n > 0)
+ {
+ if (n < 2)
+ {
+ this.stdDevValue = Double.NaN;
+ this.avgValue = data.get(0);
+ this.maxValue = data.get(0);
+ this.minValue = data.get(0);
+ }
+ else
+ {
+ this.avgValue = data.get(0);
+ this.maxValue = data.get(0);
+ this.minValue = data.get(0);
+ double sum = 0;
+ for (int i = 1; i < data.size(); i++)
+ {
+ Double currValue = data.get(i);
+ if (currValue == null)
+ {
+ currValue = new Double(0);
+ }
+ if (currValue > maxValue)
+ {
+ maxValue = currValue;
+ }
+ if (currValue < minValue)
+ {
+ minValue = currValue;
+ }
+ double newavg = avgValue + (currValue - avgValue) / (i + 1);
+ sum += (currValue - avgValue) * (currValue - newavg);
+ this.avgValue = newavg;
+ }
+ // Change to ( n - 1 ) to n if you have complete data instead of a
sample.
+ this.stdDevValue = Math.sqrt(sum / (n - 1));
+ }
+ }
+ }
+
+ /**
+ * @return the stdDevValue
+ */
+ public double getStdDevValue()
+ {
+ return stdDevValue;
+ }
+
+ /**
+ * @return the maxValue
+ */
+ public double getMaxValue()
+ {
+ return maxValue;
+ }
+
+ /**
+ * @return the minValue
+ */
+ public double getMinValue()
+ {
+ return minValue;
+ }
+
+ /**
+ * @return the avgValue
+ */
+ public double getAvgValue()
+ {
+ return avgValue;
+ }
+
+ /**
+ * @return the data
+ */
+ public List<Double> getData()
+ {
+ return data;
+ }
+
+ public long getResultCount()
+ {
+ return data.size();
+ }
+
+ }
+
+}
\ No newline at end of file
Property changes on:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/ResultCollector.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/query/JcrQueryAvgResponseTimeTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/query/JcrQueryAvgResponseTimeTest.java 2010-02-22
20:08:35 UTC (rev 1940)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/query/JcrQueryAvgResponseTimeTest.java 2010-02-23
08:30:45 UTC (rev 1941)
@@ -22,7 +22,7 @@
import org.exoplatform.services.jcr.cluster.load.AbstractAvgResponseTimeTest;
import org.exoplatform.services.jcr.cluster.load.AbstractTestAgent;
import org.exoplatform.services.jcr.cluster.load.NodeInfo;
-import org.exoplatform.services.jcr.cluster.load.WorkerResult;
+import org.exoplatform.services.jcr.cluster.load.ResultCollector;
import org.exoplatform.services.jcr.core.CredentialsImpl;
import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
import org.jboss.cache.CacheException;
@@ -114,10 +114,10 @@
* @see
org.exoplatform.services.jcr.cluster.load.AbstractAvgResponseTimeTest#getAgent(java.util.List,
java.util.List, java.util.concurrent.CountDownLatch, int, java.util.Random)
*/
@Override
- protected AbstractTestAgent getAgent(List<NodeInfo> nodesPath,
List<WorkerResult> responceResults,
+ protected AbstractTestAgent getAgent(List<NodeInfo> nodesPath,
ResultCollector resultCollector,
CountDownLatch startSignal, int readValue, Random random)
{
- return new QueryTestAgent(repository, nodesPath, responceResults, startSignal,
readValue, random);
+ return new QueryTestAgent(repository, nodesPath, resultCollector, startSignal,
readValue, random);
}
}
@@ -136,10 +136,10 @@
* @param READ_VALUE
* @param random
*/
- public QueryTestAgent(RepositoryImpl repository, List<NodeInfo> nodesPath,
List<WorkerResult> responceResults,
+ public QueryTestAgent(RepositoryImpl repository, List<NodeInfo> nodesPath,
ResultCollector resultCollector,
CountDownLatch startSignal, int readValue, Random random)
{
- super(nodesPath, responceResults, startSignal, readValue, random);
+ super(nodesPath, resultCollector, startSignal, readValue, random);
this.threadUUID = UUID.randomUUID();
this.repository = repository;
initRoot();
@@ -216,7 +216,7 @@
* @see
org.exoplatform.services.jcr.cluster.load.AbstractTestAgent#doRead(java.util.List)
*/
@Override
- public void doRead(List<NodeInfo> nodesPath, List<WorkerResult>
responseResults)
+ public void doRead(List<NodeInfo> nodesPath, ResultCollector
resultCollector)
{
Session sessionLocal = null;
try
@@ -236,7 +236,7 @@
long start = System.currentTimeMillis();
QueryResult res = q.execute();
long sqlsize = res.getNodes().getSize();
- responseResults.add(new WorkerResult(true, System.currentTimeMillis() -
start));
+ resultCollector.addResult(true, System.currentTimeMillis() - start);
//log.info(word + " found:" + sqlsize + " time=" +
(System.currentTimeMillis() - start));
}
@@ -258,7 +258,7 @@
* @see
org.exoplatform.services.jcr.cluster.load.AbstractTestAgent#doWrite(java.util.List)
*/
@Override
- public void doWrite(List<NodeInfo> nodesPath, List<WorkerResult>
responseResults)
+ public void doWrite(List<NodeInfo> nodesPath, ResultCollector
resultCollector)
{
// get any word
int i = random.nextInt(words.length);
@@ -273,7 +273,7 @@
Node threadNode = getOrCreateNode(getOrCreateNode(TEST_ROOT,
sessionLocal.getRootNode()), threadUUID);
addCountent(threadNode, UUID.randomUUID(), word);
sessionLocal.save();
- responseResults.add(new WorkerResult(false, System.currentTimeMillis() -
start));
+ resultCollector.addResult(false, System.currentTimeMillis() - start);
//log.info(word + " time : " + (System.currentTimeMillis() -
start));
}
catch (Exception e1)
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/AbstractWebDavTestAgent.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/AbstractWebDavTestAgent.java 2010-02-22
20:08:35 UTC (rev 1940)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/AbstractWebDavTestAgent.java 2010-02-23
08:30:45 UTC (rev 1941)
@@ -21,7 +21,7 @@
import org.exoplatform.services.jcr.cluster.JCRWebdavConnection;
import org.exoplatform.services.jcr.cluster.load.AbstractTestAgent;
import org.exoplatform.services.jcr.cluster.load.NodeInfo;
-import org.exoplatform.services.jcr.cluster.load.WorkerResult;
+import org.exoplatform.services.jcr.cluster.load.ResultCollector;
import java.util.List;
import java.util.Random;
@@ -51,10 +51,10 @@
* @param READ_VALUE
* @param random
*/
- public AbstractWebDavTestAgent(List<NodeInfo> nodesPath,
List<WorkerResult> responceResults,
+ public AbstractWebDavTestAgent(List<NodeInfo> nodesPath, ResultCollector
resultCollector,
CountDownLatch startSignal, int READ_VALUE, Random random)
{
- super(nodesPath, responceResults, startSignal, READ_VALUE, random);
+ super(nodesPath, resultCollector, startSignal, READ_VALUE, random);
}
protected JCRWebdavConnection getNewConnection()
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/WebDavAvgResponseTimeTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/WebDavAvgResponseTimeTest.java 2010-02-22
20:08:35 UTC (rev 1940)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/WebDavAvgResponseTimeTest.java 2010-02-23
08:30:45 UTC (rev 1941)
@@ -23,9 +23,8 @@
import org.exoplatform.services.jcr.cluster.load.AbstractAvgResponseTimeTest;
import org.exoplatform.services.jcr.cluster.load.AbstractTestAgent;
import org.exoplatform.services.jcr.cluster.load.NodeInfo;
-import org.exoplatform.services.jcr.cluster.load.WorkerResult;
+import org.exoplatform.services.jcr.cluster.load.ResultCollector;
-import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;
@@ -47,7 +46,7 @@
/**
* How much thread will be added on the next iteration.
*/
- private static final int ITERATION_GROWING_POLL = 10;
+ private static final int ITERATION_GROWING_POLL = 25;
/**
* Number between 0 and 100 show % how many read operations.
@@ -58,7 +57,7 @@
public void testWebDav() throws Exception
{
- WebDavTest test = new WebDavTest(ITERATION_GROWING_POLL, ITERATION_TIME, 10,
READ_VALUE);
+ WebDavTest test = new WebDavTest(ITERATION_GROWING_POLL, ITERATION_TIME, 50,
READ_VALUE);
test.testResponce();
}
@@ -89,9 +88,8 @@
super.setUp();
WebDavTestAgent setUpAgent = new WebDavTestAgent(null, null, null, null, 0,
null);
- String testRoot = setUpAgent.createDirIfAbsent("", TEST_ROOT, new
ArrayList<WorkerResult>());
- iterationRoot =
- setUpAgent.createDirIfAbsent(testRoot, UUID.randomUUID().toString(), new
ArrayList<WorkerResult>());
+ String testRoot = setUpAgent.createDirIfAbsent("", TEST_ROOT, new
ResultCollector());
+ iterationRoot = setUpAgent.createDirIfAbsent(testRoot,
UUID.randomUUID().toString(), new ResultCollector());
}
/**
@@ -108,10 +106,10 @@
* @see
org.exoplatform.services.jcr.cluster.load.AbstractAvgResponseTimeTest#getAgent(java.util.List,
java.util.List, java.util.concurrent.CountDownLatch, int, java.util.Random)
*/
@Override
- protected AbstractTestAgent getAgent(List<NodeInfo> nodesPath,
List<WorkerResult> responceResults,
+ protected AbstractTestAgent getAgent(List<NodeInfo> nodesPath,
ResultCollector resultCollector,
CountDownLatch startSignal, int readValue, Random random)
{
- return new WebDavTestAgent(iterationRoot, nodesPath, responceResults,
startSignal, readValue, random);
+ return new WebDavTestAgent(iterationRoot, nodesPath, resultCollector,
startSignal, readValue, random);
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/WebDavTestAgent.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/WebDavTestAgent.java 2010-02-22
20:08:35 UTC (rev 1940)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/WebDavTestAgent.java 2010-02-23
08:30:45 UTC (rev 1941)
@@ -22,9 +22,8 @@
import org.exoplatform.common.http.client.HTTPResponse;
import org.exoplatform.services.jcr.cluster.JCRWebdavConnection;
import org.exoplatform.services.jcr.cluster.load.NodeInfo;
-import org.exoplatform.services.jcr.cluster.load.WorkerResult;
+import org.exoplatform.services.jcr.cluster.load.ResultCollector;
-import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;
@@ -40,6 +39,8 @@
private String testRoot;
+ private boolean readFresh = true;
+
/**
* @param nodesPath
* @param responceResults
@@ -47,10 +48,10 @@
* @param READ_VALUE
* @param random
*/
- public WebDavTestAgent(String testRoot, List<NodeInfo> nodesPath,
List<WorkerResult> responceResults,
+ public WebDavTestAgent(String testRoot, List<NodeInfo> nodesPath,
ResultCollector resultCollector,
CountDownLatch startSignal, int READ_VALUE, Random random)
{
- super(nodesPath, responceResults, startSignal, READ_VALUE, random);
+ super(nodesPath, resultCollector, startSignal, READ_VALUE, random);
this.testRoot = testRoot;
}
@@ -58,9 +59,8 @@
* @see
org.exoplatform.services.jcr.cluster.load.AbstractTestAgent#doRead(java.util.List)
*/
@Override
- public void doRead(List<NodeInfo> nodesPath, List<WorkerResult>
responseResults)
+ public void doRead(List<NodeInfo> nodesPath, ResultCollector resultCollector)
{
- //List<WorkerResult> result = new ArrayList<WorkerResult>();
if (nodesPath.size() > 0)
{
@@ -68,10 +68,12 @@
while (readNodePath == null)
{
NodeInfo nodeInfo = nodesPath.get(random.nextInt(nodesPath.size()));
- // if ((System.currentTimeMillis() - nodeInfo.created) >
30000)
- // {
+ if (!readFresh && (System.currentTimeMillis() -
nodeInfo.getCreated()) < 30000)
+ {
+ return;
+ }
+
readNodePath = nodeInfo.getPath();
- // }
}
long start = System.currentTimeMillis();
@@ -82,7 +84,7 @@
HTTPResponse response = conn.getNode(readNodePath);
if (response.getStatusCode() == HTTPStatus.OK)
{
- responseResults.add(new WorkerResult(true, System.currentTimeMillis() -
start));
+ resultCollector.addResult(true, System.currentTimeMillis() - start);
}
else
{
@@ -113,28 +115,28 @@
@Override
protected void prepare()
{
- testRoot = createDirIfAbsent(testRoot, UUID.randomUUID().toString(), new
ArrayList<WorkerResult>());
+ testRoot = createDirIfAbsent(testRoot, UUID.randomUUID().toString(), new
ResultCollector());
}
/**
* @see
org.exoplatform.services.jcr.cluster.load.AbstractTestAgent#doWrite(java.util.List)
*/
@Override
- public void doWrite(List<NodeInfo> nodesPath, List<WorkerResult>
responseResults)
+ public void doWrite(List<NodeInfo> nodesPath, ResultCollector resultCollector)
{
JCRWebdavConnection connection = null;
try
{
connection = getNewConnection();
- String putFile =
- createDirIfAbsent(testRoot, UUID.randomUUID().toString(), new
ArrayList<WorkerResult>()) + "/file";
+ String putFile = testRoot + "/" + UUID.randomUUID().toString();
+
long start = System.currentTimeMillis();
- HTTPResponse response = connection.addNode(putFile,
("__the_data_in_nt+file__").getBytes());
+ HTTPResponse response = connection.addNode(putFile,
("__the_data_in_nt+file__").getBytes(), "text/plain");
if (response.getStatusCode() == HTTPStatus.CREATED)
{
- responseResults.add(new WorkerResult(false, System.currentTimeMillis() -
start));
+ resultCollector.addResult(false, System.currentTimeMillis() - start);
nodesPath.add(new NodeInfo(putFile, System.currentTimeMillis()));
}
else
@@ -165,7 +167,7 @@
* @param data
* @return
*/
- public String createDirIfAbsent(String root, String name, List<WorkerResult>
result)
+ public String createDirIfAbsent(String root, String name, ResultCollector
resultCollector)
{
String path = root.length() == 0 ? name : root + "/" + name;
JCRWebdavConnection connection = null;
@@ -176,7 +178,8 @@
long start = System.currentTimeMillis();
HTTPResponse nodeResponce = connection.getNode(path);
//add information about read
- result.add(new WorkerResult(true, System.currentTimeMillis() - start));
+
+ resultCollector.addResult(true, System.currentTimeMillis() - start);
if (nodeResponce.getStatusCode() != HTTPStatus.OK)
{
start = System.currentTimeMillis();
@@ -185,7 +188,7 @@
if (addResponce.getStatusCode() == HTTPStatus.CREATED)
{
- result.add(new WorkerResult(false, System.currentTimeMillis() - start));
+ resultCollector.addResult(false, System.currentTimeMillis() - start);
}
else
{
@@ -216,14 +219,14 @@
* @param data
* @return
*/
- public String createDirIfAbsent(String root, UUID uuid, List<WorkerResult>
result)
+ public String createDirIfAbsent(String root, UUID uuid, ResultCollector
resultCollector)
{
String uuidPath = uuid.toString();
- String l1 = createDirIfAbsent(root, uuidPath.substring(0, 8), result);
+ String l1 = createDirIfAbsent(root, uuidPath.substring(0, 8), resultCollector);
// String l2 = createDirIfAbsent(l1, uuidPath.substring(9, 13), result);
// String l3 = createDirIfAbsent(l2, uuidPath.substring(14, 18), result);
// String l4 = createDirIfAbsent(l3, uuidPath.substring(19, 23), result);
- return createDirIfAbsent(l1, uuidPath.substring(9), result);
+ return createDirIfAbsent(l1, uuidPath.substring(9), resultCollector);
}
}