|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.compat.DbCompat
public class DbCompat
A minimal set of BDB DB-JE compatibility constants and static methods, for internal use only. Two versions of this class, with the same public interface but different implementations, are maintained in parallel in the DB and JE source trees. By the use of the constants and methods in this class, along with a script that moves the source code from JE to DB, the source code in certain packages is kept "portable" and is shared by the two products. The script translates the package names from com.sleepycat.je to com.sleepycat.db, and perform other fix-ups as described further below. The JE directories that contain portable code are: src/com/sleepycat/bind /collections /persist /util test/com/sleepycat/bind /collections /persist /util In DB, these sources are stored in the following locations: Sources: src/java Tests: test/java/compat To keep this source code portable there are additional coding rules, above and beyond the standard rules (such as coding style) for all JE code. + In general we should try to use the JE/DB public API, since it is usually the same or similar in both products. If we use internal APIs, they will always be different and will require special handling. + When there are differences between products, the first choice for handling the difference is to use a DbCompat static method or constant. This keeps the source code the same for both products (except in this DbCompat class). + When JE-only code is needed -- for example, some APIs only exist in JE, and special handling of JE exceptions is sometimes needed -- the following special comment syntax can be used to bracket the JE-only code: JE-only code goes here This syntax must be used inside of a comment: either inside a javadoc section as shown above, or inside a single-line comment (space before last slash is to prevent ending this javadoc comment): /* * / JE-only code goes here /* * / All lines between the and lines, and including these lines, will be removed by the script that transfers code from JE to DB. + When DB-only code is needed, the code will exist in the JE product but will never be executed. For DB-only APIs, we hide the API from the user with the @hidden javadoc tag. The @hidden tag is ignored on the DB side. We do not have a way to remove DB-only code completely from the JE product, because we do not use a proprocessor for building JE. + Because DatabaseException (and all subclasses) are checked exceptions in DB but runtime exceptions in JE, we cannot omit the 'throws' declaration. Another difference is that DB normally throws DatabaseException for all errors, while JE has many specific subclasses for specific errors. Therefore, any method that calls a DB API method (for example, Database.get or put) will have a "throws DatabaseException" clause. + Special consideration is needed for the @throws clauses in javadoc. We do want to javadoc the JE-only exceptions that are thrown, so the @throws for these exceptions should be inside the "begin/end JE only" brackets. We also need to document the fact that DB may throw DatabaseException for almost any method, so we do that with a final @throws clause that looks like this:
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 ClassLoader |
getClassLoader(Environment env)
|
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 |
isDalvik()
|
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 |
---|
public static final boolean CDB
public static final boolean JOIN
public static final boolean NESTED_TRANSACTIONS
public static final boolean INSERTION_ORDERED_DUPLICATES
public static final boolean SEPARATE_DATABASE_FILES
public static final boolean MEMORY_SUBSYSTEM
public static final boolean LOCK_SUBSYSTEM
public static final boolean HASH_METHOD
public static final boolean RECNO_METHOD
public static final boolean QUEUE_METHOD
public static final boolean BTREE_RECNUM_METHOD
public static final boolean OPTIONAL_READ_UNCOMMITTED
public static final boolean SECONDARIES
public static boolean TRANSACTION_RUNNER_PRINT_STACK_TRACES
public static final boolean DATABASE_COUNT
public static final boolean NEW_JE_EXCEPTIONS
public static final boolean POPULATE_ENFORCES_CONSTRAINTS
public static final TransactionConfig READ_ONLY_TXN_CONFIG
Constructor Detail |
---|
public DbCompat()
Method Detail |
---|
public static boolean getInitializeCache(EnvironmentConfig config)
public static boolean getInitializeLocking(EnvironmentConfig config)
public static boolean getInitializeCDB(EnvironmentConfig config)
public static boolean isReplicated(Environment env)
public static boolean isTypeBtree(DatabaseConfig dbConfig)
public static boolean isTypeHash(DatabaseConfig dbConfig)
public static boolean isTypeQueue(DatabaseConfig dbConfig)
public static boolean isTypeRecno(DatabaseConfig dbConfig)
public static boolean getBtreeRecordNumbers(DatabaseConfig dbConfig)
public static boolean getReadUncommitted(DatabaseConfig dbConfig)
public static boolean getRenumbering(DatabaseConfig dbConfig)
public static boolean getSortedDuplicates(DatabaseConfig dbConfig)
public static boolean getUnsortedDuplicates(DatabaseConfig dbConfig)
public static boolean getDeferredWrite(DatabaseConfig dbConfig)
public static CursorConfig cloneCursorConfig(CursorConfig config)
public static boolean getWriteCursor(CursorConfig config)
public static void setWriteCursor(CursorConfig config, boolean write)
public static void setRecordNumber(DatabaseEntry entry, int recNum)
public static int getRecordNumber(DatabaseEntry entry)
public static String getDatabaseFile(Database db)
public static long getDatabaseCount(Database db) throws DatabaseException
DatabaseException
public static OperationStatus getCurrentRecordNumber(Cursor cursor, DatabaseEntry key, LockMode lockMode) throws DatabaseException
DatabaseException
- from DB core.public static OperationStatus getSearchRecordNumber(Cursor cursor, DatabaseEntry key, DatabaseEntry data, LockMode lockMode) throws DatabaseException
DatabaseException
- from DB core.public static OperationStatus getSearchRecordNumber(SecondaryCursor cursor, DatabaseEntry key, DatabaseEntry pKey, DatabaseEntry data, LockMode lockMode) throws DatabaseException
DatabaseException
- from DB core.public static OperationStatus putAfter(Cursor cursor, DatabaseEntry key, DatabaseEntry data) throws DatabaseException
DatabaseException
- from DB core.public static OperationStatus putBefore(Cursor cursor, DatabaseEntry key, DatabaseEntry data) throws DatabaseException
DatabaseException
- from DB core.public static OperationStatus append(Database db, Transaction txn, DatabaseEntry key, DatabaseEntry data)
public static Transaction getThreadTransaction(Environment env) throws DatabaseException
DatabaseException
public static ClassLoader getClassLoader(Environment env)
public static void setInitializeCache(EnvironmentConfig config, boolean val)
public static void setInitializeLocking(EnvironmentConfig config, boolean val)
public static void setInitializeCDB(EnvironmentConfig config, boolean val)
public static void setLockDetectModeOldest(EnvironmentConfig config)
public static void setSerializableIsolation(TransactionConfig config, boolean val)
public static boolean setImportunate(Transaction txn, boolean importunate)
public static void setBtreeComparator(DatabaseConfig dbConfig, Comparator<byte[]> comparator)
public static void setTypeBtree(DatabaseConfig dbConfig)
public static void setTypeHash(DatabaseConfig dbConfig)
public static void setTypeRecno(DatabaseConfig dbConfig)
public static void setTypeQueue(DatabaseConfig dbConfig)
public static void setBtreeRecordNumbers(DatabaseConfig dbConfig, boolean val)
public static void setReadUncommitted(DatabaseConfig dbConfig, boolean val)
public static void setRenumbering(DatabaseConfig dbConfig, boolean val)
public static void setSortedDuplicates(DatabaseConfig dbConfig, boolean val)
public static void setUnsortedDuplicates(DatabaseConfig dbConfig, boolean val)
public static void setDeferredWrite(DatabaseConfig dbConfig, boolean val)
public static void setRecordLength(DatabaseConfig dbConfig, int val)
public static void setRecordPad(DatabaseConfig dbConfig, int val)
public static boolean databaseExists(Environment env, String fileName, String dbName)
public static Database openDatabase(Environment env, Transaction txn, String fileName, String dbName, DatabaseConfig config)
public static SecondaryDatabase openSecondaryDatabase(Environment env, Transaction txn, String fileName, String dbName, Database primaryDatabase, SecondaryConfig config)
public static boolean truncateDatabase(Environment env, Transaction txn, String fileName, String dbName)
public static boolean removeDatabase(Environment env, Transaction txn, String fileName, String dbName)
public static boolean renameDatabase(Environment env, Transaction txn, String oldFileName, String oldDbName, String newFileName, String newDbName)
public static Database testOpenDatabase(Environment env, Transaction txn, String file, String name, DatabaseConfig config)
public static SecondaryDatabase testOpenSecondaryDatabase(Environment env, Transaction txn, String file, String name, Database primary, SecondaryConfig config)
public static boolean isDalvik()
public static RuntimeException unexpectedException(Exception cause)
public static RuntimeException unexpectedException(String msg, Exception cause)
public static RuntimeException unexpectedState(String msg)
public static RuntimeException unexpectedState()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |