com.sleepycat.je
Class Database

java.lang.Object
  extended by com.sleepycat.je.Database
Direct Known Subclasses:
SecondaryDatabase

public class Database
extends Object


Nested Class Summary
(package private) static class Database.DbState
           
 
Field Summary
(package private) static Database.DbState CLOSED
           
(package private)  DatabaseConfig configuration
           
(package private)  Environment envHandle
           
(package private)  Locker handleLocker
           
(package private) static Database.DbState INVALID
           
(package private) static Database.DbState OPEN
           
 
Constructor Summary
protected Database(Environment env)
          Creates a database but does not open or fully initialize it.
 
Method Summary
(package private)  void addCursor(Cursor dbc)
           
(package private)  void addTrigger(DatabaseTrigger trigger, boolean insertAtFront)
          Adds a given trigger to the list of triggers.
(package private)  void checkEnv()
           
(package private)  void checkProhibitedDbState(Database.DbState prohibited, String msg)
           
(package private)  void checkRequiredDbState(Database.DbState required, String msg)
           
 void close()
           
 OperationStatus delete(Transaction txn, DatabaseEntry key)
           
(package private)  OperationStatus deleteInternal(Locker locker, DatabaseEntry key)
          Internal version of delete() that does no parameter checking.
 OperationStatus get(Transaction txn, DatabaseEntry key, DatabaseEntry data, LockMode lockMode)
           
 DatabaseConfig getConfig()
           
(package private)  DatabaseImpl getDatabaseImpl()
          Return the databaseImpl object instance.
 String getDatabaseName()
           
(package private)  String getDebugName()
           
 Environment getEnvironment()
           
 OperationStatus getSearchBoth(Transaction txn, DatabaseEntry key, DatabaseEntry data, LockMode lockMode)
           
 List getSecondaryDatabases()
           
 DatabaseStats getStats(StatsConfig config)
           
(package private)  boolean hasTriggers()
          Returns whether any triggers are currently associated with this primary.
(package private)  void initExisting(Environment env, Locker locker, DatabaseImpl databaseImpl, DatabaseConfig dbConfig)
          Open a database, called by Environment.
(package private)  void initNew(Environment env, Locker locker, String databaseName, DatabaseConfig dbConfig)
          Create a database, called by Environment.
(package private)  void invalidate()
          Invalidate the handle, called by txn.abort by way of DbInternal.
(package private)  boolean isTransactional()
          Equivalent to getConfig().getTransactional() but cheaper.
(package private)  boolean isWritable()
           
 JoinCursor join(Cursor[] cursors, JoinConfig config)
           
(package private)  Cursor newDbcInstance(Transaction txn, CursorConfig cursorConfig)
          Is overridden by SecondaryDatabase.
(package private)  void notifyTriggers(Locker locker, DatabaseEntry priKey, DatabaseEntry oldData, DatabaseEntry newData)
          Notifies associated triggers when a put() or delete() is performed on the primary.
 Cursor openCursor(Transaction txn, CursorConfig cursorConfig)
           
 Sequence openSequence(Transaction txn, DatabaseEntry key, SequenceConfig config)
          Javadoc for this public method is generated via the doc templates in the doc_src directory.
 void preload(long maxBytes)
           
 void preload(long maxBytes, long maxMillisecs)
           
 OperationStatus put(Transaction txn, DatabaseEntry key, DatabaseEntry data)
           
(package private)  OperationStatus putInternal(Transaction txn, DatabaseEntry key, DatabaseEntry data, PutMode putMode)
          Internal version of put() that does no parameter checking.
 OperationStatus putNoDupData(Transaction txn, DatabaseEntry key, DatabaseEntry data)
           
 OperationStatus putNoOverwrite(Transaction txn, DatabaseEntry key, DatabaseEntry data)
           
(package private)  void removeCursor(Cursor dbc)
           
 void removeSequence(Transaction txn, DatabaseEntry key)
          Javadoc for this public method is generated via the doc templates in the doc_src directory.
(package private)  void removeTrigger(DatabaseTrigger trigger)
          Removes a given trigger from the list of triggers.
(package private)  void setHandleLocker(Locker locker)
          The handleLocker is the one that holds the db handle lock.
(package private)  void trace(Level level, String methodName, Transaction txn, CursorConfig config)
          Send trace messages to the java.util.logger.
