congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
MagicKey.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.infinispan.distribution.MagicKey
constructor

Best Java code snippets using org.infinispan.distribution.MagicKey.<init> (Showing top 20 results out of 315)

origin: org.infinispan/infinispan-core

  private void populateKeys(Cache primaryOwner) {
   for (int i = 0; i < keys.length; ++i) {
     keys[i] = new MagicKey("k" + i, primaryOwner);
   }
  }
}
origin: org.infinispan/infinispan-core

protected MagicKey getKeyForCache(Cache<?, ?> primary, Cache<?, ?>... backup) {
 if (cacheMode == null || !cacheMode.isScattered()) {
   return new MagicKey(primary, backup);
 } else {
   return new MagicKey(primary);
 }
}
origin: org.infinispan/infinispan-core

protected List<MagicKey> init() {
 List<MagicKey> keys = new ArrayList<>();
 int numCaches = caches(CACHE_NAME).size();
 ThreadLocalRandom random = ThreadLocalRandom.current();
 for (int i = 0; i < 100; ++i) {
   MagicKey key = new MagicKey("key" + i, cache(i % numCaches, CACHE_NAME));
   cache(random.nextInt(numCaches), CACHE_NAME).put(key, "value" + i);
   keys.add(key);
 }
 return keys;
}
origin: org.infinispan/infinispan-core

  public void testGetOfNonexistentKeyOnOwner() {
   MagicKey mk = new MagicKey("does not exist", cache(0));
   Object v = cache(0).get(mk);
   assert v == null : "Should get a null response";
  }
}
origin: org.infinispan/infinispan-core

@Test
public void testMetadataConverterSuccessNotOwner() {
 long lifespan = 25000;
 LifespanConverter converter = new LifespanConverter(true, 500);
 testConverter(new MagicKey(cache(1, CACHE_NAME), cache(2, CACHE_NAME)), FIRST_VALUE, lifespan, lifespan, converter);
}
origin: org.infinispan/infinispan-core

@Test
public void testMetadataConverterNoPassReturnOriginalNotOwner() {
 long lifespan = 25000;
 LifespanConverter converter = new LifespanConverter(true, Long.MAX_VALUE);
 testConverter(new MagicKey(cache(1, CACHE_NAME), cache(2, CACHE_NAME)), FIRST_VALUE, FIRST_VALUE, lifespan, converter);
}
origin: org.infinispan/infinispan-core

@Test
public void testMetadataFilterLocalOnly() {
 final String keyToFilterOut = "filter-me";
 testFilter(keyToFilterOut, new MagicKey(cache(0, CACHE_NAME)), 1000l,
     new KeyValueFilterAsCacheEventFilter(new LifespanFilter<Object, String>(100)));
}
origin: org.infinispan/infinispan-core

public void testAtomicMapAfterFineGrainedAtomicMapPrimary() throws Exception {
 Cache<MagicKey, Object> cache1 = cache(0, "atomic");
 MagicKey key = new MagicKey(cache1);
 getFineGrainedAtomicMap(cache1, key);
 expectException(IllegalStateException.class, () -> getAtomicMap(cache1, key));
}
origin: org.infinispan/infinispan-core

@Test
public void testLocalNodeNonOwnerAndClusterListener() {
 Cache<Object, String> cache0 = cache(0, CACHE_NAME);
 Cache<Object, String> cache1 = cache(1, CACHE_NAME);
 Cache<Object, String> cache2 = cache(2, CACHE_NAME);
 ClusterListener clusterListener = listener();
 cache0.addListener(clusterListener);
 MagicKey key = new MagicKey(cache1, cache2);
 verifySimpleInsertion(cache0, key, FIRST_VALUE, null, clusterListener, FIRST_VALUE);
}
origin: org.infinispan/infinispan-core

@Test
public void testMetadataFilterNotOwner() {
 final String keyToFilterOut = "filter-me";
 testFilter(keyToFilterOut, new MagicKey(cache(1, CACHE_NAME), cache(2, CACHE_NAME)), 1000l,
     new KeyValueFilterAsCacheEventFilter(new LifespanFilter<Object, String>(100)));
}
origin: org.infinispan/infinispan-core

@Test
public void testCreateFromNonOwnerWithListenerNotOwner() {
 Cache<Object, String> cache0 = cache(0, CACHE_NAME);
 Cache<Object, String> cache1 = cache(1, CACHE_NAME);
 Cache<Object, String> cache2 = cache(2, CACHE_NAME);
 ClusterListener clusterListener = listener();
 cache0.addListener(clusterListener);
 MagicKey key = new MagicKey(cache1, cache2);
 verifySimpleInsertion(cache2, key, FIRST_VALUE, null, clusterListener, FIRST_VALUE);
}
origin: org.infinispan/infinispan-core

