Class HealthChecker

java.lang.Object
is.galia.status.HealthChecker

public final class HealthChecker extends Object

Checks various aspects of the application to verify that they are functioning correctly:

Source I/O
When an image endpoint successfully completes a request, it calls addSourceUsage(Source) to register the source it used to do so. This class tests the I/O of each unique source.
The variant cache
An image is written to the variant cache (if available) and read back.
The info cache
An info is written to the info cache (if available) and read back.
  • Constructor Details

    • HealthChecker

      public HealthChecker()
  • Method Details

    • addSourceUsage

      public static void addSourceUsage(Source source)

      Informs the class of a Source that has just been used successfully, and could be used again in the course of a health check. Should be called by image processing endpoints after processing has completed successfully.

      This method is thread-safe.

    • getSourceUsages

      public static Set<SourceUsage> getSourceUsages()
      For testing only!
    • overrideHealth

      public static void overrideHealth(Health health)
      For testing only!
      Parameters:
      health - Custom instance that will be returned by checkSerially(). Supply null to clear the override.
    • checkSerially

      public Health checkSerially()

      Performs a health check as explained in the class documentation. Each group of checks (variant cache, source I/O, etc.) is performed sequentially. If any check fails, all remaining checks are skipped.

      N.B.: it may be faster to do all of the checks concurrently; but this could also result in having to do more checks than necessary, since, if a single check fails, none of the others matter.

      Returns:
      Instance reflecting the application health.
      See Also:
    • checkConcurrently

      public Health checkConcurrently()

      Performs a health check as explained in the class documentation. Each group of checks (variant cache, source I/O, etc.) is performed concurrently. This may cause the check to complete faster than the one via checkSerially() but it also may result in performing more checks than necessary.

      Returns:
      Instance reflecting the application health.
      See Also: