Class FrontcachePlugins

java.lang.Object
org.frontcache.plugin.host.FrontcachePlugins

public final class FrontcachePlugins extends Object
The node's plugins - found once per process, started and stopped with the engine.

Finding them

Every "META-INF/frontcache-plugin.properties" on the core's class path names a plugin's entry class; the class is instantiated through its no-argument constructor. A pre-2.13 FrontcacheModule found through its META-INF/services file and carrying no manifest is run through LegacyModulePlugin as a manage plugin, with a deprecation WARN. A manifest that is refused, a class that cannot be loaded, a duplicate id, an unsupported plugin-api major or a kind this node does not offer: logged, reported in get-node-stats, and the node starts without that plugin.

A plugin that fails is a plugin that is absent

Every call into a plugin is wrapped. One that throws in start is dropped until the next start; one that contributes something of a kind it did not declare (an event listener without observe, an endpoint without serve, a management action without manage) is refused and stopped. Nothing here may stop a node from serving. A started plugin's endpoint answers /fc-x/<id>/ through PluginEndpoints.

A plugin's config

A manifest's config names conf/<file>, which no other plugin and no core file may be. It is read, parsed and resolved here (PluginConfigs) and handed to FrontcachePlugin.configure(Config) before every start; a refusal there is a plugin that does not start. reloadConfig(String) re-reads it for a running plugin (which keeps its old config when the new one is refused, and has its event listeners read again when it accepts it) and starts one that failed on its config.
  • Method Details

    • start

      public static void start(String publicDomain, Supplier<List<GuardRule>> guardRules)
      Starts every plugin; called by the engine on each start, reload included.
      Parameters:
      publicDomain - FrontCacheEngine.getPublicDomain(), null when unset
      guardRules - the engine's current guard rules, for the guard summary
    • reloadConfig

      public static FrontcachePlugins.ConfigReload reloadConfig(String id)
      reload-plugin-config: re-reads a plugin's conf/<config>. A running plugin is configured with it - and keeps the config it had when it refuses the new one; a plugin whose last start failed on its config is started with it. Emits ConfigReloaded.
      Returns:
      the outcome; never null
    • validateConfig

      public static List<String> validateConfig(String id, String content)
      Whether a config the caller wants to write would be accepted: it parses, resolves, and the plugin's FrontcachePlugin.validateConfig(Config) accepts it. Touches nothing the plugin runs on.
      Returns:
      every reason it would be refused; empty when it would not
    • configFile

      public static String configFile(String id)
      The conf/ file a loaded plugin's manifest names - never composed from a caller's input - or null when there is no such plugin, it was refused, or it has no config.
    • stop

      public static void stop(boolean shutdown)
      Parameters:
      shutdown - see FrontcachePlugin.stop(boolean)
    • modeKnown

      public static void modeKnown(org.frontcache.plugin.NodeMode deployedAs)
      Called by FrontCacheServlet / FrontCacheFilter as they start - possibly before the engine, so it reaches every loaded plugin rather than only the started ones.
    • managementAction

      public static org.frontcache.plugin.ManagementAction managementAction(String name)
      The management action a started plugin answers under name, or null.
    • managementActionDescriptions

      public static Map<String,String> managementActionDescriptions()
      Every plugin action's description, by name - for the help action.
    • managementActionNames

      public static Set<String> managementActionNames()
      The management action names the started plugins answer.
    • bindMeters

      public static void bindMeters(Object meterRegistry)
      Lets every loaded plugin register its meters - see FrontcachePlugin.bindMeters(Object). Loaded rather than started: the exporter may be built before the engine, and meters read their state at scrape time anyway.
    • ids

      public static List<String> ids()
      The ids of the started plugins, in load order - get-node-stats' modules.
    • stats

      public static List<PluginStats> stats()
      Every plugin found, started or not - get-node-stats' plugins.
    • loadedIds

      public static List<String> loadedIds()
      The ids of every plugin found, for the metrics exporter's per-plugin series.
    • stats

      public static PluginStats stats(String id)
      One plugin's stats by id, read at scrape time; null when there is none.