public void start() throws Exception {
// Get the heartbeat period in mSecs
long period = interval * 1000;
if (period < = 0) {
log.debug("Heartbeat disabled");
return;
}
// Skip if schedule is already set
//
if(heartbeatSchedule == null) {
try {
// Organise schedulled emission of heartbeat notification
Object userData = null; // No user payload
Date startTime = new Date(); // Start immediately
Long nbOccurences = new Long(0); // Go on forever
// If timer MBean not registered, exception will be thrown
heartbeatSchedule = (Integer) agent.invoke(
timer,
"addNotification",
new Object[] {
EventTypes.HEARTBEAT,
NOTIFICATION_MSG,
userData,
startTime,
new Long(period),
nbOccurences
},
new String[] {
"java.lang.String",
"java.lang.String",
Object.class.getName(),
Date.class.getName(),
Long.TYPE.getName(),
Long.TYPE.getName()
});
log.debug("Heartbeat period set to " + period + " msecs");
}
catch (Exception e) {
log.error("while setting heartbeat notification", e);
throw e;
}
}
}
Setup the production of heart-beat notifications |