Class MultiClusterGigaSpaceConfigurer

java.lang.Object
org.openspaces.core.multicluster.MultiClusterGigaSpaceConfigurer

public final class MultiClusterGigaSpaceConfigurer extends Object
Programmatic configurer for a multi-cluster proxy, in the shape of 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 a GigaSpace 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.