1<!--$Id: lock_stat.so,v 10.71 2008/03/21 18:20:27 ubell Exp $-->
2<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
3<!--See the file LICENSE for redistribution information.-->
4<html>
5<head>
6<title>Berkeley DB: DbEnv::lock_stat</title>
7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
9</head>
10<body bgcolor=white>
11<table width="100%"><tr valign=top>
12<td>
13<b>DbEnv::lock_stat</b>
14</td>
15<td align=right>
16<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a>
17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
18</tr></table>
19<hr size=1 noshade>
20<tt>
21<b><pre>
22#include &lt;db_cxx.h&gt;
23<p>
24int
25DbEnv::lock_stat(DB_LOCK_STAT **statp, u_int32_t flags);
26<p>
27int
28DbEnv::lock_stat_print(u_int32_t flags);
29</pre></b>
30<hr size=1 noshade>
31<b>Description: DbEnv::lock_stat</b>
32<p>The DbEnv::lock_stat method returns the locking subsystem statistics.</p>
33<p>The DbEnv::lock_stat method creates a statistical structure of type
34DB_LOCK_STAT and copies a pointer to it into a user-specified memory
35location.</p>
36<p>Statistical structures are stored in allocated memory.  If application-specific allocation
37routines have been declared (see <a href="../api_cxx/env_set_alloc.html">DbEnv::set_alloc</a> for more
38information), they are used to allocate the memory; otherwise, the
39standard C library <b>malloc</b>(3) is used.  The caller is
40responsible for deallocating the memory.  To deallocate the memory, free
41the memory reference; references inside the returned memory need not be
42individually freed.</p>
43<p>The following DB_LOCK_STAT fields will be filled in:</p>
44<br>
45<b>u_int32_t st_id;</b><ul compact><li>The last allocated locker ID.</ul>
46<b>u_int32_t st_cur_maxid;</b><ul compact><li>The current maximum unused locker ID.</ul>
47<b>u_int32_t st_nmodes;</b><ul compact><li>The number of lock modes.</ul>
48<b>u_int32_t st_maxlocks;</b><ul compact><li>The maximum number of locks possible.</ul>
49<b>u_int32_t st_maxlockers;</b><ul compact><li>The maximum number of lockers possible.</ul>
50<b>u_int32_t st_maxobjects;</b><ul compact><li>The maximum number of lock objects possible.</ul>
51<b>u_int32_t st_partitions;</b><ul compact><li>The number of lock table partitions.</ul>
52<b>u_int32_t st_nlocks;</b><ul compact><li>The number of current locks.</ul>
53<b>u_int32_t st_maxnlocks;</b><ul compact><li>The maximum number of locks at any one time. Note that if there is more
54than one partition, this is the sum of the maximum across all partitions.</ul>
55<b>u_int32_t st_maxhlocks;</b><ul compact><li>The maximum number of locks in any hash bucket at any one time.</ul>
56<b>u_int32_t st_locksteals;</b><ul compact><li>The maximum number of locks stolen by for an empty partition.</ul>
57<b>u_int32_t st_maxlsteals;</b><ul compact><li>The maximum number of lock steals for any one partition.</ul>
58<b>u_int32_t st_nlockers;</b><ul compact><li>The number of current lockers.</ul>
59<b>u_int32_t st_maxnlockers;</b><ul compact><li>The maximum number of lockers at any one time.</ul>
60<b>u_int32_t st_nobjects;</b><ul compact><li>The number of current lock objects.</ul>
61<b>u_int32_t st_maxnobjects;</b><ul compact><li>The maximum number of lock objects at any one time. Note that if there is more
62than one partition this is the sum of the maximum across all partitions.</ul>
63<b>u_int32_t st_maxhobjects;</b><ul compact><li>The maximum number of objects in any hash bucket at any one time.</ul>
64<b>u_int32_t st_objectsteals;</b><ul compact><li>The maximum number of objects stolen by for an empty partition.</ul>
65<b>u_int32_t st_maxosteals;</b><ul compact><li>The maximum number of object steals for any one partition.</ul>
66<b>u_int32_t st_nrequests;</b><ul compact><li>The total number of locks requested.</ul>
67<b>u_int32_t st_nreleases;</b><ul compact><li>The total number of locks released.</ul>
68<b>u_int32_t st_nupgrade;</b><ul compact><li>The total number of locks upgraded.</ul>
69<b>u_int32_t st_ndowngrade;</b><ul compact><li>The total number of locks downgraded.</ul>
70<b>u_int32_t st_lock_wait;</b><ul compact><li>The number of lock requests not immediately available due to conflicts,
71for which the thread of control waited.</ul>
72<b>u_int32_t st_lock_nowait;</b><ul compact><li>The number of lock requests not immediately available due to conflicts,
73for which the thread of control did not wait.</ul>
74<b>u_int32_t st_ndeadlocks;</b><ul compact><li>The number of deadlocks.</ul>
75<b>u_int32_t st_locktimeout;</b><ul compact><li>Lock timeout value.</ul>
76<b>u_int32_t st_nlocktimeouts;</b><ul compact><li>The number of lock requests that have timed out.</ul>
77<b>u_int32_t st_txntimeout;</b><ul compact><li>Transaction timeout value.</ul>
78<b>u_int32_t st_ntxntimeouts;</b><ul compact><li>The number of transactions that have timed out.  This value is also a
79component of <b>st_ndeadlocks</b>, the total number of deadlocks
80detected.</ul>
81<b>u_int32_t st_objs_wait;</b><ul compact><li>The number of requests to allocate or deallocate an object
82for which the thread of control waited.</ul>
83<b>u_int32_t st_objs_nowait;</b><ul compact><li>The number of requests to allocate or deallocate an object
84for which the thread of control did not wait.</ul>
85<b>u_int32_t st_lockers_wait;</b><ul compact><li>The number of requests to allocate or deallocate a locker
86for which the thread of control waited.</ul>
87<b>u_int32_t st_lockers_nowait;</b><ul compact><li>The number of requests to allocate or deallocate a locker
88for which the thread of control did not wait.</ul>
89<b>u_int32_t st_hash_len;</b><ul compact><li>Maximum length of a lock hash bucket.</ul>
90<b>roff_t st_regsize;</b><ul compact><li>The size of the lock region, in bytes.</ul>
91<b>u_int32_t st_part_wait;</b><ul compact><li>The number of times that a thread of control was forced to wait before
92obtaining the lock partition mutex.</ul>
93<b>u_int32_t st_part_nowait;</b><ul compact><li>The number of times that a thread of control was able to obtain
94the lock partition mutex without waiting.</ul>
95<b>u_int32_t st_part_max_wait;</b><ul compact><li>The maximum number of times that a thread of control was forced to wait before
96obtaining any one lock partition mutex.</ul>
97<b>u_int32_t st_part_max_nowait;</b><ul compact><li>The number of times that a thread of control was able to obtain
98any one lock partition mutex without waiting.</ul>
99<b>u_int32_t st_region_wait;</b><ul compact><li>The number of times that a thread of control was forced to wait before
100obtaining the lock region mutex.</ul>
101<b>u_int32_t st_region_nowait;</b><ul compact><li>The number of times that a thread of control was able to obtain
102the lock region mutex without waiting.</ul>
103<br>
104<p>The DbEnv::lock_stat method may not be called before the <a href="../api_cxx/env_open.html">DbEnv::open</a> method is called.</p>
105<p>The DbEnv::lock_stat method
106either returns a non-zero error value
107or throws an exception that encapsulates a non-zero error value on
108failure, and returns 0 on success.
109</p>
110<b>Parameters</b> <br>
111 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or
112the following value:
113<br>
114<b><a name="DB_STAT_CLEAR">DB_STAT_CLEAR</a></b><ul compact><li>Reset statistics after returning their values.</ul>
115<br></ul>
116 <b>statp</b><ul compact><li>The <b>statp</b> parameter references memory into which
117a pointer to the allocated statistics structure is copied.</ul> 
118<br>
119<br><b>Errors</b>
120<p>The DbEnv::lock_stat method
121may fail and throw
122<a href="../api_cxx/except_class.html">DbException</a>,
123encapsulating one of the following non-zero errors, or return one of
124the following non-zero errors:</p>
125<br>
126<b>EINVAL</b><ul compact><li>An
127invalid flag value or parameter was specified.</ul>
128<br>
129<hr size=1 noshade>
130<b>Description: DbEnv::lock_stat_print</b>
131<p>The DbEnv::lock_stat_print method displays the
132locking subsystem statistical information, as described for the DbEnv::lock_stat method.
133The information is printed to a specified output channel (see the
134<a href="../api_cxx/env_set_msgfile.html">DbEnv::set_msgfile</a> method for more information), or passed to an
135application callback function (see the <a href="../api_cxx/env_set_msgcall.html">DbEnv::set_msgcall</a> method for
136more information).</p>
137<p>The DbEnv::lock_stat_print method may not be called before the <a href="../api_cxx/env_open.html">DbEnv::open</a> method is called.</p>
138<p>The DbEnv::lock_stat_print method
139either returns a non-zero error value
140or throws an exception that encapsulates a non-zero error value on
141failure, and returns 0 on success.
142</p>
143<b>Parameters</b> <br>
144 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one
145or more of the following values:
146<br>
147<b><a name="DB_STAT_ALL">DB_STAT_ALL</a></b><ul compact><li>Display all available information.</ul>
148<b><a name="DB_STAT_CLEAR">DB_STAT_CLEAR</a></b><ul compact><li>Reset statistics after displaying their values.</ul>
149<b><a name="DB_STAT_LOCK_CONF">DB_STAT_LOCK_CONF</a></b><ul compact><li>Display the lock conflict matrix.</ul>
150<b><a name="DB_STAT_LOCK_LOCKERS">DB_STAT_LOCK_LOCKERS</a></b><ul compact><li>Display the lockers within hash chains.</ul>
151<b><a name="DB_STAT_LOCK_OBJECTS">DB_STAT_LOCK_OBJECTS</a></b><ul compact><li>Display the lock objects within hash chains.</ul>
152<b><a name="DB_STAT_LOCK_PARAMS">DB_STAT_LOCK_PARAMS</a></b><ul compact><li>Display the locking subsystem parameters.</ul>
153<br></ul>
154<br>
155<hr size=1 noshade>
156<br><b>Class</b>
157<a href="../api_cxx/env_class.html">DbEnv</a>, <a href="../api_cxx/lock_class.html">DbLock</a>
158<br><b>See Also</b>
159<a href="../api_cxx/lock_list.html">Locking Subsystem and Related Methods</a>
160</tt>
161<table width="100%"><tr><td><br></td><td align=right>
162<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
163</td></tr></table>
164<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
165</body>
166</html>
167