KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > LockStats


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

8
9 package com.sleepycat.je;
10
11 import java.io.Serializable JavaDoc;
12
13 import com.sleepycat.je.latch.LatchStats;
14
15 /**
16  * Javadoc for this public class is generated
17  * via the doc templates in the doc_src directory.
18  */

19 public class LockStats implements Serializable JavaDoc {
20
21     /**
22      * Total locks currently in lock table.
23      */

24     private int nTotalLocks;
25
26     /**
27      * Total read locks currently held.
28      */

29     private int nReadLocks;
30
31     /**
32      * Total write locks currently held.
33      */

34     private int nWriteLocks;
35
36     /**
37      * Total transactions waiting for locks.
38      */

39     private int nWaiters;
40
41     /**
42      * Total lock owners in lock table.
43      */

44     private int nOwners;
45
46     /**
47      * Number of times a lock request was made.
48      */

49     private long nRequests;
50
51     /**
52      * Number of times a lock request blocked.
53      */

54     private long nWaits;
55
56     /**
57      * LockTable latch stats.
58      */

59     private LatchStats lockTableLatchStats;
60
61     /**
62      * Javadoc for this public method is generated via
63      * the doc templates in the doc_src directory.
64      */

65     public int getNOwners() {
66         return nOwners;
67     }
68
69     /**
70      * Javadoc for this public method is generated via
71      * the doc templates in the doc_src directory.
72      */

73     public int getNReadLocks() {
74         return nReadLocks;
75     }
76
77     /**
78      * Javadoc for this public method is generated via
79      * the doc templates in the doc_src directory.
80      */

81     public int getNTotalLocks() {
82         return nTotalLocks;
83     }
84
85     /**
86      * Javadoc for this public method is generated via
87      * the doc templates in the doc_src directory.
88      */

89     public int getNWaiters() {
90         return nWaiters;
91     }
92
93     /**
94      * Javadoc for this public method is generated via
95      * the doc templates in the doc_src directory.
96      */

97     public int getNWriteLocks() {
98         return nWriteLocks;
99     }
100
101     /**
102      * Javadoc for this public method is generated via
103      * the doc templates in the doc_src directory.
104      */

105     public long getNRequests() {
106         return nRequests;
107     }
108
109     /**
110      * Javadoc for this public method is generated via
111      * the doc templates in the doc_src directory.
112      */

113     public long getNWaits() {
114         return nWaits;
115     }
116
117     /**
118      * Internal use only.
119      */

120     public void setNOwners(int val) {
121         nOwners = val;
122     }
123
124     /**
125      * Internal use only.
126      */

127     public void setNReadLocks(int val) {
128         nReadLocks = val;
129     }
130
131     /**
132      * Internal use only.
133      */

134     public void accumulateNTotalLocks(int val) {
135         nTotalLocks += val;
136     }
137
138     /**
139      * Internal use only.
140      */

141     public void setNWaiters(int val) {
142         nWaiters = val;
143     }
144
145     /**
146      * Internal use only.
147      */

148     public void setNWriteLocks(int val) {
149         nWriteLocks = val;
150     }
151
152     /**
153      * Internal use only.
154      */

155     public void setNRequests(long requests) {
156         this.nRequests = requests;
157     }
158
159     /**
160      * Internal use only.
161      */

162     public void setNWaits(long waits) {
163         this.nWaits = waits;
164     }
165
166     /**
167      * Internal use only.
168      */

169     public void accumulateLockTableLatchStats(LatchStats latchStats) {
170     if (lockTableLatchStats == null) {
171         lockTableLatchStats = latchStats;
172         return;
173     }
174
175         lockTableLatchStats.nAcquiresNoWaiters +=
176         latchStats.nAcquiresNoWaiters;
177         lockTableLatchStats.nAcquiresSelfOwned +=
178         latchStats.nAcquiresSelfOwned;
179         lockTableLatchStats.nAcquiresUpgrade +=
180         latchStats.nAcquiresUpgrade;
181         lockTableLatchStats.nAcquiresWithContention +=
182         latchStats.nAcquiresWithContention;
183         lockTableLatchStats.nAcquireNoWaitSuccessful +=
184         latchStats.nAcquireNoWaitSuccessful;
185         lockTableLatchStats.nAcquireNoWaitUnsuccessful +=
186         latchStats.nAcquireNoWaitUnsuccessful;
187         lockTableLatchStats.nAcquireSharedSuccessful +=
188         latchStats.nAcquireSharedSuccessful;
189     }
190
191     /**
192      * Javadoc for this public method is generated via
193      * the doc templates in the doc_src directory.
194      */

195     public String JavaDoc toString() {
196         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
197         sb.append("nTotalLocks=").append(nTotalLocks).append('\n');
198         sb.append("nReadLocks=").append(nReadLocks).append('\n');
199         sb.append("nWriteLocks=").append(nWriteLocks).append('\n');
200         sb.append("nWaiters=").append(nWaiters).append('\n');
201         sb.append("nOwners=").append(nOwners).append('\n');
202         sb.append("nRequests=").append(nRequests).append('\n');
203         sb.append("nWaits=").append(nWaits).append('\n');
204         sb.append("lockTableLatch:\n").append(lockTableLatchStats);
205         return sb.toString();
206     }
207 }
208
Popular Tags