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

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

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

origin: org.infinispan/infinispan-core

private void testBeforeTopology(BiFunction<FunctionalMap.ReadWriteMap<String, Integer>, String, Integer> op, int expectedIncrement) throws Exception {
 cache(0).put("key", 1);
 // Blocking on receiver side. We cannot block the StateResponseCommand on the server side since
 // the InternalCacheEntries in its state are the same instances of data stored in DataContainer
 // - therefore when the command is blocked on sender the command itself would be mutated by applying
 // the transaction below.
 BlockingStateConsumer bsc2 = TestingUtil.wrapComponent(cache(2), StateConsumer.class, BlockingStateConsumer::new);
 tm(2).begin();
 FunctionalMap.ReadWriteMap<String, Integer> rw = ReadWriteMapImpl.create(
    FunctionalMapImpl.create(this.<String, Integer>cache(2).getAdvancedCache()));
 assertEquals(new Integer(1), op.apply(rw, "key"));
 Transaction tx = tm(2).suspend();
 chf.setOwnerIndexes(0, 2);
 Future<?> future = fork(() -> {
   TestResourceTracker.testThreadStarted(this);
   addClusterEnabledCacheManager(cb).getCache();
 });
 bsc2.await();
 DistributionInfo distributionInfo = cache(2).getAdvancedCache().getDistributionManager().getCacheTopology().getDistribution("key");
 assertFalse(distributionInfo.isReadOwner());
 assertTrue(distributionInfo.isWriteBackup());
 tm(2).resume(tx);
 tm(2).commit();
 bsc2.unblock();
 future.get(10, TimeUnit.SECONDS);
 InternalCacheEntry<Object, Object> ice = cache(2).getAdvancedCache().getDataContainer().get("key");
 assertEquals("Current ICE: " + ice, 1 + expectedIncrement, ice.getValue());
}
origin: org.infinispan/infinispan-core

private void testAfterTopology(BiFunction<FunctionalMap.ReadWriteMap<String, Integer>, String, Integer> op, int expectedIncrement) throws Exception {
 cache(0).put("key", 1);
 // Blocking on receiver side. We cannot block the StateResponseCommand on the server side since
 // the InternalCacheEntries in its state are the same instances of data stored in DataContainer
 // - therefore when the command is blocked on sender the command itself would be mutated by applying
 // the transaction below.
 BlockingStateConsumer bsc2 = TestingUtil.wrapComponent(cache(2), StateConsumer.class, BlockingStateConsumer::new);
 chf.setOwnerIndexes(0, 2);
 Future<?> future = fork(() -> {
   TestResourceTracker.testThreadStarted(this);
   addClusterEnabledCacheManager(cb).getCache();
 });
 bsc2.await();
 DistributionInfo distributionInfo = cache(2).getAdvancedCache().getDistributionManager().getCacheTopology().getDistribution("key");
 assertFalse(distributionInfo.isReadOwner());
 assertTrue(distributionInfo.isWriteBackup());
 withTx(tm(2), () -> {
   FunctionalMap.ReadWriteMap<String, Integer> rw = ReadWriteMapImpl.create(
      FunctionalMapImpl.create(this.<String, Integer>cache(2).getAdvancedCache()));
   assertEquals(new Integer(1), op.apply(rw, "key"));
   return null;
 });
 bsc2.unblock();
 future.get(10, TimeUnit.SECONDS);
 InternalCacheEntry<Object, Object> ice = cache(2).getAdvancedCache().getDataContainer().get("key");
 assertEquals("Current ICE: " + ice, 1 + expectedIncrement, ice.getValue());
}
origin: org.infinispan/infinispan-core

private void doTest(Operation operation, boolean init) throws Exception {
 final MagicKey key = new MagicKey(cache(1), cache(2));
 if (init) {
   cache(0).put(key, "v1");
   assertInAllCache(key, "v1");
 }
 BlockingLocalTopologyManager bltm0 = replaceTopologyManagerDefaultCache(manager(0));
 BlockingLocalTopologyManager bltm1 = replaceTopologyManagerDefaultCache(manager(1));
 killMember(2, null, false);
 //CH_UPDATE + REBALANCE_START + CH_UPDATE(blocked)
 bltm0.expectRebalanceStartAfterLeave().unblock();
 bltm1.expectRebalanceStartAfterLeave().unblock();
 bltm0.expectPhaseConfirmation().unblock();
 bltm1.expectPhaseConfirmation().unblock();
 //check if we are in the correct state
 LocalizedCacheTopology cacheTopology = TestingUtil.extractComponent(cache(0), DistributionManager.class).getCacheTopology();
 DistributionInfo distributionInfo = cacheTopology.getDistribution(key);
 assertFalse(distributionInfo.isReadOwner());
 assertTrue(distributionInfo.isWriteOwner());
 assertEquals(address(1), distributionInfo.primary());
 operation.put(key, "v2", cache(1));
 BlockingLocalTopologyManager.finishRebalance(CacheTopology.Phase.READ_ALL_WRITE_ALL, bltm0, bltm1);
 waitForClusterToForm(); //let the cluster finish the state transfer
 assertInAllCache(key, "v2");
}
org.infinispan.distributionDistributionInfoisReadOwner

Popular methods of DistributionInfo

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

Popular in Java

  • Reading from database using SQL prepared statement
  • findViewById (Activity)
  • addToBackStack (FragmentTransaction)
  • setScale (BigDecimal)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Kernel (java.awt.image)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Best IntelliJ 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