congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
DistributionManager.getCacheTopology
Code IndexAdd Tabnine to your IDE (free)

How to use
getCacheTopology
method
in
org.infinispan.distribution.DistributionManager

Best Java code snippets using org.infinispan.distribution.DistributionManager.getCacheTopology (Showing top 20 results out of 315)

origin: wildfly/wildfly

public CacheLocality(Cache<?, ?> cache) {
  DistributionManager dist = cache.getAdvancedCache().getDistributionManager();
  this.locality = (dist != null) ? new ConsistentHashLocality(dist.getCacheTopology()) : new SimpleLocality(true);
}
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 Membership getMembership() {
  if (this.isSingleton()) {
    return new SingletonMembership(this.getLocalMember());
  }
  Transport transport = this.cache.getCacheManager().getTransport();
  DistributionManager dist = this.cache.getAdvancedCache().getDistributionManager();
  return (dist != null) ? new CacheMembership(transport.getAddress(), dist.getCacheTopology(), this) : new CacheMembership(transport, this);
}
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

  private int currentTopologyId(Cache cache) {
   return TestingUtil.extractComponent(cache, DistributionManager.class).getCacheTopology().getTopologyId();
  }
}
origin: org.infinispan/infinispan-core

public void testDistributionFromSecondaryOwner() throws Exception {
 Object key = "testDistributionFromSecondaryOwner";
 doTestDistribution(key, cacheManagers.stream()
    .map(cm -> cm.<Object, Integer>getCache(DIST).getAdvancedCache())
    // owner...
    .filter(cache -> cache.getDistributionManager().getCacheTopology().getDistribution(key).isWriteBackup())
    .findAny()
    .get());
}
origin: org.infinispan/infinispan-query

 @Override
 public boolean shouldModifyIndexes(FlagAffectedCommand command, InvocationContext ctx,
                   DistributionManager distributionManager, RpcManager rpcManager, Object key) {
   if (key == null || distributionManager == null) {
    return true;
   }
   DistributionInfo info = distributionManager.getCacheTopology().getDistribution(key);
   // If this is a backup node we should modify the entry in the remote context
   return info.isPrimary() || info.isWriteOwner() &&
      (ctx.isInTxScope() || !ctx.isOriginLocal() || command != null && command.hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER));
 }
},
origin: org.infinispan/infinispan-core

  private void checkRehashed(DistributionManager dm, List<Cache<Object,Object>> caches, List<Address> addresses) {
   TestingUtil.waitForNoRebalance(caches);
   assertNull(dm.getCacheTopology().getPendingCH());
   ConsistentHash ch = dm.getCacheTopology().getCurrentCH();
   assertEquals(addresses, ch.getMembers());
   for (int i = 0; i < ch.getNumSegments(); i++) {
     assertEquals(ch.getNumOwners(), ch.locateOwnersForSegment(i).size());
   }
  }
}
origin: org.infinispan/infinispan-core

public void assertActualMembers() {
  Set<org.infinispan.remoting.transport.Address> expected =
   cachesInThisPartition().stream()
               .map(c -> c.getAdvancedCache().getRpcManager().getAddress())
               .collect(Collectors.toSet());
  for (Cache c : cachesInThisPartition()) {
   eventuallyEquals(expected, () -> new HashSet<>(c.getAdvancedCache().getDistributionManager().getCacheTopology().getActualMembers()));
  }
}
origin: org.infinispan/infinispan-core

protected void assertMapsToAddress(Object o, Address addr) {
 LocalizedCacheTopology cacheTopology = caches.get(0).getAdvancedCache().getDistributionManager().getCacheTopology();
 List<Address> addresses = cacheTopology.getDistribution(o).writeOwners();
 assertEquals("Expected key " + o + " to map to address " + addr + ". List of addresses is" + addresses, true, addresses.contains(addr));
}
origin: org.infinispan/infinispan-core

  @Override
  public TestCache create(String groupName, List<Cache<GroupKey, String>> cacheList) {
   for (Cache<GroupKey, String> cache : cacheList) {
     DistributionManager distributionManager = TestingUtil.extractComponent(cache, DistributionManager.class);
     DistributionInfo distributionInfo = distributionManager.getCacheTopology().getDistribution(groupName);
     if (distributionInfo.isPrimary()) {
      return new TestCache(cache, cache.getAdvancedCache());
     }
   }
   throw new IllegalStateException("didn't find a cache... should never happen!");
  }
},
origin: org.infinispan/infinispan-server-hotrod

