I an using Ignite's Data Grid and wanted to test the off heap tiered mode. I have 1 server and 1 client as part of the grid on different machines. Here are the steps that I follow to create the cache :
The strange thing that I encounter is that not even a single entry is stored off heap. The visor shows all the entries in the client and on the server being stored on heap. But, if I do not a use a near cache then, all the entries are stored in off heap.
I want to know whether this a problem with the statistics shown by the visor or is there a change in behavior of Ignite storing entries when a near cache is enabled.
This is my Client Side Code
public class IgniteClient {
public static void main(String[] args) {
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
// IP has not been shown intentionally
ipFinder.setAddresses(Arrays.asList("*.*.*.*"));
TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setIpFinder(ipFinder);
IgniteConfiguration icfg = new IgniteConfiguration();
icfg.setMetricsUpdateFrequency(-1);
icfg.setClientMode(true);
Ignite grid = Ignition.start(icfg);
CacheConfiguration<Integer, String> ccfg = new CacheConfiguration<Integer, String>();
NearCacheConfiguration<Integer, String> ncfg = new NearCacheConfiguration<>();
ccfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED);
ccfg.setOffHeapMaxMemory(0);
ccfg.setName("data");
ncfg.setNearStartSize(1000);
IgniteCache<Integer, String> dataCache = grid.getOrCreateCache(ccfg, ncfg);
for (int i = 1; i <= 10000; i++) {
dataCache.put(i, Integer.toString(i));
}
System.out.println("The entries in data cache are " + dataCache.size(CachePeekMode.ALL));
}
}
This is my Server Side Code
public class IgniteMain {
public static void main(String[] args) {
IgniteConfiguration icfg = new IgniteConfiguration();
icfg.setMetricsUpdateFrequency(-1);
Ignite grid = Ignition.start(icfg);
}
}
This is the output of the command 'cache' on the Ignite visor which is running on the client machine
Time of the snapshot: 01/28/17, 18:23:41
+===================================================================================================================+
| Name(@) | Mode | Nodes | Entries (Heap / Off heap) | Hits | Misses | Reads | Writes |
+===================================================================================================================+
| data(@c0) | PARTITIONED | 2 | min: 10000 (10000 / 0) | min: 0 | min: 0 | min: 0 | min: 0 |
| | | | avg: 10000.00 (10000.00 / 0.00) | avg: 0.00 | avg: 0.00 | avg: 0.00 | avg: 0.00 |
| | | | max: 10000 (10000 / 0) | max: 0 | max: 0 | max: 0 | max: 0 |
+-------------------------------------------------------------------------------------------------------------------+
As you can see the visor shows that all the entries are in the heap and none of them are stored off heap.
Also, if I create and load the cache from the server and start the client (it does nothing) then all the entries are stored off heap.
To add to this there is other behavior which might throw more light.
Post the steps provided above, if you start another server node, the new server node stores the cache entries in off heap memory (assuming backup is set).
When you run the client again to clear the existing cache and add the data again, on the servers, part data is on heap and part on off heap.
I investigated and Ignite woks this way as you see.
You can track this issue for fix https://issues.apache.org/jira/browse/IGNITE-4662
Or not use near cache