Class SystemDatabaseMonitor

java.lang.Object
de.xima.fc.persistence.impl.system.health.SystemDatabaseMonitor

@Eager @ApplicationScoped public class SystemDatabaseMonitor extends Object
Monitors the database connection status.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks whether the last known status of the database connection is connected.
    boolean
    Checks whether the last known status of the database encryption settings is valid.
    boolean
    Checks whether the database connection is healthy, i.e. whether the database is reachable, the schema is up to date with the latest migrations and the encryption settings are valid.
    boolean
    Checks whether the last known status of the database schema is valid.
    boolean
    testConnectionStatus(boolean fireEvent)
    Checks whether the database connection is healthy, i.e. whether the database is reachable.
    boolean
    testEncryptionStatus(boolean fireEvent)
    Checks whether the database encryption settings are healthy, i.e. whether the database encryption settings are valid.
    boolean
    testHealth(boolean fireEvent)
    Checks whether the database connection is healthy, i.e. whether the database is reachable, the schema is up to date with the latest migrations and the encryption settings are valid.
    boolean
    testHealth(boolean fireEvent, boolean forceEvent)
    Checks whether the database connection is healthy, i.e. whether the database is reachable, the schema is up to date with the latest migrations and the encryption settings are valid.
    boolean
    testSchemaStatus(boolean fireEvent)
    Checks whether the database schema is healthy, i.e. whether the database schema is up to date with the latest migrations.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isConnectionValid

      public boolean isConnectionValid()
      Checks whether the last known status of the database connection is connected. A check is run in a fixed interval. Use testConnectionStatus(boolean) to run a check now.
      Returns:
      true if the database connection is connected, false otherwise.
    • isSchemaValid

      public boolean isSchemaValid()
      Checks whether the last known status of the database schema is valid. A check is run in a fixed interval. Use testSchemaStatus(boolean) to run a check now.
      Returns:
      true if the database schema is valid, false otherwise.
    • isEncryptionValid

      public boolean isEncryptionValid()
      Checks whether the last known status of the database encryption settings is valid. A check is run in a fixed interval. Use testEncryptionStatus(boolean) to run a check now.
      Returns:
      true if the database encryption settings are valid, false otherwise.
    • testConnectionStatus

      public boolean testConnectionStatus(boolean fireEvent)
      Checks whether the database connection is healthy, i.e. whether the database is reachable. In contrast with isConnectionValid(), this method actually performs a check and tries to reach the database, instead of returning the current status.
      Returns:
      true if the database connection is healthy, false otherwise.
    • testSchemaStatus

      public boolean testSchemaStatus(boolean fireEvent)
      Checks whether the database schema is healthy, i.e. whether the database schema is up to date with the latest migrations. In contrast with isSchemaValid(), this method actually performs a check and tries to verify the database schema, instead of returning the current status.
      Returns:
      true if the database schema is healthy, false otherwise.
    • testEncryptionStatus

      public boolean testEncryptionStatus(boolean fireEvent)
      Checks whether the database encryption settings are healthy, i.e. whether the database encryption settings are valid. In contrast with isEncryptionValid(), this method actually performs a check and tries to verify the database encryption settings, instead of returning the current status.
      Returns:
      true if the database encryption settings are healthy, false otherwise.
    • isHealthy

      public boolean isHealthy()
      Checks whether the database connection is healthy, i.e. whether the database is reachable, the schema is up to date with the latest migrations and the encryption settings are valid. This method returns the last known status based on the periodic checks or the active checks performed by testHealth(boolean). Use testHealth(boolean) to perform an active check and update the status.
      Returns:
      true if the database connection is healthy, false otherwise.
    • testHealth

      public boolean testHealth(boolean fireEvent)
      Checks whether the database connection is healthy, i.e. whether the database is reachable, the schema is up to date with the latest migrations and the encryption settings are valid. In contrast with isHealthy(), this method actually performs a check and tries to reach the database, verify the schema and encryption settings, instead of returning the current status.
      Returns:
      true if the database connection is healthy, false otherwise.
    • testHealth

      public boolean testHealth(boolean fireEvent, boolean forceEvent)
      Checks whether the database connection is healthy, i.e. whether the database is reachable, the schema is up to date with the latest migrations and the encryption settings are valid. In contrast with isHealthy(), this method actually performs a check and tries to reach the database, verify the schema and encryption settings, instead of returning the current status.
      Parameters:
      fireEvent - whether to fire a health change event if the health status has changed
      forceEvent - whether to force firing a health change event even if the health status has not changed
      Returns:
      true if the database connection is healthy, false otherwise.