-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/jw/merge-rel23-to-devel' into de…
…velop
- Loading branch information
Showing
32 changed files
with
814 additions
and
259 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
...persistence/api/src/main/java/org/opennms/netmgt/enlinkd/model/CdpLinkTopologyEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + '\'' + | ||
'}'; | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
...kd/persistence/api/src/main/java/org/opennms/netmgt/enlinkd/model/NodeTopologyEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + | ||
'}'; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...nce/api/src/main/java/org/opennms/netmgt/enlinkd/persistence/api/TopologyEntityCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...tence/api/src/main/java/org/opennms/netmgt/enlinkd/persistence/api/TopologyEntityDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.