public void testConditionalReplace() {
 final MagicKey KEY = new MagicKey(cache(0));
 cache(0).put(KEY, VALUE1);
 assertTrue(cache(0).replace(KEY, VALUE1, VALUE2));
 assertFalse(cache(0).replace(KEY, VALUE1, VALUE3));
 assertTrue(cache(1).replace(KEY, VALUE2, VALUE3));
 assertFalse(cache(1).replace(KEY, VALUE2, VALUE1));
 assertTrue(cache(2).replace(KEY, VALUE3, VALUE1));
 assertFalse(cache(2).replace(KEY, VALUE3, VALUE2));
}
origin: org.infinispan/infinispan-core

@Test
public void testCacheEventFilterConverter() {
 Cache<Object, String> cache0 = cache(0, CACHE_NAME);
 Cache<Object, String> cache1 = cache(0, CACHE_NAME);
 Cache<Object, String> cache2 = cache(0, CACHE_NAME);
 String convertedValue = "my-value";
 FilterConverter filterConverter = new FilterConverter(true, convertedValue);
 ClusterListener clusterListener = listener();
 cache0.addListener(clusterListener, filterConverter, filterConverter);
 MagicKey key = new MagicKey(cache1, cache2);
 verifySimpleInsertion(cache0, key, "doesn't-matter", null, clusterListener, convertedValue);
}
origin: org.infinispan/infinispan-core

public void testCacheLocalInBackupOwner() {
 final AdvancedCache<Object, String> cache1 = advancedCache(0, cacheName);
 final AdvancedCache<Object, String> cache2 = advancedCache(1, cacheName);
 final Object key = new MagicKey("k-bo", cache1);
 cache2.withFlags(CACHE_MODE_LOCAL).put(key, "value");
 assertCacheValue(cache2, key, "value");
 assertCacheValue(cache1, key, null);
}
origin: org.infinispan/infinispan-core

public void testGetEntry() throws Exception {
 Cache<MagicKey, String> cache = cache(0);
 MagicKey localKey = new MagicKey(cache(0));
 MagicKey remoteKey = new MagicKey(cache(1));
 cache.put(localKey, localKey.toString());
 cache.put(remoteKey, remoteKey.toString());
 assertNotNull(cache.getAdvancedCache().getCacheEntry(localKey));
 assertNotNull(cache.getAdvancedCache().getCacheEntry(remoteKey));
}
origin: org.infinispan/infinispan-core

@Override
protected void createCacheManagers() throws Throwable {
 ConfigurationBuilder cfg = createConfig();
 cm1 = TestCacheManagerFactory.createClusteredCacheManager(cfg);
 cm2 = TestCacheManagerFactory.createClusteredCacheManager(cfg);
 registerCacheManager(cm1, cm2);
 cm1.getCache();
 waitForClusterToForm();
 key = new MagicKey("Key mapped to Cache2", cm2.getCache());
}
origin: org.infinispan/infinispan-core

public void testRetrievalWhenPartitionIsDegradedButLocal() {
 Cache<MagicKey, String> cache0 = cache(0);
 cache0.put(new MagicKey(cache(1), cache(2)), "not-local");
 cache0.put(new MagicKey(cache(0), cache(1)), "local");
 splitCluster(new int[]{0, 1}, new int[]{2, 3});
 partition(0).assertDegradedMode();
 try (CloseableIterator<Map.Entry<MagicKey, String>> iterator = Closeables.iterator(cache0.getAdvancedCache()
     .withFlags(Flag.CACHE_MODE_LOCAL).entrySet().stream())) {
   assertEquals("local", iterator.next().getValue());
   assertFalse(iterator.hasNext());
 }
}
origin: org.infinispan/infinispan-core

@Override
protected void createCacheManagers() throws Throwable {
 final ConfigurationBuilder c = getDefaultClusteredCacheConfig(mode, true);
 c.transaction().lockingMode(LockingMode.PESSIMISTIC);
 createCluster(c, 2);
 waitForClusterToForm();
 controlInterceptor = new ControlInterceptor();
 cache(0).getAdvancedCache().addInterceptor(controlInterceptor, 1);
 key = new MagicKey("k", cache(0));
}
origin: org.infinispan/infinispan-core

@Override
protected void beforeSplit() {
 // Put values locally before the split as an AvaililibityException will be thrown during the split
 conflictKey = new MagicKey(cache(p0.node(0)), cache(p1.node(0)));
 cache(p0.node(0)).put(conflictKey, "V1");
 cache(p1.node(0)).getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL).put(conflictKey, "V2");
}
origin: org.infinispan/infinispan-core

public void testPutOnNonOwner() {  //todo [anistor] this does not test putAll !
 MagicKey mk = new MagicKey("key", cache(0));
 cache(3).getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP).put(mk, "value");
 assert cache(0).getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP).get(mk) != null;
 assert cache(1).getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP).get(mk) == null;
 assert cache(2).getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP).get(mk) == null;
 assert cache(3).getAdvancedCache().withFlags(Flag.SKIP_REMOTE_LOOKUP).get(mk) == null;
}
org.infinispan.distributionMagicKey<init>

Popular methods of MagicKey

  • findSegment
  • getHashCodeForSegment
  • segments
  • toString

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Path (java.nio.file)
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Join (org.hibernate.mapping)
  • Option (scala)
  • Top PhpStorm plugins
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