Changes between Version 11 and Version 12 of net.sf.basedb.opengrid/using


Ignore:
Timestamp:
Jan 20, 2017, 11:55:30 AM (8 years ago)
Author:
Nicklas Nordborg
Comment:

Added section about configuration changes

Legend:

Unmodified
Added
Removed
Modified
  • net.sf.basedb.opengrid/using

    v11 v12  
    358358}}}
    359359
     360=== Reacting to configuration changes ===
     361
     362The `opengrid-config.xml` is normally read in fully when the Open Grid Scheduler service extension is started. Changes to the configuration file are not applied until the service is re-started. For some extensions it may be critical to be able to detect when this happens. Luckily, everything that is needed is already built into the BASE core API. Extensions that need to know when the Open Grid Scheduler service is stoppped or started simply need to register an event handler with the manager in BASE. The event handler should listen to `SERVICE_STOPPED` or `SERVICE_STARTED` events for the `net.sf.basedb.opengrid.service` extension.
     363
     364{{{
     365// We need a filter that listens for SERVICE_STARTED event related to the Open Grid Scheduler service
     366EventFilter serviceStarted = new ExtensionEventFilter(
     367   "net.sf.basedb.opengrid.service", Services.SERVICE_STARTED);
     368
     369// We need to implement an event handler which, for example, reloads our own configuration file
     370EventHandler handler = new MyEventHandler();
     371
     372// Register the event handler with BASE
     373// The classloader parameter is important for not leaking memory
     374// in case this extension is updated or uninstalled
     375Registry registry = Application.getExtensionsManager().getRegistry();
     376registry.registerEventHandler(handler, serviceStarted , this.getClass().getClassLoader());
     377}}}
     378
    360379