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

How to use
getSegment
method
in
org.infinispan.distribution.LocalizedCacheTopology

Best Java code snippets using org.infinispan.distribution.LocalizedCacheTopology.getSegment (Showing top 11 results out of 315)

origin: org.infinispan/infinispan-embedded-query

private int getSegment(Object key) {
 DistributionManager distributionManager = this.getDistributionManager();
 if (distributionManager == null) {
   return 0;
 }
 return distributionManager.getCacheTopology().getSegment(key);
}
origin: org.infinispan/infinispan-query

private int getSegment(Object key) {
 DistributionManager distributionManager = this.getDistributionManager();
 if (distributionManager == null) {
   return 0;
 }
 return distributionManager.getCacheTopology().getSegment(key);
}
origin: org.infinispan/infinispan-core

@Override
protected void assertOwnershipAndNonOwnership(Object key, boolean allowL1) {
 if (lostSegments.contains(getCacheTopology(c1).getSegment(key)))
   return;
 super.assertOwnershipAndNonOwnership(key, allowL1);
}
origin: org.infinispan/infinispan-core

@Override
protected void assertOnAllCaches(Object key, String value) {
 if (lostSegments.contains(getCacheTopology(c1).getSegment(key)))
 return;
 super.assertOnAllCaches(key, value);
}
origin: org.infinispan/infinispan-query

@Override
public String getShardFromKey(Object key) {
 int segment = distributionManager.getCacheTopology().getSegment(key);
 logger.debugf("Segment for key %s: %d", key, segment);
 return this.getShardDistribution().getShardFromSegment(segment);
}
origin: org.infinispan/infinispan-embedded-query

@Override
public String getShardFromKey(Object key) {
 int segment = distributionManager.getCacheTopology().getSegment(key);
 logger.debugf("Segment for key %s: %d", key, segment);
 return this.getShardDistribution().getShardFromSegment(segment);
}
origin: org.infinispan/infinispan-core

private static synchronized int getHashCodeForSegment(LocalizedCacheTopology cacheTopology, int segment) {
 int numSegments = cacheTopology.getReadConsistentHash().getNumSegments();
 // Caching the hash codes prevents random failures in tests where we create many magic keys
 int[] hcs = hashCodes.computeIfAbsent(numSegments, k -> new int[numSegments]);
 int hc = hcs[segment];
 if (hc != 0) {
   return hc;
 }
 Random r = new Random();
 int attemptsLeft = 100 * numSegments;
 int dummy;
 do {
   dummy = r.nextInt();
   attemptsLeft--;
   if (attemptsLeft < 0) {
    throw new IllegalStateException("Could not find any key in segment " + segment);
   }
 } while (cacheTopology.getSegment(dummy) != segment);
 return hcs[segment] = dummy;
}
origin: org.infinispan/infinispan-core

private String findKeyBasedOnOwnership(String keyPrefix, LocalizedCacheTopology cacheTopology, boolean shouldBePrimaryOwner) {
 for (int i = 0; i < 1000; i++) {
   String key = keyPrefix + i;
   boolean isPrimaryOwner = cacheTopology.getDistribution(key).isPrimary();
   if (isPrimaryOwner == shouldBePrimaryOwner) {
    if (shouldBePrimaryOwner) {
      log.debugf("Found key %s with primary owner %s, segment %d", key, cacheTopology.getLocalAddress(),
           cacheTopology.getSegment(key));
    } else {
      log.debugf("Found key %s with primary owner != %s, segment %d", key, cacheTopology.getLocalAddress(),
           cacheTopology.getSegment(key));
    }
    return key;
   }
 }
 throw new RuntimeException("No key could be found for owner, this may be a bug in test or really bad luck!");
}
origin: org.infinispan/infinispan-core

@Test
public void testAffinityPartitioner() throws Exception {
 Cache<AffinityKey, String> cache = cacheManagers.get(0).getCache();
 IntStream.range(0, 10).boxed().forEach(num -> cache.put(new AffinityKey(num), "value"));
 addClusterEnabledCacheManager(getConfigurationBuilder());
 waitForClusterToForm();
 cacheManagers.stream().map(cm -> cm.getCache().getAdvancedCache()).forEach(advancedCache -> {
   LocalizedCacheTopology cacheTopology = advancedCache.getDistributionManager().getCacheTopology();
   advancedCache.getDataContainer().keySet().forEach(key -> {
    int keySegmentId = ((AffinityKey) key).segmentId;
    assertEquals(cacheTopology.getSegment(key), keySegmentId);
   });
 });
}
origin: org.infinispan/infinispan-core

      key, cacheTopology.getSegment(key), owners, cacheTopology);
throw th;
origin: org.infinispan/infinispan-core

int segmentToUse = cache.getAdvancedCache().getDistributionManager().getCacheTopology().getSegment(keyToChange);
org.infinispan.distributionLocalizedCacheTopologygetSegment

Popular methods of LocalizedCacheTopology

  • getDistribution
  • getTopologyId
  • <init>
  • getActualMembers
  • getCurrentCH
  • getMembers
  • getPhase
  • isReadOwner
  • isWriteOwner
  • getLocalAddress
  • getMembersPersistentUUIDs
  • getPendingCH
  • getMembersPersistentUUIDs,
  • getPendingCH,
  • getReadConsistentHash,
  • getRebalanceId,
  • getUnionCH,
  • getWriteConsistentHash,
  • getWriteOwners

Popular in Java

  • Making http requests using okhttp
  • compareTo (BigDecimal)
  • getSystemService (Context)
  • requestLocationUpdates (LocationManager)
  • Menu (java.awt)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • 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