当前位置: 首页>>代码示例>>Java>>正文


Java BufferPoolMXBean.getMemoryUsed方法代码示例

本文整理汇总了Java中java.lang.management.BufferPoolMXBean.getMemoryUsed方法的典型用法代码示例。如果您正苦于以下问题:Java BufferPoolMXBean.getMemoryUsed方法的具体用法?Java BufferPoolMXBean.getMemoryUsed怎么用?Java BufferPoolMXBean.getMemoryUsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.management.BufferPoolMXBean的用法示例。


在下文中一共展示了BufferPoolMXBean.getMemoryUsed方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: next

import java.lang.management.BufferPoolMXBean; //导入方法依赖的package包/类
@Override
public Object next() {
  if (!beforeFirst) {
    throw new IllegalStateException();
  }
  beforeFirst = false;
  final MemoryInfo memoryInfo = new MemoryInfo();

  final DrillbitEndpoint endpoint = context.getIdentity();
  memoryInfo.hostname = endpoint.getAddress();
  memoryInfo.user_port = endpoint.getUserPort();

  final MemoryUsage heapMemoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
  memoryInfo.heap_current = heapMemoryUsage.getUsed();
  memoryInfo.heap_max = heapMemoryUsage.getMax();

  BufferPoolMXBean directBean = getDirectBean();
  memoryInfo.jvm_direct_current = directBean.getMemoryUsed();


  memoryInfo.direct_current = context.getDrillbitContext().getAllocator().getAllocatedMemory();
  memoryInfo.direct_max = TopLevelAllocator.MAXIMUM_DIRECT_MEMORY;
  return memoryInfo;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:25,代码来源:MemoryIterator.java

示例2: 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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:Basic.java

示例3: next

import java.lang.management.BufferPoolMXBean; //导入方法依赖的package包/类
@Override
public Object next() {
  if (!beforeFirst) {
    throw new IllegalStateException();
  }
  beforeFirst = false;
  final MemoryInfo memoryInfo = new MemoryInfo();

  final NodeEndpoint endpoint = dbContext.getEndpoint();
  memoryInfo.hostname = endpoint.getAddress();
  memoryInfo.fabric_port = endpoint.getFabricPort();

  final MemoryUsage heapMemoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
  memoryInfo.heap_current = heapMemoryUsage.getUsed();
  memoryInfo.heap_max = heapMemoryUsage.getMax();

  BufferPoolMXBean directBean = getDirectBean();
  memoryInfo.jvm_direct_current = directBean.getMemoryUsed();


  memoryInfo.direct_current = dbContext.getAllocator().getAllocatedMemory();
  memoryInfo.direct_max = SabotConfig.getMaxDirectMemory();
  return memoryInfo;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:25,代码来源:MemoryIterator.java

示例4: next

import java.lang.management.BufferPoolMXBean; //导入方法依赖的package包/类
@Override
public Object next() {
  if (!beforeFirst) {
    throw new IllegalStateException();
  }
  beforeFirst = false;
  final MemoryInfo memoryInfo = new MemoryInfo();

  final DrillbitEndpoint endpoint = context.getIdentity();
  memoryInfo.hostname = endpoint.getAddress();
  memoryInfo.user_port = endpoint.getUserPort();

  final MemoryUsage heapMemoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
  memoryInfo.heap_current = heapMemoryUsage.getUsed();
  memoryInfo.heap_max = heapMemoryUsage.getMax();

  BufferPoolMXBean directBean = getDirectBean();
  memoryInfo.jvm_direct_current = directBean.getMemoryUsed();


  memoryInfo.direct_current = context.getDrillbitContext().getAllocator().getAllocatedMemory();
  memoryInfo.direct_max = DrillConfig.getMaxDirectMemory();
  return memoryInfo;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:25,代码来源:MemoryIterator.java

示例5: run

import java.lang.management.BufferPoolMXBean; //导入方法依赖的package包/类
@Override
public void run() {
    try {
        long memoryUsed = 0;
        for (BufferPoolMXBean bufferPool : bufferPools) {
            if (bufferPool.getName().equals("direct")) {
                memoryUsed = bufferPool.getMemoryUsed();
            }
        }

        Counter counter = new Counter(ValueType.VALUE);
        counter.set(memoryUsed);
        check(counter, config.getDescription(), "Allocate more direct memory. ");
    } catch (Exception x) {
        // TODO what?
    }
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:18,代码来源:DirectBufferHealthChecker.java

示例6: 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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:39,代码来源:EchoServer.java

示例7: 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;
}
 
开发者ID:centro,项目名称:monitoring-center,代码行数:65,代码来源:BufferPoolMetricSet.java


注:本文中的java.lang.management.BufferPoolMXBean.getMemoryUsed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。