/** * Begin txn. * * @param timeOut the time out * @return the long * @throws js.co.uk.tuplespace.store.TransactionException the transaction exception */ public synchronized TransactionID beginTxn(final Long timeOut) throws TransactionException { // new id final Transaction<V> txn = new Transaction<V>(++transactionID, parentCollection); txnTimeoutQueue.add(txn, timeOut, TimeUnit.MILLISECONDS); idToTxnMap.put(txn.getTxnId(), txn); return txn.getTxnId(); }
@Override public void begin(Transaction txn) { // debug("%s begin", txn.getLabel()) ; if (this.txn.getTxnId() != txn.getTxnId()) throw new TDBException( String.format("Different transactions: %s %s", this.txn.getLabel(), txn.getLabel())); if (passthrough) throw new TDBException("Already active"); passthrough = false; allocOffset = base.allocOffset().getId(); // base node table empty e.g. first use. journalObjFileStartOffset = journalObjFile.length(); // Because the data is written in prepare, the journal of object data is // always empty at the start of a transaction. if (journalObjFileStartOffset != 0) warn( log, "%s journalStartOffset not zero: %d/0x%02X", txn.getLabel(), journalObjFileStartOffset, journalObjFileStartOffset); allocOffset += journalObjFileStartOffset; this.nodeTableJournal = new NodeTableNative(nodeIndex, journalObjFile); this.nodeTableJournal = NodeTableCache.create(nodeTableJournal, CacheSize, CacheSize, 100); // This class knows about non-mappable inline values. mapToJournal(NodeId)/mapFromJournal. this.nodeTableJournal = NodeTableInline.create(nodeTableJournal); }
public TransactionDataset(List<Transaction> txnsList) { this.txnsByUserIdMap = new HashMap<Integer, List<Transaction>>(); this.txnsByTxnIdMap = new HashMap<String, Transaction>(txnsList.size()); for (Transaction e : txnsList) { txnsByTxnIdMap.put(String.valueOf(e.getTxnId()), e); Integer userId = e.getUserId(); List<Transaction> userTxns = txnsByUserIdMap.get(userId); if (userTxns == null) { userTxns = new ArrayList<Transaction>(); txnsByUserIdMap.put(userId, userTxns); } if (maxUserId == null || e.getUserId() > maxUserId) { maxUserId = e.getUserId(); } userTxns.add(e); } instanceBuilder = new TransactionInstanceBuilder(); }