ee,hash,hashing,transaction,transactions,locking,logging,access method,access me
public static DbLockTab open(String dir, int flags, int mode, DbEnv dbenv)
method returns a "lock region" identified by the directory dir.
dir pathname argument is interpreted as described in
Berkeley DB File Naming.
The flags and mode arguments specify how files will be opened
and/or created if they do not already exist.
The flags value is specified by logically OR'ing together one or more of the
- Create any underlying files, as necessary. If the files do not already
exist and the DB_CREATE flag is not specified, the call will fail.
- Cause the m4_reg(DbLockTab) handle returned by DbLockTab.open to be useable
by multiple threads within a single address space, i.e., to be
Note, threading is assumed in the Java API, so no special flags are required,
and Berkeley DB functions will always behave as if the DB_THREAD flag was specified.
All files created by the lock subsystem are created with mode mode (as described
in chmod(2)) and modified by the process' umask value at the time
of creation (see umask(2)))).
The group ownership of created files is based on the system and directory
defaults, and is not further specified by Berkeley DB.
The locking subsystem is configured
based on the dbenv argument. It is expected that applications
will use a single DbEnv object as the argument to all of the
subsystems in the Berkeley DB package. The fields of the DbEnv object
used by DbLockTab.open are described below.
Any of the DbEnv fields that are not explicitly set will default
to appropriate values.
The following fields in the DbEnv object may be initialized, using
the appropriate set method, before calling DbLockTab.open:
- DbErrcall db_errcall;
- String db_errpfx;
- int db_verbose;
- The error fields of the DbEnv behave as described for
- byte lk_conflicts;
- A lk_modes by lk_modes array.
A non-0 value for the array element:
indicates that requested_mode and held_mode conflict.
The not-granted mode must be represented by 0.
If lk_conflicts is null, the conflicts array
db_rw_conflicts is used; see Standard Lock Modes for a description of that array.
- int lk_detect;
- If non-0, specifies that the deadlock detector be run whenever a lock
conflict occurs, and specifies which transaction should be aborted in
the case of a deadlock.
The lk_detect field must be set to one of the following values.
- Use the default policy as specified by db_deadlock.
- Abort the oldest transaction.
- Abort a random transaction involved in the deadlock.
- Abort the youngest transaction.
- int lk_max;
- The maximum number of locks to be held or requested in the table.
This value is used by DbLockTab.open to estimate how much space to
allocate for various lock-table data structures.
If lk_max is 0, a default value is used.
- int lk_modes;
- The number of lock modes to be recognized by the lock table (including
the not-granted mode). If lk_modes is 0, the value
DB_LOCK_RW_N is used.
method throws an exception that encapsulates an errno on failure.
- If the dbenv argument to DbLockTab.open was initialized using
DbEnv.appinit the environment variable DB_HOME may
be used as the path of the database home for the interpretation of
the dir argument.
- If the dbenv argument to DbLockTab.open was NULL or not initialized
using DbEnv.appinit the environment variable TMPDIR may
be used as the directory in which to create the lock table, as described in
If a fatal error occurs in Berkeley DB, the DbLockTab.open method may fail and throw a
DbRunRecoveryException, at which point all subsequent database
calls will also fail in the same way.
method may fail and throw an exception
for any of the errors specified for the following Berkeley DB and C library
In addition, the DbLockTab.open
method may fail and throw an exception
for the following conditions:
- The shared memory region was locked and (repeatedly) unavailable.
- An invalid flag value or parameter was specified.
The DB_THREAD flag was specified and spinlocks are not implemented for