public CacheMetricsSnapshot(CacheMetrics loc,Collection<CacheMetrics> metrics){
  cacheName=loc.name();
  isEmpty=loc.isEmpty();
  isWriteBehindEnabled=loc.isWriteBehindEnabled();
  writeBehindFlushSize=loc.getWriteBehindFlushSize();
  writeBehindFlushThreadCnt=loc.getWriteBehindFlushThreadCount();
  writeBehindFlushFreq=loc.getWriteBehindFlushFrequency();
  writeBehindStoreBatchSize=loc.getWriteBehindStoreBatchSize();
  writeBehindBufSize=loc.getWriteBehindBufferSize();
  size=loc.getSize();
  keySize=loc.getKeySize();
  keyType=loc.getKeyType();
  valType=loc.getValueType();
  isStoreByVal=loc.isStoreByValue();
  isStatisticsEnabled=loc.isStatisticsEnabled();
  isManagementEnabled=loc.isManagementEnabled();
  isReadThrough=loc.isReadThrough();
  isWriteThrough=loc.isWriteThrough();
  offHeapMaxSize=loc.getOffHeapMaxSize();
  for (  CacheMetrics e : metrics) {
    reads+=e.getCacheGets();
    puts+=e.getCachePuts();
    hits+=e.getCacheHits();
    misses+=e.getCacheMisses();
    txCommits+=e.getCacheTxCommits();
    txRollbacks+=e.getCacheTxRollbacks();
    evicts+=e.getCacheEvictions();
    removes+=e.getCacheRemovals();
    putAvgTimeNanos+=e.getAveragePutTime();
    getAvgTimeNanos+=e.getAverageGetTime();
    rmvAvgTimeNanos+=e.getAverageRemoveTime();
    commitAvgTimeNanos+=e.getAverageTxCommitTime();
    rollbackAvgTimeNanos+=e.getAverageTxRollbackTime();
    if (e.getOverflowSize() > -1)     overflowSize+=e.getOverflowSize();
 else     overflowSize=-1;
    offHeapGets+=e.getOffHeapGets();
    offHeapPuts+=e.getOffHeapPuts();
    offHeapRemoves+=e.getOffHeapRemovals();
    offHeapEvicts+=e.getOffHeapEvictions();
    offHeapHits+=e.getOffHeapHits();
    offHeapMisses+=e.getOffHeapMisses();
    offHeapEntriesCnt+=e.getOffHeapEntriesCount();
    offHeapPrimaryEntriesCnt+=e.getOffHeapPrimaryEntriesCount();
    offHeapBackupEntriesCnt+=e.getOffHeapBackupEntriesCount();
    offHeapAllocatedSize+=e.getOffHeapAllocatedSize();
    swapGets+=e.getSwapGets();
    swapPuts+=e.getSwapPuts();
    swapRemoves+=e.getSwapRemovals();
    swapHits+=e.getSwapHits();
    swapMisses+=e.getSwapMisses();
    swapEntriesCnt+=e.getSwapEntriesCount();
    swapSize+=e.getSwapSize();
    if (e.getDhtEvictQueueCurrentSize() > -1)     dhtEvictQueueCurrSize+=e.getDhtEvictQueueCurrentSize();
 else     dhtEvictQueueCurrSize=-1;
    txThreadMapSize+=e.getTxThreadMapSize();
    txXidMapSize+=e.getTxXidMapSize();
    txCommitQueueSize+=e.getTxCommitQueueSize();
    txPrepareQueueSize+=e.getTxPrepareQueueSize();
    txStartVerCountsSize+=e.getTxStartVersionCountsSize();
    txCommittedVersionsSize+=e.getTxCommittedVersionsSize();
    txRolledbackVersionsSize+=e.getTxRolledbackVersionsSize();
    if (e.getTxDhtThreadMapSize() > -1)     txDhtThreadMapSize+=e.getTxDhtThreadMapSize();
 else     txDhtThreadMapSize=-1;
    if (e.getTxDhtXidMapSize() > -1)     txDhtXidMapSize+=e.getTxDhtXidMapSize();
 else     txDhtXidMapSize=-1;
    if (e.getTxDhtCommitQueueSize() > -1)     txDhtCommitQueueSize+=e.getTxDhtCommitQueueSize();
 else     txDhtCommitQueueSize=-1;
    if (e.getTxDhtPrepareQueueSize() > -1)     txDhtPrepareQueueSize+=e.getTxDhtPrepareQueueSize();
 else     txDhtPrepareQueueSize=-1;
    if (e.getTxDhtStartVersionCountsSize() > -1)     txDhtStartVerCountsSize+=e.getTxDhtStartVersionCountsSize();
 else     txDhtStartVerCountsSize=-1;
    if (e.getTxDhtCommittedVersionsSize() > -1)     txDhtCommittedVersionsSize+=e.getTxDhtCommittedVersionsSize();
 else     txDhtCommittedVersionsSize=-1;
    if (e.getTxDhtRolledbackVersionsSize() > -1)     txDhtRolledbackVersionsSize+=e.getTxDhtRolledbackVersionsSize();
 else     txDhtRolledbackVersionsSize=-1;
    if (e.getWriteBehindTotalCriticalOverflowCount() > -1)     writeBehindTotalCriticalOverflowCnt+=e.getWriteBehindTotalCriticalOverflowCount();
 else     writeBehindTotalCriticalOverflowCnt=-1;
    if (e.getWriteBehindCriticalOverflowCount() > -1)     writeBehindCriticalOverflowCnt+=e.getWriteBehindCriticalOverflowCount();
 else     writeBehindCriticalOverflowCnt=-1;
    if (e.getWriteBehindErrorRetryCount() > -1)     writeBehindErrorRetryCnt+=e.getWriteBehindErrorRetryCount();
 else     writeBehindErrorRetryCnt=-1;
  }
  int size=metrics.size();
  if (size > 1) {
    putAvgTimeNanos/=size;
    getAvgTimeNanos/=size;
    rmvAvgTimeNanos/=size;
    commitAvgTimeNanos/=size;
    rollbackAvgTimeNanos/=size;
  }
}

