package cn.reghao.autodop.common.util.jvm.po;

import cn.reghao.autodop.common.util.ByteConverter;
import cn.reghao.autodop.common.util.ByteType;
import lombok.Data;

import java.lang.management.BufferPoolMXBean;

/**
 * @author reghao
 * @date 2020-10-21 15:49:56
 */
@Data
public class BufferPoolStat {
    private String poolName;
    private long bufferCount;
    private String totalMemory;
    private String usedMemory;

    public BufferPoolStat(BufferPoolMXBean bufferPoolBean) {
        ByteConverter converter = new ByteConverter();
        this.poolName = bufferPoolBean.getName();
        this.bufferCount = bufferPoolBean.getCount();
        this.totalMemory = converter.convert(ByteType.Bytes, bufferPoolBean.getTotalCapacity());
        this.usedMemory = converter.convert(ByteType.Bytes, bufferPoolBean.getMemoryUsed());
    }
}