(package private)  void trace(Level level, String methodName, Transaction txn, DatabaseEntry key, DatabaseEntry data, LockMode lockMode)
          Send trace messages to the java.util.logger.
 int truncate(Transaction txn, boolean countRecords)
          Deprecated. It has not been possible to implement this method with correct transactional semantics without incurring a performance penalty on all Database operations. Truncate functionality has been moved to Environment.truncateDatabase(), which requires that all Database handles on the database are closed before the truncate operation can execute.
(package private)  int truncateInternal(Locker locker, boolean countRecords)
          Deprecated.  
 DatabaseStats verify(VerifyConfig config)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN

static Database.DbState OPEN

CLOSED

static Database.DbState CLOSED

INVALID

static Database.DbState INVALID

envHandle

Environment envHandle

configuration

DatabaseConfig configuration

handleLocker

Locker handleLocker
Constructor Detail

Database

protected Database(Environment env)
Creates a database but does not open or fully initialize it. Is protected for use in compat package.

Method Detail

initNew

void initNew(Environment env,
             Locker locker,
             String databaseName,
             DatabaseConfig dbConfig)
       throws DatabaseException
Create a database, called by Environment.

Throws:
DatabaseException

initExisting

void initExisting(Environment env,
                  Locker locker,
                  DatabaseImpl databaseImpl,
                  DatabaseConfig dbConfig)
            throws DatabaseException
Open a database, called by Environment.

Throws:
DatabaseException

close

public void close()
           throws DatabaseException
Throws:
DatabaseException

openSequence

public Sequence openSequence(Transaction txn,
                             DatabaseEntry key,
                             SequenceConfig config)
                      throws DatabaseException
Javadoc for this public method is generated via the doc templates in the doc_src directory.

Throws:
DatabaseException

removeSequence

public void removeSequence(Transaction txn,
                           DatabaseEntry key)
                    throws DatabaseException
Javadoc for this public method is generated via the doc templates in the doc_src directory.

Throws:
DatabaseException

openCursor

public Cursor openCursor(Transaction txn,
                         CursorConfig cursorConfig)
                  throws DatabaseException
Throws:
DatabaseException

newDbcInstance

Cursor newDbcInstance(Transaction txn,
                      CursorConfig cursorConfig)
                throws DatabaseException
Is overridden by SecondaryDatabase.

Throws:
DatabaseException

delete

public OperationStatus delete(Transaction txn,
                              DatabaseEntry key)
                       throws DatabaseException
Throws:
DatabaseException

deleteInternal

OperationStatus deleteInternal(Locker locker,
                               DatabaseEntry key)
                         throws DatabaseException
Internal version of delete() that does no parameter checking. Notify triggers. Deletes all duplicates.

Throws:
DatabaseException

get

public OperationStatus get(Transaction txn,
                           DatabaseEntry key,
                           DatabaseEntry data,
                           LockMode lockMode)
                    throws DatabaseException
Throws:
DatabaseException

getSearchBoth

public OperationStatus getSearchBoth(Transaction txn,
                                     DatabaseEntry key,
                                     DatabaseEntry data,
                                     LockMode lockMode)
                              throws DatabaseException
Throws:
DatabaseException

put

public OperationStatus put(Transaction txn,
                           DatabaseEntry key,
                           DatabaseEntry data)
                    throws DatabaseException
Throws:
DatabaseException

putNoOverwrite

public OperationStatus putNoOverwrite(Transaction txn,
                                      DatabaseEntry key,
                                      DatabaseEntry data)
                               throws DatabaseException
Throws:
DatabaseException

putNoDupData

public OperationStatus putNoDupData(Transaction txn,
                                    DatabaseEntry key,
                                    DatabaseEntry data)
                             throws DatabaseException
Throws:
DatabaseException

putInternal

OperationStatus putInternal(Transaction txn,
                            DatabaseEntry key,
                            DatabaseEntry data,
                            PutMode putMode)
                      throws DatabaseException
Internal version of put() that does no parameter checking.

Throws:
DatabaseException

join

public JoinCursor join(Cursor[] cursors,
                       JoinConfig config)
                throws DatabaseException
Throws:
DatabaseException

truncate

public int truncate(Transaction txn,
                    boolean countRecords)
             throws DatabaseException
Deprecated. It has not been possible to implement this method with correct transactional semantics without incurring a performance penalty on all Database operations. Truncate functionality has been moved to Environment.truncateDatabase(), which requires that all Database handles on the database are closed before the truncate operation can execute.