public CacheMetricsSnapshot ( CacheMetrics loc , Collection < CacheMetrics > metrics ) { cacheName = loc . name ( ) ; isEmpty = loc . isEmpty ( ) ; isWriteBehindEnabled = loc . isWriteBehindEnabled ( ) ; writeBehindFlushSize = loc . getWriteBehindFlushSize ( ) ; writeBehindFlushThreadCnt = loc . getWriteBehindFlushThreadCount ( ) ; writeBehindFlushFreq = loc . getWriteBehindFlushFrequency ( ) ; writeBehindStoreBatchSize = loc . getWriteBehindStoreBatchSize ( ) ; writeBehindBufSize = loc . getWriteBehindBufferSize ( ) ; size = loc . getSize ( ) ; keySize = loc . getKeySize ( ) ; keyType = loc . getKeyType ( ) ; valType = loc . getValueType ( ) ; isStoreByVal = loc . isStoreByValue ( ) ; isStatisticsEnabled = loc . isStatisticsEnabled ( ) ; isManagementEnabled = loc . isManagementEnabled ( ) ; isReadThrough = loc . isReadThrough ( ) ; isWriteThrough = loc . isWriteThrough ( ) ; offHeapMaxSize = loc . getOffHeapMaxSize ( ) ; for ( CacheMetrics e : metrics ) { reads += e . getCacheGets ( ) ; puts += e . getCachePuts ( ) ; hits += e . getCacheHits ( ) ; misses += e . getCacheMisses ( ) ; txCommits += e . getCacheTxCommits ( ) ; txRollbacks += e . getCacheTxRollbacks ( ) ; evicts += e . getCacheEvictions ( ) ; removes += e . getCacheRemovals ( ) ; putAvgTimeNanos += e . getAveragePutTime ( ) ; getAvgTimeNanos += e . getAverageGetTime ( ) ; rmvAvgTimeNanos += e . getAverageRemoveTime ( ) ; commitAvgTimeNanos += e . getAverageTxCommitTime ( ) ; rollbackAvgTimeNanos += e . getAverageTxRollbackTime ( ) ; if ( e . getOverflowSize ( ) > - 1 ) overflowSize += e . getOverflowSize ( ) ; else overflowSize = - 1 ; offHeapGets += e . getOffHeapGets ( ) ; offHeapPuts += e . getOffHeapPuts ( ) ; offHeapRemoves += e . getOffHeapRemovals ( ) ; offHeapEvicts += e . getOffHeapEvictions ( ) ; offHeapHits += e . getOffHeapHits ( ) ; offHeapMisses += e . getOffHeapMisses ( ) ; offHeapEntriesCnt += e . getOffHeapEntriesCount ( ) ; offHeapPrimaryEntriesCnt += e . getOffHeapPrimaryEntriesCount ( ) ; offHeapBackupEntriesCnt += e . getOffHeapBackupEntriesCount ( ) ; offHeapAllocatedSize += e . getOffHeapAllocatedSize ( ) ; swapGets += e . getSwapGets ( ) ; swapPuts += e . getSwapPuts ( ) ; swapRemoves += e . getSwapRemovals ( ) ; swapHits += e . getSwapHits ( ) ; swapMisses += e . getSwapMisses ( ) ; swapEntriesCnt += e . getSwapEntriesCount ( ) ; swapSize += e . getSwapSize ( ) ; if ( e . getDhtEvictQueueCurrentSize ( ) > - 1 ) dhtEvictQueueCurrSize += e . getDhtEvictQueueCurrentSize ( ) ; else dhtEvictQueueCurrSize = - 1 ; txThreadMapSize += e . getTxThreadMapSize ( ) ; txXidMapSize += e . getTxXidMapSize ( ) ; txCommitQueueSize += e . getTxCommitQueueSize ( ) ; txPrepareQueueSize += e . getTxPrepareQueueSize ( ) ; txStartVerCountsSize += e . getTxStartVersionCountsSize ( ) ; txCommittedVersionsSize += e . getTxCommittedVersionsSize ( ) ; txRolledbackVersionsSize += e . getTxRolledbackVersionsSize ( ) ; if ( e . getTxDhtThreadMapSize ( ) > - 1 ) txDhtThreadMapSize += e . getTxDhtThreadMapSize ( ) ; else txDhtThreadMapSize = - 1 ; if ( e . getTxDhtXidMapSize ( ) > - 1 ) txDhtXidMapSize += e . getTxDhtXidMapSize ( ) ; else txDhtXidMapSize = - 1 ; if ( e . getTxDhtCommitQueueSize ( ) > - 1 ) txDhtCommitQueueSize += e . getTxDhtCommitQueueSize ( ) ; else txDhtCommitQueueSize = - 1 ; if ( e . getTxDhtPrepareQueueSize ( ) > - 1 ) txDhtPrepareQueueSize += e . getTxDhtPrepareQueueSize ( ) ; else txDhtPrepareQueueSize = - 1 ; if ( e . getTxDhtStartVersionCountsSize ( ) > - 1 ) txDhtStartVerCountsSize += e . getTxDhtStartVersionCountsSize ( ) ; else txDhtStartVerCountsSize = - 1 ; if ( e . getTxDhtCommittedVersionsSize ( ) > - 1 ) txDhtCommittedVersionsSize += e . getTxDhtCommittedVersionsSize ( ) ; else txDhtCommittedVersionsSize = - 1 ; if ( e . getTxDhtRolledbackVersionsSize ( ) > - 1 ) txDhtRolledbackVersionsSize += e . getTxDhtRolledbackVersionsSize ( ) ; else txDhtRolledbackVersionsSize = - 1 ; if ( e . getWriteBehindTotalCriticalOverflowCount ( ) > - 1 ) writeBehindTotalCriticalOverflowCnt += e . getWriteBehindTotalCriticalOverflowCount ( ) ; else writeBehindTotalCriticalOverflowCnt = - 1 ; if ( e . getWriteBehindCriticalOverflowCount ( ) > - 1 ) writeBehindCriticalOverflowCnt += e . getWriteBehindCriticalOverflowCount ( ) ; else writeBehindCriticalOverflowCnt = - 1 ; if ( e . getWriteBehindErrorRetryCount ( ) > - 1 ) writeBehindErrorRetryCnt += e . getWriteBehindErrorRetryCount ( ) ; else writeBehindErrorRetryCnt = - 1 ; } int size = metrics . size ( ) ; if ( size > 1 ) { putAvgTimeNanos /= size ; getAvgTimeNanos /= size ; rmvAvgTimeNanos /= size ; commitAvgTimeNanos /= size ; rollbackAvgTimeNanos /= size ; } }
constructs merged cache metrics .
