java.lang.Object
com.orientechnologies.orient.core.storage.cache.OAbstractWriteCache
com.orientechnologies.orient.core.storage.cache.local.OWOWCache
All Implemented Interfaces:
OCachePointer.WritersListener, OWriteCache

public final class OWOWCache extends OAbstractWriteCache implements OWriteCache, OCachePointer.WritersListener
Write part of disk cache which is used to collect pages which were changed on read cache and store them to the disk in background thread. In current implementation only single background thread is used to store all changed data, despite of SSD parallelization capabilities we suppose that better to write data in single big chunk by one thread than by many small chunks from many threads introducing contention and multi threading overhead. Another reasons for usage of only one thread are
  1. That we should give room for readers to read data during data write phase
  2. It provides much less synchronization overhead

Background thread is running by with predefined intervals. Such approach allows SSD GC to use pauses to make some clean up of half empty erase blocks. Also write cache is used for checking of free space left on disk and putting of database in "read mode" if space limit is reached and to perform fuzzy checkpoints. Write cache holds two different type of pages, pages which are shared with read cache and pages which belong only to write cache (so called exclusive pages). Files in write cache are accessed by id , there are two types of ids, internal used inside of write cache and external used outside of write cache. Presence of two types of ids is caused by the fact that read cache is global across all storages but each storage has its own write cache. So all ids of files should be global across whole read cache. External id is created from internal id by prefixing of internal id (in byte presentation) with bytes of write cache id which is unique across all storages opened inside of single JVM. Write cache accepts external ids as file ids and converts them to internal ids inside of its methods.

Since:
7/23/13
Author:
Andrey Lomakin (a.lomakin-at-orientdb.com)