private void init() { file = new ObjectFileTransComplex(null, file1, file2) ; }
@Override public void enactCommitted(Transaction txn) { if ( ! inTransaction ) throw new TDBTransactionException("Not in a transaction for a commit to happen") ; append() ; base.sync() ; transObjects.reposition(0) ; }
@Override public long write(ByteBuffer buffer) { if ( passthrough ) { return base.write(buffer) ; } // Write to auxillary long x = transObjects.write(buffer) ; return mapFromOther(x) ; }
@Test public void objFileTrans_04() { fill(file1, "ABC", "ABC") ; init() ; file.begin(txn) ; write(file, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") ; file.commitPrepare(txn) ; file.enactCommitted(txn) ; contains(file1, "ABC", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ") ; file.clearupCommitted(txn) ; }
@Test public void objFileTrans_05() { fill(file1, "ABC") ; init() ; file.begin(txn) ; write(file, "ABCDEF") ; file.abort(txn) ; contains(file1, "ABC") ; file.clearupCommitted(txn) ; }
@Override public ByteBuffer read(long id) { if ( passthrough ) { return base.read(id) ; } if ( id < otherAllocOffset ) return base.read(id) ; long x = mapToOther(id) ; return transObjects.read(id-otherAllocOffset) ; }
@Test public void objFileTrans_03() { fill(file1, "ABC") ; init() ; file.begin(txn) ; write(file, "X") ; file.commitPrepare(txn) ; file.enactCommitted(txn) ; contains(file1, "ABC", "X") ; file.clearupCommitted(txn) ; }
@Test public void objFileTrans_05() { fill(file1, "ABC") ; init() ; file.begin(txn) ; write(file, "ABCDEF") ; file.abort(txn) ; contains(file1, "ABC") ; file.clearupCommitted(txn) ; }
@Override public void truncate(long id) { if ( passthrough ) { base.truncate(id) ; return ; } if ( id > otherAllocOffset ) { transObjects.truncate(mapToOther(id)) ; return ; } base.truncate(id) ; transObjects.truncate(0) ; otherAllocOffset = base.length() ; }
@Test public void objFileTrans_04() { fill(file1, "ABC", "ABC") ; init() ; file.begin(txn) ; write(file, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") ; file.commitPrepare(txn) ; file.enactCommitted(txn) ; contains(file1, "ABC", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ") ; file.clearupCommitted(txn) ; }
@Override public void reposition(long id) { if ( passthrough ) { base.reposition(id) ; return ; } if ( id > otherAllocOffset ) { transObjects.reposition(mapToOther(id)) ; return ; } Log.warn(this, "Unexpected: Attempt to reposition over base file") ; base.reposition(id) ; transObjects.reposition(0) ; otherAllocOffset = base.length() ; }
private void init() { file = new ObjectFileTransComplex(null, file1, file2) ; }
@Test public void objFileTrans_02() { fill(file1, "ABC") ; init() ; file.begin(txn) ; // Test empty. contains(file2) ; file.commitPrepare(txn) ; file.enactCommitted(txn) ; contains(file1, "ABC") ; file.clearupCommitted(txn) ; }
@Test public void objFileTrans_03() { fill(file1, "ABC") ; init() ; file.begin(txn) ; write(file, "X") ; file.commitPrepare(txn) ; file.enactCommitted(txn) ; contains(file1, "ABC", "X") ; file.clearupCommitted(txn) ; }
@Test public void objFileTrans_02() { fill(file1, "ABC") ; init() ; file.begin(txn) ; // Test empty. contains(file2) ; file.commitPrepare(txn) ; file.enactCommitted(txn) ; contains(file1, "ABC") ; file.clearupCommitted(txn) ; }