3
votes

I am trying to display statistic of a map. It always showing no of hits as 0. I am using the following code.

IMap<String, byte[]> map = Hazelcast.getMap("SOMEMAP");
LocalMapStatsImpl local = (LocalMapStatsImpl) map.getLocalMapStats();
System.out.println(map.getLocalMapStats());

and the output is

LocalMapStatsImpl{ownedEntryCount=0, backupEntryCount=1, markedAsRemovedEntryCount=0, ownedEntryMemoryCost=0, backupEntryMemoryCost=13841, markedAsRemovedMemoryCost=0, creationTime=1323806943770, lastAccessTime=0, lastUpdateTime=0, lastEvictionTime=0, hits=0, lockedEntryCount=0, lockWaitCount=0, dirtyEntryCount=0, LocalMapOperationStats{total= 0, puts:OperationStat{count=0, averageLatency=0}, gets:OperationStat{count=0, verageLatency=0}, emoves:OperationStat{count=0, averageLatency=0}, others: 0, received events: 0}}

Any help is appreciated. I want to know the no of hits, size of the map and entry count.

2
any help .... ? Its urgent for me... - Yahiya

2 Answers

2
votes

Make sure you put some entries into map. As seen from stats you have only one entry in the map and that entry is owned by another node, current node has backup of that entry (ownedEntryCount=0, backupEntryCount=1).

Notice that this statistics are only for current nodes local map. If you have more than one node and current node does not own any data at the time you get the stats then you will get 0 for no of hits or owned entry count.

Using Hazelcast 1.9.4.4 (latest as of now) and single node, I can get the stats by;

IMap map = Hazelcast.getMap("test");
for (int i = 0; i < 100; i++) {
    map.put(i, i);
    map.get(i);
}
LocalMapStats stats = map.getLocalMapStats();
System.err.println(stats.getHits());
System.err.println(stats.getOwnedEntryCount());

Both hits and ownedEntryCount show 100.

LocalMapStatsImpl{ownedEntryCount=100, backupEntryCount=0, markedAsRemovedEntryCount=0, ownedEntryMemoryCost=42100, backupEntryMemoryCost=0, markedAsRemovedMemoryCost=0, creationTime=1323844949878, lastAccessTime=1323844949908, lastUpdateTime=0, lastEvictionTime=0, hits=100, lockedEntryCount=0, lockWaitCount=0, dirtyEntryCount=0, LocalMapOperationStats{total= 200, puts:OperationStat{count=100, averageLatency=0}, gets:OperationStat{count=100, averageLatency=0}, removes:OperationStat{count=0, averageLatency=0}, others: 0, received events: 0}}

Try this and see if you will get the same results. Otherwise either your map is empty or there is a bug in version you have used.

1
votes

Download hazelcast-monitor9.3.4.jar and install in it your local apache webserver. Access the web application. It will launch a login page. Just provide the cluster name, password and server:port and click connect. It will display all the maps with statistic.