Record Class ClusterDescriptor

java.lang.Object
java.lang.Record
org.openspaces.core.multicluster.ClusterDescriptor
Record Components:
name - logical cluster name used in configuration, metrics and log lines
site - free-form site / region label, reported in the topology, or null
local - whether this cluster is co-located with the client
weight - relative share for weighted read balancing, >= 1

public record ClusterDescriptor(String name, String site, boolean local, int weight) extends Record
Topology metadata for one cluster: what to call it, where it is, and how much read traffic it should take. It describes a cluster the application has already connected to - it does not say how to connect, because the application owns that.

Connection details deliberately live outside this record. A cluster enters the proxy as a GigaSpace the application built, or as a SpaceConfigurer it hands over:

GigaSpace east = new GigaSpaceConfigurer(
        new SpaceProxyConfigurer("mySpace").lookupLocators("east-host:4174")).gigaSpace();

MultiClusterGigaSpace proxy = new MultiClusterGigaSpaceConfigurer()
        .cluster(ClusterDescriptor.builder("us-east").site("us-east-1").local(true).build(), east)
        .cluster("us-west", west)
        .gigaSpace();

A descriptor is optional. cluster(name, proxy) registers a cluster with default metadata - no site, not local, weight 1. Supply one when read routing needs more to go on: weighted MultiClusterGigaSpace.ReadMode.READ_ROUND_ROBIN has nothing but weight() to distribute by, and site() and local() are what the reported topology shows.

Instances are immutable; build them with builder(String).

  • Constructor Details

    • ClusterDescriptor

      public ClusterDescriptor(String name, String site, boolean local, int weight)
      Creates an instance of a ClusterDescriptor record class.
      Parameters:
      name - the value for the name record component
      site - the value for the site record component
      local - the value for the local record component
      weight - the value for the weight record component
  • Method Details

    • of

      public static ClusterDescriptor of(String name)
      A descriptor carrying nothing but the name: no site, not local, weight 1.
    • builder

      public static ClusterDescriptor.Builder builder(String name)
    • 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 the compare method from their corresponding wrapper classes.
      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
    • site

      public String site()
      Returns the value of the site record component.
      Returns:
      the value of the site record component
    • local

      public boolean local()
      Returns the value of the local record component.
      Returns:
      the value of the local record component
    • weight

      public int weight()
      Returns the value of the weight record component.
      Returns:
      the value of the weight record component