/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * ident "%Z%%M% %I% %E% SMI" */ package com.sun.solaris.service.kstat; /** * kstat controlling object. Allows kstats to be looked up * so they can later be sampled. */ public final class KstatCtl { static { System.loadLibrary("jkstat"); KstatCtl.init(); } /** * Pointer to a kstat_ctl_t. */ private long kctl; /** * Invokes kstat_open(3KSTAT). The returned object * should be explicitly finalized when it's no longer needed. */ public KstatCtl() { kctl = open(); assert(kctl != 0); } /** * Calls kstat_close(3KSTAT). */ public void finalize() { close(kctl); kctl = 0; } /** * Invokes kstat_open(3KSTAT). */ private native long open(); /** * Invokes kstat_close(3KSTAT). */ private native int close(long kctl); /** * Invokes kstat_lookup(3KSTAT) and returns a Kstat * for any result, or null if none is found. */ public native Kstat lookup(String module, int instance, String name); /** * Invokes kstat_chain_update(3KSTAT). * * @throws KstatChainUpdateException if the native function * returns -1. */ public native void chainUpdate() throws KstatChainUpdateException; /** * Initialize cached class, method, and field IDs. */ private static native void init(); }