/** {@inheritDoc} */ public List<Event> applyThresholds(String svcName, Map<String, Double> attributes) { LatencyCollectionResource latencyResource = new LatencyCollectionResource(svcName, m_hostAddress, m_location); LatencyCollectionAttributeType latencyType = new LatencyCollectionAttributeType(); Map<String, CollectionAttribute> attributesMap = new HashMap<String, CollectionAttribute>(); for (final Entry<String, Double> entry : attributes.entrySet()) { final String ds = entry.getKey(); attributesMap.put(ds, new LatencyCollectionAttribute(latencyResource, latencyType, ds, entry.getValue())); } //The timestamp is irrelevant; latency is never a COUNTER (which is the only reason the date is used). //Yes, we have to know a little too much about the implementation details of CollectionResourceWrapper to say that, but // we have little choice CollectionResourceWrapper resourceWrapper = new CollectionResourceWrapper(new Date(), m_nodeId, m_hostAddress, m_serviceName, m_repository, latencyResource, attributesMap, m_resourceStorageDao); return Collections.unmodifiableList(applyThresholds(resourceWrapper, attributesMap)); }
/** {@inheritDoc} */ public List<Event> applyThresholds(CollectionResource resource, Map<String, CollectionAttribute> attributesMap, Date collectionTimestamp) { if (!isCollectionEnabled(resource)) { LOG.debug("applyThresholds: Ignoring resource {} because data collection is disabled for this resource.", resource); return new LinkedList<>(); } CollectionResourceWrapper resourceWrapper = new CollectionResourceWrapper( collectionTimestamp, m_nodeId, m_hostAddress, m_serviceName, m_repository, resource, attributesMap, m_resourceStorageDao); resourceWrapper.setCounterReset(counterReset); return applyThresholds(resourceWrapper, attributesMap); }
@Test(expected=IllegalArgumentException.class) public void testBadderConstructorCall() throws Throwable { try { new CollectionResourceWrapper(null, -1, null, null, null, null, null, null); } catch (Throwable e) { e.printStackTrace(); throw e; } }
@Test(expected=IllegalArgumentException.class) public void testBadConstructorCall() throws Throwable { try { new CollectionResourceWrapper(null, 1, "127.0.0.1", "HTTP", null, null, null, null); } catch (Throwable e) { //e.printStackTrace(); throw e; } }
private CollectionResourceWrapper createWrapper(SnmpCollectionResource resource, Map<String, CollectionAttribute> attributes, Date timestamp) { CollectionResourceWrapper wrapper = new CollectionResourceWrapper(timestamp, 1, "127.0.0.1", "SNMP", getRepository(), resource, attributes, getResourceStorageDao()); return wrapper; }
resource = new CollectionResourceWrapper(date, 0, null, null, null, null, null, null);