From afa19b7c39642bdbd3ae913e77cf8a9da34a9a95 Mon Sep 17 00:00:00 2001 From: Brynjar Eide Date: Mon, 19 Nov 2018 21:56:46 +0100 Subject: [PATCH 1/7] Calculate availability based on complete downtime 24 hour availability percentage per node requires the entire downtime as a sum of all services' outage intervals. --- .../opennms/netmgt/rtc/AvailabilityServiceHibernateImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/opennms-services/src/main/java/org/opennms/netmgt/rtc/AvailabilityServiceHibernateImpl.java b/opennms-services/src/main/java/org/opennms/netmgt/rtc/AvailabilityServiceHibernateImpl.java index 783e70bf422c..a61d3af7b012 100644 --- a/opennms-services/src/main/java/org/opennms/netmgt/rtc/AvailabilityServiceHibernateImpl.java +++ b/opennms-services/src/main/java/org/opennms/netmgt/rtc/AvailabilityServiceHibernateImpl.java @@ -218,8 +218,7 @@ private static double getOutageTimeInWindow(List outages, Date start downtimeInWindow += (regainedAt - lostAt); } - // Bound the downtime by the length of the window - return Math.min(downtimeInWindow, windowLength); + return downtimeInWindow; } private int getNumServices(int nodeId, List serviceNames) { From 346d06e4b950526408cd27b15885557c6285e720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20von=20R=C3=BCden?= Date: Mon, 20 May 2019 17:21:27 +0200 Subject: [PATCH 2/7] NMS-10458: Provide test --- .../netmgt/rtc/AvailabilityServiceIT.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/opennms-services/src/test/java/org/opennms/netmgt/rtc/AvailabilityServiceIT.java b/opennms-services/src/test/java/org/opennms/netmgt/rtc/AvailabilityServiceIT.java index 23f8e5211aa8..26f800ec9d26 100644 --- a/opennms-services/src/test/java/org/opennms/netmgt/rtc/AvailabilityServiceIT.java +++ b/opennms-services/src/test/java/org/opennms/netmgt/rtc/AvailabilityServiceIT.java @@ -31,6 +31,7 @@ import static org.junit.Assert.assertEquals; import java.util.Date; +import java.util.List; import org.easymock.EasyMock; import org.junit.Before; @@ -42,10 +43,12 @@ import org.opennms.core.test.db.TemporaryDatabaseAware; import org.opennms.core.test.db.annotations.JUnitTemporaryDatabase; import org.opennms.netmgt.dao.api.MonitoredServiceDao; +import org.opennms.netmgt.dao.api.NodeDao; import org.opennms.netmgt.dao.api.OutageDao; import org.opennms.netmgt.mock.MockNetwork; import org.opennms.netmgt.mock.MockService; import org.opennms.netmgt.model.OnmsMonitoredService; +import org.opennms.netmgt.model.OnmsNode; import org.opennms.netmgt.model.OnmsOutage; import org.opennms.netmgt.rtc.datablock.RTCCategory; import org.opennms.netmgt.xml.rtc.Category; @@ -54,6 +57,7 @@ import org.opennms.test.JUnitConfigurationEnvironment; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionTemplate; import com.google.common.collect.Lists; @@ -166,7 +170,60 @@ public void canCalculateAvailability() throws Exception { assertEquals(2, category.getNode().size()); } + // See NMS-10458 + @Test + @Transactional + public void verifyAvailabilityIfEverythingIsDown() { + final MockNetwork mockNetwork = new MockNetwork(); + mockNetwork.createStandardNetwork(); + m_mockDatabase.populate(mockNetwork); + + final RTCCategory rtcCat = EasyMock.createNiceMock(RTCCategory.class); + EasyMock.expect(rtcCat.getLabel()).andReturn("TEST").anyTimes(); + EasyMock.expect(rtcCat.getNodes()).andReturn(Lists.newArrayList(1, 2, 3)).anyTimes(); + EasyMock.replay(rtcCat); + + final long now = System.currentTimeMillis(); + final long oneDayAgo = now - (1000 * 60 * 60 * 24); + + // Create Outage for Node 1 + createOutage(mockNetwork.getService(1, "192.168.1.1", "ICMP"), oneDayAgo); + + // Create Outages for Node 2 + createOutage(mockNetwork.getService(2, "192.168.1.3", "ICMP"), oneDayAgo); + createOutage(mockNetwork.getService(2, "192.168.1.3", "HTTP"), oneDayAgo); + + // Calculate Availability for category + final EuiLevel euiLevel = m_availabilityService.getEuiLevel(rtcCat); + assertEquals(1, euiLevel.getCategory().size()); + + // Verify Category Availability + final Category category = euiLevel.getCategory().get(0); + assertEquals("TEST", category.getCatlabel()); + assertEquals(70.0f, category.getCatvalue(), 0.0001); + + // Verify Nodes + final List nodes = category.getNode(); + assertEquals(3, nodes.size()); + verifyNode(nodes.get(0), 1, 75.0f); + verifyNode(nodes.get(1), 2, 0.0f); + verifyNode(nodes.get(2), 3, 100.0f); + } + private OnmsMonitoredService toMonitoredService(MockService svc) { return m_monitoredServiceDao.get(svc.getNodeId(), svc.getAddress(), svc.getSvcName()); } + + private void createOutage(MockService mockService, long oneDayAgo) { + final OnmsMonitoredService monitoredService = toMonitoredService(mockService); + final OnmsOutage outage = new OnmsOutage(); + outage.setMonitoredService(monitoredService); + outage.setIfLostService(new Date(oneDayAgo)); + m_outageDao.save(outage); + } + + private static void verifyNode(Node node, long nodeId, float availability) { + assertEquals(nodeId, node.getNodeid()); + assertEquals(availability, node.getNodevalue(), 0.0001); + } } From 09170f1487d210a5c9bccdf3fb17cb5a7be7e461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20von=20R=C3=BCden?= Date: Mon, 20 May 2019 17:21:44 +0200 Subject: [PATCH 3/7] NMS-10458: Remove unused code --- .../netmgt/rtc/AvailabilityServiceHibernateImpl.java | 1 - .../java/org/opennms/netmgt/rtc/AvailabilityServiceIT.java | 6 ------ 2 files changed, 7 deletions(-) diff --git a/opennms-services/src/main/java/org/opennms/netmgt/rtc/AvailabilityServiceHibernateImpl.java b/opennms-services/src/main/java/org/opennms/netmgt/rtc/AvailabilityServiceHibernateImpl.java index a61d3af7b012..da206791239c 100644 --- a/opennms-services/src/main/java/org/opennms/netmgt/rtc/AvailabilityServiceHibernateImpl.java +++ b/opennms-services/src/main/java/org/opennms/netmgt/rtc/AvailabilityServiceHibernateImpl.java @@ -196,7 +196,6 @@ private static double getOutageTimeInWindow(List outages, Date start final long windowStart = start.getTime(); final long windowEnd = end.getTime(); - final long windowLength = windowEnd - windowStart; Preconditions.checkArgument(0 <= windowStart && windowStart < windowEnd); long downtimeInWindow = 0; diff --git a/opennms-services/src/test/java/org/opennms/netmgt/rtc/AvailabilityServiceIT.java b/opennms-services/src/test/java/org/opennms/netmgt/rtc/AvailabilityServiceIT.java index 26f800ec9d26..d65ae9509e90 100644 --- a/opennms-services/src/test/java/org/opennms/netmgt/rtc/AvailabilityServiceIT.java +++ b/opennms-services/src/test/java/org/opennms/netmgt/rtc/AvailabilityServiceIT.java @@ -43,12 +43,10 @@ import org.opennms.core.test.db.TemporaryDatabaseAware; import org.opennms.core.test.db.annotations.JUnitTemporaryDatabase; import org.opennms.netmgt.dao.api.MonitoredServiceDao; -import org.opennms.netmgt.dao.api.NodeDao; import org.opennms.netmgt.dao.api.OutageDao; import org.opennms.netmgt.mock.MockNetwork; import org.opennms.netmgt.mock.MockService; import org.opennms.netmgt.model.OnmsMonitoredService; -import org.opennms.netmgt.model.OnmsNode; import org.opennms.netmgt.model.OnmsOutage; import org.opennms.netmgt.rtc.datablock.RTCCategory; import org.opennms.netmgt.xml.rtc.Category; @@ -58,7 +56,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionTemplate; import com.google.common.collect.Lists; @@ -85,9 +82,6 @@ public class AvailabilityServiceIT implements TemporaryDatabaseAware Date: Wed, 22 May 2019 16:20:48 -0400 Subject: [PATCH 4/7] ignore vscode bits --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 6683add758d9..420124bf3868 100644 --- a/.gitignore +++ b/.gitignore @@ -10,9 +10,11 @@ target .classpath .externalToolBuilders +.factorypath .project .settings .springBeans +.vscode .DS_Store build.properties *.iml From dfdd94c3689279ff19e543f5e9d09d46587d5070 Mon Sep 17 00:00:00 2001 From: Benjamin Reed Date: Wed, 22 May 2019 16:20:57 -0400 Subject: [PATCH 5/7] updated pull request template for github --- .github/PULL_REQUEST_TEMPLATE.md | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 7acfffa3bd07..8e589395bdb0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,12 +1,30 @@ +### All Contributors -Thanks for taking time to contribute! +* [ ] Have you read and followed our [Contribution Guidelines](https://github.com/OpenNMS/opennms/blob/develop/CONTRIBUTING.md)? +* [ ] Have you [made an issue in the OpenNMS issue tracker](https://issues.opennms.org)?
+ If so, you should: + 1. update the title of this PR to be of the format: `${JIRA-ISSUE-NUMBER}: subject of pull request` + 2. update the JIRA link at the bottom of this comment to refer to the real issue number +* [ ] Have you made a comment in that issue which points back to this PR? +* [ ] Have you updated the JIRA link at the bottom of this comment to link to your issue? +* [ ] If this is a new or updated feature, is there documentation for the new behavior? +* [ ] If this is new code, are there unit and/or integration tests? + +### Pull Request Process + +One or more reviewers should be assigned to each PR. -Please read our [Contribution Guidelines](https://github.com/OpenNMS/opennms/blob/develop/CONTRIBUTING.md) and format the title of the pull request in the format of: +If you know that a particular person is subject matter expert in the area your PR affects, feel free to assign one or more reviewers when you create this PR, otherwise reviewers will be assigned for you. -${JIRA-ISSUE-NUMBER}: a-short-subject-title +Once the reviewer(s) accept the PR and the branch passes continuous integration in Bamboo, the PR is eligible for merge. + +At that time, if you have commit access (are an OpenNMS Group employee or a member of the Order of the Green Polo) you are welcome to merge the PR. +Otherwise, a reviewer can merge it for you. + +Thanks for taking time to contribute! -Please use the [JIRA](https://issues.opennms.org) issue number and create a link in the JIRA issue back to this pull request so we have a quick reference from the issue to the pull request. +### External References -* JIRA: http://issues.opennms.org/browse/${JIRA-ISSUE-NUMBER} +* JIRA (Issue Tracker): http://issues.opennms.org/browse/${JIRA-ISSUE-NUMBER} +* Bamboo (Continuous Integration): https://bamboo.opennms.org/ -Our [continuous integration system](http://bamboo.internal.opennms.com:8085) will test and verify your changes. From 6063c27ba85c2a33334fc188ba00e51a3c199142 Mon Sep 17 00:00:00 2001 From: Benjamin Reed Date: Thu, 23 May 2019 10:16:14 -0400 Subject: [PATCH 6/7] feedback from @mvrueden --- .github/PULL_REQUEST_TEMPLATE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8e589395bdb0..ca2a9b3fac31 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,6 +5,7 @@ If so, you should: 1. update the title of this PR to be of the format: `${JIRA-ISSUE-NUMBER}: subject of pull request` 2. update the JIRA link at the bottom of this comment to refer to the real issue number + 3. prefix your commit messages with the issue number, if possible * [ ] Have you made a comment in that issue which points back to this PR? * [ ] Have you updated the JIRA link at the bottom of this comment to link to your issue? * [ ] If this is a new or updated feature, is there documentation for the new behavior? From 4b6d5502fb3a0c8ee0e64ecf4e92c48a7d6a6214 Mon Sep 17 00:00:00 2001 From: Benjamin Reed Date: Thu, 23 May 2019 11:37:50 -0400 Subject: [PATCH 7/7] fix OOM in javadoc plugin build --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a3704b62d830..e081bca042f6 100644 --- a/pom.xml +++ b/pom.xml @@ -314,9 +314,9 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.3 + 2.10.4 - 2g + 3g -Xdoclint:none false