{"_id":"56cc2b9e94c8f00b00b83d76","__v":37,"project":"568a404d050eb50d00c07995","version":{"_id":"568a404e050eb50d00c07998","project":"568a404d050eb50d00c07995","__v":2,"createdAt":"2016-01-04T09:50:06.218Z","releaseDate":"2016-01-04T09:50:06.218Z","categories":["568a404e050eb50d00c07999","56cc2b81272aa4130002cce9"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"568a404e050eb50d00c07999","__v":7,"pages":["568a404f050eb50d00c0799b","5698f130cb127f0d003cc06a","5698f1483da4370d009d2079","569e6013d233620d00705550","569f3e578f6d4b0d00f13bd5","56a9d3d43b04f20d00eccaa5","56cc2b9e94c8f00b00b83d76"],"project":"568a404d050eb50d00c07995","version":"568a404e050eb50d00c07998","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-04T09:50:06.816Z","from_sync":false,"order":9999,"slug":"documentation","title":"Documentation"},"user":"56cb249019196e1300c81fde","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-02-23T09:51:26.772Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"Blazing Cache provides several MXBeans in order to publish statistics and information regarding status of cache clients and cache servers. \n\nRegarding CacheClient, two MXBeans are available: **CacheClientStatusMXBean** and **CacheClientStatisticsMXBean**, respectively providing status information and statistics on CacheClients.\n\nOn CacheServers, a single MXBean is available, **CacheServerStatusMXBean**, which provides serveral values on cache server's current status.\n\nThe following sections give a detailed overview of the data provided by the aforementioned MXBeans.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"CacheClient\"\n}\n[/block]\nJMX monitoring on CacheClients is disabled by default: publishing of status and statistics MXBeans can be activated via the corresponding builder, as shown below.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"try (CacheClient client\\n                = CacheClientBuilder\\n                .newBuilder()                \\n     \\t\\t\\t\\t\\t\\t.jmx(true)\\n                .build();) {\\nclient.start();\\nclient.waitForConnection(10000);\\n...\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nOnce started, MXBeans can be accessed locally by an instance of MBeanServer, or remotely, trhough a JMX connection.\n\nIn particular, **CacheClientStatusMXBean** can be retrieved using an instance of **ObjectName** whose name follows the pattern:\n\n* *blazingcache.client.management:type=CacheClientStatus,CacheClient={ID}*\n\nwhere *{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.\n\n **CacheClientStatusMXBean**  makes it possible to get the following set of attributes, which provide status data on the client.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Attribute Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"ClientId\",\n    \"0-1\": \"String\",\n    \"0-2\": \"Id of the cache client.\",\n    \"1-0\": \"CurrentTimestamp\",\n    \"1-1\": \"long\",\n    \"1-2\": \"Current cache client's timestamp.\",\n    \"2-0\": \"LastConnectionTimestamp\",\n    \"2-1\": \"long\",\n    \"2-2\": \"Timestamp of the last time the client connected to the server.\",\n    \"3-0\": \"ClientConnected\",\n    \"3-1\": \"boolean\",\n    \"3-2\": \"The status of client connection to cache server. True if the client is currently connected to the server.\",\n    \"4-0\": \"CacheConfiguredMaxMemory\",\n    \"4-1\": \"long\",\n    \"4-2\": \"Maximum cache size in bytes configured on the client.\",\n    \"5-0\": \"CacheUsedMemory\",\n    \"5-1\": \"long\",\n    \"5-2\": \"Amount of memory, in bytes, currently used by client's local cache.\",\n    \"6-0\": \"CacheSize\",\n    \"6-1\": \"int\",\n    \"6-2\": \"Number of keys currently stored in client's cache.\",\n    \"7-0\": \"CacheLastEvictionOldestKeyAge\",\n    \"7-1\": \"long\",\n    \"7-2\": \"The age in ns of the oldest key last evicted from the local cache. \\n\\nPut it simply, the oldest key is devised referring always to last eviction execution.\\n\\nIn case of no eviction executed on the cache yet, 0 will be returned.\"\n  },\n  \"cols\": 3,\n  \"rows\": 8\n}\n[/block]\nFurthermore, a *clear()* method can be invoked on the MXBean so as to reset the above values.\n\n\n\nAs far as statistical data is concerned, **CacheClientStatisticsMXBean** can be retrieved using an instance of **ObjectName** whose name follows this pattern:\n\n* *blazingcache.client.management:type=CacheClientStatistics,CacheClient={ID}*\n\nwhere *{ID}*, again, represents the *clientId* of the desired CacheClient.\n\nThe following attributes can be read from the MXBean instance to provide statistical data.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Attribute Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"ClientPuts\",\n    \"0-1\": \"long\",\n    \"0-2\": \"The number of puts performed by the client since last reboot.\",\n    \"1-0\": \"ClientTouches\",\n    \"1-1\": \"long\",\n    \"1-2\": \"The number of touches performed by the client since last reboot.\",\n    \"2-0\": \"ClientGets\",\n    \"2-1\": \"long\",\n    \"2-2\": \"The number of gets performed since last reboot.\",\n    \"3-0\": \"ClientFetches\",\n    \"3-1\": \"long\",\n    \"3-2\": \"The number of fetches since last reboot.\",\n    \"4-0\": \"ClientEvictions\",\n    \"4-1\": \"long\",\n    \"4-2\": \"The number of evictions performed by the client since last reboot.\",\n    \"5-0\": \"ClientInvalidations\",\n    \"5-1\": \"long\",\n    \"5-2\": \"The number of invalidations performed by the client since last reboot.\",\n    \"6-0\": \"ClientHits\",\n    \"6-1\": \"long\",\n    \"6-2\": \"The number of hits occurred in the client since last reboot.\",\n    \"7-0\": \"ClientMissedGetsToSuccessfulFetches\",\n    \"7-1\": \"long\",\n    \"7-2\": \"The number of successful reads that required a remote read, i.e. successful gets requiring a remote connection (fetch).\\n\\nThe value is counted since client's last reboot.\",\n    \"8-0\": \"ClientMissedGetsToMissedFetches\",\n    \"8-1\": \"long\",\n    \"8-2\": \"The total number of unsuccessful fetches after gets: the data requested was present neither locally nor remotely.\\n\\nThe value is counted since client's last reboot.\"\n  },\n  \"cols\": 3,\n  \"rows\": 9\n}\n[/block]\nAgain, a *clear()* method can be invoked so that the above statistical values can be set back to 0.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"CacheServer\"\n}\n[/block]\nOn **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](doc:server-configuratio).\n\nOn server, the only MXBean available - **CacheServerStatusMXBean** - can be obtained via an instance of **ObjectName** conventionally structured like this:\n\n* *blazingcache.server.management:type=CacheServerStatus,CacheServer={ID}*\n\nwhere *{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:\n\n* **{host}** is the value of property **server.host**;\n* **{port}** is the value of property **server.port**.\n\nThe following set of attributes can be read from the MXBean.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Attribute Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"CurrentTimestamp\",\n    \"0-1\": \"long\",\n    \"0-2\": \"Current server's timestamp (in ms).\",\n    \"2-0\": \"Leader\",\n    \"2-1\": \"boolean\",\n    \"2-2\": \"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.\",\n    \"3-0\": \"StateChangeTimestamp\",\n    \"3-1\": \"long\",\n    \"3-2\": \"Timestamp (in ms) corresponding to the last time the server switched from leader to backup mode (ot the other way round).\",\n    \"4-0\": \"GlobalCacheSize\",\n    \"4-1\": \"int\",\n    \"4-2\": \"Number of keys stored globally, i.e. currently present in every client cache.\",\n    \"5-0\": \"ConnectedClients\",\n    \"5-1\": \"int\",\n    \"5-2\": \"Number of clients currently connected to the server.\",\n    \"6-0\": \"LockedEntries\",\n    \"6-1\": \"int\",\n    \"6-2\": \"Number of entries on which a client acquired (and still holds) a lock on.\",\n    \"7-0\": \"PendingOperations\",\n    \"7-1\": \"long\",\n    \"7-2\": \"Number of operations requested to the server still to be completed.\",\n    \"1-0\": \"LastStartupTimestamp\",\n    \"1-1\": \"long\",\n    \"1-2\": \"Timestamp of the last startup of the server (in ms).\"\n  },\n  \"cols\": 3,\n  \"rows\": 8\n}\n[/block]","excerpt":"","slug":"jmx-monitoring","type":"basic","title":"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. [block:api-header] { "type": "basic", "title": "CacheClient" } [/block] JMX monitoring on CacheClients is disabled by default: publishing of status and statistics MXBeans can be activated via the corresponding builder, as shown below. [block:code] { "codes": [ { "code": "try (CacheClient client\n = CacheClientBuilder\n .newBuilder() \n \t\t\t\t\t\t.jmx(true)\n .build();) {\nclient.start();\nclient.waitForConnection(10000);\n...\n}", "language": "java" } ] } [/block] 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. [block:parameters] { "data": { "h-0": "Attribute Name", "h-1": "Type", "h-2": "Description", "0-0": "ClientId", "0-1": "String", "0-2": "Id of the cache client.", "1-0": "CurrentTimestamp", "1-1": "long", "1-2": "Current cache client's timestamp.", "2-0": "LastConnectionTimestamp", "2-1": "long", "2-2": "Timestamp of the last time the client connected to the server.", "3-0": "ClientConnected", "3-1": "boolean", "3-2": "The status of client connection to cache server. True if the client is currently connected to the server.", "4-0": "CacheConfiguredMaxMemory", "4-1": "long", "4-2": "Maximum cache size in bytes configured on the client.", "5-0": "CacheUsedMemory", "5-1": "long", "5-2": "Amount of memory, in bytes, currently used by client's local cache.", "6-0": "CacheSize", "6-1": "int", "6-2": "Number of keys currently stored in client's cache.", "7-0": "CacheLastEvictionOldestKeyAge", "7-1": "long", "7-2": "The age in ns of the oldest key last evicted from the local cache. \n\nPut it simply, the oldest key is devised referring always to last eviction execution.\n\nIn case of no eviction executed on the cache yet, 0 will be returned." }, "cols": 3, "rows": 8 } [/block] 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. [block:parameters] { "data": { "h-0": "Attribute Name", "h-1": "Type", "h-2": "Description", "0-0": "ClientPuts", "0-1": "long", "0-2": "The number of puts performed by the client since last reboot.", "1-0": "ClientTouches", "1-1": "long", "1-2": "The number of touches performed by the client since last reboot.", "2-0": "ClientGets", "2-1": "long", "2-2": "The number of gets performed since last reboot.", "3-0": "ClientFetches", "3-1": "long", "3-2": "The number of fetches since last reboot.", "4-0": "ClientEvictions", "4-1": "long", "4-2": "The number of evictions performed by the client since last reboot.", "5-0": "ClientInvalidations", "5-1": "long", "5-2": "The number of invalidations performed by the client since last reboot.", "6-0": "ClientHits", "6-1": "long", "6-2": "The number of hits occurred in the client since last reboot.", "7-0": "ClientMissedGetsToSuccessfulFetches", "7-1": "long", "7-2": "The number of successful reads that required a remote read, i.e. successful gets requiring a remote connection (fetch).\n\nThe value is counted since client's last reboot.", "8-0": "ClientMissedGetsToMissedFetches", "8-1": "long", "8-2": "The total number of unsuccessful fetches after gets: the data requested was present neither locally nor remotely.\n\nThe value is counted since client's last reboot." }, "cols": 3, "rows": 9 } [/block] Again, a *clear()* method can be invoked so that the above statistical values can be set back to 0. [block:api-header] { "type": "basic", "title": "CacheServer" } [/block] 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](doc:server-configuratio). 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. [block:parameters] { "data": { "h-0": "Attribute Name", "h-1": "Type", "h-2": "Description", "0-0": "CurrentTimestamp", "0-1": "long", "0-2": "Current server's timestamp (in ms).", "2-0": "Leader", "2-1": "boolean", "2-2": "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.", "3-0": "StateChangeTimestamp", "3-1": "long", "3-2": "Timestamp (in ms) corresponding to the last time the server switched from leader to backup mode (ot the other way round).", "4-0": "GlobalCacheSize", "4-1": "int", "4-2": "Number of keys stored globally, i.e. currently present in every client cache.", "5-0": "ConnectedClients", "5-1": "int", "5-2": "Number of clients currently connected to the server.", "6-0": "LockedEntries", "6-1": "int", "6-2": "Number of entries on which a client acquired (and still holds) a lock on.", "7-0": "PendingOperations", "7-1": "long", "7-2": "Number of operations requested to the server still to be completed.", "1-0": "LastStartupTimestamp", "1-1": "long", "1-2": "Timestamp of the last startup of the server (in ms)." }, "cols": 3, "rows": 8 } [/block]