1 18 19 package org.objectweb.speedo.stress; 20 21 import org.objectweb.speedo.pobjects.relations.C; 22 import org.objectweb.speedo.pobjects.relations.D; 23 import org.objectweb.util.monolog.api.BasicLevel; 24 25 import javax.jdo.JDOFatalException; 26 import javax.jdo.PersistenceManager; 27 28 33 public class TestRelation1_1Concurrency extends CDRelationHelper { 34 35 public TestRelation1_1Concurrency(String s) { 36 super(s); 37 } 38 39 protected String [] getClassNamesToInit() { 40 return new String []{ 41 org.objectweb.speedo.pobjects.relations.C.class.getName(), 42 org.objectweb.speedo.pobjects.relations.D.class.getName() 43 }; 44 } 45 46 protected String getLoggerName() { 47 return STRESS_LOG_NAME + ".TestRelation1_1Concurrency"; 48 } 49 50 protected int getNbSucc() { 51 return 2; } 53 54 protected void perform(StressHelper.Task task, 55 int threadId, 56 int txId, 57 Object ctx, 58 StressHelper.PerformResult res) { 59 CDCtx cdctx = (CDCtx) ctx; 60 PersistenceManager pm = getPM(task, threadId, txId); 61 try { 62 res.beginTest(); 63 beginTx(pm, task, threadId, txId); 64 65 int oid = getOid(cdctx, true, getNbSucc()); 66 67 C c1 = (C) pm.getObjectById(cdctx.oidsC[oid], false); 68 C c2 = (C) pm.getObjectById(cdctx.oidsC[oid+1], false); 69 D d1 = (D) pm.getObjectById(cdctx.oidsD[oid], false); 70 D d2 = (D) pm.getObjectById(cdctx.oidsD[oid+1], false); 71 72 c1.setD(d1); 73 assertTrue(d1.getC() == c1); 74 c2.setD(d2); 75 assertTrue(d2.getC() == c2); 76 c1.setD(d2); 77 assertTrue(d1.getC() == null); 78 assertTrue(d2.getC() == c1); 79 assertTrue(c2.getD() == null); 80 d1.setC(c2); 81 assertTrue(c2.getD() == d1); 82 d1.setC(c1); 83 assertTrue(c1.getD() == d1); 84 assertTrue(d2.getC() == null); 85 assertTrue(c2.getD() == null); 86 87 commitTx(pm, task, threadId, txId); 88 89 res.endTest(); 90 } catch (JDOFatalException e) { 91 rollbackOnException(pm, e, res, task, threadId, txId); 92 } catch (Throwable e) { 93 stopOnError(pm, e, res, task, threadId, txId); 94 } finally { 95 closePM(pm, threadId, txId, task, res); 96 } 97 } 98 99 103 public void testIntercative() { 104 if (interactive) { 105 logger.log(BasicLevel.INFO, "testInteractive"); 106 perform(Integer.getInteger(THREAD, 1).intValue(), 107 Integer.getInteger(TX, 1).intValue(), 108 Integer.getInteger(TIMEOUT, 1).intValue(), 109 new CDCtx(Integer.getInteger(DBSIZE, 1000).intValue())); 110 } else { 111 logger.log(BasicLevel.INFO, "Non Interactive mode: ignore testInteractive"); 112 } 113 } 114 115 118 private void perform( 119 int nbThread, 120 int dbSize, 121 int nbTx, 122 int threadTimeout) { 123 perform(nbThread, nbTx, threadTimeout, new CDCtx(dbSize)); 124 } 125 126 129 public void testRelation1_1ConcurrencyTh1Tx100() { 130 if (!interactive) { 131 logger.log(BasicLevel.INFO, "testRelation1_1ConcurrencyTh1Tx100"); 132 perform(1, 10000, 100, 1000000); 133 } else { 134 logger.log(BasicLevel.INFO, "Non Interactive mode: ignore testRelation1_1ConcurrencyTh1Tx100"); 135 } 136 } 137 138 141 public void testRelation1_1ConcurrencyTh1Tx1000() { 142 if (!interactive) { 143 logger.log(BasicLevel.INFO, "testRelation1_1ConcurrencyTh1Tx1000"); 144 perform(1, 10000, 1000, 1000000); 145 } else { 146 logger.log(BasicLevel.INFO, "Non Interactive mode: ignore testRelation1_1ConcurrencyTh1Tx1000"); 147 } 148 } 149 150 153 public void testRelation1_1ConcurrencyTh1Tx10000() { 154 if (!interactive) { 155 logger.log(BasicLevel.INFO, "testRelation1_1ConcurrencyTh1Tx10000"); 156 perform(1, 10000, 10000, 1000000); 157 } else { 158 logger.log(BasicLevel.INFO, "Non Interactive mode: ignore testRelation1_1ConcurrencyTh1Tx10000"); 159 } 160 } 161 162 165 public void testRelation1_1ConcurrencyTh2Tx100() { 166 if (!interactive) { 167 logger.log(BasicLevel.INFO, "testRelation1_1ConcurrencyTh2Tx100"); 168 perform(2, 10000, 100, 1000000); 169 } else { 170 logger.log(BasicLevel.INFO, "Non Interactive mode: ignore testRelation1_1ConcurrencyTh2Tx100"); 171 } 172 } 173 174 177 public void testRelation1_1ConcurrencyTh2Tx1000() { 178 if (!interactive) { 179 logger.log(BasicLevel.INFO, "testRelation1_1ConcurrencyTh2Tx1000"); 180 perform(2, 10000, 1000, 1000000); 181 } else { 182 logger.log(BasicLevel.INFO, "Non Interactive mode: ignore testRelation1_1ConcurrencyTh2Tx1000"); 183 } 184 } 185 186 189 public void testRelation1_1ConcurrencyTh2Tx10000() { 190 if (!interactive) { 191 logger.log(BasicLevel.INFO, "testRelation1_1ConcurrencyTh2Tx10000"); 192 perform(2, 10000, 10000, 1000000); 193 } else { 194 logger.log(BasicLevel.INFO, "Non Interactive mode: ignore testRelation1_1ConcurrencyTh2Tx10000"); 195 } 196 } 197 198 201 public void testRelation1_1ConcurrencyTh10Tx100() { 202 if (!interactive) { 203 logger.log(BasicLevel.INFO, "testRelation1_1ConcurrencyTh10Tx100"); 204 perform(10, 10000, 100, 1000000); 205 } else { 206 logger.log(BasicLevel.INFO, "Non Interactive mode: ignore testRelation1_1ConcurrencyTh10Tx100"); 207 } 208 } 209 210 213 public void testRelation1_1ConcurrencyTh10Tx1000() { 214 if (!interactive) { 215 logger.log(BasicLevel.INFO, "testRelation1_1ConcurrencyTh10Tx1000"); 216 perform(10, 10000, 1000, 1000000); 217 } else { 218 logger.log(BasicLevel.INFO, "Non Interactive mode: ignore testRelation1_1ConcurrencyTh10Tx1000"); 219 } 220 } 221 222 225 public void testRelation1_1ConcurrencyTh10Tx10000() { 226 if (!interactive) { 227 logger.log(BasicLevel.INFO, "testRelation1_1ConcurrencyTh10Tx10000"); 228 perform(10, 10000, 10000, 1000000); 229 } else { 230 logger.log(BasicLevel.INFO, "Non Interactive mode: ignore testRelation1_1ConcurrencyTh10Tx10000"); 231 } 232 } 233 } 234 | Popular Tags |