ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Алексей Рябов <ryabo...@gmail.com>
Subject Cache size Ignite 2.0?
Date Tue, 30 May 2017 14:00:21 GMT
Hello,

i am trying to get the offHeap size of my cache. This code:

try (Ignite ignite = Ignition.start()){
    CacheConfiguration<String, BinaryObject> cfg = new CacheConfiguration<>();
    cfg.setName("sample");
    cfg.setStatisticsEnabled(true);
    cfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED);

    IgniteCache<String, BinaryObject> cache =
ignite.getOrCreateCache(cfg).withKeepBinary();
    cache.clear();
    for (int i=0; i<100; i++) {
        BinaryObjectBuilder builder = ignite.binary().builder("sample");
        builder.setField("field1", i*1000);
        builder.setField("field2", i);
        cache.put(Integer.toString(i), builder.build());
    }
    System.out.println("statistics: " + cache.metrics().isStatisticsEnabled());
    System.out.println(cache.metrics().getOffHeapAllocatedSize());
} catch (Exception e) {
    e.printStackTrace();
}


works fine in Ignite version 1.9.0:

...

[16:57:39] Topology snapshot [ver=1, servers=1, clients=0, CPUs=8, heap=3.5GB]
statistics: true
11890
[16:57:39] Ignite node stopped OK [uptime=00:00:00:230]

...

but in 2.0.0 (i commented cout line
cfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED)) methon
getOffHeapAllocatedSize returns zero:

...

[16:59:13] Topology snapshot [ver=1, servers=1, clients=0, CPUs=8, heap=3.5GB]
statistics: true
0
[16:59:22] Ignite node stopped OK [uptime=00:00:08:965]

...

Is there anything special that I should do in 2.0.0 to get the size of my cache?


Thanks a lot,

Aleksey.

Mime
View raw message