protected void rollback(final long txID) throws Exception { TransactionHolder tx = transactions.remove(txID); if (tx == null) { throw new IllegalStateException("Cannot find tx " + txID); } beforeJournalOperation(); journal.appendRollbackRecord(txID, sync); journal.debugWait(); }
protected void commit(final long txID) throws Exception { TransactionHolder tx = transactions.remove(txID); if (tx == null) { throw new IllegalStateException("Cannot find tx " + txID); } beforeJournalOperation(); journal.appendCommitRecord(txID, sync); records.addAll(tx.records); for (RecordInfo l : tx.deletes) { removeRecordsForID(l.id); } journal.debugWait(); }
protected void prepare(final long txID, final EncodingSupport xid) throws Exception { TransactionHolder tx = transactions.get(txID); if (tx == null) { tx = new TransactionHolder(); transactions.put(txID, tx); } if (tx.prepared) { throw new IllegalStateException("Transaction is already prepared"); } beforeJournalOperation(); journal.appendPrepareRecord(txID, xid, sync); tx.prepared = true; journal.debugWait(); }
protected void addWithSize(final int size, final long... arguments) throws Exception { for (long element : arguments) { byte[] record = generateRecord(size); beforeJournalOperation(); journal.appendAddRecord(element, (byte) 0, record, sync); records.add(new RecordInfo(element, (byte) 0, record, false, (short) 0)); } journal.debugWait(); }
protected void delete(final long... arguments) throws Exception { for (long element : arguments) { beforeJournalOperation(); journal.appendDeleteRecord(element, sync); removeRecordsForID(element); } journal.debugWait(); }
protected void deleteTx(final long txID, final long... arguments) throws Exception { TransactionHolder tx = getTransaction(txID); for (long element : arguments) { beforeJournalOperation(); journal.appendDeleteRecordTransactional(txID, element); tx.deletes.add(new RecordInfo(element, (byte) 0, null, true, (short) 0)); } journal.debugWait(); }
protected void update(final long... arguments) throws Exception { for (long element : arguments) { byte[] updateRecord = generateRecord(recordLength); beforeJournalOperation(); journal.appendUpdateRecord(element, (byte) 0, updateRecord, sync); records.add(new RecordInfo(element, (byte) 0, updateRecord, true, (short) 0)); } journal.debugWait(); }
protected void addTx(final long txID, final long... arguments) throws Exception { TransactionHolder tx = getTransaction(txID); for (long element : arguments) { // SIZE_BYTE + SIZE_LONG + SIZE_LONG + SIZE_INT + record.length + // SIZE_BYTE byte[] record = generateRecord(recordLength - (JournalImpl.SIZE_ADD_RECORD_TX + 1)); beforeJournalOperation(); journal.appendAddRecordTransactional(txID, element, (byte) 0, record); tx.records.add(new RecordInfo(element, (byte) 0, record, false, (short) 0)); } journal.debugWait(); }
protected void updateTx(final long txID, final long... arguments) throws Exception { TransactionHolder tx = getTransaction(txID); for (long element : arguments) { byte[] updateRecord = generateRecord(recordLength - (JournalImpl.SIZE_ADD_RECORD_TX + 1)); beforeJournalOperation(); journal.appendUpdateRecordTransactional(txID, element, (byte) 0, updateRecord); tx.records.add(new RecordInfo(element, (byte) 0, updateRecord, true, (short) 0)); } journal.debugWait(); }
journal.debugWait();