db4o 7.4

com.db4o.io
Class NonFlushingIoAdapter

java.lang.Object
  extended by com.db4o.io.IoAdapter
      extended by com.db4o.io.VanillaIoAdapter
          extended by com.db4o.io.NonFlushingIoAdapter

public class NonFlushingIoAdapter
extends VanillaIoAdapter

Delegating IoAdapter that does not pass on calls to sync data to the underlying device.

This IoAdapter can be used to improve performance at the cost of a higher risk of database file corruption upon abnormal termination of a session against a database.

An example of possible usage:
RandomAccessFileAdapter randomAccessFileAdapter = new RandomAccessFileAdapter();
NonFlushingIoAdapter nonFlushingIoAdapter = new NonFlushingIoAdapter(randomAccessFileAdapter);
CachedIoAdapter cachedIoAdapter = new CachedIoAdapter(nonFlushingIoAdapter);
Configuration configuration = Db4o.newConfiguration();
configuration.io(cachedIoAdapter);


db4o uses a resume-commit-on-crash strategy to ensure ACID transactions. When a transaction commits,
- (1) a list "pointers that are to be modified" is written to the database file,
- (2) the database file is switched into "in-commit" mode,
- (3) the pointers are actually modified in the database file,
- (4) the database file is switched to "not-in-commit" mode.
If the system is halted by a hardware or power failure
- before (2)
all objects will be available as before the commit
- between (2) and (4) the commit is restarted when the database file is opened the next time, all pointers will be read from the "pointers to be modified" list and all of them will be modified to the state they are intended to have after commit
- after (4) no work is necessary, the transaction is committed.

In order for the above to be 100% failsafe, the order of writes to the storage medium has to be obeyed. On operating systems that use in-memory file caching, the OS cache may revert the order of writes to optimize file performance.

db4o enforces the correct write order by calling sync() after every single one of the above steps during transaction commit. The calls to sync() have a high performance cost. By using this IoAdapter it is possible to omit these calls, at the cost of a risc of corrupted database files upon hardware-, power- or operating system failures.


Constructor Summary
NonFlushingIoAdapter(IoAdapter delegateAdapter)
           
 
Method Summary
 IoAdapter open(java.lang.String path, boolean lockFile, long initialLength, boolean readOnly)
          implement to open the file
 void sync()
          implement to flush the file contents to storage
 
Methods inherited from class com.db4o.io.VanillaIoAdapter
close, delete, exists, getLength, read, seek, write
 
Methods inherited from class com.db4o.io.IoAdapter
blockCopy, blockSeek, blockSeek, blockSize, blockSize, copy, delegatedIoAdapter, read, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonFlushingIoAdapter

public NonFlushingIoAdapter(IoAdapter delegateAdapter)
Method Detail

open

public IoAdapter open(java.lang.String path,
                      boolean lockFile,
                      long initialLength,
                      boolean readOnly)
               throws Db4oIOException
Description copied from class: IoAdapter
implement to open the file

Specified by:
open in class IoAdapter
Throws:
Db4oIOException

sync

public void sync()
          throws Db4oIOException
Description copied from class: IoAdapter
implement to flush the file contents to storage

Overrides:
sync in class VanillaIoAdapter
Throws:
Db4oIOException

db4o 7.4

Copyright 2007 db4objects Inc. All rights reserved.