Throws:
DatabaseException

truncateInternal

int truncateInternal(Locker locker,
                     boolean countRecords)
               throws DatabaseException
Deprecated. 

Internal unchecked truncate that optionally counts records.

Throws:
DatabaseException

preload

public void preload(long maxBytes)
             throws DatabaseException
Throws:
DatabaseException

preload

public void preload(long maxBytes,
                    long maxMillisecs)
             throws DatabaseException
Throws:
DatabaseException

getStats

public DatabaseStats getStats(StatsConfig config)
                       throws DatabaseException
Throws:
DatabaseException

verify

public DatabaseStats verify(VerifyConfig config)
                     throws DatabaseException
Throws:
DatabaseException

getDatabaseName

public String getDatabaseName()
                       throws DatabaseException
Throws:
DatabaseException

getDebugName

String getDebugName()

getConfig

public DatabaseConfig getConfig()
                         throws DatabaseException
Throws:
DatabaseException

isTransactional

boolean isTransactional()
                  throws DatabaseException
Equivalent to getConfig().getTransactional() but cheaper.

Throws:
DatabaseException

getEnvironment

public Environment getEnvironment()
                           throws DatabaseException
Throws:
DatabaseException

getSecondaryDatabases

public List getSecondaryDatabases()
                           throws DatabaseException
Throws:
DatabaseException

isWritable

boolean isWritable()
Returns:
true if the Database was opened read/write.

getDatabaseImpl

DatabaseImpl getDatabaseImpl()
Return the databaseImpl object instance.


setHandleLocker

void setHandleLocker(Locker locker)
The handleLocker is the one that holds the db handle lock.


removeCursor

void removeCursor(Cursor dbc)

addCursor

void addCursor(Cursor dbc)

checkRequiredDbState

void checkRequiredDbState(Database.DbState required,
                          String msg)
                    throws DatabaseException
Throws:
DatabaseException - if the Database state is not this value.

checkProhibitedDbState

void checkProhibitedDbState(Database.DbState prohibited,
                            String msg)
                      throws DatabaseException
Throws:
DatabaseException - if the Database state is this value.

checkEnv

void checkEnv()
        throws RunRecoveryException
Throws:
RunRecoveryException - if the underlying environment is invalid

invalidate

void invalidate()
Invalidate the handle, called by txn.abort by way of DbInternal.


trace

void trace(Level level,
           String methodName,
           Transaction txn,
           DatabaseEntry key,
           DatabaseEntry data,
           LockMode lockMode)
     throws DatabaseException
Send trace messages to the java.util.logger. Don't rely on the logger alone to conditionalize whether we send this message, we don't even want to construct the message if the level is not enabled.

Throws:
DatabaseException

trace

void trace(Level level,
           String methodName,
           Transaction txn,
           CursorConfig config)
     throws DatabaseException
Send trace messages to the java.util.logger. Don't rely on the logger alone to conditionalize whether we send this message, we don't even want to construct the message if the level is not enabled.

Throws:
DatabaseException

hasTriggers

boolean hasTriggers()
Returns whether any triggers are currently associated with this primary. Note that an update of the trigger list may be in progress and this method does not wait for that update to be completed.


addTrigger

void addTrigger(DatabaseTrigger trigger,
                boolean insertAtFront)
          throws DatabaseException
Adds a given trigger to the list of triggers. Called while opening a SecondaryDatabase.

Parameters:
insertAtFront - true to insert at the front, or false to append.
Throws:
DatabaseException

removeTrigger

void removeTrigger(DatabaseTrigger trigger)
             throws DatabaseException
Removes a given trigger from the list of triggers. Called by SecondaryDatabase.close().

Throws:
DatabaseException

notifyTriggers

void notifyTriggers(Locker locker,
                    DatabaseEntry priKey,
                    DatabaseEntry oldData,
                    DatabaseEntry newData)
              throws DatabaseException
Notifies associated triggers when a put() or delete() is performed on the primary. This method is normally called only if hasTriggers() has returned true earlier. This avoids acquiring a shared latch for primaries with no triggers. If a trigger is added during the update process, there is no requirement to immediately start updating it.

Parameters:
locker - the internal locker.
priKey - the primary key.
oldData - the primary data before the change, or null if the record did not previously exist.
newData - the primary data after the change, or null if the record has been deleted.
Throws:
DatabaseException


Copyright 2004-2005 Sleepycat, Inc. All Rights Reserved.