1 /*
2  * Copyright (c) 2007, 2011, Oracle and/or its affiliates. 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.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 package java.lang.management;
27 
28 /**
29  * The management interface for a buffer pool, for example a pool of
30  * {@link java.nio.ByteBuffer#allocateDirect direct} or {@link
31  * java.nio.MappedByteBuffer mapped} buffers.
32  *
33  * <p> A class implementing this interface is an
34  * {@link javax.management.MXBean}. 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&lt;BufferPoolMXBean&gt; 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  * <pre>
48  *     java.nio:type=BufferPool,name=<i>pool name</i>
49  * </pre>
50  * where <em>pool name</em> is the {@link #getName name} of the buffer pool.
51  *
52  * @since   1.7
53  */
54 public interface BufferPoolMXBean extends PlatformManagedObject {
55 
56     /**
57      * Returns the name representing this buffer pool.
58      *
59      * @return  The name of this buffer pool.
60      */
getName()61     String getName();
62 
63     /**
64      * Returns an estimate of the number of buffers in the pool.
65      *
66      * @return  An estimate of the number of buffers in this pool
67      */
getCount()68     long getCount();
69 
70     /**
71      * Returns an estimate of the total capacity of the buffers in this pool.
72      * A buffer's capacity is the number of elements it contains and the value
73      * returned by this method is an estimate of the total capacity of buffers
74      * in the pool in bytes.
75      *
76      * @return  An estimate of the total capacity of the buffers in this pool
77      *          in bytes
78      */
getTotalCapacity()79     long getTotalCapacity();
80 
81     /**
82      * Returns an estimate of the memory that the Java virtual machine is using
83      * for this buffer pool. The value returned by this method may differ
84      * from the estimate of the total {@link #getTotalCapacity capacity} of
85      * the buffers in this pool. This difference is explained by alignment,
86      * memory allocator, and other implementation specific reasons.
87      *
88      * @return  An estimate of the memory that the Java virtual machine is using
89      *          for this buffer pool in bytes, or {@code -1L} if an estimate of
90      *          the memory usage is not available
91      */
getMemoryUsed()92     long getMemoryUsed();
93 }
94