xref: /illumos-gate/usr/src/cmd/pools/poold/com/sun/solaris/domain/pools/Solver.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 
30 package com.sun.solaris.domain.pools;
31 
32 import java.util.Set;
33 
34 import com.sun.solaris.service.pools.Configuration;
35 import com.sun.solaris.service.pools.Element;
36 import com.sun.solaris.service.pools.PoolsException;
37 
38 /**
39  * This interface specifies the contract between poold and the poold
40  * allocation algorithms.
41  */
42 
43 public interface Solver {
44 	/**
45 	 * Initialize the solver.
46 	 *
47 	 * @param conf The configuration to be manipulated.
48 	 * @throws PoolsException If the initialization fails.
49 	 */
initialize(Configuration conf)50 	public void initialize(Configuration conf) throws PoolsException;
51 
52 	/**
53 	 * Evaluate whether a workload based reconfiguration is
54 	 * required.
55 	 *
56 	 * @param mon The monitor to be used during examination.
57 	 * @throws PoolsException If the examination fails.
58 	 * @throws StaleMonitorException If the monitor is stale.
59 	 */
examine(Monitor mon)60 	public boolean examine(Monitor mon) throws PoolsException,
61 	    StaleMonitorException;
62 
63 	/**
64 	 * Allocate resources. Return true if a change was made.
65 	 *
66 	 * @throws Exception If the solve fails.
67 	 */
solve()68 	public boolean solve() throws Exception;
69 
70 	/**
71 	 * Return true if all examined resources are capable of
72 	 * providing statistically valid data.
73 	 *
74 	 * If any of the monitored resources have not accumulated
75 	 * enough data to be statistically significant, then this
76 	 * monitor is not ready to be used to obtain data for all
77 	 * resources. In this case, false is returned.
78 	 *
79 	 */
isValid()80 	public boolean isValid();
81 
82 	/**
83 	 * Return a reference to the monitor which this solver is
84 	 * using to provide statistics about the configuration which
85 	 * is to be solved.
86 	 */
getMonitor()87 	public Monitor getMonitor();
88 
89 	/**
90 	 * Return the set of objectives associated with the supplied
91 	 * element.
92 	 *
93 	 * @param elem Retrieve objectives for this element.
94 	 */
getObjectives(Element elem)95 	public Set getObjectives(Element elem);
96 }
97