1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 1997,2008 Oracle. All rights reserved. 5 * 6 * $Id: LockNotGrantedException.java,v 12.8 2008/01/17 05:04:53 mjc Exp $ 7 */ 8package com.sleepycat.db; 9 10import com.sleepycat.db.internal.DbConstants; 11import com.sleepycat.db.internal.DbEnv; 12import com.sleepycat.db.internal.DbLock; 13 14/** 15A LockNotGrantedException is thrown when a lock requested using the 16{@link com.sleepycat.db.Environment#getLock Environment.getLock} or {@link com.sleepycat.db.Environment#lockVector Environment.lockVector} 17methods, where the noWait flag or lock timers were configured, could not 18be granted before the wait-time expired. 19<p> 20Additionally, LockNotGrantedException is thrown when a Concurrent Data 21Store database environment configured for lock timeouts was unable to 22grant a lock in the allowed time. 23<p> 24Additionally, LockNotGrantedException is thrown when lock or transaction 25timeouts have been configured and a database operation has timed out. 26*/ 27public class LockNotGrantedException extends DeadlockException { 28 private int index; 29 private Lock lock; 30 private int mode; 31 private DatabaseEntry obj; 32 private int op; 33 34 /* package */ LockNotGrantedException(final String message, 35 final int op, 36 final int mode, 37 final DatabaseEntry obj, 38 final DbLock lock, 39 final int index, 40 final DbEnv dbenv) { 41 super(message, DbConstants.DB_LOCK_NOTGRANTED, dbenv); 42 this.op = op; 43 this.mode = mode; 44 this.obj = obj; 45 this.lock = (lock == null) ? null : lock.wrapper; 46 this.index = index; 47 } 48 49 /** 50 Returns -1 when {@link com.sleepycat.db.Environment#getLock Environment.getLock} was called, and 51 returns the index of the failed LockRequest when {@link com.sleepycat.db.Environment#lockVector Environment.lockVector} was called. 52 */ 53 public int getIndex() { 54 return index; 55 } 56 57 /** 58 Returns null when {@link com.sleepycat.db.Environment#getLock Environment.getLock} was called, and 59 returns the lock in the failed LockRequest when {@link com.sleepycat.db.Environment#lockVector Environment.lockVector} was called. 60 */ 61 public Lock getLock() { 62 return lock; 63 } 64 65 /** 66 Returns the mode parameter when {@link com.sleepycat.db.Environment#getLock Environment.getLock} was 67 called, and returns the mode for the failed LockRequest when 68 {@link com.sleepycat.db.Environment#lockVector Environment.lockVector} was called. 69 */ 70 public int getMode() { 71 return mode; 72 } 73 74 /** 75 Returns the object parameter when {@link com.sleepycat.db.Environment#getLock Environment.getLock} was 76 called, and returns the object for the failed LockRequest when 77 {@link com.sleepycat.db.Environment#lockVector Environment.lockVector} was called. 78 */ 79 public DatabaseEntry getObj() { 80 return obj; 81 } 82 83 /** 84 Returns 0 when {@link com.sleepycat.db.Environment#getLock Environment.getLock} was called, and returns 85 the op parameter for the failed LockRequest when {@link com.sleepycat.db.Environment#lockVector Environment.lockVector} was called. 86 */ 87 public int getOp() { 88 return op; 89 } 90} 91