}
@Test
public void testProfileControllerMXBean() throws Exception {
// Ensure the object was registered at startup
ProfileControllerMXBean bean =
(ProfileControllerMXBean) profileCollector.getRegisteredMBean(
ProfileControllerMXBean.MXBEAN_NAME);
assertNotNull(bean);
// Create a proxy
ProfileControllerMXBean proxy = (ProfileControllerMXBean)
JMX.newMXBeanProxy(mbsc,
new ObjectName(ProfileControllerMXBean.MXBEAN_NAME),
ProfileControllerMXBean.class);
String[] consumers = proxy.getProfileConsumers();
for (String con : consumers) {
System.out.println("Found consumer " + con);
}
// Default profile level is min
assertEquals(ProfileLevel.MIN, proxy.getDefaultProfileLevel());
// Can set the default profile level
proxy.setDefaultProfileLevel(ProfileLevel.MEDIUM);
assertEquals(ProfileLevel.MEDIUM, proxy.getDefaultProfileLevel());
String consName =
ProfileCollectorImpl.CORE_CONSUMER_PREFIX + "DataService";
ProfileLevel level = proxy.getConsumerLevel(consName);
assertEquals(ProfileLevel.MIN, level);
DataServiceMXBean dataProxy =
JMX.newMXBeanProxy(mbsc,
new ObjectName(DataServiceMXBean.MXBEAN_NAME),
DataServiceMXBean.class);
// Test that consumer level can be changed
txnScheduler.runTask(new TestAbstractKernelRunnable() {
public void run() {
ManagedObject dummy = new DummyManagedObject();
serverNode.getDataService().setBinding("dummy", dummy);
}}, taskOwner);
assertEquals(0, dataProxy.getSetBindingCalls());
proxy.setConsumerLevel(consName, ProfileLevel.MAX);
assertEquals(ProfileLevel.MAX, proxy.getConsumerLevel(consName));
txnScheduler.runTask(new TestAbstractKernelRunnable() {
public void run() {
ManagedObject dummy = new DummyManagedObject();
serverNode.getDataService().setBinding("dummy", dummy);