public void testConcurrency() throws Throwable { DummyComponentRegistry componentRegistry = new DummyComponentRegistry(); service = getDataService(props, componentRegistry); if (service instanceof ProfileProducer) { DummyProfileCoordinator.startProfiling(((ProfileProducer) service)); } DummyTransaction txn = new DummyTransaction(); txnProxy.setCurrentTransaction(txn); service.configure(componentRegistry, txnProxy); componentRegistry.setComponent(DataManager.class, service); componentRegistry.registerAppContext(); txn.commit(); int perThread = objects + objectsBuffer; /* Create objects */ for (int t = 0; t < maxThreads; t++) { long startTime = System.currentTimeMillis(); txn = new DummyTransaction(); txnProxy.setCurrentTransaction(txn); int start = t * perThread; BigInteger block = null; for (int i = 0; i < perThread; i++) { if (startTime + 100 < System.currentTimeMillis()) { txn.commit(); txn = new DummyTransaction(); txnProxy.setCurrentTransaction(txn); if (i > 0) { service.getBinding(getObjectName(start), ModifiableObject.class); } } ModifiableObject object = new ModifiableObject(); if (i == 0) { service.manageInNewArea(object); } service.setBinding(getObjectName(start + i), object); BigInteger oidBlock = service.createReference(object).getId().shiftRight(32); if (block == null || !block.equals(oidBlock)) { block = oidBlock; System.err.println("Thread " + t + ": init block " + block); } } txn.commit(); } /* Warm up */ if (repeat != 1) { System.err.println("Warmup:"); runOperations(1); } /* Test */ for (int t = threads; t <= maxThreads; t++) { System.err.println("Threads: " + t); for (int r = 0; r < repeat; r++) { runOperations(t); } } }
public TransactionHandle createTransaction(boolean unbounded) { if (txnCoordinator != null) { return txnCoordinator.createTransaction(unbounded); } DummyTransaction txn = new DummyTransaction(); proxy.setCurrentTransaction(txn); return new TestTransactionHandle(txn); }
private void createTxn() { txn = new DummyTransaction(); txnProxy.setCurrentTransaction(txn); }
/** Creates a transaction with the default timeout. */ private DummyTransaction createTransaction() { DummyTransaction txn = new DummyTransaction(); txnProxy.setCurrentTransaction(txn); return txn; }