public List<Node> getNode() { return m_rtcCategory.getNode(); }
/** * Create an instance of {@link Category } * */ public Category createCategory() { return new Category(); }
/** * Return the current service level availability for this category. * * @return a double. */ @XmlElement(name="availability") public double getValue() { if (m_rtcCategory == null) { return 0.0; } else { return m_rtcCategory.getCatvalue(); } }
level.setHeader(m_header); org.opennms.netmgt.xml.rtc.Category levelCat = new org.opennms.netmgt.xml.rtc.Category(); levelCat.setCatlabel(rtcCat.getLabel()); levelCat.setCatvalue(m_dataMgr.getValue(rtcCat, curTime, rWindow)); levelCat.getNode().add(levelNode);
@Test public void categoryIsFullyAvailableWhenNoServicesArePresent() throws Exception { final RTCCategory rtcCat = EasyMock.createNiceMock(RTCCategory.class); EasyMock.expect(rtcCat.getLabel()).andReturn("Routers"); // This nodeid should not exist in the database EasyMock.expect(rtcCat.getNodes()).andReturn(Lists.newArrayList(99999)); EasyMock.replay(rtcCat); final EuiLevel euiLevel = m_availabilityService.getEuiLevel(rtcCat); assertEquals(1, euiLevel.getCategory().size()); final Category category = euiLevel.getCategory().get(0); assertEquals(100.0, category.getCatvalue(), 0.001); assertEquals(1, category.getNode().size()); final Node node = category.getNode().get(0); assertEquals(100.0, node.getNodevalue(), 0.001); assertEquals(0, node.getNodesvccount()); assertEquals(0, node.getNodesvcdowncount()); }
/** * Return the number of services that are currently down with this category. * * @return a long. */ @XmlElement(name="service-down-count") public synchronized long getServiceDownCount() { if (m_serviceDownCount == null) { // This will initialize m_serviceDownCount getServiceCount(); } if (m_serviceDownCount == null) { LOG.warn("Could not fetch service down count for category: {}", m_rtcCategory.getCatlabel()); return 0; } else { return m_serviceDownCount.longValue(); } }
level.setHeader(header); final Category levelCat = new Category(); levelCat.setCatlabel(category.getLabel()); levelCat.getNode().add(levelNode); levelCat.setCatvalue(RTCUtils.getOutagePercentage(outageTimeInCategory, rWindow, numServicesInCategory));
assertEquals(100.0, category.getCatvalue(), 0.001); assertEquals(2, category.getNode().size()); assertEquals(4, category.getNode().get(0).getNodesvccount()); assertEquals(2, category.getNode().get(1).getNodesvccount()); assertEquals(RTCUtils.getOutagePercentage(1800000, 86400000, 6), category.getCatvalue(), 0.0001); assertEquals(2, category.getNode().size());
/** * Return the number of services that are currently down with this category. * * @return a long. */ @XmlElement(name="service-down-count") public synchronized long getServiceDownCount() { if (m_serviceDownCount == null) { // This will initialize m_serviceDownCount getServiceCount(); } if (m_serviceDownCount == null) { LOG.warn("Could not fetch service down count for category: {}", m_rtcCategory.getCatlabel()); return 0; } else { return m_serviceDownCount.longValue(); } }
public List<Node> getNode() { return m_rtcCategory.getNode(); }
/** * Return the current service level availability for this category. * * @return a double. */ @XmlElement(name="availability") public double getValue() { if (m_rtcCategory == null) { return 0.0; } else { return m_rtcCategory.getCatvalue(); } }
/** * Return a percentage of the ratio of services that are up to all services * in this category. * * @return a double. */ @XmlElement(name="service-percentage") public synchronized double getServicePercentage() { if (m_servicePercentage == null) { // This will initialize m_servicePercentage getServiceCount(); } if (m_servicePercentage == null) { LOG.warn("Could not fetch service percentage for category: {}", m_rtcCategory.getCatlabel()); return 0.0; } else { return m_servicePercentage.doubleValue(); } }
@XmlElementWrapper(name="nodes") @XmlElement(name="node") public List<Long> getNodeIds() { final List<Long> nodeIds = new ArrayList<>(); if (m_rtcCategory != null) { for (final Node node : m_rtcCategory.getNode()) { nodeIds.add(node.getNodeid()); } } return nodeIds; }
/** * Return a percentage of the ratio of services that are up to all services * in this category. * * @return a double. */ @XmlElement(name="service-percentage") public synchronized double getServicePercentage() { if (m_servicePercentage == null) { // This will initialize m_servicePercentage getServiceCount(); } if (m_servicePercentage == null) { LOG.warn("Could not fetch service percentage for category: {}", m_rtcCategory.getCatlabel()); return 0.0; } else { return m_servicePercentage.doubleValue(); } }
@XmlElementWrapper(name="nodes") @XmlElement(name="node") public List<Long> getNodeIds() { final List<Long> nodeIds = new ArrayList<>(); if (m_rtcCategory != null) { for (final Node node : m_rtcCategory.getNode()) { nodeIds.add(node.getNodeid()); } } return nodeIds; }
/** * Create a new instance to wrapper information from the categories.xml file * (that defines a category) and information from the RTC (that gives * current service level availability). * * @param categoryDef a {@link org.opennms.netmgt.config.categories.Category} object. * @param rtcCategory a {@link org.opennms.netmgt.xml.rtc.Category} object. * @param lastUpdated a {@link java.util.Date} object. */ protected Category(final org.opennms.netmgt.config.categories.Category categoryDef, final org.opennms.netmgt.xml.rtc.Category rtcCategory, final Date lastUpdated) { if (categoryDef == null || rtcCategory == null || lastUpdated == null) { throw new IllegalArgumentException("Cannot take null parameters."); } if (categoryDef.getLabel() == null || !categoryDef.getLabel().equals(rtcCategory.getCatlabel())) { throw new IllegalArgumentException("Cannot take category " + "definition and rtc category " + "value whose names do not " + "match."); } m_categoryDef = categoryDef; m_rtcCategory = rtcCategory; m_lastUpdated = lastUpdated; m_serviceCount = null; m_serviceDownCount = null; m_servicePercentage = null; }
public AvailabilityNode getNode(final Long nodeId) { if (m_rtcCategory != null) { for (final Node node : m_rtcCategory.getNode()) { if (node.getNodeid() == nodeId) { return new AvailabilityNode(node); } } } return null; }
/** * Create a new instance to wrapper information from the categories.xml file * (that defines a category) and information from the RTC (that gives * current service level availability). * * @param categoryDef a {@link org.opennms.netmgt.config.categories.Category} object. * @param rtcCategory a {@link org.opennms.netmgt.xml.rtc.Category} object. * @param lastUpdated a {@link java.util.Date} object. */ protected Category(final org.opennms.netmgt.config.categories.Category categoryDef, final org.opennms.netmgt.xml.rtc.Category rtcCategory, final Date lastUpdated) { if (categoryDef == null || rtcCategory == null || lastUpdated == null) { throw new IllegalArgumentException("Cannot take null parameters."); } if (categoryDef.getLabel() == null || !categoryDef.getLabel().equals(rtcCategory.getCatlabel())) { throw new IllegalArgumentException("Cannot take category " + "definition and rtc category " + "value whose names do not " + "match."); } m_categoryDef = categoryDef; m_rtcCategory = rtcCategory; m_lastUpdated = lastUpdated; m_serviceCount = null; m_serviceDownCount = null; m_servicePercentage = null; }
public AvailabilityNode getNode(final Long nodeId) { if (m_rtcCategory != null) { for (final Node node : m_rtcCategory.getNode()) { if (node.getNodeid() == nodeId) { return new AvailabilityNode(node); } } } return null; }
/** * Update a category with new values. * * @param rtcCategory a {@link org.opennms.netmgt.xml.rtc.Category} object. */ public void updateCategory(final org.opennms.netmgt.xml.rtc.Category rtcCategory) { if (rtcCategory == null) { throw new IllegalArgumentException("Cannot take null parameters."); } final String categoryName = rtcCategory.getCatlabel(); m_factory.getWriteLock().lock(); try { org.opennms.netmgt.config.categories.Category categoryDef = m_factory.getCategory(categoryName); org.opennms.web.category.Category category = new org.opennms.web.category.Category(categoryDef, rtcCategory, new Date()); synchronized (m_categoryMap) { m_categoryMap.put(categoryName, category); } } finally { m_factory.getWriteLock().unlock(); } LOG.debug("{} was updated", categoryName); }