dCache/dcache — pull request #129 by alrossi (2013-07-18 14:13:16+00:00)
Title: (2.6) statistics: Fix NPE in Html tree creation

It has been noted that the statistics module fails to produce the top level html and to run the collection cron correctly. In the first case, one sees an error such as the first reported below. In the second, a different error occurs. These two errors, however, appear to be related.

As the code currently stands, the "count" array used in several methods remains uninitialized until inside the subsequent loop. However, initialization is not loop-invariant, as those loops may fail to run under certain conditions, in particular when the list of statistics files is empty.

This patch provides the appropriate pre-loop initialization of the array.

Note that this class has a number of dead variables and methods. I did not eliminate them, however, as it occurs to me that one might wish to do a bit more cleanup and "modernize" this code. I leave this to another patch.

Before this patch, one observes the following.

1. Using the admin command create html, one sees:

Exception in creating html tree for : /var/lib/dcache/billing/2013/06/05/2013-06-05-13.raw
java.lang.NullPointerException: null
at diskCacheV111.services.PoolStatisticsV0.printTotal(PoolStatisticsV0.java:1204) ~[dcache-core-2.6.1.jar:2.6.1]
at diskCacheV111.services.PoolStatisticsV0.prepareDailyHtml(PoolStatisticsV0.java:1136) ~[dcache-core-2.6.1.jar:2.6.1]
at diskCacheV111.services.PoolStatisticsV0.prepareDailyHtmlFiles(PoolStatisticsV0.java:1041) ~[dcache-core-2.6.1.jar:2.6.1]
at diskCacheV111.services.PoolStatisticsV0.access$1100(PoolStatisticsV0.java:116) ~[dcache-core-2.6.1.jar:2.6.1]
at diskCacheV111.services.PoolStatisticsV0$HourlyRunner.run(PoolStatisticsV0.java:432) ~[dcache-core-2.6.1.jar:2.6.1]
at dmg.cells.nucleus.CellNucleus$1.run(CellNucleus.java:657) [cells-2.6.1.jar:2.6.1]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_09]

2. Using the admin command create stat, one sees:

at diskCacheV111.services.PoolStatisticsV0.getPoolRepositoryStatistics(PoolStatisticsV0.java:1361) ~[dcache-core-2.6.6-SNAPSHOT.jar:2.6.6-SNAPSHOT]
at diskCacheV111.services.PoolStatisticsV0.createStatisticsMap(PoolStatisticsV0.java:838) ~[dcache-core-2.6.6-SNAPSHOT.jar:2.6.6-SNAPSHOT]
at diskCacheV111.services.PoolStatisticsV0.createHourlyRawFile(PoolStatisticsV0.java:973) ~[dcache-core-2.6.6-SNAPSHOT.jar:2.6.6-SNAPSHOT]
at diskCacheV111.services.PoolStatisticsV0.access$500(PoolStatisticsV0.java:116) ~[dcache-core-2.6.6-SNAPSHOT.jar:2.6.6-SNAPSHOT]
at diskCacheV111.services.PoolStatisticsV0 $HourlyRunner.run(PoolStatisticsV0.java:400) ~[dcache-core-2.6.6-SNAPSHOT.jar:2.6.6-SNAPSHOT]
at dmg.cells.nucleus.CellNucleus$1.run(CellNucleus.java:657) [cells-2.6.6-SNAPSHOT.jar:2.6.6-SNAPSHOT]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0]
15 Jul 2013 15:57:08 (PoolStatistics) [] prepareDailyHtmlFiles : File not found : /var/lib/dcache/statistics/2013/07/15/2013-07-15-day.drw

After the patch is applied, both of these commands work again, and the top index.html is produced.

Target: master@1ab1d24b01a614e8011a3be0915dced3dbb90ee8
Request: 2.6
Request: 2.2
Require-notes: yes
Require-book: no
Ticket: http://rt.dcache.org/Ticket/Display.html?id=785
Bug: http://rt.dcache.org/Ticket/Display.html?id=785
Acked-by: Gerd

RELEASE NOTES:

Fixes NullPointer bug which prevents under certain conditions top-level index.html from being created (and the statistics page being found in the browser).