01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: LockResult.java,v 1.15.2.2 2008/01/07 15:14:17 cwl Exp $
07: */
08:
09: package com.sleepycat.je.txn;
10:
11: import com.sleepycat.je.tree.LN;
12: import com.sleepycat.je.utilint.DbLsn;
13:
14: /**
15: * This class is a container to encapsulate a LockGrantType and a WriteLockInfo
16: * so that they can both be returned from writeLock.
17: */
18: public class LockResult {
19: private LockGrantType grant;
20: private WriteLockInfo info;
21: private LN ln;
22:
23: /* Made public for unittests */
24: public LockResult(LockGrantType grant, WriteLockInfo info) {
25: this .grant = grant;
26: this .info = info;
27: }
28:
29: public LN getLN() {
30: return ln;
31: }
32:
33: public void setLN(LN ln) {
34: this .ln = ln;
35: }
36:
37: public LockGrantType getLockGrant() {
38: return grant;
39: }
40:
41: public void setAbortLsn(long abortLsn, boolean abortKnownDeleted) {
42: setAbortLsnInternal(abortLsn, abortKnownDeleted, false);
43: }
44:
45: public void setAbortLsn(long abortLsn, boolean abortKnownDeleted,
46: boolean createdThisTxn) {
47: setAbortLsnInternal(abortLsn, abortKnownDeleted, createdThisTxn);
48: }
49:
50: private void setAbortLsnInternal(long abortLsn,
51: boolean abortKnownDeleted, boolean createdThisTxn) {
52: /* info can be null if this is called on behalf of a BasicLocker. */
53: if (info != null && info.neverLocked) {
54: /* Only set if not null, otherwise keep NULL_LSN as abortLsn. */
55: if (abortLsn != DbLsn.NULL_LSN) {
56: info.abortLsn = abortLsn;
57: info.abortKnownDeleted = abortKnownDeleted;
58: }
59: info.createdThisTxn = createdThisTxn;
60: info.neverLocked = false;
61: }
62: }
63: }
|