下面列出了java.util.concurrent.ThreadPoolExecutor#getLargestPoolSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void print(final ThreadPoolExecutor pool) {
System.out.println("==========================================");
final int activeCount = pool.getActiveCount();
System.out.println("activeCount = " + activeCount);
final int corePoolSize = pool.getCorePoolSize();
System.out.println("corePoolSize = " + corePoolSize);
final int largestPoolSize = pool.getLargestPoolSize();
System.out.println("largestPoolSize = " + largestPoolSize);
final int maximumPoolSize = pool.getMaximumPoolSize();
System.out.println("maximumPoolSize = " + maximumPoolSize);
final int poolSize = pool.getPoolSize();
System.out.println("poolSize = " + poolSize);
final int queueSize = pool.getQueue().size();
System.out.println("queueSize = " + queueSize);
final long taskCount = pool.getTaskCount();
System.out.println("taskCount = " + taskCount);
System.out.println("==========================================");
}
ExecutorStateEvent(ExecutorService executor, LeaseCoordinator leaseCoordinator) {
if (executor instanceof ThreadPoolExecutor) {
this.isThreadPoolExecutor = true;
ThreadPoolExecutor ex = (ThreadPoolExecutor) executor;
this.executorName = ex.getClass().getSimpleName();
this.currentQueueSize = ex.getQueue().size();
this.activeThreads = ex.getActiveCount();
this.coreThreads = ex.getCorePoolSize();
this.largestPoolSize = ex.getLargestPoolSize();
this.maximumPoolSize = ex.getMaximumPoolSize();
}
this.leasesOwned = leaseCoordinator.getAssignments().size();
}
public CacheBaseInfo(HeapCache _heapCache, InternalCache _userCache, long now) {
infoCreatedTime = now;
cache = _userCache;
heapCache = _heapCache;
metrics = _heapCache.metrics;
EvictionMetrics em = _heapCache.eviction.getMetrics();
newEntryCnt = em.getNewEntryCount();
expiredRemoveCnt = em.getExpiredRemovedCount();
evictedCnt = em.getEvictedCount();
maxSize = em.getMaxSize();
maxWeight = em.getMaxWeight();
currentWeight = em.getCurrentWeight();
clearedTime = _heapCache.clearedTime;
keyMutationCnt = _heapCache.keyMutationCnt;
removedCnt = em.getRemovedCount();
clearRemovedCnt = _heapCache.clearRemovedCnt;
clearCnt = _heapCache.clearCnt;
internalExceptionCnt = _heapCache.internalExceptionCnt;
evictionRunningCnt = em.getEvictionRunningCount();
integrityState = _heapCache.getIntegrityState();
collisionInfo = new CollisionInfo();
_heapCache.hash.calcHashCollisionInfo(collisionInfo);
extraStatistics = em.getExtraStatistics();
if (extraStatistics.startsWith(", ")) {
extraStatistics = extraStatistics.substring(2);
}
size = heapCache.getLocalSize();
missCnt = metrics.getReadThroughCount() + metrics.getExplicitLoadCount() +
metrics.getPeekHitNotFreshCount() + metrics.getPeekMissCount();
hitCnt = em.getHitCount();
correctedPutCnt = metrics.getPutNewEntryCount() + metrics.getPutHitCount();
if (_heapCache.loaderExecutor instanceof ExclusiveExecutor) {
ThreadPoolExecutor ex = ((ExclusiveExecutor) _heapCache.loaderExecutor).getThreadPoolExecutor();
asyncLoadsInFlight = ex.getActiveCount();
asyncLoadsStarted = ex.getTaskCount();
loaderThreadsLimit = ex.getCorePoolSize();
loaderThreadsMaxActive = ex.getLargestPoolSize();
}
totalLoadCnt = metrics.getReadThroughCount() + metrics.getExplicitLoadCount() +
metrics.getRefreshCount();
}