ElasticHeapMXBean.java 4.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
/*
 * Copyright (c) 2019 Alibaba Group Holding Limited. All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation. Alibaba designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */

package com.alibaba.management;

import java.lang.management.PlatformManagedObject;
import java.util.List;

/**
 * The ElasticHeapMXBean interface provides APIs for manipulating memory commitment of heap
 */
public interface ElasticHeapMXBean extends PlatformManagedObject {

    /**
     * @return ElasticHeapEvaluationMode of elastic heap
     * @throws UnsupportedOperationException if -XX:+G1ElasticHeap is not enabled
     */
    public ElasticHeapEvaluationMode getEvaluationMode();

    /**
     * Set memory commit percent of young generation in heap
     *
     * @param percent commit percent of young generation to set
     * @throws UnsupportedOperationException if -XX:+G1ElasticHeap is not enabled
     * @throws IllegalStateException if commit percent cannot be set. Error can be gotten by Exception.getMessage()
     * @throws IllegalArgumentException if percent is not 0 or between
     *          ElasticHeapMinYoungCommitPercent(VM option) and 100
     */
    public void setYoungGenCommitPercent(int percent);

    /**
     * @return memory commit percent of young generation percentage in heap
     * (toInt(YoungGenCommitPercent * 100))
     * @throws UnsupportedOperationException if -XX:+G1ElasticHeap is not enabled
     * @throws IllegalStateException if not in command control mode
     */
    public int getYoungGenCommitPercent();

    /**
     * Set memory commit percent of young generation in heap
     *
     * @param percent percent of heap to set to trigger concurrent mark and do memory uncommitment
     * @throws UnsupportedOperationException if -XX:+G1ElasticHeap is not enabled
     * @throws IllegalStateException if IHOP percent cannot be set. Error can be gotten by Exception.getMessage()
     * @throws IllegalArgumentException if percent is not between 0 and 100
     */
    public void setUncommitIHOP(int percent);

    /**
     * @return percent of heap to set to trigger concurrent mark and do memory uncommitment
     * @throws UnsupportedOperationException if -XX:+G1ElasticHeap is not enabled
     * @throws IllegalStateException if not in command control mode
     */
    public int getUncommitIHOP();


    /**
     * @return number of uncommited bytes of young generation in heap
     * @throws UnsupportedOperationException if -XX:+G1ElasticHeap is not enabled
     * @throws IllegalStateException if not in command control mode
     */
    public long getTotalYoungUncommittedBytes();

    /**
     * Set memory commit percent of heap
     *
     * @param percent the percentage of Softmx in Xmx to set
     * @throws UnsupportedOperationException if -XX:+G1ElasticHeap is not enabled
     * @throws IllegalStateException if percent cannot be set. Error can be gotten by Exception.getMessage()
     * @throws IllegalArgumentException if percent is between 0 and 100
     */
    public void setSoftmxPercent(int percent);

    /**
     * @return softmx percent
     * @throws UnsupportedOperationException if -XX:+G1ElasticHeap is not enabled
     * @throws IllegalStateException if not in softmx mode
     */
    public int getSoftmxPercent();

    /**
     * @return number of uncommited bytes of heap
     * @throws UnsupportedOperationException if -XX:+G1ElasticHeap is not enabled
     * @throws IllegalStateException if not in softmx mode
     */
    public long getTotalUncommittedBytes();
}