use of org.opennms.netmgt.model.ResourcePath in project opennms by OpenNMS.
the class RrdResourceAttributeUtilsTest method createResource.
private OnmsResource createResource() {
OnmsResource topResource = new OnmsResource("1", "Node One", new MockResourceType(), new HashSet<OnmsAttribute>(0), new ResourcePath("foo"));
Set<OnmsAttribute> attributes = new HashSet<OnmsAttribute>(1);
attributes.add(new RrdGraphAttribute("foo", "1/eth0", "foo.jrb"));
OnmsResource childResource = new OnmsResource("eth0", "Interface eth0", new MockResourceType(), attributes, new ResourcePath("foo"));
childResource.setParent(topResource);
return childResource;
}
use of org.opennms.netmgt.model.ResourcePath in project opennms by OpenNMS.
the class InterfaceSnmpResourceType method getResourceByParentPathAndInterface.
private OnmsResource getResourceByParentPathAndInterface(ResourcePath parent, String intf, String label, Long ifSpeed, String ifSpeedFriendly) throws DataAccessException {
final ResourcePath path = ResourcePath.get(parent, intf);
final AttributeLoader loader = new AttributeLoader(m_resourceStorageDao, path, ifSpeed, ifSpeedFriendly);
final Set<OnmsAttribute> set = new LazySet<OnmsAttribute>(loader);
return new OnmsResource(intf, label, this, set, path);
}
use of org.opennms.netmgt.model.ResourcePath in project opennms by OpenNMS.
the class AbstractPersister method persistStringAttribute.
/**
* {@inheritDoc}
*/
@Override
public void persistStringAttribute(CollectionAttribute attribute) {
LOG.debug("Persisting {}", attribute);
CollectionResource resource = attribute.getResource();
String value = attribute.getStringValue();
if (value == null) {
LOG.info("No data collected for attribute {}. Skipping.", attribute);
return;
}
try {
ResourcePath path = ResourceTypeUtils.getResourcePathWithRepository(m_repository, resource.getPath());
persistStringAttribute(path, attribute.getName(), value);
} catch (PersistException e) {
LOG.error("Unable to save string attribute {}.", attribute, e);
}
}
use of org.opennms.netmgt.model.ResourcePath in project opennms by OpenNMS.
the class DefaultCollectionAgentService method getStorageResourcePath.
/**
* <p>getStorageDir</p>
*
* @return a {@link java.io.File} object.
*/
@Override
public final ResourcePath getStorageResourcePath() {
final String foreignSource = getForeignSource();
final String foreignId = getForeignId();
final ResourcePath dir;
if (isStoreByForeignSource() && foreignSource != null && foreignId != null) {
dir = ResourcePath.get(ResourceTypeUtils.FOREIGN_SOURCE_DIRECTORY, foreignSource, foreignId);
} else {
dir = ResourcePath.get(String.valueOf(getNodeId()));
}
LOG.debug("getStorageDir: isStoreByForeignSource = {}, foreignSource = {}, foreignId = {}, dir = {}", isStoreByForeignSource(), foreignSource, foreignId, dir);
return dir;
}
use of org.opennms.netmgt.model.ResourcePath in project opennms by OpenNMS.
the class GroupPersister method visitGroup.
/**
* {@inheritDoc}
*/
@Override
public void visitGroup(AttributeGroup group) {
pushShouldPersist(group);
if (shouldPersist()) {
Map<String, String> dsNamesToRrdNames = new LinkedHashMap<String, String>();
for (CollectionAttribute a : group.getAttributes()) {
if (a.getType().isNumeric()) {
dsNamesToRrdNames.put(a.getName(), group.getName());
}
}
setBuilder(createBuilder(group.getResource(), group.getName(), group.getGroupType().getAttributeTypes()));
ResourcePath path = ResourceTypeUtils.getResourcePathWithRepository(getRepository(), group.getResource().getPath());
m_resourceStorageDao.updateMetricToResourceMappings(path, dsNamesToRrdNames);
}
}
Aggregations