From do-not-reply at jboss.org Thu Feb 18 08:25:21 2010
Content-Type: multipart/mixed; boundary="===============2150359023007852358=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r1898 - in
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load:
query and 1 other directories.
Date: Thu, 18 Feb 2010 08:25:20 -0500
Message-ID: <201002181325.o1IDPKhJ022754@svn01.web.mwc.hst.phx2.redhat.com>
--===============2150359023007852358==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: skabashnyuk
Date: 2010-02-18 08:25:20 -0500 (Thu, 18 Feb 2010)
New Revision: 1898
Added:
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/query/JcrQueryAvgResponseTimeTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/=
jcr/cluster/load/webdav/WebDavAvgResponseTimeTest.java
Removed:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/=
jcr/cluster/load/AbstractAvgResponceTimeTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/=
jcr/cluster/load/query/JcrQueryAvgResponceTimeTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/=
jcr/cluster/load/webdav/WebDavAvgResponceTimeTest.java
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/webdav/WebDavTestAgent.java
Log:
EXOJCR-510 : Added more statistical information to the result: now it show=
s, ammount of work minimum, maximum, average, stddev of response time.=
E
Deleted: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/ser=
vices/jcr/cluster/load/AbstractAvgResponceTimeTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/AbstractAvgResponceTimeTest.java 2010-02-18 13:23:36 UTC =
(rev 1897)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/AbstractAvgResponceTimeTest.java 2010-02-18 13:25:20 UTC =
(rev 1898)
@@ -1,140 +0,0 @@
-/*
- * 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.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Sergey K=
abashnyuk
- * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ks=
m $
- *
- */
-public abstract class AbstractAvgResponceTimeTest
-{
-
- private final int iterationGrowingPoll;
-
- private final int iterationTime;
-
- private final int initialSize;
-
- private final int readValue;
-
- /**
- * @param iterationGrowingPoll
- * @param iterationTime
- * @param initialSize
- */
- public AbstractAvgResponceTimeTest(int iterationGrowingPoll, int iterat=
ionTime, int initialSize, int readValue)
- {
- super();
- this.iterationGrowingPoll =3D iterationGrowingPoll;
- this.iterationTime =3D iterationTime;
- this.initialSize =3D initialSize;
- this.readValue =3D readValue;
- }
-
- public void testResponce() throws Exception
- {
- final List nodesPath =3D new ArrayList();
- //start from 1 thread
- int threadCount =3D initialSize;
-
- Random random =3D new Random();
-
- while (true)
- {
-
- final List responceResults =3D Collections.synchron=
izedList(new ArrayList());
-
- ExecutorService threadPool =3D Executors.newFixedThreadPool(threa=
dCount);
- CountDownLatch startSignal =3D new CountDownLatch(1);
- AbstractTestAgent[] testAgents =3D new AbstractTestAgent[threadCo=
unt];
- //pool initialization
- for (int i =3D 0; i < threadCount; i++)
- {
- testAgents[i] =3D getAgent(nodesPath, responceResults, startSi=
gnal, readValue, random);
- threadPool.execute(testAgents[i]);
-
- }
- responceResults.clear();
- startSignal.countDown();//let all threads proceed
-
- Thread.sleep(iterationTime);
-
- threadPool.shutdown();
- for (int i =3D 0; i < testAgents.length; i++)
- {
- testAgents[i].setShouldStop(true);
- }
- //wait 10 minutes
- threadPool.awaitTermination(60 * 10, TimeUnit.SECONDS);
- dumpResults(responceResults, threadCount);
- threadCount +=3D iterationGrowingPoll;
- }
- }
-
- /**
- * Create new agent
- * @param nodesPath
- * @param responceResults
- * @param startSignal
- * @param READ_VALUE
- * @param random
- * @return
- */
- protected abstract AbstractTestAgent getAgent(List nodesPath,=
List responceResults,
- CountDownLatch startSignal, int readValue, Random random);
-
- private void dumpResults(List responceResults, int thread=
Count)
- {
- long sum_read =3D 0;
- long sum_write =3D 0;
- long read =3D 0;
- long write =3D 0;
- for (WorkerResult workerResult : responceResults)
- {
-
- if (workerResult.isRead())
- {
- read++;
- sum_read +=3D workerResult.getResponceTime();
- }
- else
- {
- write++;
- sum_write +=3D workerResult.getResponceTime();
- }
- }
- if ((read + write) > 0)
- {
- System.out.println(" ThreadCount=3D " + threadCount + " Read=3D" =
+ read + " Write=3D" + write + " value "
- + (read * 100 / (read + write)) + " Avg read resp=3D" + (read =
> 0 ? (sum_read / read) : 0)
- + " Avg write resp=3D" + (write > 0 ? (sum_write / write) : 0)=
);
- }
- responceResults.clear();
- }
-}
Copied: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/serv=
ices/jcr/cluster/load/AbstractAvgResponseTimeTest.java (from rev 1827, jcr/=
trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/clu=
ster/load/AbstractAvgResponceTimeTest.java)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/AbstractAvgResponseTimeTest.java =
(rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/AbstractAvgResponseTimeTest.java 2010-02-18 13:25:20 UTC =
(rev 1898)
@@ -0,0 +1,331 @@
+/*
+ * 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.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Sergey K=
abashnyuk
+ * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ks=
m $
+ *
+ */
+public abstract class AbstractAvgResponseTimeTest
+{
+
+ private final int iterationGrowingPoll;
+
+ private final int iterationTime;
+
+ private final int initialSize;
+
+ private final int readValue;
+
+ private final DecimalFormat df =3D new DecimalFormat("#####.##");
+
+ /**
+ * @param iterationGrowingPoll
+ * @param iterationTime
+ * @param initialSize
+ */
+ public AbstractAvgResponseTimeTest(int iterationGrowingPoll, int iterat=
ionTime, int initialSize, int readValue)
+ {
+ super();
+ this.iterationGrowingPoll =3D iterationGrowingPoll;
+ this.iterationTime =3D iterationTime;
+ this.initialSize =3D initialSize;
+ this.readValue =3D readValue;
+ }
+
+ public void testResponce() throws Exception
+ {
+ final List nodesPath =3D new LinkedList();
+ //start from 1 thread
+ int threadCount =3D initialSize;
+
+ Random random =3D new Random();
+
+ while (true)
+ {
+ //test init
+ setUp();
+
+ final List responceResults =3D new LinkedList();
+
+ ExecutorService threadPool =3D Executors.newFixedThreadPool(threa=
dCount);
+ CountDownLatch startSignal =3D new CountDownLatch(1);
+ AbstractTestAgent[] testAgents =3D new AbstractTestAgent[threadCo=
unt];
+
+ //pool initialization
+ for (int i =3D 0; i < threadCount; i++)
+ {
+ testAgents[i] =3D getAgent(nodesPath, responceResults, startSi=
gnal, readValue, random);
+ //init agent
+ testAgents[i].prepare();
+ threadPool.execute(testAgents[i]);
+
+ }
+ responceResults.clear();
+ startSignal.countDown();//let all threads proceed
+
+ Thread.sleep(iterationTime);
+
+ threadPool.shutdown();
+ for (int i =3D 0; i < testAgents.length; i++)
+ {
+ testAgents[i].setShouldStop(true);
+ }
+ //wait 10 minutes
+ threadPool.awaitTermination(60 * 10, TimeUnit.SECONDS);
+ dumpResults(responceResults, threadCount, iterationTime);
+ threadCount +=3D iterationGrowingPoll;
+ tearDown();
+ }
+ }
+
+ /**
+ * Made some actions before iteration run
+ * @throws Exception
+ */
+ protected void setUp() throws Exception
+ {
+
+ }
+
+ /**
+ * Made some actions after iteration finished
+ * @throws Exception
+ */
+ protected void tearDown() throws Exception
+ {
+
+ }
+
+ /**
+ * Create new agent
+ * @param nodesPath
+ * @param responceResults
+ * @param startSignal
+ * @param READ_VALUE
+ * @param random
+ * @return
+ */
+ protected abstract AbstractTestAgent getAgent(List nodesPath,=
List responceResults,
+ CountDownLatch startSignal, int readValue, Random random);
+
+ private void dumpResults(List responceResults, int thread=
Count, int iterationTime)
+ {
+
+ List readResult =3D new ArrayList();
+ List writeResult =3D new ArrayList();
+
+ for (WorkerResult workerResult : responceResults)
+ {
+ if (workerResult =3D=3D null)
+ {
+ continue;
+ }
+ if (workerResult.isRead())
+ {
+ // read++;
+ // sum_read +=3D workerResult.getResponceTime();
+ readResult.add(new Double(workerResult.getResponceTime()));
+ }
+ else
+ {
+ writeResult.add(new Double(workerResult.getResponceTime()));
+ }
+ }
+ ResultInfo readResultInfo =3D new ResultInfo(readResult);
+ readResultInfo.calculate();
+
+ ResultInfo writeResultInfo =3D new ResultInfo(writeResult);
+ writeResultInfo.calculate();
+
+ StringBuffer result =3D new StringBuffer();
+ result.append("ThreadCount=3D ").append(threadCount);
+ result.append(" TPS =3D ").append(
+ Math.round(((readResultInfo.getResultCount() + writeResultInfo.ge=
tResultCount()) * 1000) / iterationTime));
+ result.append(" Total read=3D ").append(df.format(readResultInfo.get=
ResultCount()));
+ result.append(" Max=3D ").append(df.format(readResultInfo.getMaxValu=
e()));
+ result.append(" Min=3D ").append(df.format(readResultInfo.getMinValu=
e()));
+ result.append(" Avg=3D ").append(df.format(readResultInfo.getAvgValu=
e()));
+ result.append(" StdDev=3D ").append(df.format(readResultInfo.getStdD=
evValue()));
+ result.append(" Total write=3D ").append(writeResultInfo.getResultCo=
unt());
+ result.append(" Max=3D ").append(df.format(writeResultInfo.getMaxVal=
ue()));
+ result.append(" Min=3D ").append(df.format(writeResultInfo.getMinVal=
ue()));
+ result.append(" Avg=3D ").append(df.format(writeResultInfo.getAvgVal=
ue()));
+ result.append(" StdDev=3D ").append(df.format(writeResultInfo.getStd=
DevValue()));
+
+ System.out.println(result.toString());
+ // long sum_read =3D 0;
+ // long sum_write =3D 0;
+ // long read =3D 0;
+ // long write =3D 0;
+ // for (WorkerResult workerResult : responceResults)
+ // {
+ // if (workerResult =3D=3D null)
+ // {
+ // continue;
+ // }
+ // if (workerResult.isRead())
+ // {
+ // read++;
+ // sum_read +=3D workerResult.getResponceTime();
+ // }
+ // else
+ // {
+ // write++;
+ // sum_write +=3D workerResult.getResponceTime();
+ // }
+ // }
+ // if ((read + write) > 0)
+ // {
+ // StringBuffer result =3D new StringBuffer();
+ // result.append("ThreadCount=3D ").append(threadCount);
+ // result.append(" TPS =3D ").append(Math.round(((read + wri=
te) * 1000) / iterationTime));
+ // if (read > 0)
+ // {
+ // result.append(" Total read =3D ").append(read);
+ //
+ // result.append(" Avg read response =3D ").append((sum_r=
ead / read));
+ // }
+ // if (write > 0)
+ // {
+ // result.append(" Total write =3D ").append(write);
+ //
+ // result.append(" Avg write response =3D ").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 data;
+
+ /**
+ * @param data
+ */
+ public ResultInfo(List data)
+ {
+ super();
+ this.data =3D data;
+ }
+
+ private void calculate()
+ {
+ final int n =3D data.size();
+ if (n < 2)
+ {
+ this.stdDevValue =3D Double.NaN;
+ this.avgValue =3D data.get(0);
+ this.maxValue =3D data.get(0);
+ this.minValue =3D data.get(0);
+ }
+ else
+ {
+ this.avgValue =3D data.get(0);
+ this.maxValue =3D data.get(0);
+ this.minValue =3D data.get(0);
+ double sum =3D 0;
+ for (int i =3D 1; i < data.size(); i++)
+ {
+ Double currValue =3D data.get(i);
+ if (currValue > maxValue)
+ {
+ maxValue =3D currValue;
+ }
+ if (currValue < minValue)
+ {
+ minValue =3D currValue;
+ }
+ double newavg =3D avgValue + (currValue - avgValue) / (i + =
1);
+ sum +=3D (currValue - avgValue) * (currValue - newavg);
+ this.avgValue =3D newavg;
+ }
+ // Change to ( n - 1 ) to n if you have complete data instead =
of a sample.
+ this.stdDevValue =3D 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 getData()
+ {
+ return data;
+ }
+
+ public long getResultCount()
+ {
+ return data.size();
+ }
+
+ }
+}
Property changes on: jcr/trunk/exo.jcr.component.core/src/test/java/org/exo=
platform/services/jcr/cluster/load/AbstractAvgResponseTimeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/se=
rvices/jcr/cluster/load/AbstractTestAgent.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/AbstractTestAgent.java 2010-02-18 13:23:36 UTC (rev 1897)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/AbstractTestAgent.java 2010-02-18 13:25:20 UTC (rev 1898)
@@ -59,15 +59,23 @@
* Do read
* @return
*/
- public abstract List doRead(List nodesPath);
+ public abstract void doRead(List nodesPath, List responseResults);
=
/**
* Do write
* @return
*/
- public abstract List doWrite(List nodesPath);
+ public abstract void doWrite(List nodesPath, List responseResults);
=
/**
+ * Prepare agent
+ */
+ protected void prepare()
+ {
+
+ }
+
+ /**
* @see java.lang.Runnable#run()
*/
public void run()
@@ -75,16 +83,17 @@
try
{
startSignal.await();
+
while (!shouldStop)
{
- if (random.nextInt(100) > readValue)
+ if (nodesPath.size() < 10 || random.nextInt(100) > readValue)
{
=
- responceResults.addAll(doWrite(nodesPath));
+ doWrite(nodesPath, responceResults);
}
else
{
- responceResults.addAll(doRead(nodesPath));
+ doRead(nodesPath, responceResults);
}
}
}
Deleted: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/ser=
vices/jcr/cluster/load/query/JcrQueryAvgResponceTimeTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/query/JcrQueryAvgResponceTimeTest.java 2010-02-18 13:23:3=
6 UTC (rev 1897)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/query/JcrQueryAvgResponceTimeTest.java 2010-02-18 13:25:2=
0 UTC (rev 1898)
@@ -1,344 +0,0 @@
-/*
- * 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.query;
-
-import org.exoplatform.services.jcr.JcrImplBaseTest;
-import org.exoplatform.services.jcr.cluster.load.AbstractAvgResponceTimeTe=
st;
-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.core.CredentialsImpl;
-import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
-import org.jboss.cache.CacheException;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-import java.util.UUID;
-import java.util.concurrent.CountDownLatch;
-
-import javax.jcr.AccessDeniedException;
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.LoginException;
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryResult;
-import javax.jcr.version.VersionException;
-
-/**
- * @author Sergey K=
abashnyuk
- * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ks=
m $
- *
- */
-public class JcrQueryAvgResponceTimeTest extends JcrImplBaseTest
-{
-
- /**
- * 2min default time of work of one iteration.
- */
- private static final int ITERATION_TIME =3D 60 * 1000;
-
- /**
- * How much thread will be added on the next iteration.
- */
- private static final int ITERATION_GROWING_POLL =3D 15;
-
- /**
- * Number between 0 and 100 show % how many read operations. =
- */
- private static final int READ_VALUE =3D 90;
-
- private static final String[] words =3D
- new String[]{"private", "branch", "final", "string", "logging", "bot=
tle", "property", "node", "repository",
- "exception", "cycle", "value", "index", "meaning", "strange", "wo=
rds", "hello", "outline", "finest",
- "basetest", "writer"};
-
- public static final String FIELDNAME_COUNT =3D "count";
-
- public static final String FIELDNAME_CONTENT =3D "Content";
-
- public static final String FIELDNAME_STATISTIC =3D "Statistic";
-
- private static final String TEST_ROOT =3D "JcrQueryAvgResponceTimeTest";
-
- public void testname() throws Exception
- {
- QueryAvgResponceTimeTest test =3D
- new QueryAvgResponceTimeTest(repository, ITERATION_GROWING_POLL, =
ITERATION_TIME, 5, READ_VALUE);
- test.testResponce();
-
- }
-
- private class QueryAvgResponceTimeTest extends AbstractAvgResponceTimeT=
est
- {
-
- private final RepositoryImpl repository;
-
- /**
- * @param iterationGrowingPoll
- * @param iterationTime
- * @param initialSize
- * @param readValue
- */
- public QueryAvgResponceTimeTest(RepositoryImpl repository, int itera=
tionGrowingPoll, int iterationTime,
- int initialSize, int readValue)
- {
- super(iterationGrowingPoll, iterationTime, initialSize, readValue=
);
- this.repository =3D repository;
- }
-
- /**
- * @see org.exoplatform.services.jcr.cluster.load.AbstractAvgResponc=
eTimeTest#getAgent(java.util.List, java.util.List, java.util.concurrent.Cou=
ntDownLatch, int, java.util.Random)
- */
- @Override
- protected AbstractTestAgent getAgent(List nodesPath, List<=
WorkerResult> responceResults,
- CountDownLatch startSignal, int readValue, Random random)
- {
- return new QueryTestAgent(repository, nodesPath, responceResults,=
startSignal, readValue, random);
- }
-
- }
-
- private class QueryTestAgent extends AbstractTestAgent
- {
- private final RepositoryImpl repository;
-
- private UUID threadUUID;
-
- /**
- * @param repository =
- * @param nodesPath
- * @param responceResults
- * @param startSignal
- * @param READ_VALUE
- * @param random
- */
- public QueryTestAgent(RepositoryImpl repository, List node=
sPath, List responceResults,
- CountDownLatch startSignal, int readValue, Random random)
- {
- super(nodesPath, responceResults, startSignal, readValue, random);
- this.threadUUID =3D UUID.randomUUID();
- this.repository =3D repository;
- initRoot();
- }
-
- /**
- * @param repository
- * @throws LoginException
- * @throws NoSuchWorkspaceException
- * @throws RepositoryException
- * @throws ItemExistsException
- * @throws PathNotFoundException
- * @throws VersionException
- * @throws ConstraintViolationException
- * @throws LockException
- * @throws AccessDeniedException
- * @throws InvalidItemStateException
- * @throws NoSuchNodeTypeException
- */
- private void initRoot()
- {
- int maxAttempts =3D 10;
- CredentialsImpl credentials =3D new CredentialsImpl("admin", "adm=
in".toCharArray());
- for (int i =3D 0; i < maxAttempts; i++)
- {
- boolean isSuccessful =3D false;
- Session sessionLocal =3D null;
- try
- {
-
- sessionLocal =3D repository.login(credentials, "ws");
- // prepare nodes
- Node wsRoot =3D sessionLocal.getRootNode();
- Node threadNode =3D getOrCreateNode(getOrCreateNode(TEST_RO=
OT, wsRoot), threadUUID);
- sessionLocal.save();
- sessionLocal.logout();
- sessionLocal =3D null;
- isSuccessful =3D true;
- }
- catch (CacheException e)
- {
- log.error("error on creating root attempt " + i + " from " =
+ maxAttempts);
- //ignore
- }
- catch (RepositoryException e)
- {
- log.error("error on creating root attempt " + i + " from " =
+ maxAttempts);
- }
- finally
- {
- if (sessionLocal !=3D null)
- {
- try
- {
- sessionLocal.refresh(false);
- sessionLocal.logout();
- }
- catch (RepositoryException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- if (isSuccessful)
- {
- break;
- }
- }
-
- }
-
- /**
- * @see org.exoplatform.services.jcr.cluster.load.AbstractTestAgent#=
doRead(java.util.List)
- */
- @Override
- public List doRead(List nodesPath)
- {
- List result =3D new ArrayList();
- Session sessionLocal =3D null;
- try
- {
- // login
- CredentialsImpl credentials =3D new CredentialsImpl("admin", "=
admin".toCharArray());
-
- sessionLocal =3D repository.login(credentials, "ws");
- Node testRoot =3D sessionLocal.getRootNode().getNode(TEST_ROOT=
);
- // prepare nodes
- int i =3D random.nextInt(words.length);
- String word =3D words[i];
- Query q =3D
- sessionLocal.getWorkspace().getQueryManager().createQuery(
- "SELECT * FROM nt:base WHERE " + FIELDNAME_CONTENT + "=
=3D'" + word + "' AND jcr:path LIKE '"
- + testRoot.getPath() + "/%'", Query.SQL);
- long start =3D System.currentTimeMillis();
- QueryResult res =3D q.execute();
- long sqlsize =3D res.getNodes().getSize();
- result.add(new WorkerResult(true, System.currentTimeMillis() -=
start));
- //log.info(word + " found:" + sqlsize + " time=3D" + (System.c=
urrentTimeMillis() - start));
-
- }
- catch (Exception e)
- {
- log.error(e);
- }
- finally
- {
- if (sessionLocal !=3D null)
- {
- sessionLocal.logout();
- sessionLocal =3D null;
- }
- }
- return result;
- }
-
- /**
- * @see org.exoplatform.services.jcr.cluster.load.AbstractTestAgent#=
doWrite(java.util.List)
- */
- @Override
- public List doWrite(List nodesPath)
- {
- List result =3D new ArrayList();
- // get any word
- int i =3D random.nextInt(words.length);
- String word =3D words[i];
-
- Session sessionLocal =3D null;
- try
- {
- CredentialsImpl credentials =3D new CredentialsImpl("admin", "=
admin".toCharArray());
- sessionLocal =3D repository.login(credentials, "ws");
- long start =3D System.currentTimeMillis();
- Node threadNode =3D getOrCreateNode(getOrCreateNode(TEST_ROOT,=
sessionLocal.getRootNode()), threadUUID);
- addCountent(threadNode, UUID.randomUUID(), word);
- sessionLocal.save();
- result.add(new WorkerResult(false, System.currentTimeMillis() =
- start));
- //log.info(word + " time : " + (System.currentTimeMillis() - s=
tart));
- }
- catch (Exception e1)
- {
- if (sessionLocal !=3D null)
- {
- // discard session changes =
- try
- {
- sessionLocal.refresh(false);
- }
- catch (RepositoryException e)
- {
- log.error("An error occurs", e);
- }
- }
- log.error("An error occurs", e1);
- }
- finally
- {
- if (sessionLocal !=3D null)
- {
- sessionLocal.logout();
- sessionLocal =3D null;
- }
- }
- return result;
- }
-
- private void addCountent(Node testRoot, UUID nodePath, String conten=
t) throws RepositoryException
- {
- Node l5 =3D getOrCreateNode(testRoot, nodePath);
- l5.setProperty(FIELDNAME_CONTENT, content);
- }
-
- private Node getOrCreateNode(Node testRoot, UUID nodePath) throws Re=
positoryException
- {
- String uuidPath =3D nodePath.toString();
- Node l1 =3D getOrCreateNode(uuidPath.substring(0, 8), testRoot);
- Node l2 =3D getOrCreateNode(uuidPath.substring(9, 13), l1);
- Node l3 =3D getOrCreateNode(uuidPath.substring(14, 18), l2);
- Node l4 =3D getOrCreateNode(uuidPath.substring(19, 23), l3);
- return getOrCreateNode(uuidPath.substring(24), l4);
-
- }
-
- /**
- * Gets or creates node
- * =
- * @param name
- * @param parent
- * @return
- * @throws RepositoryException
- */
- private Node getOrCreateNode(String name, Node parent) throws Reposi=
toryException
- {
- if (parent.hasNode(name))
- {
- return parent.getNode(name);
- }
- return parent.addNode(name);
- }
- }
-}
Copied: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/serv=
ices/jcr/cluster/load/query/JcrQueryAvgResponseTimeTest.java (from rev 1827=
, jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/j=
cr/cluster/load/query/JcrQueryAvgResponceTimeTest.java)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/query/JcrQueryAvgResponseTimeTest.java =
(rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/query/JcrQueryAvgResponseTimeTest.java 2010-02-18 13:25:2=
0 UTC (rev 1898)
@@ -0,0 +1,339 @@
+/*
+ * 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.query;
+
+import org.exoplatform.services.jcr.JcrImplBaseTest;
+import org.exoplatform.services.jcr.cluster.load.AbstractAvgResponseTimeTe=
st;
+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.core.CredentialsImpl;
+import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
+import org.jboss.cache.CacheException;
+
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+import javax.jcr.version.VersionException;
+
+/**
+ * @author Sergey K=
abashnyuk
+ * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ks=
m $
+ *
+ */
+public class JcrQueryAvgResponseTimeTest extends JcrImplBaseTest
+{
+
+ /**
+ * 2min default time of work of one iteration.
+ */
+ private static final int ITERATION_TIME =3D 60 * 1000;
+
+ /**
+ * How much thread will be added on the next iteration.
+ */
+ private static final int ITERATION_GROWING_POLL =3D 15;
+
+ /**
+ * Number between 0 and 100 show % how many read operations. =
+ */
+ private static final int READ_VALUE =3D 90;
+
+ private static final String[] words =3D
+ new String[]{"private", "branch", "final", "string", "logging", "bot=
tle", "property", "node", "repository",
+ "exception", "cycle", "value", "index", "meaning", "strange", "wo=
rds", "hello", "outline", "finest",
+ "basetest", "writer"};
+
+ public static final String FIELDNAME_COUNT =3D "count";
+
+ public static final String FIELDNAME_CONTENT =3D "Content";
+
+ public static final String FIELDNAME_STATISTIC =3D "Statistic";
+
+ private static final String TEST_ROOT =3D "JcrQueryAvgResponceTimeTest";
+
+ public void testname() throws Exception
+ {
+ QueryAvgResponceTimeTest test =3D
+ new QueryAvgResponceTimeTest(repository, ITERATION_GROWING_POLL, =
ITERATION_TIME, 5, READ_VALUE);
+ test.testResponce();
+
+ }
+
+ private class QueryAvgResponceTimeTest extends AbstractAvgResponseTimeT=
est
+ {
+
+ private final RepositoryImpl repository;
+
+ /**
+ * @param iterationGrowingPoll
+ * @param iterationTime
+ * @param initialSize
+ * @param readValue
+ */
+ public QueryAvgResponceTimeTest(RepositoryImpl repository, int itera=
tionGrowingPoll, int iterationTime,
+ int initialSize, int readValue)
+ {
+ super(iterationGrowingPoll, iterationTime, initialSize, readValue=
);
+ this.repository =3D repository;
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.cluster.load.AbstractAvgRespons=
eTimeTest#getAgent(java.util.List, java.util.List, java.util.concurrent.Cou=
ntDownLatch, int, java.util.Random)
+ */
+ @Override
+ protected AbstractTestAgent getAgent(List nodesPath, List<=
WorkerResult> responceResults,
+ CountDownLatch startSignal, int readValue, Random random)
+ {
+ return new QueryTestAgent(repository, nodesPath, responceResults,=
startSignal, readValue, random);
+ }
+
+ }
+
+ private class QueryTestAgent extends AbstractTestAgent
+ {
+ private final RepositoryImpl repository;
+
+ private UUID threadUUID;
+
+ /**
+ * @param repository =
+ * @param nodesPath
+ * @param responceResults
+ * @param startSignal
+ * @param READ_VALUE
+ * @param random
+ */
+ public QueryTestAgent(RepositoryImpl repository, List node=
sPath, List responceResults,
+ CountDownLatch startSignal, int readValue, Random random)
+ {
+ super(nodesPath, responceResults, startSignal, readValue, random);
+ this.threadUUID =3D UUID.randomUUID();
+ this.repository =3D repository;
+ initRoot();
+ }
+
+ /**
+ * @param repository
+ * @throws LoginException
+ * @throws NoSuchWorkspaceException
+ * @throws RepositoryException
+ * @throws ItemExistsException
+ * @throws PathNotFoundException
+ * @throws VersionException
+ * @throws ConstraintViolationException
+ * @throws LockException
+ * @throws AccessDeniedException
+ * @throws InvalidItemStateException
+ * @throws NoSuchNodeTypeException
+ */
+ private void initRoot()
+ {
+ int maxAttempts =3D 10;
+ CredentialsImpl credentials =3D new CredentialsImpl("admin", "adm=
in".toCharArray());
+ for (int i =3D 0; i < maxAttempts; i++)
+ {
+ boolean isSuccessful =3D false;
+ Session sessionLocal =3D null;
+ try
+ {
+
+ sessionLocal =3D repository.login(credentials, "ws");
+ // prepare nodes
+ Node wsRoot =3D sessionLocal.getRootNode();
+ Node threadNode =3D getOrCreateNode(getOrCreateNode(TEST_RO=
OT, wsRoot), threadUUID);
+ sessionLocal.save();
+ sessionLocal.logout();
+ sessionLocal =3D null;
+ isSuccessful =3D true;
+ }
+ catch (CacheException e)
+ {
+ log.error("error on creating root attempt " + i + " from " =
+ maxAttempts);
+ //ignore
+ }
+ catch (RepositoryException e)
+ {
+ log.error("error on creating root attempt " + i + " from " =
+ maxAttempts);
+ }
+ finally
+ {
+ if (sessionLocal !=3D null)
+ {
+ try
+ {
+ sessionLocal.refresh(false);
+ sessionLocal.logout();
+ }
+ catch (RepositoryException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ if (isSuccessful)
+ {
+ break;
+ }
+ }
+
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.cluster.load.AbstractTestAgent#=
doRead(java.util.List)
+ */
+ @Override
+ public void doRead(List nodesPath, List resp=
onseResults)
+ {
+ Session sessionLocal =3D null;
+ try
+ {
+ // login
+ CredentialsImpl credentials =3D new CredentialsImpl("admin", "=
admin".toCharArray());
+
+ sessionLocal =3D repository.login(credentials, "ws");
+ Node testRoot =3D sessionLocal.getRootNode().getNode(TEST_ROOT=
);
+ // prepare nodes
+ int i =3D random.nextInt(words.length);
+ String word =3D words[i];
+ Query q =3D
+ sessionLocal.getWorkspace().getQueryManager().createQuery(
+ "SELECT * FROM nt:base WHERE " + FIELDNAME_CONTENT + "=
=3D'" + word + "' AND jcr:path LIKE '"
+ + testRoot.getPath() + "/%'", Query.SQL);
+ long start =3D System.currentTimeMillis();
+ QueryResult res =3D q.execute();
+ long sqlsize =3D res.getNodes().getSize();
+ responseResults.add(new WorkerResult(true, System.currentTimeM=
illis() - start));
+ //log.info(word + " found:" + sqlsize + " time=3D" + (System.c=
urrentTimeMillis() - start));
+
+ }
+ catch (Exception e)
+ {
+ log.error(e);
+ }
+ finally
+ {
+ if (sessionLocal !=3D null)
+ {
+ sessionLocal.logout();
+ sessionLocal =3D null;
+ }
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.cluster.load.AbstractTestAgent#=
doWrite(java.util.List)
+ */
+ @Override
+ public void doWrite(List nodesPath, List res=
ponseResults)
+ {
+ // get any word
+ int i =3D random.nextInt(words.length);
+ String word =3D words[i];
+
+ Session sessionLocal =3D null;
+ try
+ {
+ CredentialsImpl credentials =3D new CredentialsImpl("admin", "=
admin".toCharArray());
+ sessionLocal =3D repository.login(credentials, "ws");
+ long start =3D System.currentTimeMillis();
+ Node threadNode =3D getOrCreateNode(getOrCreateNode(TEST_ROOT,=
sessionLocal.getRootNode()), threadUUID);
+ addCountent(threadNode, UUID.randomUUID(), word);
+ sessionLocal.save();
+ responseResults.add(new WorkerResult(false, System.currentTime=
Millis() - start));
+ //log.info(word + " time : " + (System.currentTimeMillis() - s=
tart));
+ }
+ catch (Exception e1)
+ {
+ if (sessionLocal !=3D null)
+ {
+ // discard session changes =
+ try
+ {
+ sessionLocal.refresh(false);
+ }
+ catch (RepositoryException e)
+ {
+ log.error("An error occurs", e);
+ }
+ }
+ log.error("An error occurs", e1);
+ }
+ finally
+ {
+ if (sessionLocal !=3D null)
+ {
+ sessionLocal.logout();
+ sessionLocal =3D null;
+ }
+ }
+ }
+
+ private void addCountent(Node testRoot, UUID nodePath, String conten=
t) throws RepositoryException
+ {
+ Node l5 =3D getOrCreateNode(testRoot, nodePath);
+ l5.setProperty(FIELDNAME_CONTENT, content);
+ }
+
+ private Node getOrCreateNode(Node testRoot, UUID nodePath) throws Re=
positoryException
+ {
+ String uuidPath =3D nodePath.toString();
+ Node l1 =3D getOrCreateNode(uuidPath.substring(0, 8), testRoot);
+ Node l2 =3D getOrCreateNode(uuidPath.substring(9, 13), l1);
+ Node l3 =3D getOrCreateNode(uuidPath.substring(14, 18), l2);
+ Node l4 =3D getOrCreateNode(uuidPath.substring(19, 23), l3);
+ return getOrCreateNode(uuidPath.substring(24), l4);
+
+ }
+
+ /**
+ * Gets or creates node
+ * =
+ * @param name
+ * @param parent
+ * @return
+ * @throws RepositoryException
+ */
+ private Node getOrCreateNode(String name, Node parent) throws Reposi=
toryException
+ {
+ if (parent.hasNode(name))
+ {
+ return parent.getNode(name);
+ }
+ return parent.addNode(name);
+ }
+ }
+}
Property changes on: jcr/trunk/exo.jcr.component.core/src/test/java/org/exo=
platform/services/jcr/cluster/load/query/JcrQueryAvgResponseTimeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/ser=
vices/jcr/cluster/load/webdav/WebDavAvgResponceTimeTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/webdav/WebDavAvgResponceTimeTest.java 2010-02-18 13:23:36=
UTC (rev 1897)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/webdav/WebDavAvgResponceTimeTest.java 2010-02-18 13:25:20=
UTC (rev 1898)
@@ -1,86 +0,0 @@
-/*
- * 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.webdav;
-
-import junit.framework.TestCase;
-
-import org.exoplatform.services.jcr.cluster.load.AbstractAvgResponceTimeTe=
st;
-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 java.util.List;
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * @author Sergey K=
abashnyuk
- * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ks=
m $
- *
- */
-public class WebDavAvgResponceTimeTest extends TestCase
-{
-
- /**
- * 2min default time of work of one iteration.
- */
- private static final int ITERATION_TIME =3D 60 * 1000;
-
- /**
- * How much thread will be added on the next iteration.
- */
- private static final int ITERATION_GROWING_POLL =3D 5;
-
- /**
- * Number between 0 and 100 show % how many read operations. =
- */
- private static final int READ_VALUE =3D 90;
-
- public void testWebDav() throws Exception
- {
- WebDavTest test =3D new WebDavTest(ITERATION_GROWING_POLL, ITERATION=
_TIME, 1, READ_VALUE);
- test.testResponce();
- }
-
- private class WebDavTest extends AbstractAvgResponceTimeTest
- {
- /**
- * @param iterationGrowingPoll
- * @param iterationTime
- * @param initialSize
- * @param readValue
- */
- public WebDavTest(int iterationGrowingPoll, int iterationTime, int i=
nitialSize, int readValue)
- {
- super(iterationGrowingPoll, iterationTime, initialSize, readValue=
);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @see org.exoplatform.services.jcr.cluster.load.AbstractAvgResponc=
eTimeTest#getAgent(java.util.List, java.util.List, java.util.concurrent.Cou=
ntDownLatch, int, java.util.Random)
- */
- @Override
- protected AbstractTestAgent getAgent(List nodesPath, List<=
WorkerResult> responceResults,
- CountDownLatch startSignal, int readValue, Random random)
- {
- return new WebDavTestAgent(nodesPath, responceResults, startSigna=
l, readValue, random);
- }
-
- }
-}
Copied: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/serv=
ices/jcr/cluster/load/webdav/WebDavAvgResponseTimeTest.java (from rev 1827,=
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jc=
r/cluster/load/webdav/WebDavAvgResponceTimeTest.java)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/webdav/WebDavAvgResponseTimeTest.java =
(rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/webdav/WebDavAvgResponseTimeTest.java 2010-02-18 13:25:20=
UTC (rev 1898)
@@ -0,0 +1,118 @@
+/*
+ * 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.webdav;
+
+import junit.framework.TestCase;
+
+import org.exoplatform.services.jcr.cluster.load.AbstractAvgResponseTimeTe=
st;
+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 java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * @author Sergey K=
abashnyuk
+ * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ks=
m $
+ *
+ */
+public class WebDavAvgResponseTimeTest extends TestCase
+{
+
+ /**
+ * 2min default time of work of one iteration.
+ */
+ private static final int ITERATION_TIME =3D 60 * 1000;
+
+ /**
+ * How much thread will be added on the next iteration.
+ */
+ private static final int ITERATION_GROWING_POLL =3D 10;
+
+ /**
+ * Number between 0 and 100 show % how many read operations. =
+ */
+ private static final int READ_VALUE =3D 90;
+
+ private static final String TEST_ROOT =3D "WebDavAvgResponseTimeTestRoo=
t";
+
+ public void testWebDav() throws Exception
+ {
+ WebDavTest test =3D new WebDavTest(ITERATION_GROWING_POLL, ITERATION=
_TIME, 10, READ_VALUE);
+ test.testResponce();
+ }
+
+ private class WebDavTest extends AbstractAvgResponseTimeTest
+ {
+ private String iterationRoot;
+
+ private int counter;
+
+ /**
+ * @param iterationGrowingPoll
+ * @param iterationTime
+ * @param initialSize
+ * @param readValue
+ */
+ public WebDavTest(int iterationGrowingPoll, int iterationTime, int i=
nitialSize, int readValue)
+ {
+ super(iterationGrowingPoll, iterationTime, initialSize, readValue=
);
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.cluster.load.AbstractAvgRespons=
eTimeTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception
+ {
+ // TODO Auto-generated method stub
+ super.setUp();
+ WebDavTestAgent setUpAgent =3D new WebDavTestAgent(null, null, nu=
ll, null, 0, null);
+
+ String testRoot =3D setUpAgent.createDirIfAbsent("", TEST_ROOT, n=
ew ArrayList());
+ iterationRoot =3D
+ setUpAgent.createDirIfAbsent(testRoot, UUID.randomUUID().toStr=
ing(), new ArrayList());
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.cluster.load.AbstractAvgRespons=
eTimeTest#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.cluster.load.AbstractAvgRespons=
eTimeTest#getAgent(java.util.List, java.util.List, java.util.concurrent.Cou=
ntDownLatch, int, java.util.Random)
+ */
+ @Override
+ protected AbstractTestAgent getAgent(List nodesPath, List<=
WorkerResult> responceResults,
+ CountDownLatch startSignal, int readValue, Random random)
+ {
+ return new WebDavTestAgent(iterationRoot, nodesPath, responceResu=
lts, startSignal, readValue, random);
+ }
+
+ }
+}
Property changes on: jcr/trunk/exo.jcr.component.core/src/test/java/org/exo=
platform/services/jcr/cluster/load/webdav/WebDavAvgResponseTimeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/se=
rvices/jcr/cluster/load/webdav/WebDavTestAgent.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/webdav/WebDavTestAgent.java 2010-02-18 13:23:36 UTC (rev =
1897)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/cluster/load/webdav/WebDavTestAgent.java 2010-02-18 13:25:20 UTC (rev =
1898)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.cluster.load.webdav;
=
+import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.common.http.client.HTTPResponse;
import org.exoplatform.services.jcr.cluster.JCRWebdavConnection;
import org.exoplatform.services.jcr.cluster.load.NodeInfo;
@@ -26,6 +27,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
+import java.util.UUID;
import java.util.concurrent.CountDownLatch;
=
/**
@@ -36,12 +38,8 @@
public class WebDavTestAgent extends AbstractWebDavTestAgent
{
=
- private volatile static long l1FolderCount =3D 0;
+ private String testRoot;
=
- private String l1FolderName;
-
- private long l2FolderCount;
-
/**
* @param nodesPath
* @param responceResults
@@ -49,19 +47,20 @@
* @param READ_VALUE
* @param random
*/
- public WebDavTestAgent(List nodesPath, List res=
ponceResults, CountDownLatch startSignal,
- int READ_VALUE, Random random)
+ public WebDavTestAgent(String testRoot, List nodesPath, List<=
WorkerResult> responceResults,
+ CountDownLatch startSignal, int READ_VALUE, Random random)
{
super(nodesPath, responceResults, startSignal, READ_VALUE, random);
+ this.testRoot =3D testRoot;
}
=
/**
* @see org.exoplatform.services.jcr.cluster.load.AbstractTestAgent#doR=
ead(java.util.List)
*/
@Override
- public List doRead(List nodesPath)
+ public void doRead(List nodesPath, List respons=
eResults)
{
- List result =3D new ArrayList();
+ //List result =3D new ArrayList();
if (nodesPath.size() > 0)
{
=
@@ -76,14 +75,20 @@
=
}
long start =3D System.currentTimeMillis();
- JCRWebdavConnection conn =3D getNewConnection();
+ JCRWebdavConnection conn =3D null;
try
{
+ conn =3D getNewConnection();
HTTPResponse response =3D conn.getNode(readNodePath);
- if (response.getStatusCode() !=3D 200)
+ if (response.getStatusCode() =3D=3D HTTPStatus.OK)
{
+ responseResults.add(new WorkerResult(true, System.currentTi=
meMillis() - start));
+ }
+ else
+ {
System.out.println("Can not get (response code " + response=
.getStatusCode()
+ new String(response.getData()) + " ) node with path : =
" + readNodePath);
+
}
=
}
@@ -93,47 +98,52 @@
}
finally
{
- conn.stop();
+ if (conn !=3D null)
+ {
+ conn.stop();
+ }
}
=
- result.add(new WorkerResult(true, System.currentTimeMillis() - st=
art));
-
}
- return result;
}
=
/**
+ * @see org.exoplatform.services.jcr.cluster.load.AbstractTestAgent#pre=
pare()
+ */
+ @Override
+ protected void prepare()
+ {
+ testRoot =3D createDirIfAbsent(testRoot, UUID.randomUUID().toString(=
), new ArrayList());
+ }
+
+ /**
* @see org.exoplatform.services.jcr.cluster.load.AbstractTestAgent#doW=
rite(java.util.List)
*/
@Override
- public List doWrite(List nodesPath)
+ public void doWrite(List nodesPath, List respon=
seResults)
{
- List result =3D new ArrayList();
- long start =3D 0;
+
JCRWebdavConnection connection =3D null;
try
{
connection =3D getNewConnection();
+ String putFile =3D
+ createDirIfAbsent(testRoot, UUID.randomUUID().toString(), new =
ArrayList()) + "/file";
+ long start =3D System.currentTimeMillis();
+ HTTPResponse response =3D connection.addNode(putFile, ("__the_dat=
a_in_nt+file__").getBytes());
=
- if (l1FolderName =3D=3D null || l2FolderCount =3D=3D 100)
+ if (response.getStatusCode() =3D=3D HTTPStatus.CREATED)
{
- l1FolderName =3D "folder" + (l1FolderCount++);
- start =3D System.currentTimeMillis();
- connection.addDir(l1FolderName);
- l2FolderCount =3D 0;
- result.add(new WorkerResult(false, System.currentTimeMillis() =
- start));
+ responseResults.add(new WorkerResult(false, System.currentTime=
Millis() - start));
+ nodesPath.add(new NodeInfo(putFile, System.currentTimeMillis()=
));
}
- String path =3D l1FolderName + "/" + "node" + l2FolderCount++;
- start =3D System.currentTimeMillis();
- HTTPResponse response =3D connection.addNode(path, ("__the_data_i=
n_nt+file__" + l2FolderCount).getBytes());
-
- if (response.getStatusCode() !=3D 201)
+ else
{
System.out.println(Thread.currentThread().getName() + " : Can =
not add (response code "
- + response.getStatusCode() + new String(response.getData())=
+ " ) node with path : " + path);
+ + response.getStatusCode() + new String(response.getData())=
+ " ) file with path : " + putFile);
+
}
- result.add(new WorkerResult(false, System.currentTimeMillis() - s=
tart));
- nodesPath.add(new NodeInfo(path, System.currentTimeMillis()));
+
}
catch (Exception e)
{
@@ -146,6 +156,74 @@
connection.stop();
}
}
- return result;
}
+
+ /**
+ * Create WebDav node if not exist
+ * @param root
+ * @param name
+ * @param data
+ * @return
+ */
+ public String createDirIfAbsent(String root, String name, List result)
+ {
+ String path =3D root.length() =3D=3D 0 ? name : root + "/" + name;
+ JCRWebdavConnection connection =3D null;
+ try
+ {
+ connection =3D getNewConnection();
+
+ long start =3D System.currentTimeMillis();
+ HTTPResponse nodeResponce =3D connection.getNode(path);
+ //add information about read
+ result.add(new WorkerResult(true, System.currentTimeMillis() - st=
art));
+ if (nodeResponce.getStatusCode() !=3D HTTPStatus.OK)
+ {
+ start =3D System.currentTimeMillis();
+ HTTPResponse addResponce =3D connection.addDir(path);
+ //add information about write
+
+ if (addResponce.getStatusCode() =3D=3D HTTPStatus.CREATED)
+ {
+ result.add(new WorkerResult(false, System.currentTimeMillis=
() - start));
+ }
+ else
+ {
+ System.out.println(Thread.currentThread().getName() + " : C=
an not add (response code "
+ + addResponce.getStatusCode() + new String(addResponce.g=
etData()) + " ) node with path : " + path);
+
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ System.out.println(e.getLocalizedMessage());
+ }
+ finally
+ {
+ if (connection !=3D null)
+ {
+ connection.stop();
+ }
+ }
+ return path;
+ }
+
+ /**
+ * Create WebDav node if not exist
+ * @param root
+ * @param uuid
+ * @param data
+ * @return
+ */
+ public String createDirIfAbsent(String root, UUID uuid, List result)
+ {
+ String uuidPath =3D uuid.toString();
+ String l1 =3D createDirIfAbsent(root, uuidPath.substring(0, 8), resu=
lt);
+ // String l2 =3D createDirIfAbsent(l1, uuidPath.substring(9, 13=
), result);
+ // String l3 =3D createDirIfAbsent(l2, uuidPath.substring(14, 1=
8), result);
+ // String l4 =3D createDirIfAbsent(l3, uuidPath.substring(19, 2=
3), result);
+ return createDirIfAbsent(l1, uuidPath.substring(9), result);
+
+ }
}
--===============2150359023007852358==--