private void registerAttributePoller(Set<JmxAttributePollConfig<?>> configs) {
Set<AttributePollHandler<? super Object>> handlers = Sets.newLinkedHashSet();
long minPeriod = Integer.MAX_VALUE;
final ObjectName objectName = Iterables.get(configs, 0).getObjectName();
final String jmxAttributeName = Iterables.get(configs, 0).getAttributeName();
for (JmxAttributePollConfig<?> config : configs) {
handlers.add(new AttributePollHandler<Object>(config, getEntity(), this));
if (config.getPeriod() > 0) minPeriod = Math.min(minPeriod, config.getPeriod());
}
getPoller().scheduleAtFixedRate(
new Callable<Object>() {
@Override
public Object call() throws Exception {
if (log.isTraceEnabled()) log.trace("jmx attribute polling for {} sensors at {} -> {}", new Object[] {getEntity(), getJmxUri(), jmxAttributeName});
return getHelper().getAttribute(objectName, jmxAttributeName);
}
},
new DelegatingPollHandler<Object>(handlers), minPeriod);
}