Source Code Cross Referenced for TestQueryConcurrency.java in  » Database-ORM » Speedo_1.4.5 » org » objectweb » speedo » stress » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » Speedo_1.4.5 » org.objectweb.speedo.stress 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (C) 2001-2004 France Telecom R&D
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */package org.objectweb.speedo.stress;
018:
019:        import javax.jdo.JDOFatalException;
020:        import javax.jdo.PersistenceManager;
021:
022:        import junit.framework.TestSuite;
023:        import junit.textui.TestRunner;
024:
025:        import org.objectweb.speedo.Alea;
026:        import org.objectweb.speedo.api.ExceptionHelper;
027:        import org.objectweb.speedo.pobjects.basic.BasicA;
028:        import org.objectweb.speedo.pobjects.collection.AMMB;
029:        import org.objectweb.speedo.pobjects.collection.BMMB;
030:        import org.objectweb.speedo.pobjects.collection.Ref2Ref2AMMB;
031:        import org.objectweb.speedo.pobjects.ref.Department;
032:        import org.objectweb.speedo.pobjects.ref.Employee;
033:        import org.objectweb.speedo.pobjects.userid.AutoIncFieldId;
034:        import org.objectweb.speedo.pobjects.userid.Ref2AutoIncFieldId;
035:        import org.objectweb.speedo.runtime.query.TestQueries;
036:        import org.objectweb.util.monolog.api.BasicLevel;
037:
038:        /**
039:         * Stresses the query execution of Speedo.
040:         *
041:         * @author M. Guillemin
042:         */
043:        public class TestQueryConcurrency extends QueryHelper {
044:
045:            public static int RESULT_MAX = 1000;
046:
047:            protected String QUERYSUBSET = getLoggerName() + ".querysubset";
048:
049:            private static TestQueries test = new TestQueries(
050:                    "TestQueryConcurrency");
051:
052:            public TestQueryConcurrency(String s) {
053:                super (s);
054:            }
055:
056:            protected String[] getClassNamesToInit() {
057:                return new String[] { Employee.class.getName(),
058:                        Department.class.getName(), AMMB.class.getName(),
059:                        BMMB.class.getName(), Ref2Ref2AMMB.class.getName(),
060:                        Ref2AutoIncFieldId.class.getName(),
061:                        AutoIncFieldId.class.getName(), BasicA.class.getName() };
062:            }
063:
064:            protected String getLoggerName() {
065:                return STRESS_LOG_NAME + ".TestQueryConcurrency";
066:            }
067:
068:            public static void main(String[] args) {
069:                TestRunner.run(new TestSuite(TestQueryConcurrency.class));
070:            }
071:
072:            protected void perform(StressHelper.Task task, int threadId,
073:                    int txId, Object _ctx, StressHelper.PerformResult res) {
074:                QueryCtx queryCtx = (QueryCtx) _ctx;
075:                PersistenceManager pm = getPM(task, threadId, txId);
076:                try {
077:                    res.beginTest();
078:                    beginTx(pm, task, threadId, txId);
079:
080:                    int query = queryCtx.queries[Alea.rand(0,
081:                            queryCtx.queries.length - 1)];
082:                    //for (query=0; query<35; query++)
083:                    launchTest(query, threadId);
084:
085:                    commitTx(pm, task, threadId, txId);
086:                    res.endTest();
087:                } catch (JDOFatalException e) {
088:                    rollbackOnException(pm, e, res, task, threadId, txId);
089:                } catch (Throwable e) {
090:                    stopOnError(pm, e, res, task, threadId, txId);
091:                } finally {
092:                    closePM(pm, threadId, txId, task, res);
093:                }
094:            }
095:
096:            /**
097:             * Tests the execution of different queries, with interactive
098:             * setting of test parameteres (see file userconf/stress.properties).
099:             */
100:            public void testInteractive() {
101:                if (interactive) {
102:                    perform(Integer.getInteger(THREAD, 10).intValue(), Integer
103:                            .getInteger(TX, 100).intValue(), Integer
104:                            .getInteger(TIMEOUT, 200000).intValue(),
105:                            new QueryCtx(System.getProperty(QUERYSUBSET)));
106:                }
107:            }
108:
109:            /**
110:             * Switch method
111:             */
112:            private void performQuery(int nbThread, int nbTx, int threadTimeout) {
113:                perform(nbThread, nbTx, threadTimeout, new QueryCtx(System
114:                        .getProperty(QUERYSUBSET)));
115:            }
116:
117:            /**
118:             * Tests 100 transactions where each of them execute 1 query on 100 objects using 1 thread.
119:             */
120:            public void testQueryConcurrencyTh1Tx100Qu1() {
121:                if (!interactive) {
122:                    performQuery(1, 100, 1000000);
123:                }
124:            }
125:
126:            /**
127:             * Tests 1000 transactions where each of them execute 1 query on 1000 objects using 1 thread.
128:             */
129:
130:            public void testQueryConcurrencyTh1Tx1000Qu1() {
131:                if (!interactive) {
132:                    performQuery(1, 1000, 1000000);
133:                }
134:            }
135:
136:            /**
137:             * Tests 10000 transactions where each of them execute 1 query on 10000 objects using 1 thread.
138:             */
139:
140:            public void testQueryConcurrencyTh1Tx10000Qu1() {
141:                if (!interactive) {
142:                    performQuery(1, 10000, 1000000);
143:                }
144:            }
145:
146:            /**
147:             * Tests 100000 transactions where each of them execute 1 query on 100000 objects using 1 thread.
148:             */
149:
150:            public void testQueryConcurrencyTh1Tx100000Qu1() {
151:                if (!interactive) {
152:                    performQuery(1, 100000, 1000000);
153:                }
154:            }
155:
156:            /**
157:             * Tests 100 transactions where each of them execute 1 query on 100 objects using 10 thread.
158:             */
159:            public void testQueryConcurrencyTh10Tx100Qu1() {
160:                if (!interactive) {
161:                    performQuery(10, 100, 1000000);
162:                }
163:            }
164:
165:            /**
166:             * Tests 1000 transactions where each of them execute 1 query on 1000 objects using 10 thread.
167:             */
168:
169:            public void testQueryConcurrencyTh10Tx1000Qu1() {
170:                if (!interactive) {
171:                    performQuery(10, 1000, 1000000);
172:                }
173:            }
174:
175:            /**
176:             * Tests 10000 transactions where each of them execute 1 query on 10000 objects using 10 thread.
177:             */
178:
179:            public void testQueryConcurrencyTh10Tx10000Qu1() {
180:                if (!interactive) {
181:                    performQuery(10, 10000, 1000000);
182:                }
183:            }
184:
185:            /**
186:             * Tests 100000 transactions where each of them execute 1 query on 100000 objects using 10 thread.
187:             */
188:
189:            public void testQueryConcurrencyTh10Tx100000Qu1() {
190:                if (!interactive) {
191:                    performQuery(10, 100000, 1000000);
192:                }
193:            }
194:
195:            private void launchTest(int queryidx, int threadId) {
196:                String msg = "Thread " + threadId + " method: ";
197:                try {
198:                    switch (queryidx) {
199:                    case 0:
200:                        msg += "test0Parameter";
201:                        logger.log(BasicLevel.DEBUG, msg);
202:                        test.test0Parameter();
203:                        break;
204:                    case 1:
205:                        msg += "test10rder";
206:                        logger.log(BasicLevel.DEBUG, msg);
207:                        test.test10rder();
208:                        break;
209:                    case 2:
210:                        msg += "test20rder";
211:                        logger.log(BasicLevel.DEBUG, msg);
212:                        test.test20rder();
213:                        break;
214:                    case 3:
215:                        msg += "test1Parameter";
216:                        logger.log(BasicLevel.DEBUG, msg);
217:                        test.test1Parameter();
218:                        break;
219:                    case 4:
220:                        msg += "testFieldParameter";
221:                        logger.log(BasicLevel.DEBUG, msg);
222:                        test.testFieldParameter();
223:                        break;
224:                    case 5:
225:                        msg += "test2Parameters";
226:                        logger.log(BasicLevel.DEBUG, msg);
227:                        test.test2Parameters();
228:                        break;
229:                    case 6:
230:                        msg += "test3Parameters";
231:                        logger.log(BasicLevel.DEBUG, msg);
232:                        test.test3Parameters();
233:                        break;
234:                    case 7:
235:                        msg += "testMapParameters";
236:                        logger.log(BasicLevel.DEBUG, msg);
237:                        test.testMapParameters();
238:                        break;
239:                    case 8:
240:                        msg += "testArrayParameters";
241:                        logger.log(BasicLevel.DEBUG, msg);
242:                        test.testArrayParameters();
243:                        break;
244:                    case 9:
245:                        msg += "testFieldRef";
246:                        logger.log(BasicLevel.DEBUG, msg);
247:                        test.testFieldRef();
248:                        break;
249:                    case 10:
250:                        msg += "testThis";
251:                        logger.log(BasicLevel.DEBUG, msg);
252:                        test.testThis();
253:                        break;
254:                    case 11:
255:                        msg += "testParamRef";
256:                        logger.log(BasicLevel.DEBUG, msg);
257:                        test.testParamRef();
258:                        break;
259:                    case 12:
260:                        msg += "testBsContainsParamA0B0";
261:                        logger.log(BasicLevel.DEBUG, msg);
262:                        test.testBsContainsParamA0B0();
263:                        break;
264:                    case 13:
265:                        msg += "testBsContainsParamA0B2";
266:                        logger.log(BasicLevel.DEBUG, msg);
267:                        test.testBsContainsParamA0B2();
268:                        break;
269:                    case 14:
270:                        msg += "testBsContainsVarB3EmptyShortPath";
271:                        logger.log(BasicLevel.DEBUG, msg);
272:                        test.testBsContainsVarB3EmptyShortPath();
273:                        break;
274:                    case 15:
275:                        msg += "testBsContainsVarB0ShortPath";
276:                        logger.log(BasicLevel.DEBUG, msg);
277:                        test.testBsContainsVarB0ShortPath();
278:                        break;
279:                    case 16:
280:                        msg += "testBsContainsVarB1ShortPath";
281:                        logger.log(BasicLevel.DEBUG, msg);
282:                        test.testBsContainsVarB1ShortPath();
283:                        break;
284:                    case 17:
285:                        msg += "testBsContainsVarB3EmptyLongPath";
286:                        logger.log(BasicLevel.DEBUG, msg);
287:                        test.testBsContainsVarB3EmptyLongPath();
288:                        break;
289:                    case 18:
290:                        msg += "testBsContainsVarB0LongPath";
291:                        logger.log(BasicLevel.DEBUG, msg);
292:                        test.testBsContainsVarB0LongPath();
293:                        break;
294:                    case 19:
295:                        msg += "testBsContainsVarB1LongPath";
296:                        logger.log(BasicLevel.DEBUG, msg);
297:                        test.testBsContainsVarB1LongPath();
298:                        break;
299:                    case 20:
300:                        msg += "testBsIsEmptyA0";
301:                        logger.log(BasicLevel.DEBUG, msg);
302:                        test.testBsIsEmptyA0();
303:                        break;
304:                    case 21:
305:                        msg += "testBsIsEmptyA3";
306:                        logger.log(BasicLevel.DEBUG, msg);
307:                        test.testBsIsEmptyA3();
308:                        break;
309:                    case 22:
310:                        msg += "testBsIsEmptyA0WithNot";
311:                        logger.log(BasicLevel.DEBUG, msg);
312:                        test.testBsIsEmptyA0WithNot();
313:                        break;
314:                    case 23:
315:                        msg += "testBsIsEmptyA3WithNot";
316:                        logger.log(BasicLevel.DEBUG, msg);
317:                        test.testBsIsEmptyA3WithNot();
318:                        break;
319:                    case 24:
320:                        msg += "testBsContainsVarB3EmptyLongPath";
321:                        logger.log(BasicLevel.DEBUG, msg);
322:                        test.testBsContainsVarB3EmptyLongPath();
323:                        break;
324:                    case 25:
325:                        msg += "testBsContainsVarB3EmptyLongPath";
326:                        logger.log(BasicLevel.DEBUG, msg);
327:                        test.testBsContainsVarB3EmptyLongPath();
328:                        break;
329:                    case 26:
330:                        msg += "testBsIsNotEmptyA0Global";
331:                        logger.log(BasicLevel.DEBUG, msg);
332:                        test.testBsIsNotEmptyA0Global();
333:                        break;
334:                    case 27:
335:                        msg += "testBsIsNotEmptyA0Local";
336:                        logger.log(BasicLevel.DEBUG, msg);
337:                        test.testBsIsNotEmptyA0Local();
338:                        break;
339:                    case 28:
340:                        msg += "testBsIsNotEmptyA3Global";
341:                        logger.log(BasicLevel.DEBUG, msg);
342:                        test.testBsIsNotEmptyA3Global();
343:                        break;
344:                    case 29:
345:                        msg += "testNotA0";
346:                        logger.log(BasicLevel.DEBUG, msg);
347:                        test.testNotA0();
348:                        break;
349:                    case 30:
350:                        msg += "testExtentAMMBfalse";
351:                        logger.log(BasicLevel.DEBUG, msg);
352:                        test.testExtentAMMBfalse();
353:                        break;
354:                    case 31:
355:                        msg += "testExtentBMMBfalse";
356:                        logger.log(BasicLevel.DEBUG, msg);
357:                        test.testExtentBMMBfalse();
358:                        break;
359:                    case 32:
360:                        msg += "testQueryBasedOnExtent";
361:                        logger.log(BasicLevel.DEBUG, msg);
362:                        test.testQueryBasedOnExtent();
363:                        break;
364:                    case 33:
365:                        msg += "testSequenceIdNavigateToPrimitive";
366:                        logger.log(BasicLevel.DEBUG, msg);
367:                        test.testSequenceIdNavigateToPrimitive();
368:                        break;
369:                    case 34:
370:                        msg += "testSequenceIdNavigateToPrimitive2";
371:                        logger.log(BasicLevel.DEBUG, msg);
372:                        test.testSequenceIdNavigateToPrimitive2();
373:                        break;
374:                    }
375:                } catch (Exception e) {
376:                    Exception ie = ExceptionHelper.getNested(e);
377:                    logger.log(BasicLevel.ERROR, msg, ie);
378:                    fail(msg + ie.getMessage());
379:                }
380:            }
381:
382:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.