Ignite ignite = startGrid(0); checkHistory(ignite, F.asList(topVer(1, 0)), 1); //fullHistSize = 1 startGrid(1); checkHistory(ignite, F.asList( topVer(1, 0), // FullHistSize = 1. topVer(2, 0), // FullHistSize = 2. topVer(2, 1)), // FullHistSize = 3. 3); startGrid(2); checkHistory(ignite, F.asList( topVer(1, 0), // FullHistSize = 1. topVer(2, 0), // FullHistSize = 2. topVer(2, 1), // FullHistSize = 3. topVer(3, 0), // FullHistSize = 4. topVer(3, 1)), // FullHistSize = 5. 5); startGrid(3); checkHistory(ignite, F.asList( topVer(2, 1), // FullHistSize = 3. topVer(3, 0), // FullHistSize = 4. topVer(3, 1), // FullHistSize = 5. topVer(4, 0), // FullHistSize = (6 - IGNITE_AFFINITY_HISTORY_SIZE(5)/2) = 4.
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stopAllGrids(); super.afterTest(); }
/** * @param ignite Node. * @param expHist Expected history. * @param expSize Expected 'non client events' history size. * @throws Exception If failed. */ private void checkHistory(Ignite ignite, List<AffinityTopologyVersion> expHist, int expSize) throws Exception { awaitPartitionMapExchange(); GridCacheProcessor proc = ((IgniteKernal)ignite).context().cache(); int cnt = 0; for (GridCacheContext cctx : proc.context().cacheContexts()) { GridAffinityAssignmentCache aff = GridTestUtils.getFieldValue(cctx.affinity(), "aff"); AtomicInteger fullHistSize = GridTestUtils.getFieldValue(aff, "fullHistSize"); assertEquals(expSize, fullHistSize.get()); Map<AffinityTopologyVersion, Object> cache = GridTestUtils.getFieldValue(aff, "affCache"); assertEquals("Unexpected history: " + cache.keySet(), expHist.size(), cache.size()); for (AffinityTopologyVersion topVer : expHist) assertTrue("No history [ver=" + topVer + ", hist=" + cache.keySet() + ']', cache.containsKey(topVer)); cnt++; } assert cnt > 4; }