[exo-jcr-commits] exo-jcr SVN: r1946 - in jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load: query and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Feb 23 11:23:18 EST 2010
Author: skabashnyuk
Date: 2010-02-23 11:23:17 -0500 (Tue, 23 Feb 2010)
New Revision: 1946
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 : Fixed write 10, and growing read
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-23 14:47:23 UTC (rev 1945)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AbstractAvgResponseTimeTest.java 2010-02-23 16:23:17 UTC (rev 1946)
@@ -43,6 +43,11 @@
private final int readValue;
/**
+ * Fixed number of write agent
+ */
+ private final int WRITE_AGENT_COUNT = 10;
+
+ /**
* 10%
*/
private final int WARM_UP_RATIO = 10;
@@ -76,17 +81,26 @@
final List<NodeInfo> nodesPath = new LinkedList<NodeInfo>();
- ExecutorService threadPool = Executors.newFixedThreadPool(threadCount);
+ ExecutorService threadPool = Executors.newFixedThreadPool(threadCount + WRITE_AGENT_COUNT);
CountDownLatch startSignal = new CountDownLatch(1);
- AbstractTestAgent[] testAgents = new AbstractTestAgent[threadCount];
+ AbstractTestAgent[] testAgents = new AbstractTestAgent[threadCount + WRITE_AGENT_COUNT];
ResultCollector resultCollector = new ResultCollector();
//pool initialization
- for (int i = 0; i < threadCount; i++)
+ //init write
+ for (int i = 0; i < WRITE_AGENT_COUNT; i++)
{
- testAgents[i] = getAgent(nodesPath, resultCollector, startSignal, readValue, random);
+ testAgents[i] = getAgent(nodesPath, resultCollector, startSignal, readValue, random, false);
//init agent
testAgents[i].prepare();
threadPool.execute(testAgents[i]);
+ }
+ //init read
+ for (int i = WRITE_AGENT_COUNT; i < threadCount + WRITE_AGENT_COUNT; i++)
+ {
+ testAgents[i] = getAgent(nodesPath, resultCollector, startSignal, readValue, random, true);
+ //init agent
+ testAgents[i].prepare();
+ threadPool.execute(testAgents[i]);
}
resultCollector.startIteration();
@@ -97,26 +111,30 @@
//reset result after warm up
resultCollector.reset();
Thread.sleep(iterationTime - warmUpTime);
+ long totalRead = resultCollector.getTotalReadTime();
+ long totalWrite = resultCollector.getTotalWriteTime();
+ long readAndWrite = totalRead + totalWrite;
+ long ratio = (totalRead * 100) / readAndWrite;
+ System.out.println("Ratio =" + ratio);
+ // 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);
+ // }
- 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++)
{
@@ -166,6 +184,6 @@
* @return
*/
protected abstract AbstractTestAgent getAgent(List<NodeInfo> nodesPath, ResultCollector resultCollector,
- CountDownLatch startSignal, int readValue, Random random);
+ CountDownLatch startSignal, int readValue, Random random, boolean isReadThread);
}
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-23 14:47:23 UTC (rev 1945)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AbstractTestAgent.java 2010-02-23 16:23:17 UTC (rev 1946)
@@ -46,17 +46,20 @@
private boolean blockWrite;
+ private final boolean isReadThread;
+
/**
*
*/
public AbstractTestAgent(List<NodeInfo> nodesPath, ResultCollector resultCollector, CountDownLatch startSignal,
- int readValue, Random random)
+ int readValue, Random random, boolean isReadThread)
{
this.nodesPath = nodesPath;
this.resultCollector = resultCollector;
this.random = random;
this.startSignal = startSignal;
this.readValue = readValue;
+ this.isReadThread = isReadThread;
}
/**
@@ -82,31 +85,47 @@
while (!shouldStop)
{
- long totalRead = resultCollector.getTotalReadTime();
- long totalWrite = resultCollector.getTotalWriteTime();
- long readAndWrite = totalRead + totalWrite;
- if (blockWrite)
+ if (isReadThread)
{
- doRead(nodesPath, resultCollector);
- }
- else
- {
- long ratio = 0;
- if (readAndWrite > 0)
+ if (nodesPath.size() > 1)
{
- ratio = (totalRead * 100) / readAndWrite;
+ doRead(nodesPath, resultCollector);
}
- //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);
+ Thread.sleep(100);
}
}
+ else if (!blockWrite)
+ {
+ doWrite(nodesPath, resultCollector);
+ }
+ //
+ // long totalRead = resultCollector.getTotalReadTime();
+ // long totalWrite = resultCollector.getTotalWriteTime();
+ // long readAndWrite = totalRead + totalWrite;
+ // if (blockWrite)
+ // {
+ // doRead(nodesPath, resultCollector);
+ // }
+ // else
+ // {
+ // long ratio = 0;
+ // if (readAndWrite > 0)
+ // {
+ // ratio = (totalRead * 100) / readAndWrite;
+ // }
+ // //prevent to match write
+ // if (System.currentTimeMillis() - LAST_WRITE_START > 500 && (nodesPath.size() < 1 || ratio > readValue))
+ // {
+ // LAST_WRITE_START = System.currentTimeMillis();
+ // doWrite(nodesPath, resultCollector);
+ // }
+ // else
+ // {
+ // doRead(nodesPath, resultCollector);
+ // }
+ // }
}
}
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-23 14:47:23 UTC (rev 1945)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/query/JcrQueryAvgResponseTimeTest.java 2010-02-23 16:23:17 UTC (rev 1946)
@@ -115,9 +115,9 @@
*/
@Override
protected AbstractTestAgent getAgent(List<NodeInfo> nodesPath, ResultCollector resultCollector,
- CountDownLatch startSignal, int readValue, Random random)
+ CountDownLatch startSignal, int readValue, Random random, boolean isReadThread)
{
- return new QueryTestAgent(repository, nodesPath, resultCollector, startSignal, readValue, random);
+ return new QueryTestAgent(repository, nodesPath, resultCollector, startSignal, readValue, random, isReadThread);
}
}
@@ -137,9 +137,9 @@
* @param random
*/
public QueryTestAgent(RepositoryImpl repository, List<NodeInfo> nodesPath, ResultCollector resultCollector,
- CountDownLatch startSignal, int readValue, Random random)
+ CountDownLatch startSignal, int readValue, Random random, boolean isReadThread)
{
- super(nodesPath, resultCollector, startSignal, readValue, random);
+ super(nodesPath, resultCollector, startSignal, readValue, random, true);
this.threadUUID = UUID.randomUUID();
this.repository = repository;
initRoot();
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-23 14:47:23 UTC (rev 1945)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/AbstractWebDavTestAgent.java 2010-02-23 16:23:17 UTC (rev 1946)
@@ -52,9 +52,9 @@
* @param random
*/
public AbstractWebDavTestAgent(List<NodeInfo> nodesPath, ResultCollector resultCollector,
- CountDownLatch startSignal, int READ_VALUE, Random random)
+ CountDownLatch startSignal, int READ_VALUE, Random random, boolean isReadThread)
{
- super(nodesPath, resultCollector, startSignal, READ_VALUE, random);
+ super(nodesPath, resultCollector, startSignal, READ_VALUE, random, isReadThread);
}
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-23 14:47:23 UTC (rev 1945)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/WebDavAvgResponseTimeTest.java 2010-02-23 16:23:17 UTC (rev 1946)
@@ -46,7 +46,7 @@
/**
* How much thread will be added on the next iteration.
*/
- private static final int ITERATION_GROWING_POLL = 25;
+ private static final int ITERATION_GROWING_POLL = 50;
/**
* Number between 0 and 100 show % how many read operations.
@@ -65,8 +65,6 @@
{
private String iterationRoot;
- private int counter;
-
/**
* @param iterationGrowingPoll
* @param iterationTime
@@ -86,7 +84,7 @@
{
// TODO Auto-generated method stub
super.setUp();
- WebDavTestAgent setUpAgent = new WebDavTestAgent(null, null, null, null, 0, null);
+ WebDavTestAgent setUpAgent = new WebDavTestAgent(null, null, null, null, 0, null, false);
String testRoot = setUpAgent.createDirIfAbsent("", TEST_ROOT, new ResultCollector());
iterationRoot = setUpAgent.createDirIfAbsent(testRoot, UUID.randomUUID().toString(), new ResultCollector());
@@ -107,9 +105,10 @@
*/
@Override
protected AbstractTestAgent getAgent(List<NodeInfo> nodesPath, ResultCollector resultCollector,
- CountDownLatch startSignal, int readValue, Random random)
+ CountDownLatch startSignal, int readValue, Random random, boolean isReadThread)
{
- return new WebDavTestAgent(iterationRoot, nodesPath, resultCollector, startSignal, readValue, random);
+ return new WebDavTestAgent(iterationRoot, nodesPath, resultCollector, startSignal, readValue, random,
+ isReadThread);
}
}
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-23 14:47:23 UTC (rev 1945)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/webdav/WebDavTestAgent.java 2010-02-23 16:23:17 UTC (rev 1946)
@@ -49,9 +49,9 @@
* @param random
*/
public WebDavTestAgent(String testRoot, List<NodeInfo> nodesPath, ResultCollector resultCollector,
- CountDownLatch startSignal, int READ_VALUE, Random random)
+ CountDownLatch startSignal, int READ_VALUE, Random random, boolean isReadThread)
{
- super(nodesPath, resultCollector, startSignal, READ_VALUE, random);
+ super(nodesPath, resultCollector, startSignal, READ_VALUE, random, isReadThread);
this.testRoot = testRoot;
}
More information about the exo-jcr-commits
mailing list