/** * 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(); } }
/** * 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(); } }
/** * 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(); } }
/** * 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(); } }
/** * 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; }
/** * 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; }
/** * 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); }
/** * 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); }