Record Class ServerInfo

java.lang.Object
java.lang.Record
cloud.spawnery.agent.api.ServerInfo
Record Components:
registered - whether the proxies have this server in their routing tables. A server can be ServerPhase.READY and not registered, during the first half of a drain, so a plugin deciding where to send somebody wants this and not the phase.
state - what the server said it was doing, or "" if it has said nothing; see SpawneryApi.announce(java.lang.String, java.util.Map<java.lang.String, java.lang.String>). Unrelated to phase().
attributes - whatever else that server chose to publish, empty until it publishes something. Immutable.
incarnation - which run of this server this is: an opaque token that changes whenever the process behind the name is replaced, and never otherwise. Compare it, never parse it.

A persistent server keeps its name across restarts, so anything that remembers a server and later asks whether this is still the one it meant compares this and not the name.

Empty for a server whose pod the operator has not seen yet, which is a server nobody is being sent to.

number - which of its group's servers this is, counted the way a person counts: the second hub is 2. Stable for as long as the server exists.

Given out again once this server is gone, so two servers that were both "Hub-2" at different times are told apart by incarnation() and never by this.

0 for a server nobody numbered, and for the ordinal-zero server of a persistent group, which reports its ordinal here. Show the name for those rather than a zero.

held - whether an admin took this server's retirement back: nothing automatic removes it any more; it stays until it ends by itself.
node - the Kubernetes node the server's pod runs on, empty while it is not scheduled.
playableSlots - how many of slots count as capacity. Equal to slots when nothing narrowed it, and for a report from an operator older than this field.
resources - the resources stamped on this server when it was started, ServerResources.NONE for one without any and for a report from an operator older than this field.
unschedulable - whether the Kubernetes scheduler has found no node for this server's pod: the cluster has no room for it right now, whatever the cause, and left alone the server fails at the startup deadline. Never true together with a non-empty node(). False while the scheduler has not looked yet, once the pod is placed, and for a report from an operator older than this field.

public record ServerInfo(String name, String group, ServerPhase phase, int players, int slots, boolean registered, String state, Map<String,String> attributes, String incarnation, int number, boolean held, String node, int playableSlots, ServerResources resources, boolean unschedulable) extends Record
One backend, as the operator last described it.

A value and not a handle: call SpawneryApi.server(java.lang.String) again for a newer one.

  • Constructor Details

    • ServerInfo

      public ServerInfo(String name, String group, ServerPhase phase, int players, int slots, boolean registered, String state, Map<String,String> attributes, String incarnation, int number, boolean held, String node, int playableSlots, ServerResources resources, boolean unschedulable)
      Creates an instance of a ServerInfo record class.
      Parameters:
      name - the value for the name record component
      group - the value for the group record component
      phase - the value for the phase record component
      players - the value for the players record component
      slots - the value for the slots record component
      registered - the value for the registered record component
      state - the value for the state record component
      attributes - the value for the attributes record component
      incarnation - the value for the incarnation record component
      number - the value for the number record component
      held - the value for the held record component
      node - the value for the node record component
      playableSlots - the value for the playableSlots record component
      resources - the value for the resources record component
      unschedulable - the value for the unschedulable record component
    • ServerInfo

      public ServerInfo(String name, String group, ServerPhase phase, int players, int slots, boolean registered, String state, Map<String,String> attributes, String incarnation, int number, boolean held, String node, int playableSlots, ServerResources resources)
      The record as it was before unschedulable, which it reads as false.
    • ServerInfo

      public ServerInfo(String name, String group, ServerPhase phase, int players, int slots, boolean registered, String state, Map<String,String> attributes, String incarnation, int number, boolean held, String node, int playableSlots)
      The record as it was before resources, which it reads as none.
    • ServerInfo

      public ServerInfo(String name, String group, ServerPhase phase, int players, int slots, boolean registered, String state, Map<String,String> attributes, String incarnation, int number, boolean held, String node)
      The record as it was before playableSlots, which it reads as every seat.
    • ServerInfo

      public ServerInfo(String name, String group, ServerPhase phase, int players, int slots, boolean registered, String state, Map<String,String> attributes, String incarnation, int number, boolean held)
      The record as it was before node, which it reads as not scheduled.
    • ServerInfo

      public ServerInfo(String name, String group, ServerPhase phase, int players, int slots, boolean registered, String state, Map<String,String> attributes, String incarnation, int number)
      The record as it was before held, which it reads as false.
  • Method Details

    • freeSlots

      public int freeSlots()
      How many more players this server would accept, never negative: a report can show more players than slots while a lowered maxPlayers reaches the running pods.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • group

      public String group()
      Returns the value of the group record component.
      Returns:
      the value of the group record component
    • phase

      public ServerPhase phase()
      Returns the value of the phase record component.
      Returns:
      the value of the phase record component
    • players

      public int players()
      Returns the value of the players record component.
      Returns:
      the value of the players record component
    • slots

      public int slots()
      Returns the value of the slots record component.
      Returns:
      the value of the slots record component
    • registered

      public boolean registered()
      Returns the value of the registered record component.
      Returns:
      the value of the registered record component
    • state

      public String state()
      Returns the value of the state record component.
      Returns:
      the value of the state record component
    • attributes

      public Map<String,String> attributes()
      Returns the value of the attributes record component.
      Returns:
      the value of the attributes record component
    • incarnation

      public String incarnation()
      Returns the value of the incarnation record component.
      Returns:
      the value of the incarnation record component
    • number

      public int number()
      Returns the value of the number record component.
      Returns:
      the value of the number record component
    • held

      public boolean held()
      Returns the value of the held record component.
      Returns:
      the value of the held record component
    • node

      public String node()
      Returns the value of the node record component.
      Returns:
      the value of the node record component
    • playableSlots

      public int playableSlots()
      Returns the value of the playableSlots record component.
      Returns:
      the value of the playableSlots record component
    • resources

      public ServerResources resources()
      Returns the value of the resources record component.
      Returns:
      the value of the resources record component
    • unschedulable

      public boolean unschedulable()
      Returns the value of the unschedulable record component.
      Returns:
      the value of the unschedulable record component