src/java.management/share/classes/java/lang/management/BufferPoolMXBean.java
author mgronlun
Mon, 28 Oct 2019 21:17:47 +0100
branchJEP-349-branch
changeset 58826 fb51e2ae730e
parent 47216 71c04702a3d5
permissions -rw-r--r--
move stub
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 9013
diff changeset
     2
 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
     4
 *
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1143
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1143
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    10
 *
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    15
 * accompanied this code).
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    16
 *
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1143
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1143
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1143
diff changeset
    23
 * questions.
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    24
 */
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    25
9013
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    26
package java.lang.management;
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    27
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    28
/**
9013
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    29
 * The management interface for a buffer pool, for example a pool of
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    30
 * {@link java.nio.ByteBuffer#allocateDirect direct} or {@link
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    31
 * java.nio.MappedByteBuffer mapped} buffers.
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    32
 *
9013
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    33
 * <p> A class implementing this interface is an
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    34
 * {@link javax.management.MXBean}. A Java
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    35
 * virtual machine has one or more implementations of this interface. The {@link
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    36
 * java.lang.management.ManagementFactory#getPlatformMXBeans getPlatformMXBeans}
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    37
 * method can be used to obtain the list of {@code BufferPoolMXBean} objects
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    38
 * representing the management interfaces for pools of buffers as follows:
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    39
 * <pre>
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    40
 *     List&lt;BufferPoolMXBean&gt; pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    41
 * </pre>
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    42
 *
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    43
 * <p> The management interfaces are also registered with the platform {@link
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    44
 * javax.management.MBeanServer MBeanServer}. The {@link
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    45
 * javax.management.ObjectName ObjectName} that uniquely identifies the
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    46
 * management interface within the {@code MBeanServer} takes the form:
9013
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    47
 * <pre>
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    48
 *     java.nio:type=BufferPool,name=<i>pool name</i>
eedac0b9f552 7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents: 5506
diff changeset
    49
 * </pre>
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    50
 * where <em>pool name</em> is the {@link #getName name} of the buffer pool.
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    51
 *
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    52
 * @since   1.7
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    53
 */
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    54
public interface BufferPoolMXBean extends PlatformManagedObject {
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    55
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    56
    /**
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    57
     * Returns the name representing this buffer pool.
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    58
     *
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    59
     * @return  The name of this buffer pool.
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    60
     */
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    61
    String getName();
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    62
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    63
    /**
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    64
     * Returns an estimate of the number of buffers in the pool.
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    65
     *
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    66
     * @return  An estimate of the number of buffers in this pool
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    67
     */
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    68
    long getCount();
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    69
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    70
    /**
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    71
     * Returns an estimate of the total capacity of the buffers in this pool.
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    72
     * A buffer's capacity is the number of elements it contains and the value
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    73
     * returned by this method is an estimate of the total capacity of buffers
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    74
     * in the pool in bytes.
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    75
     *
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    76
     * @return  An estimate of the total capacity of the buffers in this pool
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    77
     *          in bytes
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    78
     */
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    79
    long getTotalCapacity();
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    80
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    81
    /**
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    82
     * Returns an estimate of the memory that the Java virtual machine is using
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    83
     * for this buffer pool. The value returned by this method may differ
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    84
     * from the estimate of the total {@link #getTotalCapacity capacity} of
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    85
     * the buffers in this pool. This difference is explained by alignment,
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    86
     * memory allocator, and other implementation specific reasons.
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    87
     *
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    88
     * @return  An estimate of the memory that the Java virtual machine is using
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    89
     *          for this buffer pool in bytes, or {@code -1L} if an estimate of
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    90
     *          the memory usage is not available
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    91
     */
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    92
    long getMemoryUsed();
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents:
diff changeset
    93
}