@Test public void testGenericResource() throws Exception { CollectionAgent agent = createCollectionAgent(); MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig(); OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig); ResourceType rt = new ResourceType(); rt.setName("hrStorageIndex"); rt.setLabel("host-resources storage"); StorageStrategy strategy = new StorageStrategy(); strategy.setClazz("org.opennms.netmgt.dao.support.SiblingColumnStorageStrategy"); strategy.addParameter(new Parameter("sibling-column-name", "hrStorageLabel")); strategy.addParameter(new Parameter("replace-all", "s/^- rt.setStorageStrategy(strategy); PersistenceSelectorStrategy pstrategy = new PersistenceSelectorStrategy(); pstrategy.setClazz("org.opennms.netmgt.collectd.PersistAllSelectorStrategy"); rt.setPersistenceSelectorStrategy(pstrategy); GenericIndexResourceType resourceType = new GenericIndexResourceType(agent, collection, rt); SnmpCollectionResource resource = new GenericIndexResource(resourceType, resourceType.getName(), new SnmpInstId(100)); SnmpAttribute used = addAttributeToCollectionResource(resource, "hrStorageUsed", "gauge", "hrStorageIndex", "5000"); SnmpAttribute label = addAttributeToCollectionResource(resource, "hrStorageLabel", "string", "hrStorageIndex", "/opt"); Map<String, CollectionAttribute> attributes = new HashMap<String, CollectionAttribute>(); attributes.put(used.getName(), used); attributes.put(label.getName(), label); CollectionResourceWrapper wrapper = createWrapper(resource, attributes); Assert.assertEquals("opt", wrapper.getInstanceLabel()); }
public String getInstanceLabel() { return m_resource != null ? m_resource.getLabel() : null; }
CollectionResourceWrapper { public String getInstanceLabel() { return m_resource != null ? m_resource.getLabel() : null; } }
CollectionResourceWrapper { public String getInstanceLabel() { return m_resource != null ? m_resource.getLabel() : null; } CollectionResourceWrapper(Date collectionTimestamp, int nodeId, String hostAddress, String serviceName, RrdRepository repository, CollectionResource resource, Map<String, CollectionAttribute> attributes); }
CollectionResourceWrapper { public String getInstanceLabel() { return m_resource != null ? m_resource.getLabel() : null; } CollectionResourceWrapper(Date collectionTimestamp, int nodeId, String hostAddress, String serviceName, RrdRepository repository, CollectionResource resource, Map<String, CollectionAttribute> attributes); int getNodeId(); String getHostAddress(); String getServiceName(); RrdRepository getRepository(); String getDsLabel(); void setDsLabel(String dsLabel); String getInstance(); String getInstanceLabel(); String getResourceTypeName(); String getResourceId(); String getIfLabel(); String getIfIndex(); boolean isAnInterfaceResource(); boolean isValidInterfaceResource(); Double getAttributeValue(String ds); String getFieldValue(String ds); @Override String toString(); }
CollectionResourceWrapper { public String getInstanceLabel() { return m_resource != null ? m_resource.getLabel() : null; } CollectionResourceWrapper(Date collectionTimestamp, int nodeId, String hostAddress, String serviceName, RrdRepository repository, CollectionResource resource, Map<String, CollectionAttribute> attributes); int getNodeId(); String getHostAddress(); String getServiceName(); RrdRepository getRepository(); String getDsLabel(); void setDsLabel(String dsLabel); String getInstance(); String getInstanceLabel(); String getResourceTypeName(); String getResourceId(); String getIfLabel(); String getIfIndex(); boolean isAnInterfaceResource(); boolean isValidInterfaceResource(); Double getAttributeValue(String ds); String getFieldValue(String ds); @Override String toString();  }