Class Config.EventPersistence
java.lang.Object
io.hypersistence.optimizer.core.config.Config.EventPersistence
- Enclosing class:
- Config
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildSettings(org.hibernate.SessionFactory sessionFactory, String fallbackApplicationName) Build the resolvedEventPersistenceSettingsfor this configuration.booleansetApplicationName(String applicationName) setBatchSize(int batchSize) setEnabled(boolean enabled) setRuntimeMaxRollupSize(int runtimeMaxRollupSize) setRuntimeRollupWindowMillis(long runtimeRollupWindowMillis) setSchemaAction(SchemaAction schemaAction) setWebAppAuth(String webAppAuthUsername, String webAppAuthPassword) Enable Basic authentication on the web app with the given credentials.setWebAppEnabled(boolean webAppEnabled) Start the web app automatically when the Optimizer bootstraps.setWebAppHost(String webAppHost) Set the host the web app binds to (defaultlocalhost).setWebAppPort(int webAppPort) Set the port the web app binds to.
-
Constructor Details
-
EventPersistence
public EventPersistence()
-
-
Method Details
-
isEnabled
public boolean isEnabled() -
setEnabled
-
getApplicationName
-
setApplicationName
-
setBatchSize
-
setRuntimeRollupWindowMillis
-
setRuntimeMaxRollupSize
-
setSchemaAction
-
setWebAppEnabled
Start the web app automatically when the Optimizer bootstraps. The web app runs inside the host application and reuses the same HibernateSessionFactory(hence the same database credentials and connection pool) that the Optimizer is built on. By default it binds a dynamically-allocated free port onlocalhostand 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
Set the host the web app binds to (defaultlocalhost).- Parameters:
webAppHost- the web app host- Returns:
- this
Config.EventPersistence
-
setWebAppPort
Set the port the web app binds to. Leave it at0(the default) to have a free port allocated dynamically; the resolved URL is then logged at startup.- Parameters:
webAppPort- the web app port, or0for a dynamic one- Returns:
- this
Config.EventPersistence
-
setWebAppAuth
Enable Basic authentication on the web app with the given credentials.- Parameters:
webAppAuthUsername- the Basic auth user namewebAppAuthPassword- the Basic auth password- Returns:
- this
Config.EventPersistence
-
buildSettings
public EventPersistenceSettings buildSettings(org.hibernate.SessionFactory sessionFactory, String fallbackApplicationName) Build the resolvedEventPersistenceSettingsfor this configuration.- Parameters:
sessionFactory- the host application'sSessionFactory, reused both to generate the schema and to borrow JDBC connectionsfallbackApplicationName- the application name to use when none is configured (e.g. the JMX Persistence Unit name)- Returns:
- the resolved
EventPersistenceSettings
-