Tabnine Logo
DistributionInfo.primary
Code IndexAdd Tabnine to your IDE (free)

How to use
primary
method
in
org.infinispan.distribution.DistributionInfo

Best Java code snippets using org.infinispan.distribution.DistributionInfo.primary (Showing top 17 results out of 315)

origin: wildfly/wildfly

Node locatePrimaryOwner(String sessionId) {
  DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager();
  Address address = (dist != null) ? dist.getCacheTopology().getDistribution(new Key<>(sessionId)).primary() : null;
  Node node = (address != null) ? this.memberFactory.createNode(address) : null;
  return (node != null) ? node : this.group.getLocalMember();
}
origin: wildfly/wildfly

  @Override
  public String locate(String sessionId) {
    DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager();
    Address address = (dist != null) && !this.cache.getCacheConfiguration().clustering().cacheMode().isScattered() ? dist.getCacheTopology().getDistribution(new Key<>(sessionId)).primary() : this.cache.getCacheManager().getAddress();
    Node node = (address != null) ? this.factory.createNode(address) : null;
    Map.Entry<String, Void> entry = (node != null) ? this.registry.getEntry(node) : null;
    if (entry == null) {
      entry = this.registry.getEntry(this.registry.getGroup().getLocalMember());
    }
    return (entry != null) ? entry.getKey() : null;
  }
}
origin: wildfly/wildfly

Node locatePrimaryOwner(I id) {
  DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager();
  Address address = (dist != null) && !this.cache.getCacheConfiguration().clustering().cacheMode().isScattered() ? dist.getCacheTopology().getDistribution(new Key<>(id)).primary() : null;
  Node member = (address != null) ? this.nodeFactory.createNode(address) : null;
  return (member != null) ? member : this.registry.getGroup().getLocalMember();
}
origin: org.infinispan/infinispan-core

if (di.primary().equals(ownerAddress)) {
  return valueToTest;
origin: org.infinispan/infinispan-core

private Address owner(Object key) {
 return advancedCache(0).getDistributionManager().getCacheTopology().getDistribution(key).primary();
}
origin: org.infinispan/infinispan-core

private Address owner(Object key) {
 return advancedCache(0).getDistributionManager().getCacheTopology().getDistribution(key).primary();
}
origin: org.keycloak/keycloak-model-infinispan

private Address getOwnerAddress(Cache cache, Object key) {
  DistributionManager dist = cache.getAdvancedCache().getDistributionManager();
  Address address = (dist != null) && !cache.getCacheConfiguration().clustering().cacheMode().isScattered() ?
      dist.getCacheTopology().getDistribution(key).primary() :
      cache.getCacheManager().getAddress();
  return address;
}
origin: org.infinispan/infinispan-query

private Cache<String, Foo> getKeyLocation(String key) {
 Address cache1Address = cache1.getAdvancedCache().getRpcManager().getAddress();
 LocalizedCacheTopology cacheTopology = cache1.getAdvancedCache().getDistributionManager().getCacheTopology();
 DistributionInfo distribution = cacheTopology.getDistribution(key);
 Address primary = distribution.primary();
 return primary.equals(cache1Address) ? cache1 : cache2;
}
origin: org.jboss.eap/wildfly-clustering-ejb-infinispan

Node locatePrimaryOwner(I id) {
  DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager();
  Address address = (dist != null) && !this.cache.getCacheConfiguration().clustering().cacheMode().isScattered() ? dist.getCacheTopology().getDistribution(new Key<>(id)).primary() : null;
  Node member = (address != null) ? this.nodeFactory.createNode(address) : null;
  return (member != null) ? member : this.registry.getGroup().getLocalMember();
}
origin: org.infinispan/infinispan-core

protected Object createSameHashCodeKey(String name) {
 final Address address = cache.getAdvancedCache().getRpcManager().getAddress();
 DistributionManager distributionManager = cache.getAdvancedCache().getDistributionManager();
 int hashCode = 0;
 SameHashCodeKey key = new SameHashCodeKey(name, hashCode);
 while (!distributionManager.getCacheTopology().getDistribution(key).primary().equals(address)) {
   hashCode++;
   key = new SameHashCodeKey(name, hashCode);
 }
 return key;
}
origin: org.infinispan/infinispan-query

private Optional<Cache<Object, Person>> findCache(Ownership ownership, Object key) {
 List<Cache<Object, Person>> caches = caches();
 ClusteringDependentLogic cdl = cache1.getAdvancedCache().getComponentRegistry().getComponent(ClusteringDependentLogic.class);
 DistributionInfo distribution = cdl.getCacheTopology().getDistribution(key);
 Predicate<Cache<?, ?>> predicate = null;
 switch (ownership) {
   case PRIMARY:
    predicate = c -> c.getAdvancedCache().getRpcManager().getAddress().equals(distribution.primary());
    break;
   case BACKUP:
    predicate = c -> distribution.writeBackups().contains(c.getAdvancedCache().getRpcManager().getAddress());
    break;
   case NON_OWNER:
    predicate = c -> !distribution.writeOwners().contains(c.getAdvancedCache().getRpcManager().getAddress());
 }
 return caches.stream().filter(predicate).findFirst();
}
origin: org.infinispan/infinispan-core

  @Override
  protected Object createSameHashCodeKey(String name) {
   final Cache otherCache = otherCacheManager.getCache();
   final Address address = otherCache.getAdvancedCache().getRpcManager().getAddress();
   DistributionManager distributionManager = otherCache.getAdvancedCache().getDistributionManager();
   int hashCode = 0;
   SameHashCodeKey key = new SameHashCodeKey(name, hashCode);
   while (!distributionManager.getCacheTopology().getDistribution(key).primary().equals(address)) {
     hashCode++;
     key = new SameHashCodeKey(name, hashCode);
   }
   return key;
  }
}
origin: org.infinispan/infinispan-core

   clusterListener.events.size() >= 1 && clusterListener.events.size() <= 5);
