点燃缓存是否以本地模式返回缓存的指标

时间:2018-11-07 16:43:07

标签: ignite gridgain

似乎Ignite不会返回local mode中的缓存指标。

我在Ignite 2.6中用于测试的代码是:

IgniteConfiguration igniteConfig = new IgniteConfiguration();
CacheConfiguration cacheConfig = new CacheConfiguration("testCache");
cacheConfig.setStatisticsEnabled(true);
igniteConfig.setCacheConfiguration(cacheConfig);

for (CacheMode cacheMode : CacheMode.values()) {
    cacheConfig.setCacheMode(cacheMode);
    try (Ignite ignite = Ignition.start(igniteConfig)) {
        IgniteCache cache = ignite.<String, String>getOrCreateCache(cacheConfig.getName());
        System.out.println(cacheMode + " local metrics size before:" + cache.localMetrics().getSize());
        System.out.println(cacheMode + " metrics size before:" + cache.metrics().getSize());
        //adding a sleep just in case it's needed
        Thread.sleep(5000);
        cache.put("key", "val");
        System.out.println(cacheMode + " local metrics size after:" + cache.localMetrics().getSize());
        System.out.println(cacheMode + " metrics size after:" + cache.metrics().getSize());
    }
}

输出显示,对于REPLICATED和PARTITIONED缓存,IgniteCache.metricsIgniteCache.localMetrics都将put设置为1后报告大小,而当缓存处于LOCAL缓存模式时,它们都报告为即使在放置之后也为0。

编辑:一些进一步的调试表明,并非所有指标都缺失。例如使用:

IgniteConfiguration igniteConfig = new IgniteConfiguration();
CacheConfiguration cacheConfig = new CacheConfiguration("testCache");
cacheConfig.setStatisticsEnabled(true);
igniteConfig.setCacheConfiguration(cacheConfig);
cacheConfig.setCacheMode(CacheMode.LOCAL);

try (Ignite ignite = Ignition.start(igniteConfig)) {
    IgniteCache cache = ignite.<String, String>getOrCreateCache(cacheConfig.getName());
    cache.put("key", "val");
    cache.put("key2", "val2");
    cache.remove("key2");

    System.out.println(cache.localMetrics());
}

我得到:

CacheMetricsSnapshot [reads=0, puts=2, hits=0, misses=0, txCommits=0, txRollbacks=0, evicts=0, removes=1, putAvgTimeNanos=8054.916, getAvgTimeNanos=0.0, rmvAvgTimeNanos=3732.072, commitAvgTimeNanos=0.0, rollbackAvgTimeNanos=0.0, cacheName=testCache, offHeapGets=0, offHeapPuts=0, offHeapRemoves=0, offHeapEvicts=0, offHeapHits=0, offHeapMisses=0, offHeapEntriesCnt=1, heapEntriesCnt=0, offHeapPrimaryEntriesCnt=1, offHeapBackupEntriesCnt=1, offHeapAllocatedSize=0, size=0, keySize=0, isEmpty=false, 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, rebalanceClearingPartitionsLeft=0, keyType=java.lang.Object, valType=java.lang.Object, isStoreByVal=true, isStatisticsEnabled=true, isManagementEnabled=false, isReadThrough=false, isWriteThrough=false, isValidForReading=true, isValidForWriting=true]

这表明,“放置和删除”指标似乎可行,但大小为0。

1 个答案:

答案 0 :(得分:0)

看起来它现在不适用于本地缓存。但是,您可以改用offHeapEntriesCnt指标-它显示适当的大小。

我已经创建了用于解决此问题的票证:https://issues.apache.org/jira/browse/IGNITE-10398