Terracotta 10.5 | Ehcache API Developer Guide | Clustered Caches | Ehcache Cluster Tier Manager Lifecycle
 
Ehcache Cluster Tier Manager Lifecycle
When configuring a cache manager to connect to a cluster tier manager there are three possible connection modes:
CacheManagerBuilder<PersistentCacheManager> autoCreate =
CacheManagerBuilder.newCacheManagerBuilder()
.with(ClusteringServiceConfigurationBuilder.cluster(
URI.create("terracotta://localhost:9410/my-application"))
.autoCreate() // <1>
.resourcePool("resource-pool", 32, MemoryUnit.MB,
"primary-server-resource"))
.withCache("clustered-cache",
CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder()
.with(ClusteredResourcePoolBuilder.clusteredShared("resource-pool"))));

CacheManagerBuilder<PersistentCacheManager> expecting =
CacheManagerBuilder.newCacheManagerBuilder()
.with(ClusteringServiceConfigurationBuilder.cluster(
URI.create("terracotta://localhost:9410/my-application"))
.expecting() // <2>
.resourcePool("resource-pool", 32, MemoryUnit.MB, "primary-server-resource"))
.withCache("clustered-cache",
CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder()
.with(ClusteredResourcePoolBuilder.clusteredShared("resource-pool"))));

CacheManagerBuilder<PersistentCacheManager> configless =
CacheManagerBuilder.newCacheManagerBuilder()
.with(ClusteringServiceConfigurationBuilder.cluster(
URI.create("terracotta://localhost:9410/my-application"))) // <3>

.withCache("clustered-cache",
CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class,
ResourcePoolsBuilder.newResourcePoolsBuilder()
.with(ClusteredResourcePoolBuilder.clusteredShared("resource-pool"))));
1
In auto-create mode if no cluster tier manager exists then one is created with the supplied configuration. If it exists and its configuration matches the supplied configuration then a connection is established. If the supplied configuration does not match then the cache manager will fail to initialize.
2
In expected mode if a cluster tier manager exists and its configuration matches the supplied configuration then a connection is established. If the supplied configuration does not match or the cluster tier manager does not exist then the cache manager will fail to initialize.
3
In config-less mode if a cluster tier manager exists then a connection is established without regard to its configuration. If it does not exist then the cache manager will fail to initialize.

Copyright © 2010-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.