Address cache0primary = cache0.getAdvancedCache().getDistributionManager().getCacheTopology().getDistribution(key).primary();
Address cache2primary = cache2.getAdvancedCache().getDistributionManager().getCacheTopology().getDistribution(key).primary();
origin: org.infinispan/infinispan-core

protected <K, V> Cache<K, V> getLockOwner(Object key, String cacheName) {
 Configuration c = getCache(0, cacheName).getCacheConfiguration();
 if (c.clustering().cacheMode().isInvalidation()) {
   return getCache(0, cacheName); //for replicated caches only the coordinator acquires lock
 } else if (!c.clustering().cacheMode().isClustered()) {
   throw new IllegalStateException("This is not a clustered cache!");
 } else {
   Address address = getCache(0, cacheName).getAdvancedCache().getDistributionManager().getCacheTopology()
      .getDistribution(key).primary();
   for (Cache<K, V> cache : this.<K, V>caches(cacheName)) {
    if (cache.getAdvancedCache().getRpcManager().getTransport().getAddress().equals(address)) {
      return cache;
    }
   }
   throw new IllegalStateException();
 }
}
origin: org.infinispan/infinispan-core

private void introduceCacheConflicts() {
 LocalizedCacheTopology topology = getCache(0).getDistributionManager().getCacheTopology();
 for (int i = 0; i < NUMBER_OF_CACHE_ENTRIES; i += INCONSISTENT_VALUE_INCREMENT) {
   Address primary = topology.getDistribution(i).primary();
   AdvancedCache<Object, Object> primaryCache = manager(primary).getCache(CACHE_NAME).getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL);
   if (i % NULL_VALUE_FREQUENCY == 0)
    primaryCache.remove(i);
   else
    primaryCache.put(i, "INCONSISTENT");
 }
}
origin: org.infinispan/infinispan-core

Object key = k(method, i);
cache(LON, 0).put(key, VALUE);
if (topology.getDistribution(key).primary().equals(coordLON)) {
 keysOnCoordinator.add(key);
origin: org.infinispan/infinispan-core

private void doTest(Operation operation, boolean init) throws Exception {
 final MagicKey key = new MagicKey(cache(1), cache(2));
 if (init) {
   cache(0).put(key, "v1");
   assertInAllCache(key, "v1");
 }
 BlockingLocalTopologyManager bltm0 = replaceTopologyManagerDefaultCache(manager(0));
 BlockingLocalTopologyManager bltm1 = replaceTopologyManagerDefaultCache(manager(1));
 killMember(2, null, false);
 //CH_UPDATE + REBALANCE_START + CH_UPDATE(blocked)
 bltm0.expectRebalanceStartAfterLeave().unblock();
 bltm1.expectRebalanceStartAfterLeave().unblock();
 bltm0.expectPhaseConfirmation().unblock();
 bltm1.expectPhaseConfirmation().unblock();
 //check if we are in the correct state
 LocalizedCacheTopology cacheTopology = TestingUtil.extractComponent(cache(0), DistributionManager.class).getCacheTopology();
 DistributionInfo distributionInfo = cacheTopology.getDistribution(key);
 assertFalse(distributionInfo.isReadOwner());
 assertTrue(distributionInfo.isWriteOwner());
 assertEquals(address(1), distributionInfo.primary());
 operation.put(key, "v2", cache(1));
 BlockingLocalTopologyManager.finishRebalance(CacheTopology.Phase.READ_ALL_WRITE_ALL, bltm0, bltm1);
 waitForClusterToForm(); //let the cluster finish the state transfer
 assertInAllCache(key, "v2");
}
org.infinispan.distributionDistributionInfoprimary

Popular methods of DistributionInfo

  • isPrimary
  • writeOwners
  • isWriteOwner
  • isReadOwner
  • isWriteBackup
  • readOwners
  • writeBackups
  • writeOwnership

Popular in Java

  • Creating JSON documents from java classes using gson
  • addToBackStack (FragmentTransaction)
  • notifyDataSetChanged (ArrayAdapter)
  • findViewById (Activity)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Reference (javax.naming)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now