本文整理汇总了Java中java.lang.management.BufferPoolMXBean.getTotalCapacity方法的典型用法代码示例。如果您正苦于以下问题:Java BufferPoolMXBean.getTotalCapacity方法的具体用法?Java BufferPoolMXBean.getTotalCapacity怎么用?Java BufferPoolMXBean.getTotalCapacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.management.BufferPoolMXBean
的用法示例。
在下文中一共展示了BufferPoolMXBean.getTotalCapacity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: check
import java.lang.management.BufferPoolMXBean; //导入方法依赖的package包/类
static void check(List<BufferPoolMXBean> pools,
int minBufferCount,
long minTotalCapacity)
{
int bufferCount = 0;
long totalCap = 0;
long totalMem = 0;
for (BufferPoolMXBean pool: pools) {
bufferCount += pool.getCount();
totalCap += pool.getTotalCapacity();
totalMem += pool.getMemoryUsed();
}
if (bufferCount < minBufferCount)
throw new RuntimeException("Count less than expected");
if (totalMem < minTotalCapacity)
throw new RuntimeException("Memory usage less than expected");
if (totalCap < minTotalCapacity)
throw new RuntimeException("Total capacity less than expected");
}
示例2: heartbeat
import java.lang.management.BufferPoolMXBean; //导入方法依赖的package包/类
@Override
protected void heartbeat() {
// Let them know we are alive
// Print some stats about the ByteBuffers
List<BufferPoolMXBean> byteBufferPools =
ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
String direct = "direct";
String mapped = "mapped";
for (BufferPoolMXBean bean: byteBufferPools) {
if (bean.getName().equalsIgnoreCase(direct)) {
direct += " - " + bean.getMemoryUsed() + "/" + bean.getTotalCapacity();
}
if (bean.getName().equalsIgnoreCase(mapped)) {
mapped += " - " + bean.getMemoryUsed() + "/" + bean.getTotalCapacity();
}
}
logMessage(direct + " , " + mapped);
logMessage("Currently connected clients: " + getConnectedClients().size());
logMessage("Total bytes received : " + bytesReceived);
logMessage("Total clients connected : " + clientsConnected);
logMessage("Total clients disconnected : " + clientsDisconnected);
synchronized (connectionsPerSecond) {
if (!connectionsPerSecond.isEmpty()) {
logMessage("CPS Max: " + Collections.max(connectionsPerSecond.values()) );
}
}
synchronized (connectionsPerMinute) {
if (!connectionsPerMinute.isEmpty()) {
logMessage("CPM Max: " + Collections.max(connectionsPerMinute.values()) );
}
}
logMessage();
}
示例3: BufferPoolMetricSet
import java.lang.management.BufferPoolMXBean; //导入方法依赖的package包/类
BufferPoolMetricSet() {
this.bufferPoolMXBeans = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
List<BufferPoolStatus> bufferPoolStatuses = new ArrayList<>();
Map<String, Metric> metricsByNames = new HashMap<>();
for (final BufferPoolMXBean bufferPoolMXBean : bufferPoolMXBeans) {
final String bufferPoolName = bufferPoolMXBean.getName();
final Gauge<Long> sizeGauge = new Gauge<Long>() {
@Override
public Long getValue() {
return bufferPoolMXBean.getCount();
}
};
metricsByNames.put(MetricNamingUtil.join(bufferPoolName, "size"), sizeGauge);
final Gauge<Long> totalCapacityInBytesGauge = new Gauge<Long>() {
@Override
public Long getValue() {
return bufferPoolMXBean.getTotalCapacity();
}
};
metricsByNames.put(MetricNamingUtil.join(bufferPoolName, "totalCapacityInBytes"), totalCapacityInBytesGauge);
final Gauge<Long> usedMemoryInBytesGauge;
if (bufferPoolMXBean.getMemoryUsed() >= 0) {
usedMemoryInBytesGauge = new Gauge<Long>() {
@Override
public Long getValue() {
return bufferPoolMXBean.getMemoryUsed();
}
};
metricsByNames.put(MetricNamingUtil.join(bufferPoolName, "usedMemoryInBytes"), usedMemoryInBytesGauge);
} else {
usedMemoryInBytesGauge = null;
}
bufferPoolStatuses.add(new BufferPoolStatus() {
@Override
public String getName() {
return bufferPoolName;
}
@Override
public Gauge<Long> getSizeGauge() {
return sizeGauge;
}
@Override
public Gauge<Long> getTotalCapacityInBytesGauge() {
return totalCapacityInBytesGauge;
}
@Override
public Gauge<Long> getUsedMemoryInBytesGauge() {
return usedMemoryInBytesGauge;
}
});
}
this.bufferPoolStatuses = bufferPoolStatuses;
this.metricsByNames = metricsByNames;
}