Class HubDefinitionFile.Parsed

java.lang.Object
com.iizix.server.hub.HubDefinitionFile.Parsed
Enclosing class:
HubDefinitionFile

public static final class HubDefinitionFile.Parsed extends Object
The result of a parse: the values, the defaults where the file sets nothing, and the diagnostics. The lists are unmodifiable.
Author:
Christopher Mindus
  • Field Details

    • name

      public final String name
      The hub's name, null when the file does not set a valid one: the file is then not usable.
    • policy

      public final HubDefinitionFile.Policy policy
      The election policy.
    • lease

      public final int lease
      The lease, in seconds.
    • margin

      public final int margin
      The margin a challenger waits beyond the lease, in seconds.
    • grace

      public final int grace
      The fail-open grace, in seconds.
    • hold

      public final int hold
      The hold of a switched client, in seconds.
    • keyPath

      public final String keyPath
      The path of the interim cluster key file as written, null when not set.
    • members

      public final List<HubDefinitionFile.Member> members
      The members in file order, which is the priority order.
    • origins

      public final List<String> origins
      The further allowed origins, normalised to lower case, in file order without duplicates.
    • diagnostics

      public final List<HubDefinitionFile.Diagnostic> diagnostics
      The diagnostics, in file order, the whole-file ones last.
  • Method Details

    • hasSevere

      public boolean hasSevere()
      Tells whether any line or value was refused.
      Returns:
      true when a SEVERE diagnostic is present.
    • isUsable

      public boolean isUsable()
      Tells whether the file can serve as a definition: it sets a valid name.
      Returns:
      true when usable.
    • member

      public HubDefinitionFile.Member member(String id)
      Finds a member by its ID, exactly as written.
      Parameters:
      id - The member ID.
      Returns:
      The member, or null when not named.
    • indexOf

      public int indexOf(String id)
      Gets the position of a member in the priority order.
      Parameters:
      id - The member ID.
      Returns:
      The zero-based index, or -1 when not named.
    • eligible

      public List<HubDefinitionFile.Member> eligible()
      Gets the eligible members: those flagged principal, in priority order.
      Returns:
      The list, never null.
    • sameElection

      public boolean sameElection(HubDefinitionFile.Parsed other)
      Tells whether another parse defines the same election: the same policy and the same members in the same order (ID, URL and flag, wherever the lines are).
      Parameters:
      other - The other parse.
      Returns:
      true when an election would read the same from both.