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 Name

Type

Description

ClientId

String

Id of the cache client.

CurrentTimestamp

long

Current cache client's timestamp.

LastConnectionTimestamp

long

Timestamp of the last time the client connected to the server.

ClientConnected

boolean

The status of client connection to cache server. True if the client is currently connected to the server.

CacheConfiguredMaxMemory

long

Maximum cache size in bytes configured on the client.

CacheUsedMemory

long

Amount of memory, in bytes, currently used by client's local cache.

CacheSize

int

Number of keys currently stored in client's cache.

CacheLastEvictionOldestKeyAge

long

The 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 Name

Type

Description

ClientPuts

long

The number of puts performed by the client since last reboot.

ClientTouches

long

The number of touches performed by the client since last reboot.

ClientGets

long

The number of gets performed since last reboot.

ClientFetches

long

The number of fetches since last reboot.

ClientEvictions

long

The number of evictions performed by the client since last reboot.

ClientInvalidations

long

The number of invalidations performed by the client since last reboot.

ClientHits

long

The number of hits occurred in the client since last reboot.

ClientMissedGetsToSuccessfulFetches

long

The 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.

ClientMissedGetsToMissedFetches

long

The 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 Name

Type

Description

CurrentTimestamp

long

Current server's timestamp (in ms).

LastStartupTimestamp

long

Timestamp of the last startup of the server (in ms).

Leader

boolean

Represents the current state of this server: true if the server is operating as leader, false if it is currently acting as a backup server.

StateChangeTimestamp

long

Timestamp (in ms) corresponding to the last time the server switched from leader to backup mode (ot the other way round).

GlobalCacheSize

int

Number of keys stored globally, i.e. currently present in every client cache.

ConnectedClients

int

Number of clients currently connected to the server.

LockedEntries

int

Number of entries on which a client acquired (and still holds) a lock on.

PendingOperations

long

Number of operations requested to the server still to be completed.


Did this page help you?