⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 availcalculations.java

📁 opennms得相关源码 请大家看看
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                        value.setContent(formatNumber("" + percent.doubleValue()));                        value.setType("data");                        Row row = new Row();                        row.addValue(dateValue);                        row.addValue(value);                        rows.addRow(row);                        if (top20Count >= 20) {                            break loop;                        }                    }                }            }        }        Col col = new Col();        col.addColTitle(0, "Node Name");        col.addColTitle(1, "Percentage Availability");		ClassicTable table = new ClassicTable();		table.setCol(col);		table.setRows(rows);		Section section = new Section();		section.setClassicTable(table);        section.setSectionName("lastMoTop20offenders");        section.setSectionTitle(label);        section.setSectionDescr(descr);        section.setSectionIndex(m_sectionIndex);        m_sectionIndex++;        catSections.addSection(section);        if (log.isDebugEnabled())            log.debug("Leaving lastMoTopNOffenders");    }    /**     * Last Months Daily availability     *      * @param days     *            Number of days for which the availability computations are     *            made     * @param endTime     *            End time     * @param sections     *            Castors sections     * @param label     *            Section name in the xml     * @param descr     *            Section descr.     * @param sectionName     *            Section name     */    private void lastMoDailyAvailability(int days, long endTime, CatSections sections, String label, String descr, String sectionName) {        lastNDaysDailyAvailability(days, endTime, sections, label, descr, sectionName);    }	/**     * Last Months Daily availability     *      * @param days     *            Number of days for which the availability computations are     *            made     * @param endTime     *            End time     * @param sections     *            Castors sections     * @param label     *            Section name in the xml     * @param descr     *            Section descr.     * @param sectionName     *            Section name     */    private void lastCalMoDailyAvailability(int days, long endTime, CatSections sections, String label, String descr, String sectionName) {        lastNDaysCalDailyAvailability(days, endTime, sections, label, descr, sectionName);    }		/**     * Last N days daily availability.     *      * @param days     *            Number of days for which the availability computations are     *            made.     * @param endTime     *            End time     * @param catSections     *            Castors sections     * @param label     *            Section name in the xml     * @param descr     *            Section descr.     * @param sectionName     *            Section name     */    private void lastNDaysCalDailyAvailability(int days, long endTime, CatSections catSections, String label, String descr, String sectionName) {        ThreadCategory.setPrefix(LOG4J_CATEGORY);        org.apache.log4j.Category log = ThreadCategory.getInstance(this.getClass());        if (log.isDebugEnabled())            log.debug("Inside lastNDaysDailyAvailability");        int numdays = 0;	    CalendarTableBuilder calBuilder = new CalendarTableBuilder(endTime);        TreeMap treeMap = new TreeMap();        SimpleDateFormat fmt = new SimpleDateFormat("dd MMM, yyyy");        String periodEnd = fmt.format(new java.util.Date(endTime));        String periodFrom = "";        while (numdays++ < days) {            if (log.isDebugEnabled())                log.debug("Computing for " + new Date(endTime));            int serviceCount = 0;            long outage = 0;            //            // get the outage and service count.            //            ListIterator listIter = m_nodes.listIterator();            while (listIter.hasNext()) {                Node node = (Node) listIter.next();                outage += node.getOutage(endTime, ROLLING_WINDOW);                serviceCount += node.getServiceCount();            }            double percentAvail;            if (serviceCount > 0)                percentAvail = 100.0 * (1 - (outage * 1.0) / (1.0 * serviceCount * ROLLING_WINDOW));            else                percentAvail = 100.0;            //need a double object in here						treeMap.put(new Date(endTime), new Double (percentAvail));            periodFrom = fmt.format(new java.util.Date(endTime));            endTime -= ROLLING_WINDOW;        }        Set keyDates = treeMap.keySet();        Iterator iter = keyDates.iterator();        int dateSlot = 0;		while (iter.hasNext()) {			Date key = (Date) iter.next();            Double percent = (Double) treeMap.get(key);			dateSlot++;			calBuilder.setPctValue(dateSlot, percent.doubleValue());		}				Section section = new Section();        section.setCalendarTable(calBuilder.getTable());        section.setSectionName(sectionName); // "LastMonthsDailyAvailability");        section.setSectionTitle(label);        section.setSectionDescr(descr);        section.setPeriod(periodFrom + " to " + periodEnd);        section.setSectionIndex(m_sectionIndex);        m_sectionIndex++;        catSections.addSection(section);        log.debug("Leaving lastNDaysCalDailyAvailability");				}	    /**     * Last N days daily availability.     *      * @param days     *            Number of days for which the availability computations are     *            made.     * @param endTime     *            End time     * @param catSections     *            Castors sections     * @param label     *            Section name in the xml     * @param descr     *            Section descr.     * @param sectionName     *            Section name     */    private void lastNDaysDailyAvailability(int days, long endTime, CatSections catSections, String label, String descr, String sectionName) {        ThreadCategory.setPrefix(LOG4J_CATEGORY);        org.apache.log4j.Category log = ThreadCategory.getInstance(this.getClass());        if (log.isDebugEnabled())            log.debug("Inside lastNDaysDailyAvailability");        int numdays = 0;        Rows rows = new Rows();        TreeMap treeMap = new TreeMap();        SimpleDateFormat fmt = new SimpleDateFormat("dd MMM, yyyy");        String periodEnd = fmt.format(new java.util.Date(endTime));        String periodFrom = "";        while (numdays++ < days) {            if (log.isDebugEnabled())                log.debug("Computing for " + new Date(endTime));            int serviceCount = 0;            long outage = 0;            //            // get the outage and service count.            //            ListIterator listIter = m_nodes.listIterator();            while (listIter.hasNext()) {                Node node = (Node) listIter.next();                outage += node.getOutage(endTime, ROLLING_WINDOW);                serviceCount += node.getServiceCount();            }            double percentAvail;            if (serviceCount > 0)                percentAvail = 100.0 * (1 - (outage * 1.0) / (1.0 * serviceCount * ROLLING_WINDOW));            else                percentAvail = 100.0;            treeMap.put(new Date(endTime), formatNumber(percentAvail + ""));            periodFrom = fmt.format(new java.util.Date(endTime));            endTime -= ROLLING_WINDOW;        }        Set keyDates = treeMap.keySet();        Iterator iter = keyDates.iterator();        while (iter.hasNext()) {            Date key = (Date) iter.next();            Value dateValue = new Value();            SimpleDateFormat fmtmp = new SimpleDateFormat("dd");            dateValue.setContent(fmtmp.format(key));            dateValue.setType("title");            String percent = (String) treeMap.get(key);            Value value = new Value();            value.setContent(percent);            value.setType("data");            Row row = new Row();            row.addValue(dateValue);            row.addValue(value);            rows.addRow(row);        }        Col col = new Col();        col.addColTitle(0, "Date");        col.addColTitle(1, "Percentage Availability");		ClassicTable table = new ClassicTable();		table.setCol(col);		table.setRows(rows);		Section section = new Section();		section.setClassicTable(table);        section.setSectionName(sectionName); // "LastMonthsDailyAvailability");        section.setSectionTitle(label);        section.setSectionDescr(descr);        section.setPeriod(periodFrom + " to " + periodEnd);        section.setSectionIndex(m_sectionIndex);        m_sectionIndex++;        catSections.addSection(section);        log.debug("Leaving lastNDaysDailyAvailability");    }    /**     * Last N Days Total Availability.     *      * @param days     *            Number of days for which the availability computations are     *            made.     * @param endTime     *            End time     * @param catSections     *            Castors sections     * @param label     *            Section name in the xml     * @param descr     *            Section descr.     */    private void lastNDaysTotalAvailability(int days, long endTime, CatSections catSections, String label, String descr) {        ThreadCategory.setPrefix(LOG4J_CATEGORY);        org.apache.log4j.Category log = ThreadCategory.getInstance(this.getClass());        log.debug("Inside lastNDaysTotalAvailability");        Rows rows = new Rows();        int serviceCount = 0;        long outage = 0;        int numdays = 0;        SimpleDateFormat fmt = new SimpleDateFormat("dd MMM, yyyy");        String periodEnd = fmt.format(new java.util.Date(endTime));        String periodFrom = "";        while (numdays++ < days) {            //            // get the outage and service count.            //            ListIterator listIter = m_nodes.listIterator();            while (listIter.hasNext()) {                Node node = (Node) listIter.next();                serviceCount += node.getServiceCount();                outage += node.getOutage(endTime, ROLLING_WINDOW);            }            periodFrom = fmt.format(new java.util.Date(endTime)) + " to " + periodEnd;            endTime -= ROLLING_WINDOW;        }        double percentAvail;        if (serviceCount > 0)            percentAvail = 100.0 * (1 - (outage * 1.0) / (1.0 * serviceCount * ROLLING_WINDOW));        else            percentAvail = 100.0;        Value dateValue = new Value();        dateValue.setContent(periodFrom);        dateValue.setType("title");        Value value = new Value();        value.setContent(formatNumber(percentAvail + ""));        value.setType("data");        Row row = new Row();        row.addValue(dateValue);        row.addValue(value);        rows.addRow(row);        Col col = new Col();        col.addColTitle(0, "Date");        col.addColTitle(1, "Percentage Availability");		ClassicTable table = new ClassicTable();		table.setCol(col);		table.setRows(rows);		Section section = new Section();		section.setClassicTable(table);        section.setSectionName("Last" + days + "TotalAvailability");        section.setSectionTitle(label);        section.setSectionDescr(descr);        section.setPeriod(periodFrom);        section.setSectionIndex(m_sectionIndex);        m_sectionIndex++;        catSections.addSection(section);        log.debug("Leaving lastNDaysTotalAvailability");    }    /**     * Last N Months Availability     *      * @param nMonths     *            Number of months for which the availability computations are     *            made.     * @param endTime     *            End time     * @param catSections

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -