Şu satırı dahil ederiz
import org.apache.ignite.cache.affinity.Affinity;
mapKeyToNode metodu
Örnek
Şu satırı dahil ederiz
import org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy; private final IgniteEx ignite = ...; private final Map<String/*Cache name*/, Affinity<Object>> affinities = new ConcurrentHashMap<>(); String cacheName = headers.getFirst("affinity-cache-name");//table name String affinityKey = headers.getFirst("affinity-key"); //user id aka data sharding key Affinity<Object> affinity = affinities.computeIfAbsent( cacheName, k -> ((GatewayProtectedCacheProxy)ignite.cache(cacheName)).context(). cache().affinity() ); ClusterNode node = affinity.mapKeyToNode(affinityKey);
Hiç yorum yok:
Yorum Gönder