1.1 --- a/logger/uihandlerserver/src/java/org/netbeans/server/uihandler/statistics/ExceptionReports.java Tue Dec 04 14:16:42 2007 +0000
1.2 +++ b/logger/uihandlerserver/src/java/org/netbeans/server/uihandler/statistics/ExceptionReports.java Tue Dec 04 19:19:22 2007 +0000
1.3 @@ -110,21 +110,24 @@
1.4 dat.monthStatistics = new TreeMap<Integer, Integer>();
1.5 dat.reportDateStatistics = new TreeMap<Integer, Integer>();
1.6 Calendar cald = Calendar.getInstance();
1.7 - int realYear = cald.get(Calendar.YEAR);
1.8 - int year = cald.get(Calendar.YEAR) % 100 - 2;
1.9 - int month = cald.get(Calendar.MONTH);
1.10 - map.put("start", 1l);
1.11 - dateMap.put("start", new Date(0));
1.12 - for (long i = month; i <= month + 25; i++){
1.13 - Long border = ((year + i / 12)*100 + i % 12) * 100;
1.14 - dateMap.put("end", new Date(realYear + (int)i /12 , (int)i % 12 + 1, 1));
1.15 - map.put("end", border);
1.16 + long realYear = cald.get(Calendar.YEAR);
1.17 + long year = cald.get(Calendar.YEAR) % 100 - 1;
1.18 + long month = cald.get(Calendar.MONTH);
1.19 + Long border = (year + month / 12)*100 + month % 12;
1.20 + Date dateBorder = new Date((int)(realYear - 1901 + month /12), (int)(month % 12 + 1), 1);
1.21 + map.put("start", border * 100);
1.22 + dateMap.put("start", dateBorder);
1.23 + for (long i = month + 1; i <= month + 12; i++){
1.24 + border = (year + i / 12)*100 + i % 12;
1.25 + dateBorder = new Date((int)(realYear - 1901 + i /12) , (int)(i % 12 + 1), 1);
1.26 + dateMap.put("end", dateBorder);
1.27 + map.put("end", border * 100);
1.28 Long count = (Long) pUtils.executeNamedQuerySingleResult("Exceptions.countByBuildInterval", map);
1.29 dat.monthStatistics.put(border.intValue(), count.intValue());
1.30 count = (Long) pUtils.executeNamedQuerySingleResult("Exceptions.countByInterval", dateMap);
1.31 dat.reportDateStatistics.put(border.intValue(), count.intValue());
1.32 - map.put("start", border);
1.33 - dateMap.put("end", new Date(realYear, month, 1));
1.34 + map.put("start", border * 100);
1.35 + dateMap.put("start", dateBorder);
1.36 }
1.37 } catch (Exception ex) {
1.38 // requires database and that is not present
1.39 @@ -136,7 +139,7 @@
1.40 super.registerPageContext(page, name, dat);
1.41 }
1.42
1.43 - public static final class Data{
1.44 + public final class Data{
1.45 int globalReportsNumber;
1.46 Map<String, Integer> components;
1.47 /**
1.48 @@ -163,12 +166,22 @@
1.49 else return Collections.emptyMap();
1.50 }
1.51
1.52 - public Map<Integer, Integer> getMonthStats(){
1.53 - return monthStatistics;
1.54 + private List<ReportItem> translate(Map<Integer, Integer> mapa){
1.55 + List<ReportItem> result = new ArrayList<ReportItem>(mapa.size());
1.56 + Iterator<Integer> it = mapa.keySet().iterator();
1.57 + while (it.hasNext()){
1.58 + Integer key = it.next();
1.59 + result.add(new ReportItem(key % 100 + 1, key / 100, mapa.get(key)));
1.60 + }
1.61 + return result;
1.62 }
1.63
1.64 - public Map<Integer, Integer> getReportDateStats(){
1.65 - return reportDateStatistics;
1.66 + public List<ReportItem> getMonthStats(){
1.67 + return translate(monthStatistics);
1.68 + }
1.69 +
1.70 + public List<ReportItem> getReportDateStats(){
1.71 + return translate(reportDateStatistics);
1.72 }
1.73
1.74 public List<String> getSortedKeys(){
1.75 @@ -186,6 +199,49 @@
1.76 }
1.77 }
1.78
1.79 + public static class ReportItem{
1.80 + private Integer month, year;
1.81 + private Integer count;
1.82 + public ReportItem(Integer month, Integer year, Integer count){
1.83 + this.month = month;
1.84 + this.year = year;
1.85 + this.count = count;
1.86 + }
1.87 +
1.88 + public String getSerie(){
1.89 + return "";
1.90 + }
1.91 +
1.92 + public String getKey(){
1.93 + return year.toString() + "/" + month.toString();
1.94 + }
1.95 +
1.96 + public Integer getValue(){
1.97 + return count;
1.98 + }
1.99 +
1.100 + @Override
1.101 + public boolean equals(Object obj) {
1.102 + if (obj instanceof ReportItem) {
1.103 + ReportItem ri = (ReportItem) obj;
1.104 + return month.equals(ri.month) && year.equals(ri.year) && count.equals(ri.count);
1.105 + } else {
1.106 + return false;
1.107 + }
1.108 + }
1.109 +
1.110 + @Override
1.111 + public int hashCode() {
1.112 + int hash = 5;
1.113 + hash = 17 * hash + (this.month != null ? this.month.hashCode() : 0);
1.114 + hash = 17 * hash + (this.year != null ? this.year.hashCode() : 0);
1.115 + hash = 17 * hash + (this.count != null ? this.count.hashCode() : 0);
1.116 + return hash;
1.117 + }
1.118 +
1.119 + }
1.120 +
1.121 +
1.122 protected void write(Preferences pref, Data d) throws BackingStoreException {
1.123 // data are saved in DB for this statistics
1.124 }
2.1 --- a/logger/uihandlerserver/test/org/netbeans/server/uihandler/statistics/ExceptionReportsTest.java Tue Dec 04 14:16:42 2007 +0000
2.2 +++ b/logger/uihandlerserver/test/org/netbeans/server/uihandler/statistics/ExceptionReportsTest.java Tue Dec 04 19:19:22 2007 +0000
2.3 @@ -33,7 +33,7 @@
2.4 import org.netbeans.server.uihandler.DatabaseTestCase;
2.5 import org.netbeans.server.uihandler.LogsManager;
2.6 import org.netbeans.server.uihandler.LogsManagerTest;
2.7 -import static org.junit.Assert.*;
2.8 +import org.netbeans.server.uihandler.statistics.ExceptionReports.ReportItem;
2.9
2.10 /**
2.11 *
2.12 @@ -47,6 +47,12 @@
2.13
2.14 public void testRegisterPageContext() throws Exception{
2.15 String IP1 = "127.0.0.1";
2.16 + LogsManager.getDefault().preparePageContext(page, IP1, null);
2.17 + ExceptionReports.Data exceptionReports =
2.18 + (ExceptionReports.Data)page.getAttribute("globalExceptionReports");
2.19 +
2.20 + assertEquals("items count", 12, exceptionReports.getMonthStats().size());
2.21 +
2.22 File log = LogsManagerTest.extractResourceAs(LogsManagerTest.class, data, "1.log", "NB2040811605.0");
2.23 log = LogsManagerTest.extractResourceAs(LogsManagerTest.class, data, "2.log", "NB2040811605.1");
2.24 waitLog(log, IP1);
2.25 @@ -55,13 +61,11 @@
2.26 log = LogsManagerTest.extractResourceAs(LogsManagerTest.class, data, "dup1", "NB2040811605.3");
2.27 waitLog(log, IP1);
2.28 LogsManager.getDefault().preparePageContext(page, IP1, null);
2.29 - ExceptionReports.Data exceptionReports =
2.30 - (ExceptionReports.Data)page.getAttribute("globalExceptionReports");
2.31 -
2.32 - assertEquals("reports of 2007/3 .. 2007/4", 1, exceptionReports.monthStatistics.get(70400).intValue());
2.33 - assertEquals("reports of 2007/1 .. 2007/2", 1, exceptionReports.monthStatistics.get(70200).intValue());
2.34 - assertEquals("reports of 2007/2 .. 2007/3", 1, exceptionReports.monthStatistics.get(70300).intValue());
2.35 - assertEquals("reports of datestats now", 3, exceptionReports.reportDateStatistics.get(71100).intValue());
2.36 + exceptionReports = (ExceptionReports.Data)page.getAttribute("globalExceptionReports");
2.37 +
2.38 + assertTrue(exceptionReports.getMonthStats().contains(new ExceptionReports.ReportItem(3, 7, 1)));
2.39 + assertTrue(exceptionReports.getMonthStats().contains(new ExceptionReports.ReportItem(4, 7, 1)));
2.40 + assertTrue(exceptionReports.getMonthStats().contains(new ExceptionReports.ReportItem(5, 7, 1)));
2.41
2.42 log = LogsManagerTest.extractResourceAs(LogsManagerTest.class, data, "dup2", "NB2040811605.4");
2.43 waitLog(log, IP1);
2.44 @@ -73,14 +77,13 @@
2.45 LogsManager.getDefault().preparePageContext(page, IP1, null);
2.46 exceptionReports = (ExceptionReports.Data)page.getAttribute("globalExceptionReports");
2.47
2.48 - assertEquals("reports of 2007/8 .. 2007/9", 1, exceptionReports.monthStatistics.get(70900).intValue());
2.49 - assertEquals("reports of 2007/7 .. 2007/8", 1, exceptionReports.monthStatistics.get(70800).intValue());
2.50 - assertEquals("reports of 2007/3 .. 2007/4", 2, exceptionReports.monthStatistics.get(70400).intValue());
2.51 - assertEquals("reports of 2007/1 .. 2007/2", 1, exceptionReports.monthStatistics.get(70200).intValue());
2.52 - assertEquals("reports of 2007/2 .. 2007/3", 1, exceptionReports.monthStatistics.get(70300).intValue());
2.53 - assertEquals("reports of 2006/11 .. 2006/12", 0, exceptionReports.monthStatistics.get(70000).intValue());
2.54 - assertEquals("reports of datestats now", 6, exceptionReports.reportDateStatistics.get(71100).intValue());
2.55 -
2.56 + assertTrue(exceptionReports.getMonthStats().contains(new ExceptionReports.ReportItem(10, 7, 1)));
2.57 + assertTrue(exceptionReports.getMonthStats().contains(new ExceptionReports.ReportItem(9, 7, 1)));
2.58 + assertTrue(exceptionReports.getMonthStats().contains(new ExceptionReports.ReportItem(5, 7, 2)));
2.59 + assertTrue(exceptionReports.getMonthStats().contains(new ExceptionReports.ReportItem(3, 7, 1)));
2.60 + assertTrue(exceptionReports.getMonthStats().contains(new ExceptionReports.ReportItem(4, 7, 1)));
2.61 + assertTrue(exceptionReports.getMonthStats().contains(new ExceptionReports.ReportItem(1, 7, 0)));
2.62 +
2.63 log = LogsManagerTest.extractResourceAs(LogsManagerTest.class, data, "dup4", "NB2040811605.7");
2.64 waitLog(log, IP1);
2.65 log = LogsManagerTest.extractResourceAs(LogsManagerTest.class, data, "outOfMem", "NB2040811605.8");
2.66 @@ -94,10 +97,9 @@
2.67 assertEquals("ide", 2, comps.get("ide").intValue());
2.68 assertEquals("openide", 2, comps.get("openide").intValue());
2.69
2.70 - assertEquals("reports of 2007/3 .. 2007/4", 4, exceptionReports.monthStatistics.get(70400).intValue());
2.71 - assertEquals("reports of 2006/11 .. 2006/12", 0, exceptionReports.monthStatistics.get(70000).intValue());
2.72 - assertEquals("reports of 2007/08 .. 2007/09", 1, exceptionReports.monthStatistics.get(70900).intValue());
2.73 - assertEquals("reports of datestats now", 8, exceptionReports.reportDateStatistics.get(71100).intValue());
2.74 + assertTrue(exceptionReports.getMonthStats().contains(new ExceptionReports.ReportItem(5, 7, 4)));
2.75 + assertTrue(exceptionReports.getMonthStats().contains(new ExceptionReports.ReportItem(1, 7, 0)));
2.76 + assertTrue(exceptionReports.getMonthStats().contains(new ExceptionReports.ReportItem(10, 7, 1)));
2.77 }
2.78
2.79 }
2.80 \ No newline at end of file
3.1 --- a/logger/uihandlerserver/web/graph/exceptionreports.jsp Tue Dec 04 14:16:42 2007 +0000
3.2 +++ b/logger/uihandlerserver/web/graph/exceptionreports.jsp Tue Dec 04 19:19:22 2007 +0000
3.3 @@ -108,15 +108,16 @@
3.4 if (exceptionReports.getMonthStats() != null) {%>
3.5 <tr>
3.6 <td align="center" width="480">
3.7 - <chart:pie
3.8 + <chart:line
3.9 collection="monthStats"
3.10 category="key"
3.11 + serie="serie"
3.12 value="value"
3.13 - title="Components issues numbers"
3.14 + title="Reports by month of build date"
3.15 />
3.16 <p>
3.17 This is a statistics describing number of error reports
3.18 - according to NetBeans build numbers.
3.19 + by month of build date.
3.20 </p>
3.21 </td>
3.22 </tr>
3.23 @@ -126,15 +127,16 @@
3.24 if (exceptionReports.getReportDateStats() != null) {%>
3.25 <tr>
3.26 <td align="center" width="480">
3.27 - <chart:pie
3.28 + <chart:bar
3.29 collection="reportDateStats"
3.30 category="key"
3.31 + serie="serie"
3.32 value="value"
3.33 - title="Components issues numbers"
3.34 + title="Reports by month of report date"
3.35 />
3.36 <p>
3.37 This is a statistics describing number of error reports
3.38 - according to NetBeans build numbers.
3.39 + by month of date of report.
3.40 </p>
3.41 </td>
3.42 </tr>