Skip to content

Commit

Permalink
Combined AttributeDefinition into CollectionAttributeType.
Browse files Browse the repository at this point in the history
  • Loading branch information
soleger committed Apr 23, 2014
1 parent a61b94b commit 0b8788d
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 105 deletions.

This file was deleted.

Expand Up @@ -53,7 +53,7 @@ public class AttributeGroupType {
*/
public static final String IF_TYPE_IGNORE = "ignore";

private SortedSet<AttributeDefinition> m_attributeTypes = new TreeSet<AttributeDefinition>(new ByNameComparator());
private SortedSet<CollectionAttributeType> m_attributeTypes = new TreeSet<CollectionAttributeType>(new ByNameComparator());

/**
* <p>Constructor for AttributeGroupType.</p>
Expand Down Expand Up @@ -114,9 +114,9 @@ public String getName() {
/**
* <p>addAttributeType</p>
*
* @param attrType a {@link org.opennms.netmgt.collectd.AttributeDefinition} object.
* @param attrType a {@link org.opennms.netmgt.collectd.CollectionAttributeType} object.
*/
public void addAttributeType(AttributeDefinition attrType) {
public void addAttributeType(CollectionAttributeType attrType) {
m_attributeTypes.add(attrType);
}

Expand All @@ -125,7 +125,7 @@ public void addAttributeType(AttributeDefinition attrType) {
*
* @return a {@link java.util.SortedSet} object.
*/
public SortedSet<AttributeDefinition> getAttributeTypes() {
public SortedSet<CollectionAttributeType> getAttributeTypes() {
return Collections.unmodifiableSortedSet(m_attributeTypes);
}

Expand Down
Expand Up @@ -38,19 +38,19 @@
* @author ranger
* @version $Id: $
*/
public final class ByNameComparator implements Comparator<AttributeDefinition>, Serializable {
public final class ByNameComparator implements Comparator<CollectionAttributeType>, Serializable {

private static final long serialVersionUID = -2596801053643459622L;

/**
* <p>compare</p>
*
* @param type0 a {@link org.opennms.netmgt.collection.api.AttributeDefinition} object.
* @param type1 a {@link org.opennms.netmgt.collection.api.AttributeDefinition} object.
* @param type0 a {@link org.opennms.netmgt.collection.api.CollectionAttributeType} object.
* @param type1 a {@link org.opennms.netmgt.collection.api.CollectionAttributeType} object.
* @return a int.
*/
@Override
public int compare(final AttributeDefinition type0, final AttributeDefinition type1) {
public int compare(final CollectionAttributeType type0, final CollectionAttributeType type1) {
return type0.getName().compareTo(type1.getName());
}

Expand Down
Expand Up @@ -88,7 +88,7 @@ public interface CollectionAttribute extends CollectionVisitable, Persistable {
CollectionAttributeType getAttributeType();

/**
* Returns type of value (typically one of "counter", "gauge", "timeticks", "integer", "octetstring" - see NumericAttributeType)
* Returns type of value (typically one of "counter", "gauge", "timeticks", "integer", "octetstring" - see {@link NumericAttributeType})
*
* @return type of value stored in this attribute (SNMP semantics)
*/
Expand Down
Expand Up @@ -35,18 +35,51 @@
* @author ranger
* @version $Id: $
*/
public interface CollectionAttributeType extends AttributeDefinition {
public interface CollectionAttributeType {
/**
* <p>getType</p>
*
* @return a {@link java.lang.String} object.
*/
String getType();

/**
* <p>getName</p>
*
* Human readable name for the attribute.
* @return a {@link java.lang.String} object.
*/
String getName();

/**
* <p>equals</p>
*
* @param o a {@link java.lang.Object} object.
* @return a boolean.
*/
@Override
boolean equals(Object o);

/**
* <p>hashCode</p>
*
* @return a int.
*/
@Override
int hashCode();

/**
* <p>getGroupType</p>
*
* @return a {@link org.opennms.netmgt.config.collector.AttributeGroupType} object.
*/
public AttributeGroupType getGroupType();
AttributeGroupType getGroupType();

/**
* <p>storeAttribute</p>
*
* @param attribute a {@link org.opennms.netmgt.collection.api.CollectionAttribute} object.
* @param persister a {@link org.opennms.netmgt.config.collector.Persister} object.
*/
public void storeAttribute(CollectionAttribute attribute, Persister persister);
void storeAttribute(CollectionAttribute attribute, Persister persister);
}
Expand Up @@ -36,9 +36,9 @@
import java.util.LinkedList;
import java.util.Set;

import org.opennms.netmgt.collection.api.AttributeDefinition;
import org.opennms.netmgt.collection.api.AttributeGroup;
import org.opennms.netmgt.collection.api.CollectionAttribute;
import org.opennms.netmgt.collection.api.CollectionAttributeType;
import org.opennms.netmgt.collection.api.CollectionResource;
import org.opennms.netmgt.collection.api.Persister;
import org.opennms.netmgt.collection.api.ServiceParameters;
Expand Down Expand Up @@ -122,9 +122,9 @@ public void completeResource(CollectionResource resource) {
*
* @param resource a {@link org.opennms.netmgt.collection.api.CollectionResource} object.
* @param name a {@link java.lang.String} object.
* @param attributeType a {@link org.opennms.netmgt.collection.api.AttributeDefinition} object.
* @param attributeType a {@link org.opennms.netmgt.collection.api.CollectionAttributeType} object.
*/
protected void createBuilder(CollectionResource resource, String name, AttributeDefinition attributeType) {
protected void createBuilder(CollectionResource resource, String name, CollectionAttributeType attributeType) {
createBuilder(resource, name, Collections.singleton(attributeType));
}

Expand All @@ -135,13 +135,13 @@ protected void createBuilder(CollectionResource resource, String name, Attribute
* @param name a {@link java.lang.String} object.
* @param attributeTypes a {@link java.util.Set} object.
*/
protected void createBuilder(CollectionResource resource, String name, Set<AttributeDefinition> attributeTypes) {
protected void createBuilder(CollectionResource resource, String name, Set<CollectionAttributeType> attributeTypes) {
m_builder = new PersistOperationBuilder(getRepository(), resource, name);
if (resource.getTimeKeeper() != null) {
m_builder.setTimeKeeper(resource.getTimeKeeper());
}
for (Iterator<AttributeDefinition> iter = attributeTypes.iterator(); iter.hasNext();) {
AttributeDefinition attrType = iter.next();
for (Iterator<CollectionAttributeType> iter = attributeTypes.iterator(); iter.hasNext();) {
CollectionAttributeType attrType = iter.next();
if (attrType instanceof NumericAttributeType) {
m_builder.declareAttribute(attrType);
}
Expand Down
Expand Up @@ -87,7 +87,6 @@
import org.opennms.core.utils.InetAddressUtils;
import org.opennms.core.utils.ParameterMap;
import org.opennms.core.utils.TimeKeeper;
import org.opennms.netmgt.collection.api.AttributeDefinition;
import org.opennms.netmgt.collection.api.AttributeGroup;
import org.opennms.netmgt.collection.api.AttributeGroupType;
import org.opennms.netmgt.collection.api.CollectionAgent;
Expand Down Expand Up @@ -320,7 +319,7 @@ private static void doCollection(final HttpCollectionSet collectionSet, final Ht
}
}

private static class HttpCollectionAttribute extends AbstractCollectionAttribute implements AttributeDefinition {
private static class HttpCollectionAttribute extends AbstractCollectionAttribute {
private final String m_alias;
private final String m_type;
private final Object m_value;
Expand Down
Expand Up @@ -41,8 +41,8 @@
import org.opennms.core.utils.DefaultTimeKeeper;
import org.opennms.core.utils.StringUtils;
import org.opennms.core.utils.TimeKeeper;
import org.opennms.netmgt.collection.api.AttributeDefinition;
import org.opennms.netmgt.collection.api.ByNameComparator;
import org.opennms.netmgt.collection.api.CollectionAttributeType;
import org.opennms.netmgt.collection.api.ResourceIdentifier;
import org.opennms.netmgt.rrd.RrdDataSource;
import org.opennms.netmgt.rrd.RrdException;
Expand All @@ -61,7 +61,7 @@ public class PersistOperationBuilder {
private final RrdRepository m_repository;
private final String m_rrdName;
private final ResourceIdentifier m_resource;
private final Map<AttributeDefinition, String> m_declarations = new TreeMap<AttributeDefinition, String>(new ByNameComparator());
private final Map<CollectionAttributeType, String> m_declarations = new TreeMap<CollectionAttributeType, String>(new ByNameComparator());
private final Map<String, String> m_metaData = new LinkedHashMap<String, String>();
private TimeKeeper m_timeKeeper = new DefaultTimeKeeper();

Expand Down Expand Up @@ -103,19 +103,19 @@ private File getResourceDir(ResourceIdentifier resource) throws FileNotFoundExce
/**
* <p>declareAttribute</p>
*
* @param attrType a {@link org.opennms.netmgt.collection.api.AttributeDefinition} object.
* @param attrType a {@link org.opennms.netmgt.collection.api.CollectionAttributeType} object.
*/
public void declareAttribute(AttributeDefinition attrType) {
public void declareAttribute(CollectionAttributeType attrType) {
m_declarations.put(attrType, "U");
}

/**
* <p>setAttributeValue</p>
*
* @param attrType a {@link org.opennms.netmgt.collection.api.AttributeDefinition} object.
* @param attrType a {@link org.opennms.netmgt.collection.api.CollectionAttributeType} object.
* @param value a {@link java.lang.String} object.
*/
public void setAttributeValue(AttributeDefinition attrType, String value) {
public void setAttributeValue(CollectionAttributeType attrType, String value) {
m_declarations.put(attrType, value);
}

Expand Down Expand Up @@ -168,8 +168,8 @@ public void commit() throws RrdException {
private String getValues() {
boolean first = true;
StringBuffer values = new StringBuffer();
for (Iterator<AttributeDefinition> iter = m_declarations.keySet().iterator(); iter.hasNext();) {
AttributeDefinition attrDef = iter.next();
for (Iterator<CollectionAttributeType> iter = m_declarations.keySet().iterator(); iter.hasNext();) {
CollectionAttributeType attrDef = iter.next();
String value = m_declarations.get(attrDef);
if (!first) {
values.append(':');
Expand All @@ -187,7 +187,7 @@ private Map<String, String> getAttributeMappings() {

private List<RrdDataSource> getDataSources() {
List<RrdDataSource> dataSources = new ArrayList<RrdDataSource>(m_declarations.size());
for (AttributeDefinition attrDef : m_declarations.keySet()) {
for (CollectionAttributeType attrDef : m_declarations.keySet()) {

String minval = "U";
String maxval = "U";
Expand Down
Expand Up @@ -32,7 +32,6 @@
import java.util.Collection;
import java.util.List;

import org.opennms.netmgt.collection.api.AttributeDefinition;
import org.opennms.netmgt.collection.api.AttributeGroupType;
import org.opennms.netmgt.collection.api.CollectionAttribute;
import org.opennms.netmgt.collection.api.CollectionAttributeType;
Expand All @@ -57,7 +56,7 @@
* @author ranger
* @version $Id: $
*/
public abstract class SnmpAttributeType implements AttributeDefinition, CollectionAttributeType {
public abstract class SnmpAttributeType implements CollectionAttributeType {

private static final Logger LOG = LoggerFactory.getLogger(SnmpAttributeType.class);

Expand Down
Expand Up @@ -36,8 +36,8 @@
import java.util.Map;

import org.opennms.core.utils.ParameterMap;
import org.opennms.netmgt.collection.api.AttributeDefinition;
import org.opennms.netmgt.collection.api.CollectionAgent;
import org.opennms.netmgt.collection.api.CollectionAttributeType;
import org.opennms.netmgt.collection.api.CollectionException;
import org.opennms.netmgt.collection.api.CollectionResource;
import org.opennms.netmgt.collection.api.CollectionSet;
Expand Down Expand Up @@ -522,10 +522,10 @@ public SnmpAgentConfig getAgentConfig() {
/**
* <p>notifyIfNotFound</p>
*
* @param attrType a {@link org.opennms.netmgt.collection.api.AttributeDefinition} object.
* @param attrType a {@link org.opennms.netmgt.collection.api.CollectionAttributeType} object.
* @param res a {@link org.opennms.netmgt.snmp.SnmpResult} object.
*/
public void notifyIfNotFound(AttributeDefinition attrType, SnmpResult res) {
public void notifyIfNotFound(CollectionAttributeType attrType, SnmpResult res) {
// Don't bother sending a rescan event in this case since localhost is not going to be there anyway
//triggerRescan();
LOG.info("Unable to locate resource for agent {} with instance id {} while collecting attribute {}", getCollectionAgent(), res.getInstance(), attrType);
Expand Down

0 comments on commit 0b8788d

Please sign in to comment.