xref: /illumos-gate/usr/src/cmd/pools/poold/com/sun/solaris/domain/pools/Monitor.java (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 2004 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.domain.pools;
30 
31 import java.util.Map;
32 
33 import com.sun.solaris.service.pools.Configuration;
34 import com.sun.solaris.service.pools.Resource;
35 import com.sun.solaris.service.pools.PoolsException;
36 
37 /**
38  * A monitoring class. The user of this interface can retrieve
39  * monitoring information related to the configuration which is
40  * examined.
41  */
42 
43 public interface Monitor {
44 	/**
45 	 * Initialize the monitoring object using details from the
46 	 * supplied configuration.
47 	 *
48 	 * @param conf The configuration to be monitored.
49 	 * @throws PoolsException If the initialize fails.
50 	 * @throws StaleMonitorException If the resource monitors
51 	 * cannot be accessed.
52 	 */
initialize(Configuration conf)53 	public void initialize(Configuration conf) throws PoolsException,
54 	    StaleMonitorException;
55 
56 	/**
57 	 * Return the next sample.
58 	 *
59 	 * This call is a blocking call. The sample will only be
60 	 * returned after pausing the invoking thread for the "sample
61 	 * interval".
62 	 *
63 	 * @throws StaleMonitorException If the sample fails.
64 	 * @throws PoolsException If there is an error manipulating the
65 	 * pools configuration.
66 	 * @throws InterruptedException If the thread is interrupted
67 	 * while waiting for the sampling time to arrive.  The caller
68 	 * may wish to check other conditions before possibly
69 	 * reinitiating the sample.
70 	 */
getNext()71 	public void getNext() throws StaleMonitorException, PoolsException,
72 	    InterruptedException;
73 
74 	/**
75 	 * Return the number of samples taken.  This is the number of
76 	 * successful calls to <code>getNext()</code>.
77 	 */
getSampleCount()78 	public int getSampleCount();
79 
80 	/**
81 	 * Return the utilization for supplied resource.
82 	 *
83 	 * @param res The resource to be examined.
84 	 *
85 	 * @throws StaleMonitorException if the resource cannot be accessed.
86 	 */
getUtilization(Resource res)87 	public double getUtilization(Resource res) throws StaleMonitorException;
isValid()88 	public boolean isValid();
get(Resource res)89 	public ResourceMonitor get(Resource res) throws StaleMonitorException;
90 }
91 
92 /**
93  * Indicates that a monitor must be re-initialized. This can occur
94  * for a number of reasons, including:
95  *
96  * <ul>
97  * <li><p>
98  * Resources created, modified, destroyed whilst sampling
99  * </ul>
100  */
101 class StaleMonitorException extends Exception {
102 }
103