Class ClazzStatistic

All Implemented Interfaces:
ClazzStatisticMBean, Shutdownable, Runnable

public class ClazzStatistic extends Shutdowner implements ClazzStatisticMBean
The ClazzStatistic collects classes and resources to find classes which are likely to be dead. At the end a little statistics is reported to a file 'clazzfish/a.b.MyMain/ClazzStatistic.csv' in the temp directory. If you want another directory or filename where this statistics should be stored you can use one of the system properties
  1. clazzfish.dump.dir
  2. clazzfish.statistics.file
Please use only one of this environment options.

As alternative you can set one of the two environment variables:

  1. CLAZZFISH_STATISTICS_DIR
  2. CLAZZFISH_STATISTICS_FILE

NOTE: If a system property like 'appname' is set which looks like a program name this property is used instead of the Main classname.

Since:
2.3 (25.11.24)
Author:
oboehm
  • Method Details

    • getInstance

      public static ClazzStatistic getInstance()
    • registerMeAsMBean

      public void registerMeAsMBean()
    • getAllClasses

      public SortedSet<ClazzRecord> getAllClasses()
    • getStatistics

      public SortedSet<ClazzRecord> getStatistics()
    • getClasspathes

      public Set<URI> getClasspathes()
    • logMe

      public void logMe()
      Prints the statistic as CSV to the log output.
      Specified by:
      logMe in interface ClazzStatisticMBean
    • getExportFile

      public File getExportFile()
      Description copied from interface: ClazzStatisticMBean
      Returns the name of the default export file.
      Specified by:
      getExportFile in interface ClazzStatisticMBean
      Returns:
      export file
    • exportCSV

      public URI exportCSV() throws IOException
      Description copied from interface: ClazzStatisticMBean
      Exports the statistics of the collected classes to the default location.
      Specified by:
      exportCSV in interface ClazzStatisticMBean
      Returns:
      export file
      Throws:
      IOException - in case of I/O problems
    • exportCSV

      public URI exportCSV(String filename) throws IOException
      Description copied from interface: ClazzStatisticMBean
      Exports the statistics of the collected classes to the file with the given filename.
      Specified by:
      exportCSV in interface ClazzStatisticMBean
      Parameters:
      filename - filename or URI, where the statistics should be exported to
      Returns:
      export URI
      Throws:
      IOException - in case of I/O problems
    • exportCSV

      public URI exportCSV(File csvFile) throws IOException
      Throws:
      IOException
    • exportCSV

      public URI exportCSV(URI uri) throws IOException
      Throws:
      IOException
    • importCSV

      public void importCSV(File csvFile)
    • importCSV

      public void importCSV(URI csvURI)
      Imports the statistics from the given URI. With issue #26 an internal Map is now used to find a ClazzRecord. The speeds up the import by a factor of 5:
      • import of 10,000 lines: 130 - 150 ms (old), 20 - 30 ms (now)
      • import of 60,000 lines: 200 - 230 ms (old), 50 - 80 ms (now)
      The times were measured on an MBP from 2020.
      Parameters:
      csvURI - URI where the statistic should be imported from
    • run

      public void run()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • toString

      public String toString()
      Overrides:
      toString in class Thread