http://git-wip-us.apache.org/repos/asf/ignite/blob/08404350/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java index 957f93b,e373f4c..5e84b3e --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java @@@ -276,8 -178,8 +190,8 @@@ public class GridDhtPreloader extends G assert exchFut.forcePreload() || exchFut.dummyReassign() || exchFut.exchangeId().topologyVersion().equals(top.topologyVersion()) : "Topology version mismatch [exchId=" + exchFut.exchangeId() + - ", cache=" + cctx.name() + - ", grp=" + grp.name() + - ", topVer=" + top.topologyVersion() + ']'; ++ ", grp=" + grp.name() + + ", topVer=" + top.topologyVersion() + ']'; GridDhtPreloaderAssignments assigns = new GridDhtPreloaderAssignments(exchFut, top.topologyVersion()); @@@ -295,96 -199,50 +211,96 @@@ } // If partition belongs to local node. - if (cctx.affinity().partitionLocalNode(p, topVer)) { + if (aff.get(p).contains(ctx.localNode())) { - GridDhtLocalPartition part = top.localPartition(p, topVer, true); + GridDhtLocalPartition part = top.localPartition(p, topVer, true, true); assert part != null; assert part.id() == p; - if (part.state() != MOVING) { - if (log.isDebugEnabled()) - log.debug("Skipping partition assignment (state is not MOVING): " + part); + ClusterNode histSupplier = null; + + if (cctx.shared().database().persistenceEnabled()) { + UUID nodeId = exchFut.partitionHistorySupplier(cctx.cacheId(), p); - continue; // For. + if (nodeId != null) + histSupplier = cctx.discovery().node(nodeId); } - Collection<ClusterNode> picked = pickedOwners(p, topVer); + if (histSupplier != null) { + if (part.state() != MOVING) { + if (log.isDebugEnabled()) + log.debug("Skipping partition assignment (state is not MOVING): " + part); + + continue; // For. + } - if (picked.isEmpty()) { - top.own(part); + assert cctx.shared().database().persistenceEnabled(); + assert remoteOwners(p, topVer).contains(histSupplier) : remoteOwners(p, topVer); - if (grp.eventRecordable(EVT_CACHE_REBALANCE_PART_DATA_LOST)) { - DiscoveryEvent discoEvt = exchFut.discoveryEvent(); + GridDhtPartitionDemandMessage msg = assigns.get(histSupplier); - grp.addRebalanceEvent(p, - EVT_CACHE_REBALANCE_PART_DATA_LOST, - discoEvt.eventNode(), - discoEvt.type(), - discoEvt.timestamp()); + if (msg == null) { + assigns.put(histSupplier, msg = new GridDhtPartitionDemandMessage( + top.updateSequence(), + exchFut.exchangeId().topologyVersion(), + cctx.cacheId())); } - if (log.isDebugEnabled()) - log.debug("Owning partition as there are no other owners: " + part); + msg.addPartition(p, true); } else { - ClusterNode n = F.rand(picked); + if (cctx.shared().database().persistenceEnabled()) { + if (part.state() == RENTING || part.state() == EVICTED) { + try { + part.rent(false).get(); + } + catch (IgniteCheckedException e) { + U.error(log, "Error while clearing outdated local partition", e); + } + + part = top.localPartition(p, topVer, true); + + assert part != null; + } + } - GridDhtPartitionDemandMessage msg = assigns.get(n); + if (part.state() != MOVING) { + if (log.isDebugEnabled()) + log.debug("Skipping partition assignment (state is not MOVING): " + part); + + continue; // For. + } + + Collection<ClusterNode> picked = pickedOwners(p, topVer); + + if (picked.isEmpty()) { + top.own(part); + - if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_PART_DATA_LOST)) { ++ if (grp.eventRecordable(EVT_CACHE_REBALANCE_PART_DATA_LOST)) { + DiscoveryEvent discoEvt = exchFut.discoveryEvent(); + - cctx.events().addPreloadEvent(p, - EVT_CACHE_REBALANCE_PART_DATA_LOST, discoEvt.eventNode(), - discoEvt.type(), discoEvt.timestamp()); - } ++ grp.addRebalanceEvent(p, ++ EVT_CACHE_REBALANCE_PART_DATA_LOST, discoEvt.eventNode(), ++ discoEvt.type(), discoEvt.timestamp()); ++ } + + if (log.isDebugEnabled()) + log.debug("Owning partition as there are no other owners: " + part); + } + else { + ClusterNode n = F.rand(picked); + + GridDhtPartitionDemandMessage msg = assigns.get(n); - if (msg == null) { - assigns.put(n, msg = new GridDhtPartitionDemandMessage( - top.updateSequence(), - exchFut.exchangeId().topologyVersion(), - cctx.cacheId())); - } + if (msg == null) { + assigns.put(n, msg = new GridDhtPartitionDemandMessage( + top.updateSequence(), + exchFut.exchangeId().topologyVersion(), + grp.groupId())); + } - msg.addPartition(p); + msg.addPartition(p, false); + } } } }
http://git-wip-us.apache.org/repos/asf/ignite/blob/08404350/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/08404350/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/08404350/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/08404350/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java ---------------------------------------------------------------------- diff --cc modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java index 4bd2372,306e298..625fb7d mode 100755,100644..100755 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
