Skip to content

Commit

Permalink
NMS-16946: More updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Chandra Gorantla authored and Chandra Gorantla committed Nov 26, 2024
1 parent a6aaa3a commit 2cb2694
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,8 @@
*/
package org.opennms.netmgt.collection.dto;

import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.OptionalLong;
import java.util.Set;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Expand Down Expand Up @@ -147,8 +140,8 @@ private Set<CollectionResource> buildCollectionResources() {
for (CollectionResourceDTO entry : this.collectionResources) {
final Resource resource = entry.getResource();
final AbstractCollectionResource collectionResource = CollectionSetBuilder.toCollectionResource(resource, agent);
resource.getTags().forEach(collectionResource::addTag);
resource.getServiceParams().forEach(collectionResource::addServiceParam);
Optional.ofNullable(resource).ifPresent(res -> resource.getTags().forEach(collectionResource::addTag));
Optional.ofNullable(resource).ifPresent(res -> resource.getServiceParams().forEach(collectionResource::addServiceParam));
for (Attribute<?> attribute : entry.getAttributes()) {
final AttributeGroupType groupType = new AttributeGroupType(attribute.getGroup(), AttributeGroupType.IF_TYPE_ALL);
final AbstractCollectionAttributeType attributeType = new AbstractCollectionAttributeType(groupType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public String toString() {
.toString();
}

public String getIpAddress() {
return ipAddress;
}

@Override
public Map<String, String> getTags() {
return tags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.opennms.integration.api.v1.timeseries.immutables.ImmutableTag;
import org.opennms.netmgt.collection.api.CollectionResource;
import org.opennms.netmgt.collection.api.LatencyCollectionResource;
import org.opennms.netmgt.collection.support.builder.LatencyTypeResource;
import org.opennms.netmgt.dao.api.NodeDao;
import org.opennms.netmgt.dao.api.SessionUtils;
import org.opennms.netmgt.model.OnmsCategory;
Expand Down Expand Up @@ -102,8 +103,13 @@ public Set<Tag> load(final CollectionResource resource) {
resource.getServiceParams().containsKey(INTERFACE_INFO_IN_TAGS) &&
Boolean.parseBoolean(resource.getServiceParams().get(INTERFACE_INFO_IN_TAGS))) {
try {
String ipAddress = ((LatencyCollectionResource) resource).getIpAddress();
scopes.add(this.entityScopeProvider.getScopeForInterface(node.getId(), ipAddress));
if (resource instanceof LatencyCollectionResource) {
String ipAddress = ((LatencyCollectionResource) resource).getIpAddress();
scopes.add(this.entityScopeProvider.getScopeForInterface(node.getId(), ipAddress));
} else if (resource instanceof LatencyTypeResource) {
String ipAddress = ((LatencyTypeResource) resource).getIpAddress();
scopes.add(this.entityScopeProvider.getScopeForInterface(node.getId(), ipAddress));
}
} catch (ClassCastException e) {
// Should never happen.
LOG.error("Exception while casting resource {} to latency resource", resource);
Expand Down

0 comments on commit 2cb2694

Please sign in to comment.