JMX Monitoring

Blazing Cache provides several MXBeans in order to publish statistics and information regarding status of cache clients and cache servers.

Regarding CacheClient, two MXBeans are available: CacheClientStatusMXBean and CacheClientStatisticsMXBean, respectively providing status information and statistics on CacheClients.

On CacheServers, a single MXBean is available, CacheServerStatusMXBean, which provides serveral values on cache server's current status.

The following sections give a detailed overview of the data provided by the aforementioned MXBeans.

CacheClient

JMX monitoring on CacheClients is disabled by default: publishing of status and statistics MXBeans can be activated via the corresponding builder, as shown below.

try (CacheClient client
                = CacheClientBuilder
                .newBuilder()                
     						.jmx(true)
                .build();) {
client.start();
client.waitForConnection(10000);
...
}

Once started, MXBeans can be accessed locally by an instance of MBeanServer, or remotely, trhough a JMX connection.

In particular, CacheClientStatusMXBean can be retrieved using an instance of ObjectName whose name follows the pattern:

  • blazingcache.client.management:type=CacheClientStatus,CacheClient={ID}

where {ID} represents the clientId of the CacheClient: this can be an id set through the client builder or, in case of a client built adopting the default id, can be retrieved using getClientId() on the desired CacheClient instance.

CacheClientStatusMXBean makes it possible to get the following set of attributes, which provide status data on the client.

Attribute NameTypeDescription
ClientIdStringId of the cache client.
CurrentTimestamplongCurrent cache client's timestamp.
LastConnectionTimestamplongTimestamp of the last time the client connected to the server.
ClientConnectedbooleanThe status of client connection to cache server. True if the client is currently connected to the server.
CacheConfiguredMaxMemorylongMaximum cache size in bytes configured on the client.
CacheUsedMemorylongAmount of memory, in bytes, currently used by client's local cache.
CacheSizeintNumber of keys currently stored in client's cache.
CacheLastEvictionOldestKeyAgelongThe age in ns of the oldest key last evicted from the local cache.

Put it simply, the oldest key is devised referring always to last eviction execution.

In case of no eviction executed on the cache yet, 0 will be returned.

Furthermore, a clear() method can be invoked on the MXBean so as to reset the above values.

As far as statistical data is concerned, CacheClientStatisticsMXBean can be retrieved using an instance of ObjectName whose name follows this pattern:

  • blazingcache.client.management:type=CacheClientStatistics,CacheClient={ID}

where {ID}, again, represents the clientId of the desired CacheClient.

The following attributes can be read from the MXBean instance to provide statistical data.

Attribute NameTypeDescription
ClientPutslongThe number of puts performed by the client since last reboot.
ClientToucheslongThe number of touches performed by the client since last reboot.
ClientGetslongThe number of gets performed since last reboot.
ClientFetcheslongThe number of fetches since last reboot.
ClientEvictionslongThe number of evictions performed by the client since last reboot.
ClientInvalidationslongThe number of invalidations performed by the client since last reboot.
ClientHitslongThe number of hits occurred in the client since last reboot.
ClientMissedGetsToSuccessfulFetcheslongThe number of successful reads that required a remote read, i.e. successful gets requiring a remote connection (fetch).

The value is counted since client's last reboot.
ClientMissedGetsToMissedFetcheslongThe total number of unsuccessful fetches after gets: the data requested was present neither locally nor remotely.

The value is counted since client's last reboot.

Again, a clear() method can be invoked so that the above statistical values can be set back to 0.

CacheServer

On CacheServer JMX monitoring is enabled as a default. In case one needs to disable, property server.jmx can be exploited to this end, as explained in Servers.

On server, the only MXBean available - CacheServerStatusMXBean - can be obtained via an instance of ObjectName conventionally structured like this:

  • blazingcache.server.management:type=CacheServerStatus,CacheServer={ID}

where {ID} represents the id of the CacheServer, which can be retrieved on the server by invoking getServerId(): by default, serverId is devised by concatenation {host}_{port}, where:

  • {host} is the value of property server.host;
  • {port} is the value of property server.port.

The following set of attributes can be read from the MXBean.

Attribute NameTypeDescription
CurrentTimestamplongCurrent server's timestamp (in ms).
LastStartupTimestamplongTimestamp of the last startup of the server (in ms).
LeaderbooleanRepresents the current state of this server: true if the server is operating as leader, false if it is currently acting as a backup server.
StateChangeTimestamplongTimestamp (in ms) corresponding to the last time the server switched from leader to backup mode (ot the other way round).
GlobalCacheSizeintNumber of keys stored globally, i.e. currently present in every client cache.
ConnectedClientsintNumber of clients currently connected to the server.
LockedEntriesintNumber of entries on which a client acquired (and still holds) a lock on.
PendingOperationslongNumber of operations requested to the server still to be completed.