cons.setProfileLevel(ProfileLevel.MAX);
ObjectName name = new ObjectName(TaskServiceMXBean.MXBEAN_NAME);
// Ensure the object was registered at startup
TaskServiceMXBean bean = (TaskServiceMXBean)
profileCollector.getRegisteredMBean(TaskServiceMXBean.MXBEAN_NAME);
assertNotNull(bean);
// Get individual fields
long delayed =
(Long) mbsc.getAttribute(name, "ScheduleDelayedTaskCalls");
long nondurable =
(Long) mbsc.getAttribute(name, "ScheduleNonDurableTaskCalls");
long nondurableDelayed =
(Long) mbsc.getAttribute(name,
"ScheduleNonDurableTaskDelayedCalls");
long periodic =
(Long) mbsc.getAttribute(name, "SchedulePeriodicTaskCalls");
long task = (Long) mbsc.getAttribute(name, "ScheduleTaskCalls");
// Create the proxy for the object
TaskServiceMXBean proxy =
JMX.newMXBeanProxy(mbsc, name, TaskServiceMXBean.class);
assertTrue(delayed <= proxy.getScheduleDelayedTaskCalls());
assertTrue(nondurable <= proxy.getScheduleNonDurableTaskCalls());
assertTrue(nondurableDelayed <=
proxy.getScheduleNonDurableTaskDelayedCalls());
assertTrue(periodic <= proxy.getSchedulePeriodicTaskCalls());
assertTrue(task <= proxy.getScheduleTaskCalls());
// Test an API
txnScheduler.runTask(new TestAbstractKernelRunnable() {
public void run() {
serverNode.getTaskService().scheduleNonDurableTask(
new TestAbstractKernelRunnable() {
public void run() { }},
false);
}
}, taskOwner);
assertTrue(nondurable < proxy.getScheduleNonDurableTaskCalls());
assertTrue(nondurable < bean.getScheduleNonDurableTaskCalls());
}