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

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

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

Refine searchRefine arrow

  • LocalizedCacheTopology.getDistribution
origin: wildfly/wildfly

  @Override
  public boolean isLocal(Object key) {
    return this.topology.getDistribution(key).isPrimary();
  }
}
origin: org.wildfly/wildfly-clustering-infinispan-spi

  @Override
  public boolean isLocal(Object key) {
    return this.topology.getDistribution(key).isPrimary();
  }
}
origin: org.infinispan/infinispan-embedded-query

 @Override
 public boolean accept(Object key, Object value, Metadata metadata) {
   return clusteringDependentLogic.getCacheTopology().getDistribution(key).isPrimary();
 }
}
origin: org.infinispan/infinispan-query

 @Override
 public boolean accept(Object key, Object value, Metadata metadata) {
   return clusteringDependentLogic.getCacheTopology().getDistribution(keyDataConversion.toStorage(key)).isPrimary();
 }
}
origin: org.infinispan/infinispan-query

 @Override
 public boolean shouldModifyIndexes(FlagAffectedCommand command, InvocationContext ctx,
                   DistributionManager distributionManager, RpcManager rpcManager, Object key) {
   if(key == null) {
    return ctx.isOriginLocal();
   }
   return (command == null || !command.hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER)) &&
         (distributionManager == null || distributionManager.getCacheTopology().getDistribution(key).isPrimary());
 }
};
origin: org.infinispan/infinispan-embedded-query

 @Override
 public boolean shouldModifyIndexes(FlagAffectedCommand command, InvocationContext ctx,
                   DistributionManager distributionManager, RpcManager rpcManager, Object key) {
   if(key == null) {
    return ctx.isOriginLocal();
   }
   return !(command.hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER) || command.hasAnyFlag(FlagBitSets.SKIP_INDEXING)) &&
         (distributionManager == null || distributionManager.getCacheTopology().getDistribution(key).isPrimary());
 }
};
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-query

private String getStringKeyForCache(Cache cache) {
 LocalizedCacheTopology topology = cache.getAdvancedCache().getDistributionManager().getCacheTopology();
 return IntStream.generate(ThreadLocalRandom.current()::nextInt).mapToObj(i -> "key" + i)
    .filter(key -> topology.getDistribution(key).isPrimary()).findAny().get();
}
origin: org.infinispan/infinispan-core

private boolean isPrimaryOwner(Cache<?, ?> cache, Object key) {
 return TestingUtil.extractComponent(cache, ClusteringDependentLogic.class).getCacheTopology().getDistribution(key).isPrimary();
}
origin: org.infinispan/infinispan-core

public void testDistributionFromPrimaryOwner() throws Exception {
 Object key = "testDistributionFromPrimaryOwner";
 doTestDistribution(key, cacheManagers.stream()
    .map(cm -> cm.<Object, Integer>getCache(DIST).getAdvancedCache())
    .filter(cache -> cache.getDistributionManager().getCacheTopology().getDistribution(key).isPrimary())
    .findAny()
    .get());
}
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-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.infinispan/infinispan-clustered-counter

private static void assertKeyDistribution(Cache<?, ?> cache, String counterName) {
 WeakCounterImpl counter = getCounter(cache.getCacheManager(), counterName);
 DistributionManager distributionManager = cache.getAdvancedCache().getDistributionManager();
 LocalizedCacheTopology topology = distributionManager.getCacheTopology();
 Set<WeakCounterKey> preferredKeys = new HashSet<>();
 WeakCounterKey[] keys = counter.getPreferredKeys();
 if (keys != null) {
   for (WeakCounterKey key : keys) {
    AssertJUnit.assertTrue(topology.getDistribution(key).isPrimary());
    AssertJUnit.assertTrue(preferredKeys.add(key));
   }
 }
 for (WeakCounterKey key : counter.getKeys()) {
   if (!preferredKeys.remove(key)) {
    AssertJUnit.assertFalse(topology.getDistribution(key).isPrimary());
   }
 }
 AssertJUnit.assertTrue(preferredKeys.isEmpty());
}
origin: org.infinispan/infinispan-core

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

  @Override
  public TestCache create(String groupName, List<Cache<GroupKey, String>> cacheList) {
   Cache<GroupKey, String> primaryOwner = null;
   AdvancedCache<GroupKey, String> nonOwner = null;
   for (Cache<GroupKey, String> cache : cacheList) {
     DistributionManager distributionManager = TestingUtil.extractComponent(cache, DistributionManager.class);
     DistributionInfo distributionInfo = distributionManager.getCacheTopology().getDistribution(groupName);
     if (primaryOwner == null && distributionInfo.isPrimary()) {
      primaryOwner = cache;
     } else if (nonOwner == null && !distributionInfo.isWriteOwner()) {
      nonOwner = cache.getAdvancedCache();
     }
     if (primaryOwner != null && nonOwner != null) {
      return new TestCache(primaryOwner, nonOwner);
     }
   }
   throw new IllegalStateException("didn't find a cache... should never happen!");
  }
};
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-hibernate-cache-commons

DistributionInfo distribution = timestampsRegion.getCache().getDistributionManager().getCacheTopology().getDistribution(Person.class.getSimpleName());
SessionFactory qsf = distribution.isPrimary() ? sf2 : sf1;
origin: org.infinispan/infinispan-embedded-query

CacheEntryEvent<K, V> event = (CacheEntryEvent<K, V>) eventWrapper.getEvent();
if (event.isPre() && isClustered || isPrimaryOnly &&
   !clusteringDependentLogic.getCacheTopology().getDistribution(eventWrapper.getKey()).isPrimary()) {
 return;
origin: org.infinispan/infinispan-query

CacheEntryEvent<K, V> event = (CacheEntryEvent<K, V>) eventWrapper.getEvent();
if (event.isPre() && isClustered || isPrimaryOnly &&
   !clusteringDependentLogic.getCacheTopology().getDistribution(eventWrapper.getKey()).isPrimary()) {
 return;
origin: org.infinispan/infinispan-core

LocalizedCacheTopology cacheTopology = advancedCache(2).getDistributionManager().getCacheTopology();
for (Object key : key2Tx.keySet()) {
  if (cacheTopology.getDistribution(key).isPrimary()) {
   migratedKey = key;
   break;
org.infinispan.distributionDistributionInfoisPrimary

Popular methods of DistributionInfo

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

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getApplicationContext (Context)
  • onCreateOptionsMenu (Activity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • 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