1 18 19 package org.objectweb.speedo.stress; 20 21 import javax.jdo.JDOFatalException; 22 import javax.jdo.PersistenceManager; 23 24 import junit.framework.Assert; 25 26 import org.objectweb.speedo.Alea; 27 import org.objectweb.speedo.pobjects.userid.LinkedIntUserId; 28 import org.objectweb.util.monolog.api.BasicLevel; 29 30 35 public class TestNavigation extends LinkedIntUserIdHelper { 36 37 public TestNavigation(String s) { 38 super(s); 39 } 40 41 protected String getLoggerName() { 42 return STRESS_LOG_NAME + ".TestNavigation"; 43 } 44 45 protected void perform(Task task, 46 int threadId, 47 int txId, 48 Object ctx, 49 PerformResult res) { 50 LIUICtx nctx = (LIUICtx) ctx; 51 PersistenceManager pm = getPM(task, threadId, txId); 52 try { 53 res.beginTest(); 54 beginTx(pm, task, threadId, txId); 55 int first = Alea.rand(0, nctx.dbSize - 1); 57 int nbRead = Alea.rand(1, 1000); 58 int name = -1; 59 if (debug) { 60 logger.log(BasicLevel.DEBUG, "first= " + first); 61 logger.log(BasicLevel.DEBUG, "nbRead= " + nbRead); 62 } 63 LinkedIntUserId current = (LinkedIntUserId) pm.getObjectById(nctx.oids[first], false); 64 for (int no = 0; no < nbRead; no++) { 65 Assert.assertNotNull("first=" + first + " nbRead=" + nbRead, current); 66 name = current.getName(); 67 if (debug) { 68 logger.log(BasicLevel.DEBUG, "Obj " + name); 69 } 70 current = current.getNext(); 71 } 72 commitTx(pm, task, threadId, txId); 73 res.endTest(); 74 } catch (JDOFatalException e) { 75 rollbackOnException(pm, e, res, task, threadId, txId); 76 } catch (Throwable e) { 77 stopOnError(pm, e, res, task, threadId, txId); 78 } finally { 79 closePM(pm, threadId, txId, task, res); 80 } 81 } 82 83 private void performNavigation(int nbThread, int dbsize, int nbTx, int to) { 84 perform(nbThread, nbTx, to, new LIUICtx(dbsize)); 85 } 86 87 88 93 public void testNavigation() { 94 if (interactive) { 95 perform(Integer.getInteger(THREAD, 10).intValue(), 96 Integer.getInteger(TX, 100).intValue(), 97 Integer.getInteger(TIMEOUT, 200000).intValue(), 98 new LIUICtx( 99 Integer.getInteger(DBSIZE, 100000).intValue())); 100 } 101 } 102 103 106 public void testNavigationTh1Tx100De1() { 107 if (!interactive) { 108 performNavigation(1, 100, 100, 1000000); 109 } 110 } 111 112 115 116 public void testNavigationTh1Tx1000De1() { 117 if (!interactive) { 118 performNavigation(1, 1000, 1000, 1000000); 119 } 120 } 121 122 126 127 public void testNavigationTh1Tx10000De1() { 128 if (!interactive) { 129 performNavigation(1, 10000, 10000, 1000000); 130 } 131 } 132 133 136 137 public void testNavigationTh1Tx100000De1() { 138 if (!interactive) { 139 performNavigation(1, 100000, 100000, 1000000); 140 } 141 } 142 143 146 public void testNavigationTh10Tx100De1() { 147 if (!interactive) { 148 performNavigation(10, 100, 100, 1000000); 149 } 150 } 151 152 155 156 public void testNavigationTh10Tx1000De1() { 157 if (!interactive) { 158 performNavigation(10, 1000, 1000, 1000000); 159 } 160 } 161 162 166 167 public void testNavigationTh10Tx10000De1() { 168 if (!interactive) { 169 performNavigation(10, 10000, 10000, 1000000); 170 } 171 } 172 173 176 177 public void testNavigationTh10Tx100000De1() { 178 if (!interactive) { 179 performNavigation(10, 100000, 100000, 1000000); 180 } 181 } 182 } 183 | Popular Tags |