Class MultiClusterGigaSpaceConfigurer
GigaSpaceConfigurer: hand it the clusters, set the routing modes, call
gigaSpace().
The application connects to each cluster; the proxy routes between them. Pass the
SpaceConfigurers and let this class call new GigaSpaceConfigurer(cfg).gigaSpace() for
each one:
SpaceProxyConfigurer east = new SpaceProxyConfigurer("mySpace").lookupLocators("east-host:4174");
SpaceProxyConfigurer west = new SpaceProxyConfigurer("mySpace").lookupLocators("west-host:4174");
MultiClusterGigaSpace gigaSpace = new MultiClusterGigaSpaceConfigurer(
Map.of("us-east", east, "us-west", west))
.activeCluster("us-east")
.writeMode(WriteMode.WRITE_SYNC)
.readMode(ReadMode.READ_ROUND_ROBIN)
.failoverPolicy(FailoverPolicy.AUTO_FAILOVER_NEXT_AVAILABLE)
.gigaSpace();
...
gigaSpace.close();
east.close(); // the SpaceConfigurers stay yours
west.close();
Or hand it GigaSpace proxies you already have - Spring beans, existing code - optionally
with a ClusterDescriptor carrying the site, weight and locality that weighted
MultiClusterGigaSpace.ReadMode.READ_ROUND_ROBIN needs:
MultiClusterGigaSpace gigaSpace = new MultiClusterGigaSpaceConfigurer()
.cluster(ClusterDescriptor.builder("us-east").site("us-east-1").local(true).build(), east)
.cluster(ClusterDescriptor.builder("us-west").weight(3).build(), west)
.readMode(ReadMode.READ_ROUND_ROBIN)
.gigaSpace();
Ownership
Cluster proxies are never owned by the multi-cluster proxy, exactly as aGigaSpace built by
GigaSpaceConfigurer does not own the SpaceConfigurer it came from. Whatever you passed
in - a GigaSpace or a SpaceConfigurer - stays yours to close. Closing the
multi-cluster proxy releases only what it created itself: the write executors and the
deferred-mutation queue.
Not thread-safe - configure on one thread, then build. The resulting proxy is thread-safe.
-
Constructor Summary
ConstructorsConstructorDescriptionAn empty configurer; add clusters with thecluster(...)methods.MultiClusterGigaSpaceConfigurer(Map<String, ? extends SpaceConfigurer> spaceConfigurers) Builds oneGigaSpaceper namedSpaceConfigurer, the waynew GigaSpaceConfigurer(spaceConfigurer).gigaSpace()would. -
Method Summary
Modifier and TypeMethodDescriptionactiveCluster(String clusterName) Chooses the initially active cluster; defaults to the first one registered.asyncQueueCapacity(int capacity) Bound on mutations still owed to a cluster - deferred, or fanned out in the background.clearSumsAcrossClusters(boolean sum) Whether a fanned-outclearreports the total removed across clusters (the default) or only the primary's count.Registers a proxy you own; it stays yours to close.cluster(String clusterName, SpaceConfigurer spaceConfigurer) Builds the cluster's proxy from aSpaceConfigureryou constructed, asnew GigaSpaceConfigurer(spaceConfigurer).gigaSpace()does.cluster(ClusterDescriptor descriptor, GigaSpace spaceProxy) Registers a proxy you own, taking its site, weight and locality from a descriptor.cluster(ClusterDescriptor descriptor, SpaceConfigurer spaceConfigurer) Builds the cluster's proxy from aSpaceConfigureryou constructed, with topology metadata from a descriptor.clusterPriority(String... clusterNames) Sets the failover priority order.clusterPriority(List<String> clusterNames) Sets the failover priority order.Registers several proxies you own at once, in iteration order.config()The configuration as it stands, already validated byMultiClusterConfig.config(MultiClusterConfig config) Replaces the whole configuration at once - handy when it comes from a properties file.create()Builds the proxy.failureThreshold(int consecutiveFailures) How many consecutive failed reads insidefailureWindow(Duration)write a cluster off.failureWindow(Duration window) fanOutTasks(boolean fanOutTasks) Whetherexecutefans a task out to every cluster.Builds the proxy: aMultiClusterGigaSpacethat application code can use anywhere aGigaSpaceis expected.jmx(boolean jmx) Exposes the proxy over JMX asorg.openspaces.core.multicluster:type=MultiClusterGigaSpace,name=NAME.Names this proxy.proxyFactory(Function<MultiClusterSetup, ? extends MultiClusterGigaSpace> proxyFactory) Builds a custom proxy instead ofDefaultMultiClusterGigaSpace- typically a subclass of it, given as a constructor reference such asAuditedGigaSpace::new.quiescePolicy(QuiescePolicy policy) readActiveCluster(String clusterName) PinsREAD_ACTIVEreads to a cluster other than the active one, so one cluster takes the writes and another serves the reads.requiredSuccessCount(int count) ForWRITE_SYNC: how many clusters must succeed.takeFanOutOnMiss(boolean takeFanOutOnMiss) Whether atakethat matched nothing locally still issues removals on other clusters.transactionPolicy(TransactionPolicy policy)
-
Constructor Details
-
MultiClusterGigaSpaceConfigurer
public MultiClusterGigaSpaceConfigurer()An empty configurer; add clusters with thecluster(...)methods. -
MultiClusterGigaSpaceConfigurer
Builds oneGigaSpaceper namedSpaceConfigurer, the waynew GigaSpaceConfigurer(spaceConfigurer).gigaSpace()would.The configurers stay yours: this class does not close them, and neither does the resulting proxy. Iteration order becomes registration order, so pass a
LinkedHashMapwhen the default priority order matters -Map.of()does not preserve order.- Throws:
IllegalArgumentException- if the map is empty, or a name is blank, repeated or maps tonull
-
-
Method Details
-
cluster
Registers a proxy you own; it stays yours to close. -
cluster
Registers a proxy you own, taking its site, weight and locality from a descriptor.Use this when clusters are wired as Spring beans but read routing still needs to know where they are: weighted
READ_ROUND_ROBINhas nothing to go on otherwise. -
cluster
Builds the cluster's proxy from aSpaceConfigureryou constructed, asnew GigaSpaceConfigurer(spaceConfigurer).gigaSpace()does. The configurer stays yours to close. -
cluster
public MultiClusterGigaSpaceConfigurer cluster(ClusterDescriptor descriptor, SpaceConfigurer spaceConfigurer) Builds the cluster's proxy from aSpaceConfigureryou constructed, with topology metadata from a descriptor. The configurer stays yours to close. -
clusters
Registers several proxies you own at once, in iteration order. -
name
Names this proxy. The name appears in log lines and is its JMX identity, so give each proxy in a JVM a distinct one. -
jmx
Exposes the proxy over JMX asorg.openspaces.core.multicluster:type=MultiClusterGigaSpace,name=NAME.Off by default: a library that registers MBeans without being asked surprises people, and two proxies sharing a name would collide. Registration failure never fails the proxy.
-
activeCluster
Chooses the initially active cluster; defaults to the first one registered. -
readActiveCluster
PinsREAD_ACTIVEreads to a cluster other than the active one, so one cluster takes the writes and another serves the reads. Unset by default: reads follow the active cluster, which is what keeps read-your-writes.- See Also:
-
clusterPriority
Sets the failover priority order. Omitted clusters follow in registration order. -
clusterPriority
Sets the failover priority order. -
writeMode
-
readMode
-
failoverPolicy
-
transactionPolicy
-
quiescePolicy
-
failureThreshold
How many consecutive failed reads insidefailureWindow(Duration)write a cluster off. It does not govern mutations: a mutation that cannot reach a cluster detaches it immediately, because that cluster has already missed data the others have. -
failureWindow
-
requiredSuccessCount
ForWRITE_SYNC: how many clusters must succeed.0means all of them. -
takeFanOutOnMiss
Whether atakethat matched nothing locally still issues removals on other clusters. -
asyncQueueCapacity
Bound on mutations still owed to a cluster - deferred, or fanned out in the background. -
fanOutTasks
Whetherexecutefans a task out to every cluster. Off by default: a task is arbitrary code that may not be idempotent, so the proxy will not duplicate it without being told to. Durable-task methods are never fanned out - their ids are issued by one cluster. -
clearSumsAcrossClusters
Whether a fanned-outclearreports the total removed across clusters (the default) or only the primary's count. -
config
Replaces the whole configuration at once - handy when it comes from a properties file. -
config
The configuration as it stands, already validated byMultiClusterConfig. -
proxyFactory
public MultiClusterGigaSpaceConfigurer proxyFactory(Function<MultiClusterSetup, ? extends MultiClusterGigaSpace> proxyFactory) Builds a custom proxy instead ofDefaultMultiClusterGigaSpace- typically a subclass of it, given as a constructor reference such asAuditedGigaSpace::new. The factory receives the validated setup and must hand it to aDefaultMultiClusterGigaSpace(MultiClusterSetup)constructor, or to a proxy that wraps one, so the routing modes and failover still apply.- Throws:
IllegalArgumentException- ifproxyFactoryis nullIllegalStateException- if the proxy was already built
-
gigaSpace
Builds the proxy: aMultiClusterGigaSpacethat application code can use anywhere aGigaSpaceis expected.Idempotent, like
GigaSpaceConfigurer.gigaSpace()- calling it twice returns the same proxy rather than registering a second proxy under the same JMX name.- Throws:
IllegalStateException- if no cluster was registeredIllegalArgumentException- if the active cluster, the read-active cluster or a priority entry names an unknown cluster
-
create
-