com.sleepycat.compat
Class DbCompat

java.lang.Object
  extended by com.sleepycat.compat.DbCompat

public class DbCompat
extends Object

A minimal set of DB-JE compatibility methods for internal use only. Two versions are maintained in parallel in the DB and JE source trees. Used by the collections package.


Field Summary
static boolean BTREE_RECNUM_METHOD
           
static boolean CDB
           
static boolean DATABASE_COUNT
           
static boolean HASH_METHOD
           
static boolean INSERTION_ORDERED_DUPLICATES
           
static boolean JOIN
           
static boolean LOCK_SUBSYSTEM
           
static boolean MEMORY_SUBSYSTEM
           
static boolean NESTED_TRANSACTIONS
           
static boolean NEW_JE_EXCEPTIONS
           
static boolean OPTIONAL_READ_UNCOMMITTED
           
static boolean POPULATE_ENFORCES_CONSTRAINTS
           
static boolean QUEUE_METHOD
           
static TransactionConfig READ_ONLY_TXN_CONFIG
          For read-only cursor operations on a replicated node, we must use a transaction to satisfy HA requirements.
static boolean RECNO_METHOD
           
static boolean SECONDARIES
           
static boolean SEPARATE_DATABASE_FILES
           
static boolean TRANSACTION_RUNNER_PRINT_STACK_TRACES
           
 
Constructor Summary
DbCompat()
           
 
Method Summary
static OperationStatus append(Database db, Transaction txn, DatabaseEntry key, DatabaseEntry data)
           
static CursorConfig cloneCursorConfig(CursorConfig config)
           
static boolean databaseExists(Environment env, String fileName, String dbName)
           
static boolean getBtreeRecordNumbers(DatabaseConfig dbConfig)
           
static OperationStatus getCurrentRecordNumber(Cursor cursor, DatabaseEntry key, LockMode lockMode)
           
static long getDatabaseCount(Database db)
           
static String getDatabaseFile(Database db)
           
static boolean getDeferredWrite(DatabaseConfig dbConfig)
           
static boolean getInitializeCache(EnvironmentConfig config)
           
static boolean getInitializeCDB(EnvironmentConfig config)
           
static boolean getInitializeLocking(EnvironmentConfig config)
           
static boolean getReadUncommitted(DatabaseConfig dbConfig)
           
static int getRecordNumber(DatabaseEntry entry)
           
static boolean getRenumbering(DatabaseConfig dbConfig)
           
static OperationStatus getSearchRecordNumber(Cursor cursor, DatabaseEntry key, DatabaseEntry data, LockMode lockMode)
           
static OperationStatus getSearchRecordNumber(SecondaryCursor cursor, DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode)
           
static boolean getSortedDuplicates(DatabaseConfig dbConfig)
           
static Transaction getThreadTransaction(Environment env)
           
static boolean getUnsortedDuplicates(DatabaseConfig dbConfig)
           
static boolean getWriteCursor(CursorConfig config)
           
static boolean isReplicated(Environment env)
           
static boolean isTypeBtree(DatabaseConfig dbConfig)
           
static boolean isTypeHash(DatabaseConfig dbConfig)
           
static boolean isTypeQueue(DatabaseConfig dbConfig)
           
static boolean isTypeRecno(DatabaseConfig dbConfig)
           
static Database openDatabase(Environment env, Transaction txn, String fileName, String dbName, DatabaseConfig config)
          Returns null if the database is not found (and AllowCreate is false) or already exists (and ExclusiveCreate is true).
static SecondaryDatabase openSecondaryDatabase(Environment env, Transaction txn, String fileName, String dbName, Database primaryDatabase, SecondaryConfig config)
          Returns null if the database is not found (and AllowCreate is false) or already exists (and ExclusiveCreate is true).
static OperationStatus putAfter(Cursor cursor, DatabaseEntry key, DatabaseEntry data)
           
static OperationStatus putBefore(Cursor cursor, DatabaseEntry key, DatabaseEntry data)
           
static boolean removeDatabase(Environment env, Transaction txn, String fileName, String dbName)
          Returns false if the database is not found.
static boolean renameDatabase(Environment env, Transaction txn, String oldFileName, String oldDbName, String newFileName, String newDbName)
          Returns false if the database is not found.
