@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); } },
@Override public Object call() throws Exception { if (log.isDebugEnabled()) log.debug("jmx operation polling for {} sensors at {} -> {}", new Object[] {getEntity(), getJmxUri(), operationName}); if (signature.size() == params.size()) { return getHelper().operation(objectName, operationName, signature, params); } else { return getHelper().operation(objectName, operationName, params.toArray()); } } },
AttributePollHandler<javax.management.Notification> handler = new AttributePollHandler<javax.management.Notification>(config, getEntity(), this) { @Override protected Object transformValueOnSuccess(javax.management.Notification val) { if (config.getOnNotification() != null) {
/** * Registers to poll a jmx-attribute for an ObjectName, where all the given configs are for that same ObjectName + attribute. */ 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()); } // TODO Not good calling this holding the synchronization lock 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); }
handlers.add(new AttributePollHandler<Object>(config, getEntity(), this)); if (config.getPeriod() > 0) minPeriod = Math.min(minPeriod, config.getPeriod());