@Override public void sync() { file.sync() ; }
@Override public void sync() { other.sync() ; }
@Override public void sync() { info("sync") ; other.sync() ; }
@Override public void sync() { super.checkTxn(); objFile.sync() ; }
@Override protected void _abort(TxnId txnId, TxnObjectFile state) { if ( isWriteTxn() ) { // One will imply the other. objFile.truncate(state.length) ; //objFile.reposition(state.position) ; // sync to make sure the file looses the unwanted part. // Neater, no abandoned sections (outside crashes). objFile.sync() ; } }
@Override protected void _commit(TxnId txnId, TxnObjectFile state) { if ( isWriteTxn() ) { // Force to disk. objFile.sync(); stateMgr.writeState(); // Move visible commit point forward. length.set(objFile.length()) ; position.set(objFile.position()) ; } }
@Test public void transObjectFile_4() { String str1 = "Test4" ; String str2 = "TheNext" ; long x1 = writeOne(transactional, transObjectFile, str1) ; ByteBuffer bb = str2bb(str2) ; long x2 = baseObjectFile.write(bb) ; baseObjectFile.sync(); long x3 = Txn.calculateRead(transactional, ()->transObjectFile.length()) ; assertEquals(x2, x3); assertNotEquals(x3, baseObjectFile.length()); // Fake recovery. ByteBuffer bbj = ByteBuffer.allocate(2*Long.BYTES) ; bbj.putLong(x3) ; bbj.putLong(0) ; bbj.rewind() ; journal.write(JournalEntryType.REDO, transObjectFile.getComponentId(), bbj) ; journal.writeJournal(JournalEntry.COMMIT) ; // Recovery. //transObjectFile.recover(bb); TransactionalBase transBase = (TransactionalBase)TransactionalFactory.createTransactional(journal, transObjectFile) ; ByteBuffer bb1 = Txn.calculateRead(transBase, ()->transObjectFile.read(x3)) ; String s1 = Bytes.fromByteBuffer(bb1) ; assertEquals(str2, s1); // Woot! transBase.getTxnMgr().shutdown(); } }