下面列出了java.lang.management.MemoryType#NON_HEAP 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Gets the memory pool statistics from the JVM.
*
* @param poolBeans The collection of memory pool beans.
* @return A string denoting the names and sizes of the memory pools.
*/
public static String getMemoryPoolStatsAsString(List<MemoryPoolMXBean> poolBeans) {
StringBuilder bld = new StringBuilder("Off-heap pool stats: ");
int count = 0;
for (MemoryPoolMXBean bean : poolBeans) {
if (bean.getType() == MemoryType.NON_HEAP) {
if (count > 0) {
bld.append(", ");
}
count++;
MemoryUsage usage = bean.getUsage();
long used = usage.getUsed() >> 20;
long committed = usage.getCommitted() >> 20;
long max = usage.getMax() >> 20;
bld.append('[').append(bean.getName()).append(": ");
bld.append(used).append('/').append(committed).append('/').append(max);
bld.append(" MB (used/committed/max)]");
}
}
return bld.toString();
}
/**
* Gets the memory pool statistics from the JVM.
*
* @param poolBeans The collection of memory pool beans.
* @return A string denoting the names and sizes of the memory pools.
*/
public static String getMemoryPoolStatsAsString(List<MemoryPoolMXBean> poolBeans) {
StringBuilder bld = new StringBuilder("Off-heap pool stats: ");
int count = 0;
for (MemoryPoolMXBean bean : poolBeans) {
if (bean.getType() == MemoryType.NON_HEAP) {
if (count > 0) {
bld.append(", ");
}
count++;
MemoryUsage usage = bean.getUsage();
long used = usage.getUsed() >> 20;
long committed = usage.getCommitted() >> 20;
long max = usage.getMax() >> 20;
bld.append('[').append(bean.getName()).append(": ");
bld.append(used).append('/').append(committed).append('/').append(max);
bld.append(" MB (used/committed/max)]");
}
}
return bld.toString();
}
/**
* Gets the memory pool statistics from the JVM.
*
* @param poolBeans The collection of memory pool beans.
* @return A string denoting the names and sizes of the memory pools.
*/
public static String getMemoryPoolStatsAsString(List<MemoryPoolMXBean> poolBeans) {
StringBuilder bld = new StringBuilder("Off-heap pool stats: ");
int count = 0;
for (MemoryPoolMXBean bean : poolBeans) {
if (bean.getType() == MemoryType.NON_HEAP) {
if (count > 0) {
bld.append(", ");
}
count++;
MemoryUsage usage = bean.getUsage();
long used = usage.getUsed() >> 20;
long committed = usage.getCommitted() >> 20;
long max = usage.getMax() >> 20;
bld.append('[').append(bean.getName()).append(": ");
bld.append(used).append('/').append(committed).append('/').append(max);
bld.append(" MB (used/committed/max)]");
}
}
return bld.toString();
}
/**
* @return Pair of global memstore size and memory type(ie. on heap or off heap).
*/
public static Pair<Long, MemoryType> getGlobalMemStoreSize(Configuration conf) {
long offheapMSGlobal = conf.getLong(OFFHEAP_MEMSTORE_SIZE_KEY, 0);// Size in MBs
if (offheapMSGlobal > 0) {
// Off heap memstore size has not relevance when MSLAB is turned OFF. We will go with making
// this entire size split into Chunks and pooling them in MemstoreLABPoool. We dont want to
// create so many on demand off heap chunks. In fact when this off heap size is configured, we
// will go with 100% of this size as the pool size
if (MemStoreLAB.isEnabled(conf)) {
// We are in offheap Memstore use
long globalMemStoreLimit = (long) (offheapMSGlobal * 1024 * 1024); // Size in bytes
return new Pair<>(globalMemStoreLimit, MemoryType.NON_HEAP);
} else {
// Off heap max memstore size is configured with turning off MSLAB. It makes no sense. Do a
// warn log and go with on heap memstore percentage. By default it will be 40% of Xmx
LOG.warn("There is no relevance of configuring '" + OFFHEAP_MEMSTORE_SIZE_KEY + "' when '"
+ MemStoreLAB.USEMSLAB_KEY + "' is turned off."
+ " Going with on heap global memstore size ('" + MEMSTORE_SIZE_KEY + "')");
}
}
return new Pair<>(getOnheapGlobalMemStoreSize(conf), MemoryType.HEAP);
}
@Override
protected RegionProcedureStore createProcedureStore(Path storeDir) throws IOException {
Pair<Long, MemoryType> pair = MemorySizeUtil.getGlobalMemStoreSize(conf);
long globalMemStoreSize = pair.getFirst();
boolean offheap = pair.getSecond() == MemoryType.NON_HEAP;
float poolSizePercentage = offheap ? 1.0F :
conf.getFloat(MemStoreLAB.CHUNK_POOL_MAXSIZE_KEY, MemStoreLAB.POOL_MAX_SIZE_DEFAULT);
float initialCountPercentage =
conf.getFloat(MemStoreLAB.CHUNK_POOL_INITIALSIZE_KEY, MemStoreLAB.POOL_INITIAL_SIZE_DEFAULT);
int chunkSize = conf.getInt(MemStoreLAB.CHUNK_SIZE_KEY, MemStoreLAB.CHUNK_SIZE_DEFAULT);
ChunkCreator.initialize(chunkSize, offheap, globalMemStoreSize, poolSizePercentage,
initialCountPercentage, null);
conf.setBoolean(MasterRegionFactory.USE_HSYNC_KEY, "hsync".equals(syncType));
CommonFSUtils.setRootDir(conf, storeDir);
MockServer server = new MockServer(conf);
region = MasterRegionFactory.create(server);
return new RegionProcedureStore(server, region, (fs, apth) -> {
});
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
public MemoryType getType() {
if (isHeap) {
return MemoryType.HEAP;
} else {
return MemoryType.NON_HEAP;
}
}
boolean isOffheap() {
return this.memType == MemoryType.NON_HEAP;
}