1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1997, 2015 Oracle and/or its affiliates. All rights reserved.
*
* $Id$
*/
package com.sleepycat.db;
import com.sleepycat.db.internal.DbLock;
/**
The LockRequest object is used to encapsulate a single lock request.
*/
public class LockRequest {
private DbLock lock;
private LockRequestMode mode;
private int modeFlag;
private DatabaseEntry obj;
private int op;
private int timeout;
/**
Construct a LockRequest with the specified operation and mode for the
specified object.
<p>
@param mode
The permissions mode for the object.
<p>
@param obj
The object being locked.
<p>
@param op
The operation being performed.
*/
public LockRequest(final LockOperation op,
final LockRequestMode mode,
final DatabaseEntry obj) {
this(op, mode, obj, null, 0);
}
/**
Construct a LockRequest with the specified operation, mode and lock,
for the specified object.
<p>
@param mode
The permissions mode for the object.
<p>
@param obj
The object being locked.
<p>
@param op
The operation being performed.
<p>
@param lock
The lock type for the object.
*/
public LockRequest(final LockOperation op,
final LockRequestMode mode,
final DatabaseEntry obj,
final Lock lock) {
this(op, mode, obj, lock, 0);
}
/**
Construct a LockRequest with the specified operation, mode, lock and
timeout for the specified object.
<p>
@param lock
The lock type for the object.
<p>
@param mode
The permissions mode for the object.
<p>
@param obj
The object being locked.
<p>
@param op
The operation being performed.
<p>
@param timeout
The timeout value for the lock.
*/
public LockRequest(final LockOperation op,
final LockRequestMode mode,
final DatabaseEntry obj,
final Lock lock,
final int timeout) {
this.setOp(op);
this.setMode(mode);
this.setObj(obj);
this.setLock(lock);
this.setTimeout(timeout);
}
/**
Set the lock reference.
<p>
@param lock
The lock reference.
*/
public void setLock(final Lock lock) {
this.lock = (lock == null) ? null : lock.unwrap();
}
/**
Set the lock mode.
<p>
@param mode
the lock mode.
*/
public void setMode(final LockRequestMode mode) {
this.mode = mode;
this.modeFlag = mode.getFlag();
}
/**
Set the lock object.
<p>
@param obj
The lock object.
*/
public void setObj(final DatabaseEntry obj) {
this.obj = obj;
}
/**
Set the operation.
<p>
@param op
The operation.
*/
public void setOp(final LockOperation op) {
this.op = op.getFlag();
}
/**
Set the lock timeout value.
<p>
@param timeout
The lock timeout value.
*/
public void setTimeout(final int timeout) {
this.timeout = timeout;
}
/**
Return the lock reference.
*/
public Lock getLock() {
if (lock != null && lock.wrapper != null)
return lock.wrapper;
else
return Lock.wrap(lock);
}
/**
Return the lock mode.
*/
public LockRequestMode getMode() {
return mode;
}
/**
Return the lock object.
*/
public DatabaseEntry getObj() {
return obj;
}
/**
Return the lock operation.
*/
public LockOperation getOp() {
return LockOperation.fromFlag(op);
}
/**
Return the lock timeout value.
*/
public int getTimeout() {
return timeout;
}
}
|