checkMBeanOperationParameterNaming(rpcManager);
}
public void testEnableJmxStats() throws Exception {
Cache<String, String> cache1 = manager(0).getCache(cachename);
Cache cache2 = manager(1).getCache(cachename);
MBeanServer mBeanServer = PerThreadMBeanServerLookup.getThreadMBeanServer();
ObjectName rpcManager1 = getCacheObjectName(JMX_DOMAIN, cachename + "(repl_sync)", "RpcManager");
ObjectName rpcManager2 = getCacheObjectName(JMX_DOMAIN2, cachename + "(repl_sync)", "RpcManager");
assert mBeanServer.isRegistered(rpcManager1);
assert mBeanServer.isRegistered(rpcManager2);
Object statsEnabled = mBeanServer.getAttribute(rpcManager1, "StatisticsEnabled");
assert statsEnabled != null;
assertEquals(statsEnabled, Boolean.TRUE);
assertEquals(mBeanServer.getAttribute(rpcManager1, "StatisticsEnabled"), Boolean.TRUE);
assertEquals(mBeanServer.getAttribute(rpcManager2, "StatisticsEnabled"), Boolean.TRUE);
// The initial state transfer uses cache commands, so it also increases the ReplicationCount value
long initialReplicationCount1 = (Long) mBeanServer.getAttribute(rpcManager1, "ReplicationCount");
cache1.put("key", "value2");
assertEquals(cache2.get("key"), "value2");
assertEquals(mBeanServer.getAttribute(rpcManager1, "ReplicationCount"), initialReplicationCount1 + 1);
assertEquals(mBeanServer.getAttribute(rpcManager1, "ReplicationFailures"), (long) 0);
// now reset statistics
mBeanServer.invoke(rpcManager1, "resetStatistics", new Object[0], new String[0]);
assertEquals(mBeanServer.getAttribute(rpcManager1, "ReplicationCount"), (long) 0);
assertEquals(mBeanServer.getAttribute(rpcManager1, "ReplicationFailures"), (long) 0);
mBeanServer.setAttribute(rpcManager1, new Attribute("StatisticsEnabled", Boolean.FALSE));
cache1.put("key", "value");
assertEquals(cache2.get("key"), "value");
assertEquals(mBeanServer.getAttribute(rpcManager1, "ReplicationCount"), (long) -1);
assertEquals(mBeanServer.getAttribute(rpcManager1, "ReplicationFailures"), (long) -1);
// reset stats enabled parameter
mBeanServer.setAttribute(rpcManager1, new Attribute("StatisticsEnabled", Boolean.TRUE));