KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > txn > LockResult


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: LockResult.java,v 1.15 2006/10/30 21:14:27 bostic Exp $
7  */

8
9 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,
46                 boolean abortKnownDeleted,
47                 boolean createdThisTxn) {
48     setAbortLsnInternal(abortLsn, abortKnownDeleted, createdThisTxn);
49     }
50
51     private void setAbortLsnInternal(long abortLsn,
52                      boolean abortKnownDeleted,
53                      boolean createdThisTxn) {
54     /* info can be null if this is called on behalf of a BasicLocker. */
55     if (info != null &&
56         info.neverLocked) {
57         /* Only set if not null, otherwise keep NULL_LSN as abortLsn. */
58         if (abortLsn != DbLsn.NULL_LSN) {
59         info.abortLsn = abortLsn;
60         info.abortKnownDeleted = abortKnownDeleted;
61         }
62         info.createdThisTxn = createdThisTxn;
63         info.neverLocked = false;
64     }
65     }
66 }
67
Popular Tags