|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.mdr.persistence.btreeimpl.btreestorage.BtreeDatabase
public class BtreeDatabase
This is the primary index for the btree implementation of Storage. It consists of three files:
The data file, with an extension of ".btd", which contains the serialized versions of the Streamable objects. This is accessed via the BtreeDatafile class.
The index file, with an extension of ".btx", which translates MOFIDs to the corresponding offset in the data file. This is accessed via the SinglevaluedBtree class.
The transactional log file has the extnsion ".btb". It exists only between the time a trasaction starts to be comitted and the time it is fully comitted or rolled back.
The data file contains enough information to regenerate the index file if the index file is lost or damaged. If the index file is missing when the btree database is opened, it is silently regenerated.
A Btree storage is transactional. This is implemented using the logging feature of the FileCache. Objects stored in a Btree storage have identity in memory. That is, fetching the same object multiple times will result in multiple references to the same object, not mutilple copies. This is implemented by MDRCache.
Performance of the Btree can be tuned by adjusting these parameters:
PAGE_SIZE is the size of the pages in the file cache.
FILE_CACHE_SIZE in the number of pages cached in memory. Increasing this will minimize the amount of reading done from the btree files, though at the cost of decreased memory for other purposes.
MDR_CACHE_SIZE is the number of currently unreferenced persistent objects kept in memory. Increasing this will reduce the number of reads done from the btree storage, though again at the cost of decreased memory for other purposes.
MDR_CACHE_THRESHHOLD is the number of changed objects to keep in memory before saving them to disk. Increasing this will reduce the amount of disk I/O done, though yet again at the cost of decreased memory for other purposes.
Method Summary | |
---|---|
void |
add(MOFID mKey,
java.lang.Object value)
Adds a repository record, throwing an exception if it already exists |
void |
add(java.lang.Object key,
java.lang.Object value)
Adds a repository record, throwing an exception if it already exists |
void |
cacheThreshholdReached(MDRCache cach,
int size)
cache has reached threshhold |
int |
checkConsistency(java.io.PrintWriter strm)
Check consistency of btree database |
void |
commitChanges()
Commits changes to transaction cache, if cache treshold is reached, flushes cache to disk. |
void |
compress()
Compress repository. |
java.lang.Object |
get(MOFID mKey)
Gets a record from the repository. |
java.lang.Object |
get(java.lang.Object key)
Gets a record from the repository. |
java.lang.Object |
getIfExists(MOFID mKey)
Gets a record from the repository. |
java.lang.Object |
getIfExists(java.lang.Object key)
Gets a record from the repository. |
Storage.EntryType |
getKeyType()
Returns the type of keys in index. |
MofidGenerator |
getMofidGenerator()
Return the MOFID generator for this repository |
java.util.Map |
getMofidMap()
Return the map of MOFID UUIDs we know about |
java.lang.String |
getName()
Returns the unique name of the index in the Storage. |
java.lang.Object |
getObject(java.lang.Object key,
SinglevaluedIndex dummy)
Like get, since we don't return keys |
java.lang.Object |
getObjectIfExists(java.lang.Object key,
SinglevaluedIndex dummy)
Like getIfExists, since we don't return keys |
Storage.EntryType |
getValueType()
Returns the type of values indexed by this index. |
java.util.Set |
keySet()
Returns a set view of the keys contained in this index. |
java.lang.String[] |
listIndexes()
List all index names |
void |
objectStateChanged(MOFID mKey)
Mark that the object has changed, and so needs to be saved on commit |
void |
objectStateChanged(java.lang.Object key)
Mark that the object has changed, and so needs to be saved on commit |
boolean |
put(java.lang.Object key,
java.lang.Object value)
Adds or replaces a repository record |
java.util.Collection |
queryByKeyPrefix(java.lang.Object prefix,
SinglevaluedIndex repos)
Returns a collection view of Map.Entry key-value pairs in the index,
where key matches the queried prefix. |
boolean |
remove(MOFID mKey)
Deletes a repository record based on a MOFID |
boolean |
remove(java.lang.Object key)
Deletes a repository record |
void |
replace(MOFID mKey,
java.lang.Object value)
Replaces the original value associated with the specified key in this index with new value. |
void |
replace(java.lang.Object key,
java.lang.Object value)
Replaces the original value associated with the specified key in this index with new value. |
void |
rollbackChanges()
roll back all changes |
void |
saveChanges()
save all changes to disk without comitting |
void |
setLoggingStream(java.io.PrintStream strm)
Set our logging stream |
void |
shutDown()
Called on exit, commited data cached in transaction cache need to be written to disk. |
int |
size()
returns the number of objects in the repository |
java.util.Collection |
values()
Returns a collection view of the values contained in the repository. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void compress() throws StorageException
StorageException
public int size()
public java.lang.String getName()
getName
in interface Index
public Storage.EntryType getValueType()
getValueType
in interface Index
public Storage.EntryType getKeyType()
getKeyType
in interface Index
public void cacheThreshholdReached(MDRCache cach, int size) throws StorageException
cacheThreshholdReached
in interface MDRCache.OverflowHandler
cach
- cache which reached threshholdsize
- number of changed objects currently in cache
StorageException
public void commitChanges() throws StorageException
StorageException
public void shutDown() throws StorageException
StorageException
public void saveChanges() throws StorageException
StorageException
public void rollbackChanges() throws StorageException
StorageException
public boolean remove(java.lang.Object key) throws StorageException
remove
in interface Index
key
- -- a String
StorageException
public boolean remove(MOFID mKey) throws StorageException
mKey
-
StorageException
public void add(java.lang.Object key, java.lang.Object value) throws StorageException
add
in interface Index
key
- -- a Stringvalue
-
StorageException
public void add(MOFID mKey, java.lang.Object value) throws StorageException
mKey
- value
-
StorageException
public void replace(java.lang.Object key, java.lang.Object value) throws StorageException
replace
in interface SinglevaluedIndex
key
- value
-
StorageException
StorageBadRequestException
public void replace(MOFID mKey, java.lang.Object value) throws StorageException
mKey
- value
-
StorageException
public boolean put(java.lang.Object key, java.lang.Object value) throws StorageException
put
in interface SinglevaluedIndex
key
- -- a Stringvalue
-
StorageException
public java.lang.Object getIfExists(java.lang.Object key) throws StorageException
getIfExists
in interface SinglevaluedIndex
key
- -- a String
StorageException
public java.lang.Object getObjectIfExists(java.lang.Object key, SinglevaluedIndex dummy) throws StorageException
getObjectIfExists
in interface SinglevaluedIndex
StorageException
public java.lang.Object getIfExists(MOFID mKey) throws StorageException
key
-
StorageException
public java.lang.Object get(java.lang.Object key) throws StorageException
get
in interface SinglevaluedIndex
key
-
StorageException
StorageBadRequestException
public java.lang.Object getObject(java.lang.Object key, SinglevaluedIndex dummy) throws StorageException
getObject
in interface SinglevaluedIndex
StorageException
public java.lang.Object get(MOFID mKey) throws StorageException
mKey
-
StorageException
public java.util.Collection queryByKeyPrefix(java.lang.Object prefix, SinglevaluedIndex repos)
SinglevaluedIndex
Map.Entry
key-value pairs in the index,
where key matches the queried prefix. Values are objects (as returned by getObject
method).
queryByKeyPrefix
in interface SinglevaluedIndex
prefix
- queried prefixrepos
- primary index
public void objectStateChanged(java.lang.Object key) throws StorageException
key
- key of object whch changed (a String)
StorageException
public void objectStateChanged(MOFID mKey) throws StorageException
mKey
- key of object whch changed
StorageException
public java.lang.String[] listIndexes() throws StorageException
StorageException
public java.util.Set keySet() throws StorageException
keySet
in interface Index
StorageException
public java.util.Collection values() throws StorageException
values
in interface SinglevaluedIndex
StorageException
public void setLoggingStream(java.io.PrintStream strm)
public MofidGenerator getMofidGenerator()
public java.util.Map getMofidMap()
public int checkConsistency(java.io.PrintWriter strm) throws StorageException
strm
- where to write inconsistencies
StorageException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |