Posts Tagged ‘cache’

ParaDe start-up

Sunday, February 24th, 2008

This is a short explanation of what happens on ParaDe startup.

Initialisation

org.makumba.parade.init contains the classes involved with initialisation. Amongst those, the InitServlet plays an important role. It is configured in the global web.xml to run at startup and tries to load the Parade object from the Hibernate cache. If it finds such an object, it will load it, otherwise, it will create a new one, perform a global cache refresh on ParaDe and add the JNotify listeners to the rows.

Note that if the database is empty at this point, Hibernate will automatically create all the tables. At startup, Hibernate also performs schema update, i.e. it checks if the schema of the database corresponds to the one of the model and performs necessary steps if it isn’t. InitServlet is also the starting point for Hibernate: it provides a configuration and declares which Hibernate model files should be loaded.

Additionally, the Freemarker templating engine is also configured by the InitServlet.

The initialisation is being ran in a thread, which means that tomcat will probably finish loading way earlier than ParaDe. Wait for the “ParaDe initialisation finished at …” message before accessing ParaDe.

ParaDe refresh

Global ParaDe refresh is triggered in two ways: either on ParaDe startup, if no ParaDe object can be found, or manually by calling the RowsAction (http://hostname:port/Rows.do?op=parade).

The refresh() method of the org.makumba.parade.model.Parade class does following:

  1. read the row definitions file (rows.properties)
  2. updates the cache accordingly to these definitions
  3. calls the refresh() methods of all RowManagers

The RowManagers perform row-wide refresh operations, which differ for each manager. Some of them call a directory-refresh method, which itself calls a file-refresh method etc.

It is during the row refresh() that all the files of a row are being cached and their other meta-information (CVS, etc…) is being cached.

Hence the rows.properties file is read only once: when there’s no previous ParaDe object available. If new rows are being added to the file, a ParaDe-wide refresh needs hence to be performed. This is of course not optimal, and a more direct way than this one should exist, but is not yet implemented.

JNotify initialisation

At startup, all the rows are getting a JNotify watch: in the case of linux, this will trigger the creation of a inotify node for all the files in a row, hence the /proc/sys/fs/inotify/max_user_watches file needs to contain a rather high value if many rows are being watched. If you get a lot of messages from JNotify at startup saying it can’t add watches, this probably means that this file is not properly configured.