|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.xnode.providers.AbstractXNodeStoreProvider
org.ceryle.xnode.providers.BerkeleyDBProvider
public class BerkeleyDBProvider
Implements the XNodeStoreProvider API for an XNodeStore, using a Berkeley DB JE backend store.
Note that no XML ID validity checking is done here; IDs supplied to methods within this class should already be validated.
The XNode Implementation (the package org.ceryle.xnode.*, both its source code and documentation), are released under the Apache 2.0 License. For more details, check the LICENSE file contained with the distribution, or see The Ceryle Project for more information. It is distributed with no warranty.
| Field Summary | |
|---|---|
protected long |
storageRatioThreshold
The threshold ratio after which the cleaner thread is started. |
| Fields inherited from class org.ceryle.xnode.providers.AbstractXNodeStoreProvider |
|---|
Filesep, m_homepath, m_storage, m_storagepath, m_xns, mh |
| Constructor Summary | |
|---|---|
BerkeleyDBProvider()
|
|
| Method Summary | |
|---|---|
void |
closeDatabase(String did)
Close the Database backing the XNodeCollection having ID did. |
void |
deleteContent(String did,
String rid)
Permanently deletes the key/data pair (database record) matching the key String rid from the Database with ID did. |
void |
deleteDatabase(String did)
Delete the Database backing the XNodeCollection having ID did. |
String |
getContent(String did,
String rid)
The method that does the actual work of retrieving the contents in the record with key String rid (record ID) from the Database with ID did. |
int |
getContentSize(String did,
String rid)
Returns the record storage size of the document in the Database with ID did for the data matching the key String rid (record ID). |
Object |
getDatabase(String did)
Return the Database backing the XNodeCollection having ID did. |
List |
getDatabaseIndex()
Returns the List of existing Database IDs. |
List |
getDocumentIndex(String did)
Returns the document index for the Database with key did, sorted, created from the Database. |
com.sleepycat.je.Environment |
getEnvironment()
Returns the BerkeleyDB JE Environment used with this implementation. |
static long |
getFileSize(File file,
int maxfiles)
Returns the size of indicated File (or directory) file. |
float |
getStorageRatio()
Calculates the average document size, based on the ratio of the total count of documents in the entire database and the space in the filesystem used, in bytes. |
boolean |
hasContent(String did,
String rid)
Returns true if the Database with ID did contains data matching the key String rid (record ID). |
boolean |
hasDatabase(String did)
Returns true if there is an existing Database with key did. |
void |
initialize(XNodeStore xnodestore)
Initializes the XNodeStoreProvider provided its parent XNodeStore. |
boolean |
isLoadedDatabase(String did)
Returns true if the Database with key did has already been loaded. |
void |
optimize(ActionListener listener)
Using any native processes, optimizes the Database. |
void |
putContent(String did,
String rid,
String content,
boolean overwrite)
The method that does the actual work of storing the String content in the Database db using the key String rid (record ID). |
void |
start()
Start the database kernel. |
void |
stop()
Shuts down the database service. |
| Methods inherited from class org.ceryle.xnode.providers.AbstractXNodeStoreProvider |
|---|
error, message, setPaths, storageExists, warning, writeXNodeToDatabase |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.purl.xnode.XNodeStoreProvider |
|---|
storageExists, writeXNodeToDatabase |
| Field Detail |
|---|
protected long storageRatioThreshold
| Constructor Detail |
|---|
public BerkeleyDBProvider()
| Method Detail |
|---|
public void initialize(XNodeStore xnodestore)
throws XNodeStoreProviderException
initialize in interface XNodeStoreProviderinitialize in class AbstractXNodeStoreProviderxnodestore - the parent XNodeStore.
XNodeStoreProviderException - if any error occurs while initializing the provider.
public void start()
throws XNodeStoreProviderException
start in interface XNodeStoreProviderstart in class AbstractXNodeStoreProviderXNodeStoreProviderException - if unable to start the database.
public com.sleepycat.je.Environment getEnvironment()
throws XNodeStoreProviderException
This is not an XNode API method.
.
XNodeStoreProviderException
public void stop()
throws XNodeStoreProviderException
stop in interface XNodeStoreProviderstop in class AbstractXNodeStoreProviderXNodeStoreProviderException - if an error occurs while stopping the database.
public Object getDatabase(String did)
throws XNodeStoreProviderException
(This is an XNodeStoreProvider API method)
getDatabase in interface XNodeStoreProvidergetDatabase in class AbstractXNodeStoreProviderdid - the ID of the Database
XNodeStoreProviderException - if any error occurs while getting or creating the Database.public boolean isLoadedDatabase(String did)
isLoadedDatabase in interface XNodeStoreProviderisLoadedDatabase in class AbstractXNodeStoreProvider
public boolean hasDatabase(String did)
throws XNodeStoreProviderException
(If the current list of loaded Databases is needed, use m_dbCache.)
(This is an XNodeStoreProvider API method)
hasDatabase in interface XNodeStoreProviderhasDatabase in class AbstractXNodeStoreProviderdid - the ID of the Database to query.
XNodeStoreProviderException - if any error occurs while querying.
public List getDatabaseIndex()
throws XNodeStoreProviderException
(This is an XNodeStoreProvider API method)
getDatabaseIndex in interface XNodeStoreProvidergetDatabaseIndex in class AbstractXNodeStoreProviderXNodeStoreProviderException - if any error occurs while building the index.
public void closeDatabase(String did)
throws XNodeStoreProviderException
(This is an XNodeStoreProvider API method)
closeDatabase in interface XNodeStoreProvidercloseDatabase in class AbstractXNodeStoreProviderdid - the ID of the Database to close.
XNodeStoreProviderException - if any error occurs while closing the Database.
public void deleteDatabase(String did)
throws XNodeStoreProviderException
(This is an XNodeStoreProvider API method)
deleteDatabase in interface XNodeStoreProviderdeleteDatabase in class AbstractXNodeStoreProviderdid - the ID of the Database to delete.
XNodeStoreProviderException - if any error occurs while deleting the Database.
public void putContent(String did,
String rid,
String content,
boolean overwrite)
throws XNodeStoreProviderException
(This is an XNodeStoreProvider API method)
putContent in interface XNodeStoreProviderputContent in class AbstractXNodeStoreProviderdid - the ID of the Databaserid - the ID of the recordcontent - the content String.overwrite - when true permit the overwrite of previous content.
XNodeStoreProviderException - if any error occurs while putting the content into the Database.
public boolean hasContent(String did,
String rid)
throws XNodeStoreProviderException
(This is an XNodeStoreProvider API method)
hasContent in interface XNodeStoreProviderhasContent in class AbstractXNodeStoreProviderdid - the ID of the Databaserid - the ID of the record
XNodeStoreProviderException - if an error occurs retrieving the content.
public int getContentSize(String did,
String rid)
hasContent(String,String)
since it does basically the same function but returns a more useful value.
This returns -1 if either of the parameters is null, if the collection or
document doesn't exist, and returns a -2 if any error occurs, rather than
throwing an exception.
(This is an XNodeStoreProvider API method)
getContentSize in interface XNodeStoreProvidergetContentSize in class AbstractXNodeStoreProviderdid - the ID of the Databaserid - the ID of the record
public String getContent(String did,
String rid)
throws XNodeStoreProviderException
(This is an XNodeStoreProvider API method)
getContent in interface XNodeStoreProvidergetContent in class AbstractXNodeStoreProviderdid - the ID of the Databaserid - the ID of the record
XNodeStoreProviderException - if an error occurs retrieving the content.
public void deleteContent(String did,
String rid)
throws XNodeStoreProviderException
(This is an XNodeStoreProvider API method)
deleteContent in interface XNodeStoreProviderdeleteContent in class AbstractXNodeStoreProviderdid - the ID of the Databaserid - the ID of the record
XNodeStoreProviderException - if an error occurs deleting the key/data pair.
public List getDocumentIndex(String did)
throws XNodeStoreProviderException
(This is an XNodeStoreProvider API method)
getDocumentIndex in interface XNodeStoreProvidergetDocumentIndex in class AbstractXNodeStoreProviderdid - the ID of the Database.
XNodeStoreProviderException - if an error occurs obtaining the document index.public void optimize(ActionListener listener)
If the optional ActionListener is provided its
ActionListener.actionPerformed(ActionEvent)
method will be called upon completion of the optimization.
Checks the ratio of storage space to database record count to determine average file size, and if the average file size falls above a threshold, starts a low-priority cleaner thread.
If the ActionListener is non-null, its actionPerformed() method will receive an ActionEvent upon completion of the cleanup (from this application's perspective; what happens within BerkeleyDB JE timing-wise is relatively unknown).
Note that this method does not throw any exceptions; it only writes error messages to the MessageHandler.
optimize in interface XNodeStoreProvideroptimize in class AbstractXNodeStoreProviderlistener - an optional listener to receive
notification upon completion.public float getStorageRatio()
If the database is disconnected, returns a zero value.
public static long getFileSize(File file,
int maxfiles)
throws IOException
IOException - if the File reference is null, does not exist, or can't be read.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||