WatchDescriptor[] wds = sla.getWatchDescriptors();
if (wds.length > 0) {
identifier = wds[0].getName();
}
SLAPolicyHandler handler = null;
ServiceElement elem = context.getServiceElement();
/* Check if the SLA matches a MeasurableCapability. */
MeasurableCapability mCap = getMeasurableCapability(identifier);
if (mCap != null) {
logger.trace("[{}] SLA [{}] correlates to a MeasurableCapability", elem.getName(), identifier);
try {
/* Load the SLA PolicyHandler and set attributes */
handler = createSLAPolicyHandler(sla, null);
ThresholdManager tMgr = new BoundedThresholdManager(mCap.getId());
tMgr.setThresholdValues(sla);
handler.setThresholdManager(tMgr);
mCap.addSecondaryThresholdManager(tMgr);
thresholdManagerReg.put(tMgr, mCap);
logger.trace("[{}] SLA ID [{}], associated to MeasurableCapability={}, SLAPolicyHandler={}",
elem.getName(), identifier, mCap.getClass().getName(), handler.getClass().getName());
} catch (Exception e) {
logger.warn("Creating SLAPolicyHandler for system SLA [{}]", sla.getIdentifier(), e);
}
/* Check if the SLA matches the ThreadDeadlockMonitor. */
} else if(identifier.equals(ThreadDeadlockMonitor.ID)) {
WatchDescriptor wDesc = ServiceElementUtil.getWatchDescriptor(elem, ThreadDeadlockMonitor.ID);
if(wDesc==null)
wDesc = ThreadDeadlockMonitor.getWatchDescriptor();
/* If the service is not forked and running in it's own VM,
* we currently do not allow service specific thread deadlock
* monitoring. There is one Cybernode-based
* ThreadDeadlockMonitor that will send out notifications */
if(wDesc.getMBeanServerConnection()==null && !runningForked()) {
logger.warn("Thread deadlock detection is provided at the process level, not " +
"enabled on a service-by-service approach within a Cybernode. The SLA declaration for " +
"the [{}] service will be ignored. Note that thread deadlock " +
"detection has been enabled by the Cybernode.", elem.getName());
return;
}
if(wDesc.getPeriod()<1000) {
logger.info("Thread deadlock monitoring has been disabled " +
"for service [{}]. The configured thread deadlock check time was " +
"[{}]. To enable thread deadlock monitoring, the thread deadlock " +
"check time must be >= 1000 milliseconds.", elem.getName(), wDesc.getPeriod());
return;
}
logger.info("Setting Thread deadlock detection: {}", sla);
try {
ClassLoader loader = impl.getClass().getClassLoader();