|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--arlut.csd.ganymede.DBStore
DBStore is the main Ganymede database class. DBStore is responsible for
actually handling the Ganymede database, and manages
database loads and dumps, locking (in conjunction with
DBSession and
DBLock),
the journal, and schema dumping.
The DBStore class holds the server's namespace and schema
dictionaries, in the form of a collection of
DBNameSpace and DBObjectBase objects. Each
DBObjectBase contains schema information for an object type,
including field definitions for all fields that may be stored in
objects of that type.
In addition to holding schema information, each DBObjectBase
contains an Invid-keyed hash of
DBObject's of that type in
memory after the database loading is complete at start-up. Changes
made to the DBStore are done in transactional contexts using DBSession, which is responsible for
initiating journal changes when individual transactions are
committed to the database. Periodically, the Ganymede server's
GanymedeScheduler task
engine will schedule a full dump to consolidate the journal and update the on-disk database
file. The server will also do a dump when the server's admin
console GanymedeAdmin
interface initiates a server shutdown.
DBStore was originally written with the intent of being able to serve as
a stand-alone in-process transactional object storage system, but in practice, DBStore
is now thoroughly integrated with the rest of the Ganymede server, and particularly
with GanymedeSession. Various
component classes (DBSession,
DBObject, and
DBField), assume that there is usually
an associated GanymedeSession to be consulted for permissions and the like.
| Field Summary | |
(package private) java.util.Hashtable |
backPointers
hash mapping Invid's to Hashtables
of Invid's. |
(package private) static boolean |
debug
Enable/disable debug in the DBStore methods |
(package private) byte |
file_major
Major revision number of the database file loaded by this DBStore object. |
(package private) byte |
file_minor
Minor revision number of the database file loaded by this DBStore object. |
(package private) static java.lang.String |
id_string
All ganymede.db and ganymede.schema files will start with this string |
(package private) DBJournal |
journal
The Journal for this database, initialized when the database is loaded. |
(package private) boolean |
loading
if true, DBObjectBase
set methods will be enabled |
DBLockSync |
lockSync
A separate object to act as a synchronization monitor for DBLock code. |
(package private) static byte |
major_version
Major file version id.. |
(package private) static byte |
major_xml_version
XML version major id |
(package private) static byte |
minor_version
Minor file version id.. |
(package private) static byte |
minor_xml_version
XML version minor id |
(package private) java.util.Vector |
nameSpaces
A collection of DBNameSpaces registered in this DBStore. |
(package private) java.util.Hashtable |
objectBases
hash mapping object type to DBObjectBase's |
(package private) int |
objectsCheckedOut
A count of how many database objects in this DBStore are currently checked out for creation, editing, or removal. |
(package private) DBBaseCategory |
rootCategory
Root of the category tree defined in this database |
private java.util.Vector |
sessions
Vector of DBSession objects. |
| Constructor Summary | |
DBStore()
This is the constructor for DBStore. |
|
| Method Summary | |
(package private) void |
addLock()
Increments the count of held locks for the admin consoles. |
(package private) void |
checkIn()
Decrements the count of checked-out objects for the admin consoles. |
(package private) void |
checkOut()
Increments the count of checked-out objects for the admin consoles. |
private DBEditObject |
createSysEventObj(DBSession session,
java.lang.String token,
java.lang.String name,
java.lang.String description,
boolean ccAdmin)
Convenience method for initializeObjects(). |
void |
debugBackPointers()
|
private java.lang.String |
describe(Invid x)
|
void |
dump(java.lang.String filename,
boolean releaseLock,
boolean archiveIt)
Dumps the database to disk |
void |
dumpXML(java.io.OutputStream outStream,
boolean dumpDataObjects,
boolean dumpSchema)
Dumps the database and/or database schema to an OutputStream as an XML file |
void |
dumpXML(java.lang.String filename,
boolean dumpDataObjects,
boolean dumpSchema)
Dumps the database to disk as an XML file |
private boolean |
exists(DBSession session,
Invid invid)
Convenience method for initializeObjects(). |
java.util.Vector |
getBaseNameList()
Returns a vector of Strings, the names of the bases currently defined in this DBStore. |
java.util.Vector |
getBases()
Returns a vector of DBObjectBases currently
defined in this DBStore. |
CategoryNode |
getCategoryNode(java.lang.String pathName)
Method to get a category from the category list, by it's full path name. |
DBNameSpace |
getNameSpace(java.lang.String name)
Method to locate a registered namespace by name. |
DBObjectBase |
getObjectBase(short id)
Returns the object definition class for the id class. |
DBObjectBase |
getObjectBase(java.lang.Short id)
Returns the object definition class for the id class. |
DBObjectBase |
getObjectBase(java.lang.String baseName)
Returns the object definition class for the id class. |
(package private) void |
initializeObjects()
Creates required objects when a new database is created from scratch, or if a pre-existing but damaged database file is loaded.. |
(package private) void |
initializeSchema()
Initialization method for a newly created DBStore.. |
void |
load(java.lang.String filename)
Load the database from disk. |
void |
load(java.lang.String filename,
boolean loadJournal)
Load the database from disk. |
void |
login(DBSession session)
Adds a session to our records. |
void |
logout(DBSession session)
Removes a session from our records. |
void |
printBases(java.io.PrintWriter out)
Do a printable dump of the object databases |
void |
printCategoryTree(java.io.PrintWriter out)
Dumps a text representation of this database's category hierarchy, starting at the root DBBaseCategory. |
void |
printCategoryTreeHTML(java.io.PrintWriter out)
Dumps an HTML representation of this database's category hierarchy, starting at the root DBBaseCategory. |
(package private) void |
removeLock()
Decrements the count of held locks for the admin consoles. |
void |
setBase(DBObjectBase base)
Method to replace/add a DBObjectBase in the DBStore. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
static final java.lang.String id_string
static final byte major_version
static final byte minor_version
static final byte major_xml_version
static final byte minor_xml_version
static boolean debug
java.util.Hashtable objectBases
java.util.Hashtable backPointers
hash mapping Invid's to Hashtables
of Invid's. Used to record the set of Invids that point to a
given Invid.
That is, backPointers.get(anInvid) returns a hashtable whose keys are the Invid's that point to that Invid via an asymmetric link.
private java.util.Vector sessions
Vector of DBSession objects.
java.util.Vector nameSpaces
DBNameSpaces registered in this DBStore.boolean loading
DBObjectBase
set methods will be enabledDBBaseCategory rootCategory
byte file_major
byte file_minor
DBJournal journal
public DBLockSync lockSync
int objectsCheckedOut
| Constructor Detail |
public DBStore()
This is the constructor for DBStore.
Currently, once you construct a DBStore object, all you can do to initialize it is call load(). This API needs to be extended to provide for programmatic bootstrapping, or another tool needs to be produced for the purpose.
| Method Detail |
public void load(java.lang.String filename)
Load the database from disk.
This method loads both the database type definition and database contents from a single disk file.
filename - Name of the database fileDBJournal
public void load(java.lang.String filename,
boolean loadJournal)
Load the database from disk.
This method loads both the database type definition and database contents from a single disk file.
filename - Name of the database fileloadJournal - if true, process and consolidate the journal
on loading.DBJournal
public void dump(java.lang.String filename,
boolean releaseLock,
boolean archiveIt)
throws java.io.IOException
Dumps the database to disk
This method dumps the entire database to disk. The thread that calls the dump method will be suspended until there are no threads performing update writes to the in-memory database. In practice this will likely never be a long interval. Note that this method *will* dump the database, even if no changes have been made. You should check the DBStore journal's isClean() method to determine whether or not a dump is really needed, if you're not sure.
The dump is guaranteed to be transaction consistent.
filename - Name of the database file to emitreleaseLock - boolean. If releaseLock==false, dump() will not release
the dump lock when it is done with the dump. This
is intended to allow for a clean shut down. For
non-terminal dumps, releaseLock should be true.archiveIt - If true, dump will create a zipped copy of the previously existing
ganymede.db file in an 'old' directory under the location where
ganymede.db is held.DBEditSet,
DBJournal
public void dumpXML(java.lang.String filename,
boolean dumpDataObjects,
boolean dumpSchema)
throws java.io.IOException
Dumps the database to disk as an XML file
This method dumps the entire database to disk. The thread that calls the dump method will be suspended until there are no threads performing update writes to the in-memory database. In practice this will likely never be a long interval. Note that this method *will* dump the database, even if no changes have been made. You should check the DBStore journal's isClean() method to determine whether or not a dump is really needed, if you're not sure.
The dump is guaranteed to be transaction consistent.
filename - Name of the database file to emitoutStream - Stream to write the XML to @param
dumpDataObjects if false, only the schema definition will be
writtendumpDataObjects - If true, the emitted file will include
the objects in the Ganymede database.dumpSchema - If true, the emitted file will include the
schema definitionDBEditSet,
DBJournal
public void dumpXML(java.io.OutputStream outStream,
boolean dumpDataObjects,
boolean dumpSchema)
throws java.io.IOException
Dumps the database and/or database schema to an OutputStream as an XML file
This method dumps the entire database to the OutputStream. The thread that calls the dump method will be suspended until there are no threads performing update writes to the in-memory database. In practice this will likely never be a long interval. Note that this method *will* dump the database, even if no changes have been made. You should check the DBStore journal's isClean() method to determine whether or not a dump is really needed, if you're not sure.
The dump is guaranteed to be transaction consistent.
outStream - Stream to write the XML to @param
dumpDataObjects if false, only the schema definition will be
writtendumpDataObjects - If true, the emitted file will include
the objects in the Ganymede database.dumpSchema - If true, the emitted file will include the
schema definitionDBEditSet,
DBJournalpublic void login(DBSession session)
Adds a session to our records.
public void logout(DBSession session)
Removes a session from our records.
public void printCategoryTreeHTML(java.io.PrintWriter out)
Dumps an HTML representation of this database's category
hierarchy, starting at the root
DBBaseCategory.
out - PrintStream to print topublic void printCategoryTree(java.io.PrintWriter out)
Dumps a text representation of this database's category
hierarchy, starting at the root
DBBaseCategory.
out - PrintStream to print topublic void printBases(java.io.PrintWriter out)
Do a printable dump of the object databases
out - PrintStream to print topublic java.util.Vector getBaseNameList()
public java.util.Vector getBases()
DBObjectBases currently
defined in this DBStore.public DBObjectBase getObjectBase(java.lang.Short id)
id - Type id for the base to be returnedpublic DBObjectBase getObjectBase(short id)
id - Type id for the base to be returnedpublic DBObjectBase getObjectBase(java.lang.String baseName)
baseName - Name of the base to be returnedpublic void setBase(DBObjectBase base)
public DBNameSpace getNameSpace(java.lang.String name)
public CategoryNode getCategoryNode(java.lang.String pathName)
void initializeSchema()
Initialization method for a newly created DBStore.. this method creates a new Schema from scratch, defining the mandatory Ganymede object types, registering their customization classes, defining fields, and all the rest.
Note that we don't go through a
DBSchemaEdit
here, we just initialize the DBObjectBase/
DBObjectBaseField structures
manually.
void initializeObjects()
Creates required objects when a new database is created from scratch, or if a pre-existing but damaged database file is loaded..
private boolean exists(DBSession session,
Invid invid)
private DBEditObject createSysEventObj(DBSession session,
java.lang.String token,
java.lang.String name,
java.lang.String description,
boolean ccAdmin)
void checkOut()
Increments the count of checked-out objects for the admin consoles.
void checkIn()
Decrements the count of checked-out objects for the admin consoles.
void addLock()
Increments the count of held locks for the admin consoles.
void removeLock()
Decrements the count of held locks for the admin consoles.
public void debugBackPointers()
private final java.lang.String describe(Invid x)
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||