You can gather various statistics from your distributed data structures via Statistics API. Since the data structures are distributed in the cluster, the Statistics API provides statistics for the local portion (1/Number of Nodes) of data on each node.
The IMap
interface has a getLocalMapStats()
method which returns a
LocalMapStats
object that holds local map statistics.
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance();
IMap<String, Customer> customers = hazelcastInstance.getMap( "customers" );
LocalMapStats mapStatistics = customers.getLocalMapStats();
System.out.println( "number of entries owned on this node = "
+ mapStatistics.getOwnedEntryCount() );
Below is the list of metrics that can be accessed via LocalMapStats
object.
/**
* Returns the number of entries owned by this member.
*/
long getOwnedEntryCount();
/**
* Returns the number of backup entries hold by this member.
*/
long getBackupEntryCount();
/**
* Returns the number of backups per entry.
*/
int getBackupCount();
/**
* Returns memory cost (number of bytes) of owned entries in this member.
*/
long getOwnedEntryMemoryCost();
/**
* Returns memory cost (number of bytes) of backup entries in this member.
*/
long getBackupEntryMemoryCost();
/**
* Returns the creation time of this map on this member.
*/
long getCreationTime();
/**
* Returns the last access (read) time of the locally owned entries.
*/
long getLastAccessTime();
/**
* Returns the last update time of the locally owned entries.
*/
long getLastUpdateTime();
/**
* Returns the number of hits (reads) of the locally owned entries.
*/
long getHits();
/**
* Returns the number of currently locked locally owned keys.
*/
long getLockedEntryCount();
/**
* Returns the number of entries that the member owns and are dirty (updated
* but not persisted yet).
* dirty entry count is meaningful when there is a persistence defined.
*/
long getDirtyEntryCount();
/**
* Returns the number of put operations
*/
long getPutOperationCount();
/**
* Returns the number of get operations
*/
long getGetOperationCount();
/**
* Returns the number of Remove operations
*/
long getRemoveOperationCount();
/**
* Returns the total latency of put operations. To get the average latency,
* divide to number of puts
*/
long getTotalPutLatency();
/**
* Returns the total latency of get operations. To get the average latency,
* divide to number of gets
*/
long getTotalGetLatency();
/**
* Returns the total latency of remove operations. To get the average latency,
* divide to number of gets
*/
long getTotalRemoveLatency();
/**
* Returns the maximum latency of put operations. To get the average latency,
* divide to number of puts
*/
long getMaxPutLatency();
/**
* Returns the maximum latency of get operations. To get the average latency,
* divide to number of gets
*/
long getMaxGetLatency();
/**
* Returns the maximum latency of remove operations. To get the average latency,
* divide to number of gets
*/
long getMaxRemoveLatency();
/**
* Returns the number of Events Received
*/
long getEventOperationCount();
/**
* Returns the total number of Other Operations
*/
long getOtherOperationCount();
/**
* Returns the total number of total operations
*/
long total();
/**
* Cost of map & near cache & backup in bytes
* todo in object mode object size is zero.
*/
long getHeapCost();
/**
* Returns statistics related to the Near Cache.
*/
NearCacheStats getNearCacheStats();
Near Cache statistics can be accessed from LocalMapStats
via
getNearCacheStats()
method which will return a NearCacheStats
object.
HazelcastInstance node = Hazelcast.newHazelcastInstance();
IMap<String, Customer> customers = node.getMap( "customers" );
LocalMapStats mapStatistics = customers.getLocalMapStats();
NearCacheStats nearCacheStatistics = mapStatistics.getNearCacheStats();
System.out.println( "near cache hit/miss ratio= "
+ nearCacheStatistics.getRatio() );
Below is the list of metrics that can be accessed via NearCacheStats
object.
This behavior applies to both client and node near caches.
/**
* Returns the creation time of this NearCache on this member
*/
long getCreationTime();
/**
* Returns the number of entries owned by this member.
*/
long getOwnedEntryCount();
/**
* Returns memory cost (number of bytes) of entries in this cache.
*/
long getOwnedEntryMemoryCost();
/**
* Returns the number of hits (reads) of the locally owned entries.
*/
long getHits();
/**
* Returns the number of misses of the locally owned entries.
*/
long getMisses();
/**
* Returns the hit/miss ratio of the locally owned entries.
*/
double getRatio();
The MultiMap
interface has a getLocalMultiMapStats()
method which returns a
LocalMultiMapStats
object that holds local MultiMap statistics.
HazelcastInstance node = Hazelcast.newHazelcastInstance();
MultiMap<String, Customer> customers = node.getMultiMap( "customers" );
LocalMultiMapStats multiMapStatistics = customers.getLocalMultiMapStats();
System.out.println( "last update time = "
+ multiMapStatistics.getLastUpdateTime() );
Below is the list of metrics that can be accessed via LocalMultiMapStats
object.
/**
* Returns the number of entries owned by this member.
*/
long getOwnedEntryCount();
/**
* Returns the number of backup entries hold by this member.
*/
long getBackupEntryCount();
/**
* Returns the number of backups per entry.
*/
int getBackupCount();
/**
* Returns memory cost (number of bytes) of owned entries in this member.
*/
long getOwnedEntryMemoryCost();
/**
* Returns memory cost (number of bytes) of backup entries in this member.
*/
long getBackupEntryMemoryCost();
/**
* Returns the creation time of this map on this member.
*/
long getCreationTime();
/**
* Returns the last access (read) time of the locally owned entries.
*/
long getLastAccessTime();
/**
* Returns the last update time of the locally owned entries.
*/
long getLastUpdateTime();
/**
* Returns the number of hits (reads) of the locally owned entries.
*/
long getHits();
/**
* Returns the number of currently locked locally owned keys.
*/
long getLockedEntryCount();
/**
* Returns the number of entries that the member owns and are dirty (updated
* but not persisted yet).
* dirty entry count is meaningful when there is a persistence defined.
*/
long getDirtyEntryCount();
/**
* Returns the number of put operations
*/
long getPutOperationCount();
/**
* Returns the number of get operations
*/
long getGetOperationCount();
/**
* Returns the number of Remove operations
*/
long getRemoveOperationCount();
/**
* Returns the total latency of put operations. To get the average latency,
* divide to number of puts
*/
long getTotalPutLatency();
/**
* Returns the total latency of get operations. To get the average latency,
* divide to number of gets
*/
long getTotalGetLatency();
/**
* Returns the total latency of remove operations. To get the average latency,
* divide to number of gets
*/
long getTotalRemoveLatency();
/**
* Returns the maximum latency of put operations. To get the average latency,
* divide to number of puts
*/
long getMaxPutLatency();
/**
* Returns the maximum latency of get operations. To get the average latency,
* divide to number of gets
*/
long getMaxGetLatency();
/**
* Returns the maximum latency of remove operations. To get the average latency,
* divide to number of gets
*/
long getMaxRemoveLatency();
/**
* Returns the number of Events Received
*/
long getEventOperationCount();
/**
* Returns the total number of Other Operations
*/
long getOtherOperationCount();
/**
* Returns the total number of total operations
*/
long total();
/**
* Cost of map & near cache & backup in bytes
* todo in object mode object size is zero.
*/
long getHeapCost();
The IQueue
interface has a getLocalQueueStats()
method which returns a
LocalQueueStats
object that holds local queue statistics.
HazelcastInstance node = Hazelcast.newHazelcastInstance();
IQueue<Order> orders = node.getQueue( "orders" );
LocalQueueStats queueStatistics = orders.getLocalQueueStats();
System.out.println( "average age of items = "
+ queueStatistics.getAvgAge() );
Below is the list of metrics that can be accessed via LocalQueueStats
object.
/**
* Returns the number of owned items in this member.
*/
long getOwnedItemCount();
/**
* Returns the number of backup items in this member.
*/
long getBackupItemCount();
/**
* Returns the min age of the items in this member.
*/
long getMinAge();
/**
* Returns the max age of the items in this member.
*/
long getMaxAge();
/**
* Returns the average age of the items in this member.
*/
long getAvgAge();
/**
* Returns the number of offer/put/add operations.
* Offers returning false will be included.
* #getRejectedOfferOperationCount can be used
* to get the rejected offers.
*/
long getOfferOperationCount();
/**
* Returns the number of rejected offers. Offer
* can be rejected because of max-size limit
* on the queue.
*/
long getRejectedOfferOperationCount();
/**
* Returns the number of poll/take/remove operations.
* Polls returning null (empty) will be included.
* #getEmptyPollOperationCount can be used to get the
* number of polls returned null.
*/
long getPollOperationCount();
/**
* Returns number of null returning poll operations.
* Poll operation might return null, if the queue is empty.
*/
long getEmptyPollOperationCount();
/**
* Returns number of other operations
*/
long getOtherOperationsCount();
/**
* Returns number of event operations
*/
long getEventOperationCount();
The ITopic
interface has a getLocalTopicStats()
method which returns a
LocalTopicStats
object that holds local topic statistics.
HazelcastInstance node = Hazelcast.newHazelcastInstance();
ITopic<Object> news = node.getTopic( "news" );
LocalTopicStats topicStatistics = news.getLocalTopicStats();
System.out.println( "number of publish operations = "
+ topicStatistics.getPublishOperationCount() );
Below is the list of metrics that can be accessed via LocalTopicStats
object.
/**
* Returns the creation time of this topic on this member
*/
long getCreationTime();
/**
* Returns the total number of published messages of this topic on this member
*/
long getPublishOperationCount();
/**
* Returns the total number of received messages of this topic on this member
*/
long getReceiveOperationCount();
The IExecutorService
interface has a getLocalExecutorStats()
method which returns a
LocalExecutorStats
object that holds local executor statistics.
HazelcastInstance node = Hazelcast.newHazelcastInstance();
IExecutorService orderProcessor = node.getExecutorService( "orderProcessor" );
LocalExecutorStats executorStatistics = orderProcessor.getLocalExecutorStats();
System.out.println( "completed task count = "
+ executorStatistics.getCompletedTaskCount() );
Below is the list of metrics that can be accessed via LocalExecutorStats
object.
/**
* Returns the number of pending operations of the executor service
*/
long getPendingTaskCount();
/**
* Returns the number of started operations of the executor service
*/
long getStartedTaskCount();
/**
* Returns the number of completed operations of the executor service
*/
long getCompletedTaskCount();
/**
* Returns the number of cancelled operations of the executor service
*/
long getCancelledTaskCount();
/**
* Returns the total start latency of operations started
*/
long getTotalStartLatency();
/**
* Returns the total execution time of operations finished
*/
long getTotalExecutionLatency();