private CacheTopology getCounterCacheTopology(EmbeddedCacheManager cacheManager) {
 AdvancedCache<?, ?> cache = cacheManager.getCache(CounterModuleLifecycle.COUNTER_CACHE_NAME).getAdvancedCache();
 return cache.getCacheConfiguration().clustering().cacheMode().isClustered() ?
    cache.getComponentRegistry().getDistributionManager().getCacheTopology() :
    null; //local cache
}
origin: org.infinispan/infinispan-core

private void waitForStateTransfer(int expectedTopologyId, Cache... caches) {
 waitForNoRebalance(caches);
 for (Cache c : caches) {
   CacheTopology cacheTopology = c.getAdvancedCache().getDistributionManager().getCacheTopology();
   assertEquals(String.format("Wrong topology on cache %s, expected %d and got %s", c, expectedTopologyId, cacheTopology),
      expectedTopologyId, cacheTopology.getTopologyId());
 }
}
origin: org.infinispan/infinispan-core

public void testSequence() {
 TriangleOrderManager triangleOrderManager = new TriangleOrderManager(4);
 DistributionManager mockDistributionManager = mock(DistributionManager.class);
 when(mockDistributionManager.getCacheTopology()).thenReturn(mockCacheTopology(0));
 TestingUtil.inject(triangleOrderManager, mockDistributionManager);
 assertEquals(1, triangleOrderManager.next(0, 0));
 assertEquals(1, triangleOrderManager.next(1, 0));
 assertEquals(2, triangleOrderManager.next(1, 0));
}
origin: org.infinispan/infinispan-core

 @Override
 public Object visitGetCacheEntryCommand(InvocationContext ctx, GetCacheEntryCommand command) throws Throwable {
   assertNotNull(stateTransferLock);
   log.tracef("Waiting for topology %d before executing %s", expectedTopologyId, command);
   CompletableFuture<Void> topologyFuture = stateTransferLock.topologyFuture(expectedTopologyId);
   if (topologyFuture != null) {
    topologyFuture.get(10, TimeUnit.SECONDS);
   }
   assertEquals(expectedTopologyId, distributionManager.getCacheTopology().getTopologyId());
   return invokeNext(ctx, command);
 }
}
origin: org.infinispan/infinispan-core

private boolean isPrimaryOwner(VisitableCommand cmd) {
 if (cmd instanceof DataCommand) {
   return cache.getAdvancedCache().getDistributionManager().getCacheTopology()
         .getDistribution(((DataCommand) cmd).getKey()).isPrimary();
 } else {
   return true;
 }
}
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-core

@Test (dependsOnMethods = "testServersDropped")
public void testCollocatedKey() {
 LocalizedCacheTopology cacheTopology =
    manager(0).getCache(cacheName).getAdvancedCache().getDistributionManager().getCacheTopology();
 for (int i = 0; i < 1000; i++) {
   List<Address> addresses = cacheTopology.getDistribution(i).writeOwners();
   Object collocatedKey = keyAffinityService.getCollocatedKey(i);
   List<Address> addressList = cacheTopology.getDistribution(collocatedKey).writeOwners();
   assertEquals(addresses, addressList);
 }
}
org.infinispan.distributionDistributionManagergetCacheTopology

Popular methods of DistributionManager

  • getWriteConsistentHash
  • locate
  • getReadConsistentHash
  • getConsistentHash
  • getPrimaryLocation
  • isRehashInProgress
  • getLocality
  • isJoinComplete
  • isLocal
  • setCacheTopology

Popular in Java

  • Finding current android device location
  • compareTo (BigDecimal)
  • putExtra (Intent)
  • setScale (BigDecimal)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Permission (java.security)
    Legacy security code; do not use.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Top 12 Jupyter Notebook extensions
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