Class MultiClusterControlSupport

java.lang.Object
org.openspaces.core.multicluster.internal.MultiClusterControlSupport

public final class MultiClusterControlSupport extends Object
Implements the control half of MultiClusterGigaSpace - everything that configures the proxy rather than touching a space.

It is a plain class, not an implementation of the interface: the interface also declares 189 GigaSpace methods, which the router places on clusters instead. DefaultMultiClusterGigaSpace forwards its OperationKind.CONTROL methods straight here, and MultiClusterControlCompletenessTest fails the build if any control method has no counterpart.

Thread-safe: the topology lives in ClusterRegistry's copy-on-write state and the configuration in an AtomicReference, so a setXxx swaps one whole valid configuration for another and an in-flight operation never sees a half-applied change.

  • Constructor Details

  • Method Details

    • attachHealth

      public void attachHealth(HealthMonitor healthMonitor, FailoverManager failoverManager)
      Attaches the health machinery once it exists. The monitor needs this object's configuration and this object needs the monitor's verdicts, so the cycle is broken by wiring after construction rather than by passing half-built objects around.
    • currentConfig

      public MultiClusterConfig currentConfig()
      The current configuration; routing code reads this once per operation.
    • registry

      public ClusterRegistry registry()
    • registerCluster

      public void registerCluster(String clusterName, GigaSpace spaceProxy)
    • unregisterCluster

      public void unregisterCluster(String clusterName)
    • unregisterCluster

      public void unregisterCluster(GigaSpace spaceProxy)
    • setActiveCluster

      public void setActiveCluster(String clusterName)
      Moves both roles to clusterName: mutations, and READ_ACTIVE reads with any pin dropped.
    • setActiveCluster

      public void setActiveCluster(GigaSpace spaceProxy)
    • setWriteActiveCluster

      public void setWriteActiveCluster(String clusterName)
      Moves only the write role. A pinned read cluster keeps the reads; without a pin they follow.
    • getActiveClusterName

      public String getActiveClusterName()
    • getActiveCluster

      public GigaSpace getActiveCluster()
    • setReadActiveCluster

      public void setReadActiveCluster(String clusterName)
      Pins READ_ACTIVE reads to clusterName, leaving the write role where it is.
    • clearReadActiveCluster

      public void clearReadActiveCluster()
      Drops the read pin, so READ_ACTIVE reads follow the active cluster again.
    • getReadActiveClusterName

      public String getReadActiveClusterName()
    • getReadActiveCluster

      public GigaSpace getReadActiveCluster()
    • getRegisteredClusters

      public Map<String, GigaSpace> getRegisteredClusters()
    • getCluster

      public GigaSpace getCluster(String clusterName)
    • getClusterName

      public String getClusterName(GigaSpace spaceProxy)
    • setWriteMode

      public void setWriteMode(MultiClusterGigaSpace.WriteMode mode)
    • getWriteMode

      public MultiClusterGigaSpace.WriteMode getWriteMode()
    • setReadMode

      public void setReadMode(MultiClusterGigaSpace.ReadMode mode)
    • getReadMode

      public MultiClusterGigaSpace.ReadMode getReadMode()
    • setFailoverPolicy

      public void setFailoverPolicy(MultiClusterGigaSpace.FailoverPolicy policy)
    • getFailoverPolicy

      public MultiClusterGigaSpace.FailoverPolicy getFailoverPolicy()
    • setClusterPriorityList

      public void setClusterPriorityList(List<String> priorityNames)
    • getClusterPriorityList

      public List<String> getClusterPriorityList()
    • addClusterToPriorityList

      public boolean addClusterToPriorityList(String clusterName)
    • removeClusterFromPriorityList

      public boolean removeClusterFromPriorityList(String clusterName)
    • getReadRotation

      public List<String> getReadRotation()
    • addClusterToReadRotation

      public boolean addClusterToReadRotation(String clusterName)
    • removeClusterFromReadRotation

      public boolean removeClusterFromReadRotation(String clusterName)
    • onClusterFailed

      public void onClusterFailed(String clusterName, Throwable cause, boolean unregister)
      Reports a cluster that could not be reached, and removes it only when the mode in force asks for that.

      Reached from a health transition, so every route into it ends here: a run of failed reads crossing failureThreshold, a health-check ping that got no answer, and a mutation that could not reach the cluster.

      unregister is WRITE_SYNC's verdict and nobody else's. Under that mode every cluster was supposed to take the write, so one that did not is behind the others and serving stale reads; it leaves the topology. Under every other mode the cluster has missed nothing the proxy is responsible for, so it keeps its place in both lists and the application decides from the CLUSTER_FAILED event whether it should eventually go.

    • setFailureThreshold

      public void setFailureThreshold(int consecutiveFailuresThreshold)
    • getFailureThreshold

      public int getFailureThreshold()
    • setFailureWindow

      public void setFailureWindow(Duration failureWindow)
    • getFailureWindow

      public Duration getFailureWindow()
    • isClusterHealthy

      public boolean isClusterHealthy(String clusterName)
      Whether the cluster is healthy, according to the health monitor's windowed state - or a live ping if nothing has been observed yet, so a freshly registered cluster gives a real answer rather than an assumption.
    • isClusterHealthy

      public boolean isClusterHealthy(GigaSpace spaceProxy)
    • failoverToNextCluster

      public void failoverToNextCluster()
      Promotes the next healthy cluster in failover order.
      Throws:
      NoAvailableClusterException - if no other cluster is healthy
    • clusterStates

      public Map<String, ClusterHealth.State> clusterStates()
      The health state of every cluster, for diagnostics.
    • addClusterStateListener

      public void addClusterStateListener(MultiClusterGigaSpace.ClusterStateListener listener)
    • removeClusterStateListener

      public void removeClusterStateListener(MultiClusterGigaSpace.ClusterStateListener listener)
    • addClusterEventListener

      public void addClusterEventListener(ClusterEventListener listener)
    • removeClusterEventListener

      public void removeClusterEventListener(ClusterEventListener listener)
    • publish

      public void publish(ClusterEvent event)
      Publishes a typed event, on the same off-the-data-path executor the state listeners use.
    • listeners

      Registered listeners, for tests and diagnostics.
    • notifyListeners

      public void notifyListeners(String previousName, GigaSpace previousProxy, String newName, GigaSpace newProxy, Throwable cause)
      Notifies listeners off the data path. A listener that blocks delays notifications only, and one that throws is logged rather than allowed to break the operation that triggered the change.
    • stats

      public MultiClusterStats stats()
    • shutdown

      public void shutdown()
      Stops the listener executor. Called by the handler's close().