You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2003/03/14 01:56:25 UTC
cvs commit: db-ojb/src/ejb/org/apache/ojb/ejb StressTestClient.java PBSessionBean.java ODMGSessionBean.java
arminw 2003/03/13 16:56:25
Modified: xdocs deployment.xml
src/ejb/org/apache/ojb/ejb StressTestClient.java
PBSessionBean.java ODMGSessionBean.java
Log:
update test cases, add new
method, improve stress test
Revision Changes Path
1.15 +3 -4 db-ojb/xdocs/deployment.xml
Index: deployment.xml
===================================================================
RCS file: /home/cvs/db-ojb/xdocs/deployment.xml,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- deployment.xml 5 Mar 2003 10:28:05 -0000 1.14
+++ deployment.xml 14 Mar 2003 00:56:24 -0000 1.15
@@ -374,7 +374,7 @@
jndi-datasource-name="java:DefaultDS"
username="sa"
password=""
- eager-release="false"
+ eager-release="true"
batch-mode="false"
useAutoCommit="0"
ignoreAutoCommitExceptions="false"
@@ -389,9 +389,8 @@
in managed environments, because it's in most cases not
allowed to change autoCommit state.
<br/>
-When using 3.0 <= jboss < 3.0.4 you have to set
-<code>eager-release="true"</code>, but it seems with releases >= 3.0.4 you have to
-set 'false' to run OJB properly - when using other application server
+When using jboss >3.0 you have to set
+<code>eager-release="true"</code> - when using other application server
<code>false</code> should be ok.
</p>
1.7 +21 -14 db-ojb/src/ejb/org/apache/ojb/ejb/StressTestClient.java
Index: StressTestClient.java
===================================================================
RCS file: /home/cvs/db-ojb/src/ejb/org/apache/ojb/ejb/StressTestClient.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StressTestClient.java 10 Jan 2003 16:52:22 -0000 1.6
+++ StressTestClient.java 14 Mar 2003 00:56:25 -0000 1.7
@@ -65,6 +65,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import java.util.Iterator;
import java.math.BigDecimal;
/**
@@ -77,7 +78,7 @@
{
private Logger log = LoggerFactory.getLogger(StressTestClient.class);
- private static int iterationsPerThread = 500;
+ private static int iterationsPerThread = 200;
private static int concurrentThreads = 20;
//used for client generated ids
private static int id = 10001;
@@ -306,7 +307,7 @@
times[0] = System.currentTimeMillis();
log.info("++ Start thread generation for ODMG api test ++");
log.info("Begin with stress test, " + concurrentThreads +
- " concurrent threads, handle " + iterationsPerThread + " articles form each thread");
+ " concurrent threads, handle " + iterationsPerThread + " articles for each thread");
for (int i = 0; i < concurrentThreads; i++)
{
StressTestClient.StressTestClientODMG tc = new StressTestClient.StressTestClientODMG();
@@ -335,13 +336,13 @@
buf.append(sep);
buf.append(concurrentThreads + " concurrent threads, handle " + iterationsPerThread + " articles per thread");
buf.append(sep);
- buf.append("Test period: " + (double) (((double) times[0]) / 1000) + " [sec]");
+ buf.append("Test period: " + (int) (((double) times[0]) / 1000*concurrentThreads) + " [sec]");
buf.append(sep);
- buf.append("Inserting period: " + (times[1] / (concurrentThreads)) + " [msec]");
+ buf.append("Inserting period: " + (times[1]) + " [msec]");
buf.append(sep);
- buf.append("Fetching period: " + (times[2] / (concurrentThreads)) + " [msec]");
+ buf.append("Fetching period: " + (times[2]) + " [msec]");
buf.append(sep);
- buf.append("Deleting period: " + (times[3] / (concurrentThreads)) + " [msec]");
+ buf.append("Deleting period: " + (times[3]) + " [msec]");
buf.append(sep);
buf.append("----------------------------------------------------");
@@ -355,14 +356,16 @@
{
private List articlesList;
private ODMGSessionRemote bean;
+ private String articleName;
public StressTestClientODMG()
{
init();
articlesList = new ArrayList();
+ articleName = "ODMG_"+Math.random();
for (int i = 0; i < iterationsPerThread; i++)
{
- articlesList.add(createArticle(i));
+ articlesList.add(createArticle(articleName, i));
}
}
@@ -423,11 +426,11 @@
* factory method that createa an PerformanceArticle
* @return the created PerformanceArticle object
*/
- private ArticleVO createArticle(int id)
+ private ArticleVO createArticle(String articleName, int id)
{
ArticleVO a = new ArticleVO();
if (clientKeyGeneration) a.setArticleId(getId());
- if (clientKeyGeneration) a.setName("New Article " + id);
+ if (clientKeyGeneration) a.setName(articleName);
a.setPrice(new BigDecimal(0.45*id));
a.setDescription("description "+id);
return a;
@@ -457,7 +460,8 @@
{
long start = System.currentTimeMillis();
- bean.getAllObjects(ArticleVO.class);
+ Iterator it = bean.getArticlesByName(articleName).iterator();
+ while(it.hasNext()) it.next();
long stop = System.currentTimeMillis();
times[2] = times[2] + (stop - start);
@@ -472,14 +476,16 @@
{
private List articlesList;
private PBSessionRemote bean;
+ private String articleName;
public StressTestClientPB()
{
init();
articlesList = new ArrayList();
+ articleName = "PB_"+Math.random();
for (int i = 0; i < iterationsPerThread; i++)
{
- articlesList.add(createArticle(i));
+ articlesList.add(createArticle(articleName, i));
}
//log.info("Articles created");
}
@@ -542,11 +548,11 @@
* factory method that createa an PerformanceArticle
* @return the created PerformanceArticle object
*/
- private ArticleVO createArticle(int id)
+ private ArticleVO createArticle(String articleName, int id)
{
ArticleVO a = new ArticleVO();
if (clientKeyGeneration) a.setArticleId(getId());
- a.setName("New Article " + id);
+ if (clientKeyGeneration) a.setName(articleName);
a.setPrice(new BigDecimal(0.45*id));
a.setDescription("description "+id);
return a;
@@ -576,7 +582,8 @@
{
long start = System.currentTimeMillis();
- bean.getAllObjects(ArticleVO.class);
+ Iterator it = bean.getArticlesByName(articleName).iterator();
+ while(it.hasNext()) it.next();
long stop = System.currentTimeMillis();
times[2] = times[2] + (stop - start);
1.9 +17 -1 db-ojb/src/ejb/org/apache/ojb/ejb/PBSessionBean.java
Index: PBSessionBean.java
===================================================================
RCS file: /home/cvs/db-ojb/src/ejb/org/apache/ojb/ejb/PBSessionBean.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- PBSessionBean.java 27 Feb 2003 20:46:42 -0000 1.8
+++ PBSessionBean.java 14 Mar 2003 00:56:25 -0000 1.9
@@ -60,6 +60,7 @@
import org.apache.ojb.broker.PersistenceBrokerException;
import org.apache.ojb.broker.query.Query;
import org.apache.ojb.broker.query.QueryByCriteria;
+import org.apache.ojb.broker.query.Criteria;
import org.apache.ojb.broker.ta.PBFactoryIF;
import org.apache.ojb.broker.ta.PersistenceBrokerFactoryIF;
import org.apache.ojb.broker.util.logging.Logger;
@@ -217,6 +218,21 @@
{
if(log.isDebugEnabled()) log.debug("getArticleCount was called");
return getCount(ArticleVO.class);
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public Collection getArticlesByName(String articleName)
+ {
+ if(log.isDebugEnabled()) log.debug("getArticlesByName was called");
+ PersistenceBroker broker = getBroker();
+ Criteria crit = new Criteria();
+ crit.addLike("name", articleName);
+ Query q = new QueryByCriteria(ArticleVO.class, crit);
+ Collection result = broker.getCollectionByQuery(q);
+ broker.close();
+ return result;
}
/**
1.11 +22 -1 db-ojb/src/ejb/org/apache/ojb/ejb/ODMGSessionBean.java
Index: ODMGSessionBean.java
===================================================================
RCS file: /home/cvs/db-ojb/src/ejb/org/apache/ojb/ejb/ODMGSessionBean.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ODMGSessionBean.java 27 Feb 2003 20:46:42 -0000 1.10
+++ ODMGSessionBean.java 14 Mar 2003 00:56:25 -0000 1.11
@@ -66,6 +66,8 @@
import org.odmg.OQLQuery;
import org.odmg.QueryException;
import org.odmg.Transaction;
+import org.odmg.QueryParameterCountInvalidException;
+import org.odmg.QueryParameterTypeInvalidException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
@@ -238,6 +240,25 @@
{
if(log.isDebugEnabled()) log.debug("getArticleCount was called");
return getObjectCount(odmg, ArticleVO.class);
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public Collection getArticlesByName(String articleName)
+ {
+ if(log.isDebugEnabled()) log.debug("getArticlesByName was called");
+ try
+ {
+ OQLQuery query = odmg.newOQLQuery();
+ query.create("select allArticles from " + ArticleVO.class.getName() + " where name like $1");
+ query.bind(articleName);
+ return (Collection) query.execute();
+ }
+ catch (QueryException e)
+ {
+ throw new EJBException("Query objects failed", e);
+ }
}
/**