xref: /illumos-gate/usr/src/cmd/pools/poold/com/sun/solaris/service/kstat/Kstat.java (revision f012ee0c3db17469b492c2cf757226f3d7b1ebbc)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  *
26  * ident	"%Z%%M%	%I%	%E% SMI"
27  */
28 
29 package com.sun.solaris.service.kstat;
30 
31 import com.sun.solaris.service.pools.*;
32 
33 /**
34  * Wraps <code>libkstat(3lib)</code>.  See
35  * <code>/usr/include/sys/kstat.h</code> for details.
36  */
37 public final class Kstat {
38 	/**
39 	 * Pointer to native <code>kstat_ctl_t</code>.
40 	 */
41 	private long kctl;
42 
43 	/**
44 	 * Pointer to native <code>kstat_t</code>.
45 	 */
46 	private long ksp;
47 
48 	Kstat(long kctl, long ksp)
49 	{
50 		this.kctl = kctl;
51 		this.ksp = ksp;
52 	}
53 
54 	/**
55 	 * Returns the kstat's <code>ks_snaptime</code> field.
56 	 */
57 	public native HRTime getSnapTime();
58 
59 	/**
60 	 * Returns the kstat's <code>ks_crtime</code> field.
61 	 */
62 	public native HRTime getCreationTime();
63 
64 	/**
65 	 * Returns the named value -- the value of the named kstat, or
66 	 * field in a raw kstat, as applicable, and available.  Returns
67 	 * <i>null</i> if no such named kstat or field is available.
68 	 *
69 	 * @throws KstatTypeNotSupportedException if the raw kstat is not
70 	 * understood.  (Presenstly, none are.)
71 	 */
72 	public native Object getValue(String name)
73 	    throws KstatTypeNotSupportedException;
74 
75 	/**
76 	 * Invokes <code>kstat_read(3kstat)</code> for tho underlying kstat.
77 	 * Throws KstatException if the native function returns an error.
78 	 */
79 	public native void read() throws KstatReadException;
80 }
81