We are using Ignite cache in application. Multiple instances joins into topology, where caches created using Ignite.getOrCreateCache()
with RendezvousAffinityFunction
for partitioning like:
public static IgniteCache<String, Value> getOrCreateCache(Ignite ignite, String cacheName, int partitionCount) {
return ignite.getOrCreateCache(
new CacheConfiguration<String, Value>(cacheName)
.setGroupName("group")
.setBackups(0)
.setCacheMode(CacheMode.PARTITIONED)
.setAtomicityMode(CacheAtomicityMode.ATOMIC)
.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC)
.setAffinity(new RendezvousAffinityFunction(true, partitionCount))
);
}
I am migrating application from thick client to thin client, thus using IgniteClient.getOrCreateCache()
like:
public static ClientCache<String, Value> getOrCreateCache(IgniteClient igniteClient, String cacheName, int partitionCount) {
return igniteClient.getOrCreateCache(
new ClientCacheConfiguration()
.setName(cacheName)
.setGroupName("group")
.setBackups(0)
.setCacheMode(CacheMode.PARTITIONED)
.setAtomicityMode(CacheAtomicityMode.ATOMIC)
.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC)
// .setAffinity() ???
);
}
I am struggling of finding more info about configuring cache over IgniteClient
, either in documentations or sources. As I could find, thin client supports partition awareness, and can distribute cache operations over nodes.
How many partition would be created on cache that way, and why isn't it configurable?
NOTE: As the other answer explains, you don't need to change the default number in 99% use cases.
With that said, partition count is provided by the affinity function. You can set it like this:
CacheConfiguration<Object, Object> cacheCfg = new CacheConfiguration<>("cache-1")
.setAffinity(new RendezvousAffinityFunction().setPartitions(512));
However, custom affinity can't be set from the client side (for technical reasons - affinity function can have custom implementation and would require code deployment).
Workarounds: