Class Config.EventPersistence

java.lang.Object
io.hypersistence.optimizer.core.config.Config.EventPersistence
Enclosing class:
Config

public static class Config.EventPersistence extends Object
The Config.EventPersistence configuration activates and tunes the feature that stores the detected events into a database table over time.

Configuration and mapping events are written once, right after scanning, using JDBC batching. Runtime events are aggregated into time windows (occurrence count and, when available, total and maximum durations), so a frequently triggered issue does not generate one row per occurrence.

The events are stored using the host application's SessionFactory, so they share the same database credentials and connection pool and no separate DataSource or JDBC URL needs to be configured.

  • Constructor Details

    • EventPersistence

      public EventPersistence()
  • Method Details

    • isEnabled

      public boolean isEnabled()
    • setEnabled

      public Config.EventPersistence setEnabled(boolean enabled)
    • getApplicationName

      public String getApplicationName()
    • setApplicationName

      public Config.EventPersistence setApplicationName(String applicationName)
    • setBatchSize

      public Config.EventPersistence setBatchSize(int batchSize)
    • setRuntimeRollupWindowMillis

      public Config.EventPersistence setRuntimeRollupWindowMillis(long runtimeRollupWindowMillis)
    • setRuntimeMaxRollupSize

      public Config.EventPersistence setRuntimeMaxRollupSize(int runtimeMaxRollupSize)
    • setSchemaAction

      public Config.EventPersistence setSchemaAction(SchemaAction schemaAction)
    • setWebAppEnabled

      public Config.EventPersistence setWebAppEnabled(boolean webAppEnabled)
      Start the web app automatically when the Optimizer bootstraps. The web app runs inside the host application and reuses the same Hibernate SessionFactory (hence the same database credentials and connection pool) that the Optimizer is built on. By default it binds a dynamically-allocated free port on localhost and logs the resulting URL.

      When disabled (the default), the web app can still be started on demand via HypersistenceOptimizer#startWebApp().

      Parameters:
      webAppEnabled - whether the web app is enabled
      Returns:
      this Config.EventPersistence
    • setWebAppHost

      public Config.EventPersistence setWebAppHost(String webAppHost)
      Set the host the web app binds to (default localhost).
      Parameters:
      webAppHost - the web app host
      Returns:
      this Config.EventPersistence
    • setWebAppPort

      public Config.EventPersistence setWebAppPort(int webAppPort)
      Set the port the web app binds to. Leave it at 0 (the default) to have a free port allocated dynamically; the resolved URL is then logged at startup.
      Parameters:
      webAppPort - the web app port, or 0 for a dynamic one
      Returns:
      this Config.EventPersistence
    • setWebAppAuth

      public Config.EventPersistence setWebAppAuth(String webAppAuthUsername, String webAppAuthPassword)
      Enable Basic authentication on the web app with the given credentials.
      Parameters:
      webAppAuthUsername - the Basic auth user name
      webAppAuthPassword - the Basic auth password
      Returns:
      this Config.EventPersistence
    • buildSettings

      public EventPersistenceSettings buildSettings(org.hibernate.SessionFactory sessionFactory, String fallbackApplicationName)
      Build the resolved EventPersistenceSettings for this configuration.
      Parameters:
      sessionFactory - the host application's SessionFactory, reused both to generate the schema and to borrow JDBC connections
      fallbackApplicationName - the application name to use when none is configured (e.g. the JMX Persistence Unit name)
      Returns:
      the resolved EventPersistenceSettings