static void setBtreeComparator(DatabaseConfig dbConfig, Comparator<byte[]> comparator)
           
static void setBtreeRecordNumbers(DatabaseConfig dbConfig, boolean val)
           
static void setDeferredWrite(DatabaseConfig dbConfig, boolean val)
           
static boolean setImportunate(Transaction txn, boolean importunate)
           
static void setInitializeCache(EnvironmentConfig config, boolean val)
           
static void setInitializeCDB(EnvironmentConfig config, boolean val)
           
static void setInitializeLocking(EnvironmentConfig config, boolean val)
           
static void setLockDetectModeOldest(EnvironmentConfig config)
           
static void setReadUncommitted(DatabaseConfig dbConfig, boolean val)
           
static void setRecordLength(DatabaseConfig dbConfig, int val)
           
static void setRecordNumber(DatabaseEntry entry, int recNum)
           
static void setRecordPad(DatabaseConfig dbConfig, int val)
           
static void setRenumbering(DatabaseConfig dbConfig, boolean val)
           
static void setSerializableIsolation(TransactionConfig config, boolean val)
           
static void setSortedDuplicates(DatabaseConfig dbConfig, boolean val)
           
static void setTypeBtree(DatabaseConfig dbConfig)
           
static void setTypeHash(DatabaseConfig dbConfig)
           
static void setTypeQueue(DatabaseConfig dbConfig)
           
static void setTypeRecno(DatabaseConfig dbConfig)
           
static void setUnsortedDuplicates(DatabaseConfig dbConfig, boolean val)
           
static void setWriteCursor(CursorConfig config, boolean write)
           
static Database testOpenDatabase(Environment env, Transaction txn, String file, String name, DatabaseConfig config)
          Fires an assertion if the database is not found (and AllowCreate is false) or already exists (and ExclusiveCreate is true).
static SecondaryDatabase testOpenSecondaryDatabase(Environment env, Transaction txn, String file, String name, Database primary, SecondaryConfig config)
          Fires an assertion if the database is not found (and AllowCreate is false) or already exists (and ExclusiveCreate is true).
static boolean truncateDatabase(Environment env, Transaction txn, String fileName, String dbName)
          Returns false if the database is not found.
static RuntimeException unexpectedException(Exception cause)
           
static RuntimeException unexpectedException(String msg, Exception cause)
           
static RuntimeException unexpectedState()
           
