Berkeley DB: DbEnv.lock_get
Description: Berkeley DB: An embedded database programmatic toolkit.
Keywords: embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++

# DbEnv.lock_get |

`

###

    import com.sleepycat.db.*;

    public DbLock lock_get(int locker, int flags, Dbt obj, int lock_mode)
        throws DbException;

# Description

The DbEnv.lock_get method acquires a lock from the lock table, returning information about it in a DbLock object.

The locker argument specified to DbEnv.lock_get is an unsigned 32-bit integer quantity. It represents the entity requesting or releasing the lock.

The flags value must be set to 0 or the following value:

Db.DB_LOCK_NOWAIT
  If a lock cannot be granted because the requested lock conflicts with an existing lock, throw a DbLockNotGrantedException immediately instead of waiting for the lock to become available.

The obj argument is an untyped byte string that specifies the object to be locked or released. Applications using the locking subsystem directly while also doing locking via the Berkeley DB access methods must take care not to inadvertently lock objects that happen to be equal to the unique file IDs used to lock files. See Access method locking conventions for more information.

The mode argument is used as an index into the environment's lock conflict matrix. When using the default lock conflict matrix, mode must be set to one of the following values:

Db.DB_LOCK_READ
  read (shared)
Db.DB_LOCK_WRITE
  write (exclusive)
Db.DB_LOCK_IWRITE
  intention to write (shared)
Db.DB_LOCK_IREAD
  intention to read (shared)
Db.DB_LOCK_IWR
  intention to read and write (shared)

See DbEnv.set_lk_conflicts and Standard Lock Modes for more information on the lock conflict matrix.

Otherwise, the DbEnv.lock_get method throws an exception that encapsulates a non-zero error value on failure.

# Errors

The DbEnv.lock_get method may fail and throw an exception encapsulating a non-zero error for the following conditions:

EINVAL
  An invalid flag value or parameter was specified.

ENOMEM
  The maximum number of locks has been reached.

If the operation was selected to resolve a deadlock, the DbEnv.lock_get method will fail and throw a DbDeadlockException exception.

The DbEnv.lock_get method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. If a catastrophic error has occurred, the DbEnv.lock_get method may fail and throw a DbRunRecoveryException, in which case all subsequent Berkeley DB calls will fail in the same way.

# Class

DbEnv, DbLock

# See Also

Locking Subsystem and Related Methods`

Copyright Sleepycat Software