📄 node.java
字号:
//// This file is part of the OpenNMS(R) Application.//// OpenNMS(R) is Copyright (C) 2002-2003 The OpenNMS Group, Inc. All rights reserved.// OpenNMS(R) is a derivative work, containing both original code, included code and modified// code that was published under the GNU General Public License. Copyrights for modified // and included code are below.//// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.//// Copyright (C) 1999-2001 Oculan Corp. All rights reserved.//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program 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 General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//// For more information contact:// OpenNMS Licensing <license@opennms.org>// http://www.opennms.org/// http://www.opennms.com///// Tab Size = 8//package org.opennms.report.datablock;import java.util.ArrayList;import java.util.List;import java.util.ListIterator;/** * This class holds the interface whaich has service information and list of * outages for the service. * * @author <A HREF="mailto:jacinta@oculan.com">Jacinta Remedios </A> * @author <A HREF="http://www.oculan.com">oculan.com </A> * */public class Node extends StandardNamedObject { /** * The log4j category used to log debug messsages and statements. */ private static final String LOG4J_CATEGORY = "OpenNMS.Report"; private static class InterfaceComparator { private String m_intfname; private InterfaceComparator(String intf) { m_intfname = intf; } static InterfaceComparator make(String name) { return new InterfaceComparator(name); } static InterfaceComparator make(Service svc) { return new InterfaceComparator(svc.getName()); } public boolean equals(Object o) { boolean rc = false; if (o != null) { if (o == this) rc = true; else if (o instanceof Interface) rc = m_intfname.equals(((Interface) o).getName()); else if (o instanceof String) rc = m_intfname.equals(o); } return rc; } } /** * List of outages. */ private ArrayList m_interfaces; /** * Flag indicating an Outage */ private boolean m_hasOutage = false; /** * Total Outage */ long m_downTime; /** * Total Window Time. */ long m_totalWindow; /** * Total Business Outage */ long m_busDownTime; /** * Total Window Time during business hours. */ long m_busTotalWindow; /** * Percentage availability. */ double m_percentAvail; /** * Percentage availability during business hours. */ double m_percentBusAvail; /** * Number of Interface/Service combinations */ int m_serviceCount; /** * Node identifier. */ int m_nodeid = -1; /** * Default Constructor. */ public Node() { m_interfaces = new ArrayList(); m_downTime = 0; } /** * Constructor that initialises the nodeid. */ public Node(String name, int id) { m_nodeid = id; setName(name); m_interfaces = new ArrayList(); m_downTime = 0; } /** * Constructor that sets the name and the outages. * * @param name * Name of the service. * @param interfaces * interfaces to be set for this node. * @param id * node id. */ public Node(String name, ArrayList interfaces, int id) { m_nodeid = id; setName(name); m_interfaces = interfaces; m_downTime = 0; } /** * Constructor that sets the outages. * * @param interfaces * Interfaces for this node to be set. */ public Node(ArrayList interfaces) { m_interfaces = interfaces; m_downTime = 0; } /** * Indicates whether the node has outages. * * @return True if has outages. */ public boolean hasOutages() { return m_hasOutage; } /** * Returns the total outage on the node. * * @return The down time. */ public long getDownTime() { return m_downTime; } /** * Returns the total outage on the node during business hours. * * @return The business hours down time. */ public long getBusDownTime() { return m_busDownTime; } /** * Returns the percentage availability on the node. * * @return The percentage availability */ public double getPercentAvail() { return m_percentAvail; } /** * Returns the percentage availability on the node during business hours. * * @return The percentage availability during business hours. */ public double getPercentBusAvail() { return m_percentBusAvail; } /** * Returns the number of unique interface/service combinations. * * @return The service count */ public int getServiceCount() { int count = 0; ListIterator lstIter = m_interfaces.listIterator(); while (lstIter.hasNext()) { Interface intf = (Interface) lstIter.next(); if (intf != null) { count += intf.getServiceCount(); } } m_serviceCount = count; return count; } /** * Returns the number of interfaces. * * @return The interface count */ public int getInterfaceCount() { if (m_interfaces != null) return m_interfaces.size(); return 0; } /** * Returns the total window for this node during business hours. * * @return The totals for the business hours window. */ public long getBusTotalWindow() { return m_busTotalWindow; } /** * Returns the total window for this node. * * @return The totals */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -