Tabnine Logo
MagicKey.findSegment
Code IndexAdd Tabnine to your IDE (free)

How to use
findSegment
method
in
org.infinispan.distribution.MagicKey

Best Java code snippets using org.infinispan.distribution.MagicKey.findSegment (Showing top 2 results out of 315)

origin: org.infinispan/infinispan-core

public MagicKey(String name, Cache<?, ?> primaryOwner, Cache<?, ?>... backupOwners) {
 this.name = name;
 Address primaryAddress = addressOf(primaryOwner);
 this.address = primaryAddress.toString();
 LocalizedCacheTopology cacheTopology = primaryOwner.getAdvancedCache().getDistributionManager().getCacheTopology();
 ConsistentHash ch = cacheTopology.getWriteConsistentHash();
 segment = findSegment(ch.getNumSegments(), s -> {
   List<Address> owners = ch.locateOwnersForSegment(s);
   if (!primaryAddress.equals(owners.get(0))) return false;
   for (Cache<?, ?> backup : backupOwners) {
    if (!owners.contains(addressOf(backup))) return false;
   }
   return true;
 });
 if (segment < 0) {
   throw new IllegalStateException("Could not find any segment owned by " + primaryOwner + ", "
    + Arrays.toString(backupOwners) + ", primary segments: " + segments(primaryOwner)
    + ", backup segments: " + Stream.of(backupOwners).collect(Collectors.toMap(Function.identity(), this::segments)));
 }
 hashcode = getHashCodeForSegment(cacheTopology, segment);
 unique = counter.getAndIncrement();
}
origin: org.infinispan/infinispan-core

public MagicKey(String name, Cache<?, ?> primaryOwner) {
 this.name = name;
 Address primaryAddress = addressOf(primaryOwner);
 this.address = primaryAddress.toString();
 LocalizedCacheTopology cacheTopology = primaryOwner.getAdvancedCache().getDistributionManager().getCacheTopology();
 ConsistentHash ch = cacheTopology.getWriteConsistentHash();
 int segment = findSegment(ch.getNumSegments(), s -> primaryAddress.equals(ch.locatePrimaryOwnerForSegment(s)));
 if (segment < 0) {
   throw new IllegalStateException("Could not find any segment owned by " + primaryOwner +
    ", primary segments: " + segments(primaryOwner));
 }
 this.segment = segment;
 hashcode = getHashCodeForSegment(cacheTopology, segment);
 unique = counter.getAndIncrement();
}
org.infinispan.distributionMagicKeyfindSegment

Popular methods of MagicKey

  • <init>
  • getHashCodeForSegment
  • segments
  • toString

Popular in Java

  • Finding current android device location
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSharedPreferences (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • Top plugins for WebStorm
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