Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jw/merge-rel23-to-devel' into de…
Browse files Browse the repository at this point in the history
…velop
  • Loading branch information
Jesse White committed Nov 30, 2018
2 parents 54c7d96 + 01f9005 commit 373928a
Show file tree
Hide file tree
Showing 32 changed files with 814 additions and 259 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2018 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2018 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
* OpenNMS(R) is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* OpenNMS(R) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with OpenNMS(R). If not, see:
* http://www.gnu.org/licenses/
*
* For more information contact:
* OpenNMS(R) Licensing <license@opennms.org>
* http://www.opennms.org/
* http://www.opennms.com/
*******************************************************************************/

package org.opennms.netmgt.enlinkd.model;

/**
* This is NOT a Hibernate/JPA entity but rather a lightweight model without less attributes than CdpLink and no lazy
* loading. We use it to retrieve link information from the database fast.
*/
public class CdpLinkTopologyEntity {

private final Integer id;
private final Integer nodeId;
private final Integer cdpCacheIfIndex;
private final String cdpInterfaceName;
private final String cdpCacheAddress;
private final String cdpCacheDeviceId;
private final String cdpCacheDevicePort;

public CdpLinkTopologyEntity(Integer id, Integer nodeId, Integer cdpCacheIfIndex, String cdpInterfaceName, String cdpCacheAddress,
String cdpCacheDeviceId, String cdpCacheDevicePort){
this.id = id;
this.nodeId = nodeId;
this.cdpCacheIfIndex = cdpCacheIfIndex;
this.cdpInterfaceName = cdpInterfaceName;
this.cdpCacheAddress = cdpCacheAddress;
this.cdpCacheDeviceId = cdpCacheDeviceId;
this.cdpCacheDevicePort = cdpCacheDevicePort;
}

public Integer getId() {
return id;
}

public Integer getNodeId() {
return nodeId;
}

public String getNodeIdAsString() {
if (getNodeId() != null) {
return getNodeId().toString();
}
return null;
}

public Integer getCdpCacheIfIndex() {
return cdpCacheIfIndex;
}

public String getCdpInterfaceName() {
return cdpInterfaceName;
}

public String getCdpCacheAddress() {
return cdpCacheAddress;
}

public String getCdpCacheDevicePort() {
return cdpCacheDevicePort;
}

public String getCdpCacheDeviceId() {
return cdpCacheDeviceId;
}

@Override
public String toString() {
return "CdpLinkInfo{" +
"id=" + id +
", nodeId=" + nodeId +
", cdpCacheIfIndex=" + cdpCacheIfIndex +
", cdpInterfaceName='" + cdpInterfaceName + '\'' +
", cdpCacheAddress='" + cdpCacheAddress + '\'' +
", cdpCacheDeviceId='" + cdpCacheDeviceId + '\'' +
", cdpCacheDevicePort='" + cdpCacheDevicePort + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2018 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2018 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
* OpenNMS(R) is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* OpenNMS(R) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with OpenNMS(R). If not, see:
* http://www.gnu.org/licenses/
*
* For more information contact:
* OpenNMS(R) Licensing <license@opennms.org>
* http://www.opennms.org/
* http://www.opennms.com/
*******************************************************************************/

package org.opennms.netmgt.enlinkd.model;

import java.io.Serializable;

import org.opennms.netmgt.model.OnmsNode;
import org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation;

/**
* This is NOT a Hibernate/JPA entity but rather a lightweight model without less attributes than OnmsNode and no lazy
* loading. We use it to retrieve node information from the database fast.
*/
public class NodeTopologyEntity implements Serializable {

private Integer id;
private OnmsNode.NodeType type;
private String sysObjectId;
private String label;
private String location;

public NodeTopologyEntity(Integer nodeid, OnmsNode.NodeType nodetype, String nodesysoid, String nodelabel, String location){
this.id = nodeid;
this.type = nodetype;
this.sysObjectId = nodesysoid;
this.label = nodelabel;
this.location = location;
}

public NodeTopologyEntity(Integer id, OnmsNode.NodeType type, String sysObjectId, String label, OnmsMonitoringLocation location){
this(id, type, sysObjectId, label, location.getLocationName());
}

public static NodeTopologyEntity toVertexInfo(OnmsNode node){
return new NodeTopologyEntity(node.getId(), node.getType(), node.getSysObjectId(), node.getLabel(), node.getLocation().getLocationName());
}

public Integer getId() {
return id;
}

public OnmsNode.NodeType getType() {
return type;
}


public String getSysObjectId() {
return sysObjectId;
}


public String getLabel() {
return label;
}


public String getLocation() {
return location;
}

@Override
public String toString() {
return "NodeTopologyEntity{" +
"id=" + id +
", type=" + type +
", sysObjectId='" + sysObjectId + '\'' +
", label='" + label + '\'' +
", location=" + location +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2018 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2018 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
* OpenNMS(R) is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* OpenNMS(R) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with OpenNMS(R). If not, see:
* http://www.gnu.org/licenses/
*
* For more information contact:
* OpenNMS(R) Licensing <license@opennms.org>
* http://www.opennms.org/
* http://www.opennms.com/
*******************************************************************************/

package org.opennms.netmgt.enlinkd.persistence.api;

import java.util.List;

import org.opennms.netmgt.enlinkd.model.CdpLinkTopologyEntity;
import org.opennms.netmgt.enlinkd.model.NodeTopologyEntity;


/**
* Caches TopologyEmtities. This is a cache wrapper around @{@link TopologyEntityDao}. See there for an explanation of
* TopologyEntrities.
* We use the cache to improve the displaying speed of topologies.
*/
public interface TopologyEntityCache {

List<NodeTopologyEntity> getNodeTopolgyEntities();

List<CdpLinkTopologyEntity> getCdpLinkTopologyEntities();

void refresh();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2018 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2018 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
* OpenNMS(R) is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* OpenNMS(R) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with OpenNMS(R). If not, see:
* http://www.gnu.org/licenses/
*
* For more information contact:
* OpenNMS(R) Licensing <license@opennms.org>
* http://www.opennms.org/
* http://www.opennms.com/
*******************************************************************************/

package org.opennms.netmgt.enlinkd.persistence.api;

import java.util.List;

import org.opennms.netmgt.enlinkd.model.CdpLinkTopologyEntity;
import org.opennms.netmgt.enlinkd.model.NodeTopologyEntity;

/**
* Retrieves TopologyEntities from the database. TopologyEntities are views on OnmsEntities (such as OnmsNode, CdpLink, etc.)
* which are reduced to the needs of displaying a toplogy:
* - they are derived from one OnmsEntity / a database table
* - they contain only the relevant subset of attributes of their OnmsEntity
* - relations are just referenced by a primitive key such as a String or Integer instead of (lazy loaded) object references
* The above features allow for fast database retrieval.
*/
public interface TopologyEntityDao {
List<NodeTopologyEntity> getNodeTopologyEntities();
List<CdpLinkTopologyEntity> getCdpLinkTopologyEntities();
}
30 changes: 30 additions & 0 deletions features/enlinkd/persistence/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,35 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opennms</groupId>
<artifactId>opennms-dao-mock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opennms.core.test-api</groupId>
<artifactId>org.opennms.core.test-api.lib</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opennms.core.test-api</groupId>
<artifactId>org.opennms.core.test-api.db</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opennms.core.test-api</groupId>
<artifactId>org.opennms.core.test-api.services</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opennms.features.collection</groupId>
<artifactId>org.opennms.features.collection.persistence.rrd</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opennms</groupId>
<artifactId>opennms-rrd-jrobin</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit 373928a

Please sign in to comment.