static RuntimeException unexpectedState(String msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CDB

public static final boolean CDB
See Also:
Constant Field Values

JOIN

public static final boolean JOIN
See Also:
Constant Field Values

NESTED_TRANSACTIONS

public static final boolean NESTED_TRANSACTIONS
See Also:
Constant Field Values

INSERTION_ORDERED_DUPLICATES

public static final boolean INSERTION_ORDERED_DUPLICATES
See Also:
Constant Field Values

SEPARATE_DATABASE_FILES

public static final boolean SEPARATE_DATABASE_FILES
See Also:
Constant Field Values

MEMORY_SUBSYSTEM

public static final boolean MEMORY_SUBSYSTEM
See Also:
Constant Field Values

LOCK_SUBSYSTEM

public static final boolean LOCK_SUBSYSTEM
See Also:
Constant Field Values

HASH_METHOD

public static final boolean HASH_METHOD
See Also:
Constant Field Values

RECNO_METHOD

public static final boolean RECNO_METHOD
See Also:
Constant Field Values

QUEUE_METHOD

public static final boolean QUEUE_METHOD
See Also:
Constant Field Values

BTREE_RECNUM_METHOD

public static final boolean BTREE_RECNUM_METHOD
See Also:
Constant Field Values

OPTIONAL_READ_UNCOMMITTED

public static final boolean OPTIONAL_READ_UNCOMMITTED
See Also:
Constant Field Values

SECONDARIES

public static final boolean SECONDARIES
See Also:
Constant Field Values

TRANSACTION_RUNNER_PRINT_STACK_TRACES

public static boolean TRANSACTION_RUNNER_PRINT_STACK_TRACES

DATABASE_COUNT

public static final boolean DATABASE_COUNT
See Also:
Constant Field Values

NEW_JE_EXCEPTIONS

public static final boolean NEW_JE_EXCEPTIONS
See Also:
Constant Field Values

POPULATE_ENFORCES_CONSTRAINTS

public static final boolean POPULATE_ENFORCES_CONSTRAINTS
See Also:
Constant Field Values

READ_ONLY_TXN_CONFIG

public static final TransactionConfig READ_ONLY_TXN_CONFIG
For read-only cursor operations on a replicated node, we must use a transaction to satisfy HA requirements. However, we use a Durability that avoids consistency checks on the Master, and we use ReadCommitted isolation since that gives the sam behavior as a non-transactional cursor: locks are released when the cursor is moved or closed.

Constructor Detail

DbCompat

public DbCompat()
Method Detail

getInitializeCache

public static boolean getInitializeCache(EnvironmentConfig config)

getInitializeLocking

public static boolean getInitializeLocking(EnvironmentConfig config)

getInitializeCDB

public static boolean getInitializeCDB(EnvironmentConfig config)

isReplicated

public static boolean isReplicated(Environment env)

isTypeBtree

public static boolean isTypeBtree(DatabaseConfig dbConfig)

isTypeHash

public static boolean isTypeHash(DatabaseConfig dbConfig)

isTypeQueue

public static boolean isTypeQueue(DatabaseConfig dbConfig)

isTypeRecno

public static boolean isTypeRecno(DatabaseConfig dbConfig)

getBtreeRecordNumbers

public static boolean getBtreeRecordNumbers(DatabaseConfig dbConfig)

getReadUncommitted

public static boolean getReadUncommitted(DatabaseConfig dbConfig)

getRenumbering

public static boolean getRenumbering(DatabaseConfig dbConfig)

getSortedDuplicates

public static boolean getSortedDuplicates(DatabaseConfig dbConfig)

getUnsortedDuplicates

public static boolean getUnsortedDuplicates(DatabaseConfig dbConfig)

getDeferredWrite

public static boolean getDeferredWrite(DatabaseConfig dbConfig)

cloneCursorConfig

public static CursorConfig cloneCursorConfig(CursorConfig config)

getWriteCursor

public static boolean getWriteCursor(CursorConfig config)

setWriteCursor

public static void setWriteCursor(CursorConfig config,
                                  boolean write)

setRecordNumber

public static void setRecordNumber(DatabaseEntry entry,
                                   int recNum)

getRecordNumber

public static int getRecordNumber(DatabaseEntry entry)

getDatabaseFile

public static String getDatabaseFile(Database db)

getDatabaseCount

public static long getDatabaseCount(Database db)
                             throws DatabaseException
Throws:
DatabaseException

getCurrentRecordNumber

public static OperationStatus getCurrentRecordNumber(Cursor cursor,
                                                     DatabaseEntry key,
                                                     LockMode lockMode)
                                              throws DatabaseException
Throws:
DatabaseException - from DB core.

getSearchRecordNumber

public static OperationStatus getSearchRecordNumber(Cursor cursor,
                                                    DatabaseEntry key,
                                                    DatabaseEntry data,
                                                    LockMode lockMode)
                                             throws DatabaseException
Throws:
DatabaseException - from DB core.

getSearchRecordNumber

public static OperationStatus getSearchRecordNumber(SecondaryCursor cursor,
                                                    DatabaseEntry key,
                                                    DatabaseEntry pKey,
                                                    DatabaseEntry data,
                                                    LockMode lockMode)
                                             throws DatabaseException
Throws:
DatabaseException - from DB core.

putAfter

public static OperationStatus putAfter(Cursor cursor,
                                       DatabaseEntry key,
                                       DatabaseEntry data)
                                throws DatabaseException
Throws:
DatabaseException - from DB core.

putBefore

public static OperationStatus putBefore(Cursor cursor,
                                        DatabaseEntry key,
                                        DatabaseEntry data)
                                 throws DatabaseException
Throws:
DatabaseException - from DB core.

append

public static OperationStatus append(Database db,
                                     Transaction txn,
                                     DatabaseEntry key,
                                     DatabaseEntry data)

getThreadTransaction

public static Transaction getThreadTransaction(Environment env)
                                        throws DatabaseException
Throws:
DatabaseException

setInitializeCache

public static void setInitializeCache(EnvironmentConfig config,
                                      boolean val)

setInitializeLocking

public static void setInitializeLocking(EnvironmentConfig config,
                                        boolean val)

setInitializeCDB

public static void setInitializeCDB(EnvironmentConfig config,
                                    boolean val)

setLockDetectModeOldest

public static void setLockDetectModeOldest(EnvironmentConfig config)

setSerializableIsolation

public static void setSerializableIsolation(TransactionConfig config,
                                            boolean val)

setImportunate

public static boolean setImportunate(Transaction txn,
                                     boolean importunate)

setBtreeComparator

public static void setBtreeComparator(DatabaseConfig dbConfig,
                                      Comparator<byte[]> comparator)

setTypeBtree

public static void setTypeBtree(DatabaseConfig dbConfig)

setTypeHash

public static void setTypeHash(DatabaseConfig dbConfig)

setTypeRecno

public static void setTypeRecno(DatabaseConfig dbConfig)

setTypeQueue

public static void setTypeQueue(DatabaseConfig dbConfig)

setBtreeRecordNumbers

public static void setBtreeRecordNumbers(DatabaseConfig dbConfig,
                                         boolean val)

setReadUncommitted

public static void setReadUncommitted(DatabaseConfig dbConfig,
                                      boolean val)

setRenumbering

public static void setRenumbering(DatabaseConfig dbConfig,
                                  boolean val)

setSortedDuplicates

public static void setSortedDuplicates(DatabaseConfig dbConfig,
                                       boolean val)

setUnsortedDuplicates

public static void setUnsortedDuplicates(DatabaseConfig dbConfig,
                                         boolean val)

setDeferredWrite

public static void setDeferredWrite(DatabaseConfig dbConfig,
                                    boolean val)

setRecordLength

public static void setRecordLength(DatabaseConfig dbConfig,
                                   int val)

setRecordPad

public static void setRecordPad(DatabaseConfig dbConfig,
                                int val)

databaseExists

public static boolean databaseExists(Environment env,
                                     String fileName,
                                     String dbName)

openDatabase

public static Database openDatabase(Environment env,
                                    Transaction txn,
                                    String fileName,
                                    String dbName,
                                    DatabaseConfig config)
Returns null if the database is not found (and AllowCreate is false) or already exists (and ExclusiveCreate is true).


openSecondaryDatabase

public static SecondaryDatabase openSecondaryDatabase(Environment env,
                                                      Transaction txn,
                                                      String fileName,
                                                      String dbName,
                                                      Database primaryDatabase,
                                                      SecondaryConfig config)
Returns null if the database is not found (and AllowCreate is false) or already exists (and ExclusiveCreate is true).


truncateDatabase

public static boolean truncateDatabase(Environment env,
                                       Transaction txn,
                                       String fileName,
                                       String dbName)
Returns false if the database is not found.


removeDatabase

public static boolean removeDatabase(Environment env,
                                     Transaction txn,
                                     String fileName,
                                     String dbName)
Returns false if the database is not found.


renameDatabase

public static boolean renameDatabase(Environment env,
                                     Transaction txn,
                                     String oldFileName,
                                     String oldDbName,
                                     String newFileName,
                                     String newDbName)
Returns false if the database is not found.


testOpenDatabase

public static Database testOpenDatabase(Environment env,
                                        Transaction txn,
                                        String file,
                                        String name,
                                        DatabaseConfig config)
Fires an assertion if the database is not found (and AllowCreate is false) or already exists (and ExclusiveCreate is true).


testOpenSecondaryDatabase

public static SecondaryDatabase testOpenSecondaryDatabase(Environment env,
                                                          Transaction txn,
                                                          String file,
                                                          String name,
                                                          Database primary,
                                                          SecondaryConfig config)
Fires an assertion if the database is not found (and AllowCreate is false) or already exists (and ExclusiveCreate is true).


unexpectedException

public static RuntimeException unexpectedException(Exception cause)

unexpectedException

public static RuntimeException unexpectedException(String msg,
                                                   Exception cause)

unexpectedState

public static RuntimeException unexpectedState(String msg)

unexpectedState

public static RuntimeException unexpectedState()


Copyright (c) 2004-2010 Oracle. All rights reserved.