Class ContextState

java.lang.Object
org.gcube.common.health.api.ContextState

public final class ContextState extends Object
The state of an application in one of its Contexts: pending before it has been prepared there, active when it works there, degraded when it works with a problem to verify, unavailable when it should work there and cannot (a fault), unconfigured when it is not set up to work there (e.g. it has no configuration in the Context: nothing to fix). A degraded, unavailable or unconfigured state has a reason, which names the Context, e.g. "The catalogue cannot reach CKAN in /gcube/devsec/CCP". The health is public: the reason names what is missing, never a secret.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The value of an application that works in the Context.
    static final String
    The value of an application that works in the Context with a problem to verify.
    static final String
    The value of an application not prepared yet in the Context.
    static final String
    The value of an application that should work in the Context and cannot: a fault.
    static final String
    The value of an application that is not set up to work in the Context: nothing to fix.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the state of an application that works in the Context.
    degraded(String reason)
    Returns the state of an application that works in the Context with a problem to verify.
    boolean
    equals(Object other)
     
    Returns the reason of a degraded, unavailable or unconfigured state.
    Returns the value of the state: pending, active, degraded, unavailable or unconfigured.
    int
     
    boolean
    Tells whether the application works in the Context (active or degraded).
    Returns the state of an application not prepared yet in the Context.
     
    Returns the state of an application that should work in the Context and cannot: a fault (e.g. a backend it needs does not answer), which makes the application degraded in its health.
    Returns the state of an application that is not set up to work in the Context (e.g. it has no configuration there): nothing to fix, so it does not change the health of the application.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • PENDING

      public static final String PENDING
      The value of an application not prepared yet in the Context.
      See Also:
    • ACTIVE

      public static final String ACTIVE
      The value of an application that works in the Context.
      See Also:
    • DEGRADED

      public static final String DEGRADED
      The value of an application that works in the Context with a problem to verify.
      See Also:
    • UNAVAILABLE

      public static final String UNAVAILABLE
      The value of an application that should work in the Context and cannot: a fault.
      See Also:
    • UNCONFIGURED

      public static final String UNCONFIGURED
      The value of an application that is not set up to work in the Context: nothing to fix.
      See Also:
  • Method Details

    • pending

      public static ContextState pending()
      Returns the state of an application not prepared yet in the Context.
      Returns:
      the pending state
    • active

      public static ContextState active()
      Returns the state of an application that works in the Context.
      Returns:
      the active state
    • degraded

      public static ContextState degraded(String reason)
      Returns the state of an application that works in the Context with a problem to verify.
      Parameters:
      reason - the problem, naming the Context
      Returns:
      the degraded state
    • unavailable

      public static ContextState unavailable(String reason)
      Returns the state of an application that should work in the Context and cannot: a fault (e.g. a backend it needs does not answer), which makes the application degraded in its health.
      Parameters:
      reason - why, naming the Context
      Returns:
      the unavailable state
    • unconfigured

      public static ContextState unconfigured(String reason)
      Returns the state of an application that is not set up to work in the Context (e.g. it has no configuration there): nothing to fix, so it does not change the health of the application.
      Parameters:
      reason - why, naming the Context
      Returns:
      the unconfigured state
    • getValue

      public String getValue()
      Returns the value of the state: pending, active, degraded, unavailable or unconfigured.
      Returns:
      the value
    • getReason

      public String getReason()
      Returns the reason of a degraded, unavailable or unconfigured state.
      Returns:
      the reason, or null for pending and active
    • isWorking

      public boolean isWorking()
      Tells whether the application works in the Context (active or degraded).
      Returns:
      true when it works there
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object