|
1 /* |
|
2 * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Sun in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 * have any questions. |
|
24 */ |
|
25 |
|
26 package java.nio; |
|
27 |
|
28 import java.lang.management.PlatformManagedObject; |
|
29 |
|
30 /** |
|
31 * The management interface for a buffer pool. |
|
32 * |
|
33 * <p> A class implementing this interface is an <a href= |
|
34 * "java.lang.management.ManagementFactory.html#MXBean">MXBean</a>. A Java |
|
35 * virtual machine has one or more implementations of this interface. The {@link |
|
36 * java.lang.management.ManagementFactory#getPlatformMXBeans getPlatformMXBeans} |
|
37 * method can be used to obtain the list of {@code BufferPoolMXBean} objects |
|
38 * representing the management interfaces for pools of buffers as follows: |
|
39 * <pre> |
|
40 * List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class); |
|
41 * </pre> |
|
42 * |
|
43 * <p> The management interfaces are also registered with the platform {@link |
|
44 * javax.management.MBeanServer MBeanServer}. The {@link |
|
45 * javax.management.ObjectName ObjectName} that uniquely identifies the |
|
46 * management interface within the {@code MBeanServer} takes the form: |
|
47 * <blockquote> |
|
48 * <tt>java.nio:type=BufferPool</tt><tt>,name=</tt><i>pool name</i> |
|
49 * </blockquote> |
|
50 * where <em>pool name</em> is the {@link #getName name} of the buffer pool. |
|
51 * |
|
52 * @since 1.7 |
|
53 */ |
|
54 |
|
55 public interface BufferPoolMXBean extends PlatformManagedObject { |
|
56 |
|
57 /** |
|
58 * Returns the name representing this buffer pool. |
|
59 * |
|
60 * @return The name of this buffer pool. |
|
61 */ |
|
62 String getName(); |
|
63 |
|
64 /** |
|
65 * Returns an estimate of the number of buffers in the pool. |
|
66 * |
|
67 * @return An estimate of the number of buffers in this pool |
|
68 */ |
|
69 long getCount(); |
|
70 |
|
71 /** |
|
72 * Returns an estimate of the total capacity of the buffers in this pool. |
|
73 * A buffer's capacity is the number of elements it contains and the value |
|
74 * returned by this method is an estimate of the total capacity of buffers |
|
75 * in the pool in bytes. |
|
76 * |
|
77 * @return An estimate of the total capacity of the buffers in this pool |
|
78 * in bytes |
|
79 */ |
|
80 long getTotalCapacity(); |
|
81 |
|
82 /** |
|
83 * Returns an estimate of the memory that the Java virtual machine is using |
|
84 * for this buffer pool. The value returned by this method may differ |
|
85 * from the estimate of the total {@link #getTotalCapacity capacity} of |
|
86 * the buffers in this pool. This difference is explained by alignment, |
|
87 * memory allocator, and other implementation specific reasons. |
|
88 * |
|
89 * @return An estimate of the memory that the Java virtual machine is using |
|
90 * for this buffer pool in bytes, or {@code -1L} if an estimate of |
|
91 * the memory usage is not available |
|
92 */ |
|
93 long getMemoryUsed(); |
|
94 } |