Package org.netbeans.mdr.persistence.btreeimpl.btreestorage

Together, the btreestorage and btreeindex packages provide the btree storage implementation for the NetBeans meta-data repository.

See:
          Description

Interface Summary
FileCache.NotifyOnCommit An object which needs to be notified before the cache commits (for instance, to write any changes to the cache before the cache is flushed to disk) implements this interface, and calls addNotifier on the cache.
MDRCache.OverflowHandler The cache handler is called when the number of changes in the cache reaches its threshhold.
 

Class Summary
BtreeDatabase This is the primary index for the btree implementation of Storage.
BtreeFactory Create a BtreeStorage
BtreeFileSource BtreePageSource implementation for pages which are stored directly in a file (the primary index pages) rather than as repository objects.
BtreeMDRSource BtreePageSource whose pages are MOF repository objects
BtreeStorage This class implements Storage using Btree files.
CachedPage This represents a page fetched from the cache.
CachedPageInputStream A stream composed of segments stored in CachedPages.
Converter This class exists only to provide data conversions between primitive types and byte arrays.
CounterIndex This is an index from names (Strings) to Integer.
FileCache FileCache provides transactional cached access to a set of files.
FileHeader Files stored in the FileCache must start with this header; it contains information used by the logging system.
IntHolder this class allows a parameter to return an integer value
IntrusiveList A doubly linked list in which the objects contain their pointers.
IntrusiveList.Member objects in an intrusive list must inherit from Member
LongHolder this class allows a parameter to return a long value
MDRCache An in-memory cache of MDR objects.
MofidIndex This is an index from names (Strings) to MOFIDs.
TransactionCache  
TransactionCache.Record  
UUID UUID is a DCE UUID, that is, a 128-bit universally unique identifier.
VirtualList An implementation of List which uses a btree database as a backing store.
 

Package org.netbeans.mdr.persistence.btreeimpl.btreestorage Description

Together, the btreestorage and btreeindex packages provide the btree storage implementation for the NetBeans meta-data repository. btreestorage is composed of several subsystems, which are semi-independent and could be reused for other purposes.

Subsystems

Utility classes

Converter contains static methods used to convert Java's integer and String types to and from byte arrays. They use the same documented formats as java.io.DataInput and DataOutput.

IntHolder and LongHolder are used to give methods output parameters.

IntrusiveList is just that. java.util.LinkedList is a non-intrusive list, and for that reason many of its operations are quite slow.

MDRCache is a memory cache of persistent objects. It uses a specialized subclass of java.lang.ref.SoftReference (CacheReference) to ensure that objects are removed from the cache only when they are no longer referenced.

UUID is a java implementation of the standard DCE UUID.

Caching and logging

This provides a transactional filesystem. A set of files is accessed via an in-memory cache of pages. Changes to the files are committed or rolled back atomically.

Each instance of FileCache is a cache containing a set of files which are updated atomically. Each file is accessed as a list of pages. A page currently in the cache is represented by a CachedPage, and uniquely identified by a PageID. Each file begins with a FileHeader, which contains information needed by the logging system.

The logging system uses before-image logging to assure atomic updates. Before a change is written to a page, that page is written to the LogFile, which contains two sorts of pages: these before=image pages, and MapPages, which associate each before-image page with a PageID. On commit, the log file is simply deleted. On rollback, the before-image pages are written back to the files they came from, and then the log file is deleted.

Information which goes across page boundaries can be accessed by grouping the appropriate CachedPages into a CachedPagrInputStream.

Tests

TestFileCache contains methods useful for testing the caching and logging subsystem. fjscript tests test0001-test0004 test the cache and test0100-test0111 test logging and recovery.

Btree data file

The btree data file stores records consisting of variable-length byte arrays using keys which are also variable-length byte arrays. (Translating a key to an offset in the file is done by the btree index file, which is implemented in the btreeindex package.) The data file is divided into extents (abstract class BtreeExtent) which are of three types: normal extents, which are the first extent in a record, continuation extents, which are the second or later extent in a record, and deleted extents, whose record has been deleted. The space in a deleted extent is available for reuse. Both normal and continuation extents are active (that is, are subclassed of the abstract class ActiveBtreeExtent.)

Tests

TestBtreeDataFile contains methods useful for testing the btree data file. fjscript tests test0201-test0202 test the data file. test0203 is a stress test for the data file written in Java.

Storage implementation

These classes help implement the storage interfaces in the persistence package. BtreeFactory is an implementation of StorageFactory which creates instances of BtreeStorage, which in turn implements Storage. The primary index of a BtreeStorage is a BtreeDatabase, which co-ordinates the data and index files, and implements SinglevaluedIndex.

VirtualList is an implementation of List which uses a BtreeStorage as a backing store. It allows lists which would not otherwise fit in memory.

MOFID is used to generate unique IDs for each MOF object.

NameIndex is an abstract base class for persistent objects used to index objects by name. It has two concrete subclasses:

Tests

TestStreamable is a simple persistent object. fjscrpt tests test0301-test0306 test the storage implementation, as does multithreaded stress test test0310.java.



Copyright © 2005 Apache Software Foundation. All Rights Reserved.