Class BaseHealthCheck<O extends HealthCheckExecutionOptions,​C extends Checker>

    • Constructor Detail

      • BaseHealthCheck

        public BaseHealthCheck()
    • Method Detail

      • constructOptions

        public abstract O constructOptions​(C c)
      • isInProgress

        public boolean isInProgress()
      • getChecksDone

        public int getChecksDone()
      • getChecksFailed

        public int getChecksFailed()
      • isReady

        public boolean isReady()
      • isEnabled

        public boolean isEnabled()
      • asTimeUnit

        protected TimeUnit asTimeUnit​(String unit)
        Converts a string representing a timeunit to the value i.e. "MILLISECONDS" to TimeUnit.MILLISECONDS
        Parameters:
        unit -
        Returns:
      • decideOnStatusWithDuration

        protected HealthCheckResultStatus decideOnStatusWithDuration​(long duration)
        Determines the level of of the healthcheck based on a time
        Parameters:
        duration - length of time taken in milliseconds
        Returns:
        HealthCheckResultStatus.CRITICAL if duration > 5 minutes; HealthCheckResultStatus.WARNING if duration > 1 minute; HealthCheckResultStatus.GOOD if duration > 0; otherwise HealthCheckResultStatus.CHECK_ERROR
      • prettyPrintBytes

        protected String prettyPrintBytes​(long value)
        Returns the amount in a human-friendly string

        i.e. with an input of 1024 the result will be "1 Kb"; for an input of 20000000 the result would be "19 Mb"

        Result is always rounded down number of the largest unit of which there is at least one of that unit.

        Unit can be Gb, Mb, Kb or bytes.

        Parameters:
        value -
        Returns:
      • prettyPrintStackTrace

        protected String prettyPrintStackTrace​(StackTraceElement[] elements)
        Returns a string of tab-separated stack trace elements
        Parameters:
        elements -
        Returns:
      • resolveDescription

        public String resolveDescription()
        Returns a human-friendly description of the healthcheck
        Returns:
        Since:
        4.1.2.173
      • getDescription

        protected abstract String getDescription()
        The key for a human-friendly description of the healthcheck
        Returns:
      • getOptions

        public O getOptions()
      • setOptions

        public void setOptions​(O options)
      • getCheckerType

        public Class<C> getCheckerType()
      • sendNotification

        public void sendNotification​(String name,
                                     HealthCheckResult checkResult,
                                     Level level)
        Sends a notification to all notifier enabled with the healthcheck service.

        Parameters:
        checkResult - information collected by the regarding health check service
        level - Level of the message to send
        name - Name of the checker executed