Class RedisBackedGridModel

java.lang.Object
org.openqa.selenium.grid.distributor.GridModel
org.openqa.selenium.grid.distributor.redis.RedisBackedGridModel

public class RedisBackedGridModel extends GridModel
Redis-backed implementation of GridModel. All grid state is stored in Redis, enabling multiple Distributor replicas to share a consistent view of the grid without any JVM-local state.

Key schema:

  • grid:node:{nodeId}:status — JSON-serialized NodeStatus
  • grid:nodes:UP / DOWN / DRAINING — Redisson RSet of NodeId strings
  • grid:node:{nodeId}:lastTouch — epoch-millis of last heartbeat
  • grid:node:{nodeId}:healthFailCount — consecutive failure count
  • grid:slot:{nodeId}:{slotUUID}:session"RESERVED" or JSON(Session)
  • Constructor Details

  • Method Details

    • add

      public void add(NodeStatus node)
      Description copied from class: GridModel
      Adds a node to the grid model, typically starting with DOWN availability until health checks pass.
      Specified by:
      add in class GridModel
      Parameters:
      node - The node status to add
    • refresh

      public void refresh(NodeStatus status)
      Description copied from class: GridModel
      Refreshes a node's status in the grid model.
      Specified by:
      refresh in class GridModel
      Parameters:
      status - The updated node status
    • touch

      public void touch(NodeStatus nodeStatus)
      Description copied from class: GridModel
      Updates the timestamp for a node to prevent it from being considered stale. May also update the node's availability if reported differently.
      Specified by:
      touch in class GridModel
      Parameters:
      nodeStatus - The node status to update
    • remove

      public void remove(NodeId id)
      Description copied from class: GridModel
      Removes a node from the grid model.
      Specified by:
      remove in class GridModel
      Parameters:
      id - The ID of the node to remove
    • purgeDeadNodes

      public void purgeDeadNodes()
      Description copied from class: GridModel
      Removes nodes that have been unresponsive for too long.
      Specified by:
      purgeDeadNodes in class GridModel
    • setAvailability

      public void setAvailability(NodeId id, Availability availability)
      Description copied from class: GridModel
      Sets the availability status for a node.
      Specified by:
      setAvailability in class GridModel
      Parameters:
      id - The ID of the node
      availability - The new availability status
    • reserve

      public boolean reserve(SlotId slotId)
      Description copied from class: GridModel
      Attempts to reserve a specific slot on a node.
      Specified by:
      reserve in class GridModel
      Parameters:
      slotId - The ID of the slot to reserve
      Returns:
      true if the reservation was successful, false otherwise
    • getSnapshot

      public Set<NodeStatus> getSnapshot()
      Description copied from class: GridModel
      Gets a snapshot of all node statuses currently in the grid model.
      Specified by:
      getSnapshot in class GridModel
      Returns:
      A set of node statuses
    • release

      public void release(@Nullable SessionId id)
      Description copied from class: GridModel
      Releases a session, making its slot available again.
      Specified by:
      release in class GridModel
      Parameters:
      id - The ID of the session to release
    • setSession

      public void setSession(SlotId slotId, @Nullable Session session)
      Description copied from class: GridModel
      Updates a reserved slot to contain an actual session.
      Specified by:
      setSession in class GridModel
      Parameters:
      slotId - The ID of the slot to update
      session - The session to associate with the slot, or null to clear
    • updateHealthCheckCount

      public void updateHealthCheckCount(NodeId id, Availability availability)
      Description copied from class: GridModel
      Updates the health check count for a node based on its availability.
      Specified by:
      updateHealthCheckCount in class GridModel
      Parameters:
      id - The ID of the node
      availability - The current availability status