Skip to main content
Package com.gpudb

Class WorkerList

All Implemented Interfaces:
Direct Known Subclasses:

public class WorkerList extends ArrayList<URL>
A list of worker URLs to use for multi-head ingest and retrieval.

The addresses belong to the connection, not to this list. A GPUdb instance discovers each cluster’s rank addresses, applies the connection’s hostname regex to them, and keeps the result per cluster; this class is a view onto that, held by a BulkInserter or RecordRetriever.

It does not resolve or filter addresses of its own. A filter has no coherent meaning here, because it cannot survive a failover: one tuned for a cluster’s addressing may match nothing on the next, and multi-head objects fail over with the connection. Set the regex on the connection instead, where it is applied to every cluster as that cluster is discovered.

The one choice that is meaningful per object is declining multi-head altogether — see WorkerList(). That names an intent rather than an address, and an intent transfers across clusters where a list of addresses does not.

Note entry i of this list is rank i + 1; the head rank is not a member, and a rank removed from the cluster keeps its slot as null. The worker indices in the shard routing table are rank numbers, so compacting the list would silently misroute every rank above the hole.

  • Constructor Details

    • WorkerList

      public WorkerList()
      Creates an empty WorkerList, which declines multi-head operations for the BulkInserter or RecordRetriever it is given to.

      That object will route through the head node for its lifetime. The choice is authoritative: it is not undone when the worker list is rebuilt after a failover or a shard rebalance.

      This is the way to decline multi-head for a single object while keeping the connection’s fail-over. Disabling auto-discovery is not equivalent — it also stops the client discovering the other clusters in an HA ring, so it costs fail-over as well.

      Nothing inside the API may use this constructor: it is a caller’s way of expressing an intent, and an internal use would silently pin its own list to head-node-only.

    • WorkerList

      @Deprecated public WorkerList(List<URL> urls)
      Deprecated.
      for internal use. Pass null to a BulkInserter or RecordRetriever to use the connection’s own addresses, or WorkerList() to decline multi-head.
      Creates a WorkerList populated with the given URLs.

      The list is honored as given, but is not maintained: after the connection fails over or back, the object adopts that cluster’s addresses instead, because a list of one cluster’s rank addresses says nothing about another’s.

      Parameters:
      urls - the worker rank URLs, with null in the slot of any rank removed from the cluster
    • WorkerList

      public WorkerList(GPUdb gpudb) throws GPUdbException
      Creates a WorkerList from the worker rank addresses the given connection has already discovered for the cluster it is currently on.

      This reads the connection’s addresses; it does not query the server or re-resolve them. They were filtered through the connection’s hostname regex when that cluster was discovered, so they already reflect it.

      If the connection has no worker addresses for the current cluster — multi-head is off at the server, or the cluster advertises none this client can use — the list is empty and the object using it operates through the head node.

      Parameters:
      gpudb - the GPUdb instance whose addresses to use
      Throws:
      GPUdbException - never thrown; retained for source compatibility
    • WorkerList

      @Deprecated public WorkerList(GPUdb gpudb, Pattern ipRegex) throws GPUdbException
      Deprecated.
      the regex is ignored. Address filtering belongs on the connection — see GPUdbBase.Options.setHostnameRegex(java.lang.String) — because a filter at this scope cannot survive a failover: one tuned for a cluster’s addressing may match nothing on the next. This constructor behaves as WorkerList(GPUdb).
      Parameters:
      gpudb - the GPUdb instance whose addresses to use
      ipRegex - ignored
      Throws:
      GPUdbException - never thrown; retained for source compatibility
    • WorkerList

      @Deprecated public WorkerList(GPUdb gpudb, String ipPrefix) throws GPUdbException
      Deprecated.
      the prefix is ignored; see WorkerList(GPUdb, Pattern) for why, and GPUdbBase.Options.setHostnameRegex(java.lang.String) for the replacement.
      Parameters:
      gpudb - the GPUdb instance whose addresses to use
      ipPrefix - ignored
      Throws:
      GPUdbException - never thrown; retained for source compatibility
  • Method Details

    • getIpRegex

      @Deprecated public Pattern getIpRegex()
      Deprecated.
      a worker list has no regex of its own. Addresses are filtered by the connection; see GPUdbBase.Options.getHostnameRegex().
      Returns:
      always null
    • isMultiHeadEnabled

      public boolean isMultiHeadEnabled()
      Whether multi-head operations can be used with this list.
      Returns:
      whether the list names any worker rank