Apache Ignite Near Cache - 本地缓存指标

时间:2017-12-13 05:55:34

标签: ignite

我一直在尝试使用Ignite Near Caches。这样做我在群集中配置了两个服务器节点的客户端节点。我实例化了一个近缓存,并希望看到缓存命中/未命中的相关指标。功能上一切正常,但我无法确定近缓存指标的位置。

我尝试通过调用

提取缓存指标
NearCacheConfiguration<Integer, Integer> nearCfg = 
    new NearCacheConfiguration<>();

nearCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(100));
nearCfg.setNearStartSize(50);

IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(
    new CacheConfiguration<Integer, Integer>("myCache"), nearCfg);
// run some cache puts and gets
for (int i=0; i<10000; i++) { cache.put(i, i); }
for (int i=0; i<10000; i++) { cache.get(i); }

// then try to retrieve metrics
System.out.println(cache.localMetrics());
System.out.println(cache.metrics());

输出

CacheMetricsSnapshot [reads=0, puts=0, hits=0, misses=0, txCommits=0, txRollbacks=0, evicts=0, removes=0, putAvgTimeNanos=0.0, getAvgTimeNanos=0.0, rmvAvgTimeNanos=0.0, commitAvgTimeNanos=0.0, rollbackAvgTimeNanos=0.0, cacheName=myCache, offHeapGets=0, offHeapPuts=0, offHeapRemoves=0, offHeapEvicts=0, offHeapHits=0, offHeapMisses=0, offHeapEntriesCnt=0, heapEntriesCnt=0, offHeapPrimaryEntriesCnt=0, offHeapBackupEntriesCnt=0, offHeapAllocatedSize=0, size=0, keySize=0, isEmpty=true, dhtEvictQueueCurrSize=0, txThreadMapSize=0, txXidMapSize=0, txCommitQueueSize=0, txPrepareQueueSize=0, txStartVerCountsSize=0, txCommittedVersionsSize=0, txRolledbackVersionsSize=0, txDhtThreadMapSize=0, txDhtXidMapSize=0, txDhtCommitQueueSize=0, txDhtPrepareQueueSize=0, txDhtStartVerCountsSize=0, txDhtCommittedVersionsSize=0, txDhtRolledbackVersionsSize=0, isWriteBehindEnabled=false, writeBehindFlushSize=-1, writeBehindFlushThreadCnt=-1, writeBehindFlushFreq=-1, writeBehindStoreBatchSize=-1, writeBehindTotalCriticalOverflowCnt=0, writeBehindCriticalOverflowCnt=0, writeBehindErrorRetryCnt=0, writeBehindBufSize=-1, totalPartitionsCnt=0, rebalancingPartitionsCnt=0, keysToRebalanceLeft=0, rebalancingKeysRate=0, rebalancingBytesRate=0, rebalanceStartTime=0, rebalanceFinishTime=0, keyType=java.lang.Object, valType=java.lang.Object, isStoreByVal=true, isStatisticsEnabled=false, isManagementEnabled=false, isReadThrough=false, isWriteThrough=false, isValidForReading=true, isValidForWriting=true]
CacheMetricsSnapshot [reads=0, puts=0, hits=0, misses=0, txCommits=0, txRollbacks=0, evicts=0, removes=0, putAvgTimeNanos=0.0, getAvgTimeNanos=0.0, rmvAvgTimeNanos=0.0, commitAvgTimeNanos=0.0, rollbackAvgTimeNanos=0.0, cacheName=myCache, offHeapGets=0, offHeapPuts=0, offHeapRemoves=0, offHeapEvicts=0, offHeapHits=0, offHeapMisses=0, offHeapEntriesCnt=0, heapEntriesCnt=100, offHeapPrimaryEntriesCnt=0, offHeapBackupEntriesCnt=0, offHeapAllocatedSize=0, size=0, keySize=0, isEmpty=true, dhtEvictQueueCurrSize=-1, txThreadMapSize=0, txXidMapSize=0, txCommitQueueSize=0, txPrepareQueueSize=0, txStartVerCountsSize=0, txCommittedVersionsSize=0, txRolledbackVersionsSize=0, txDhtThreadMapSize=0, txDhtXidMapSize=-1, txDhtCommitQueueSize=0, txDhtPrepareQueueSize=0, txDhtStartVerCountsSize=0, txDhtCommittedVersionsSize=-1, txDhtRolledbackVersionsSize=-1, isWriteBehindEnabled=false, writeBehindFlushSize=-1, writeBehindFlushThreadCnt=-1, writeBehindFlushFreq=-1, writeBehindStoreBatchSize=-1, writeBehindTotalCriticalOverflowCnt=-1, writeBehindCriticalOverflowCnt=-1, writeBehindErrorRetryCnt=-1, writeBehindBufSize=-1, totalPartitionsCnt=0, rebalancingPartitionsCnt=0, keysToRebalanceLeft=0, rebalancingKeysRate=0, rebalancingBytesRate=0, rebalanceStartTime=-1, rebalanceFinishTime=-1, keyType=java.lang.Object, valType=java.lang.Object, isStoreByVal=true, isStatisticsEnabled=false, isManagementEnabled=false, isReadThrough=false, isWriteThrough=false, isValidForReading=true, isValidForWriting=true]

看起来没有有意义的指标。我认为它可能是配置统计信息的NearCacheConfiguration的一部分,就像CacheConfiguration一样,但没有。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我明白了。我错过了传递给igniteCache对象的CacheConfiguration。

代码段是:

Sub imd_data()

    Dim IE As New InternetExplorer, html As HTMLDocument, ele As Object

    With IE
        .Visible = True
        .navigate "http://www.imdb.com/"
        Do Until .readyState = READYSTATE_COMPLETE: Loop
        Set html = .document
    End With

    html.getElementById("navbar-query").Value = "Blood Diamond"
    html.getElementById("navbar-submit-button").Click
    Application.Wait Now + TimeValue("00:00:05")
    html.getElementsByClassName("result_text")(0).getElementsByTagName("a")(0).Click
    Application.Wait Now + TimeValue("00:00:05")

    For Each ele In html.getElementsByClassName("imdbRating")
        With ele.getElementsByClassName("ratingValue")
            If .Length Then r = r + 1: Cells(r, 1) = .Item(0).innerText
        End With
        With ele.getElementsByClassName("small")
            If .Length Then Cells(r, 2) = .Item(0).innerText
        End With
    Next ele

    IE.Quit
End Sub

运行所有缓存操作后,我现在看到统计信息。