You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by monstereo <me...@gmail.com> on 2018/07/25 18:29:39 UTC

CacheMetrics does not show the correct results

code that is generated cache values

public static void populateCache(IgniteCache igniteCache){
        for (int i = 0; i < 10000; i++){
            igniteCache.put(i, String.valueOf(i));
        }
    }

    public static void main(String[] args) {
        Ignite node1 = Ignition.start("defaultPath);
       

        CacheConfiguration cacheConfiguration = new CacheConfiguration();
        cacheConfiguration.setName("sampleCache");
        cacheConfiguration.setCacheMode(CacheMode.REPLICATED);
        cacheConfiguration.setStatisticsEnabled(true);
        IgniteCache igniteCache =
node1.getOrCreateCache(cacheConfiguration);

        populateCache(igniteCache);
        System.out.println(igniteCache.size());



Here is the another ignite node :
public static void main(String[] args) throws InterruptedException {
        Ignite node2 =
IgniteFactory.createIgniteNodeWithDefaultConfiguration("s");

        IgniteCache igniteCache = node2.getOrCreateCache("sampleCache");
        CacheMetrics cacheMetrics = igniteCache.metrics();
        System.out.println(cacheMetrics.getOffHeapBackupEntriesCount());


First I run the node1, and wait until see output (cache size)
then, I run the node2, but offheap backup entry count returns 0.
(after a seconds, I run the node2 again (creating new node), then offheap
backup entry count returns 10062 -and other different values)

What is the reason for this?
How can i solve it? (I want to see 10000 backup when I run the node2 first
time)



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: CacheMetrics does not show the correct results

Posted by Evgenii Zhuravlev <e....@gmail.com>.
Ignite updates metrics once in 2 seconds by default, it can be changed by
using
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/IgniteConfiguration.html#setMetricsUpdateFrequency-long-

Evgenii

2018-07-26 14:11 GMT+03:00 monstereo <me...@gmail.com>:

> when i added
>
> TimeUnit.SECONDS.sleep(5);
>
> this line, it solved.
>
> But if we had more datas, maybe sleep time would be larger
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Re: CacheMetrics does not show the correct results

Posted by monstereo <me...@gmail.com>.
when i added

TimeUnit.SECONDS.sleep(5);

this line, it solved.

But if we had more datas, maybe sleep time would be larger



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/