1 package org.prevayler.demos.scalability; 2 3 4 6 public class TransactionTestRun extends ScalabilityTestRun { 7 8 private int halfTheObjects; 9 10 11 public TransactionTestRun(ScalabilityTestSubject subject, int numberOfObjects, int minThreads, int maxThreads) { 12 super(subject, numberOfObjects, minThreads, maxThreads); 13 } 14 15 protected String name() { 16 return "Transaction Test"; 17 } 18 19 protected void prepare() { 20 super.prepare(); 21 halfTheObjects = numberOfObjects / 2; 22 } 23 24 35 protected void executeOperation(Object connection, long operationSequence) { 36 Record recordToInsert = new Record(numberOfObjects + operationSequence); 37 long idToDelete = spreadId(operationSequence); 38 Record recordToUpdate = new Record(halfTheObjects + idToDelete); 39 40 ((TransactionConnection)connection).performTransaction(recordToInsert, recordToUpdate, idToDelete); 41 } 42 43 44 46 private long spreadId(long id) { 47 return (id / halfTheObjects) * halfTheObjects + ((id * 16807) % halfTheObjects); } 50 } 51 | Popular Tags |