ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: 5578
Date Tue, 25 Jul 2017 15:24:35 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-5578 84562b86e -> 39f668e14


5578


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/39f668e1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/39f668e1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/39f668e1

Branch: refs/heads/ignite-5578
Commit: 39f668e1413c4d36376d3387cd9a3fd4016936d1
Parents: 84562b8
Author: sboikov <sboikov@gridgain.com>
Authored: Tue Jul 25 18:24:28 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Tue Jul 25 18:24:28 2017 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/TestDebugLog.java    | 219 +++++++++++++++++++
 .../processors/cache/GridCacheContext.java      |   5 +
 .../processors/cache/GridCacheMapEntry.java     |   8 +
 .../GridCachePartitionExchangeManager.java      |   3 +
 .../distributed/dht/GridDhtCacheEntry.java      |   3 +
 .../dht/GridDhtPartitionTopologyImpl.java       |  11 +
 .../GridDhtAtomicAbstractUpdateFuture.java      |   4 +
 .../GridNearAtomicSingleUpdateFuture.java       |   5 +-
 .../dht/preloader/GridDhtPartitionDemander.java |   3 +
 .../GridDhtPartitionsExchangeFuture.java        |  21 +-
 .../dht/preloader/GridDhtPreloader.java         |   3 +
 .../distributed/CacheExchangeMergeTest.java     |  50 +++--
 12 files changed, 311 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/39f668e1/modules/core/src/main/java/org/apache/ignite/TestDebugLog.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/TestDebugLog.java b/modules/core/src/main/java/org/apache/ignite/TestDebugLog.java
new file mode 100644
index 0000000..94c5eb2
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/TestDebugLog.java
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+/**
+ * TODO
+ */
+public class TestDebugLog {
+    /** */
+    private static final List<Object> msgs = Collections.synchronizedList(new ArrayList<>(100_000));
+
+    /** */
+    private static final SimpleDateFormat DEBUG_DATE_FMT = new SimpleDateFormat("HH:mm:ss,SSS");
+
+    static class Message {
+        String thread = Thread.currentThread().getName();
+
+        String msg;
+
+        long ts = U.currentTimeMillis();
+
+        public Message(String msg) {
+            this.msg = msg;
+        }
+
+        public String toString() {
+            return "Msg [msg=" + msg + ", thread=" + thread + ", time=" + DEBUG_DATE_FMT.format(new
Date(ts)) + ']';
+        }
+    }
+
+    static class EntryMessage extends Message {
+        Object key;
+        Object val;
+
+        public EntryMessage(Object key, Object val, String msg) {
+            super(msg);
+
+            this.key = key;
+            this.val = val;
+        }
+
+        public String toString() {
+            return "EntryMsg [key=" + key + ", val=" + val + ", msg=" + msg + ", thread="
+ thread + ", time=" + DEBUG_DATE_FMT.format(new Date(ts)) + ']';
+        }
+    }
+
+    static class PartMessage extends Message {
+        int p;
+        Object val;
+
+        public PartMessage(int p, Object val, String msg) {
+            super(msg);
+
+            this.p = p;
+            this.val = val;
+        }
+
+        public String toString() {
+            return "PartMessage [p=" + p + ", val=" + val + ", msg=" + msg + ", thread="
+ thread + ", time=" + DEBUG_DATE_FMT.format(new Date(ts)) + ']';
+        }
+    }
+
+    static final boolean out = false;
+
+    public static void addMessage(String msg) {
+        msgs.add(new Message(msg));
+
+        if (out)
+            System.out.println(msg);
+    }
+
+    public static void addEntryMessage(Object key, Object val, String msg) {
+        if (key instanceof KeyCacheObject)
+            key = ((KeyCacheObject)key).value(null, false);
+
+        EntryMessage msg0 = new EntryMessage(key, val, msg);
+
+        msgs.add(msg0);
+
+        if (out) {
+            System.out.println(msg0.toString());
+
+            System.out.flush();
+        }
+    }
+
+    public static void addPartMessage(int p, Object val, String msg) {
+        PartMessage msg0 = new PartMessage(p, val, msg);
+
+        msgs.add(msg0);
+
+        if (out) {
+            System.out.println(msg0.toString());
+
+            System.out.flush();
+        }
+    }
+
+    public static void printMessages(boolean file, Integer part) {
+        List<Object> msgs0;
+
+        synchronized (msgs) {
+            msgs0 = new ArrayList<>(msgs);
+
+            msgs.clear();
+        }
+
+        if (file) {
+            try {
+                FileOutputStream out = new FileOutputStream("test_debug.log");
+
+                PrintWriter w = new PrintWriter(out);
+
+                for (Object msg : msgs0) {
+                    if (part != null && msg instanceof PartMessage) {
+                        if (((PartMessage) msg).p != part)
+                            continue;
+                    }
+
+                    w.println(msg.toString());
+                }
+
+                w.close();
+
+                out.close();
+            }
+            catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        else {
+            for (Object msg : msgs0)
+                System.out.println(msg);
+        }
+    }
+
+    public static void printKeyMessages(boolean file, Object key) {
+        List<Object> msgs0;
+
+        synchronized (msgs) {
+            msgs0 = new ArrayList<>(msgs);
+
+            msgs.clear();
+        }
+
+        if (file) {
+            try {
+                FileOutputStream out = new FileOutputStream("test_debug.log");
+
+                PrintWriter w = new PrintWriter(out);
+
+                for (Object msg : msgs0) {
+                    if (msg instanceof EntryMessage && !((EntryMessage)msg).key.equals(key))
+                        continue;
+
+                    w.println(msg.toString());
+                }
+
+                w.close();
+
+                out.close();
+            }
+            catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        else {
+            for (Object msg : msgs0) {
+                if (msg instanceof EntryMessage && !((EntryMessage)msg).key.equals(key))
+                    continue;
+
+                System.out.println(msg);
+            }
+        }
+    }
+
+    public static void clear() {
+        msgs.clear();
+    }
+
+    public static void clearEntries() {
+        for (Iterator it = msgs.iterator(); it.hasNext();) {
+            Object msg = it.next();
+
+            if (msg instanceof EntryMessage)
+                it.remove();
+        }
+    }
+
+    public static void main(String[] args) {
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/39f668e1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 33db2ff..31fda7a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -39,6 +39,7 @@ import javax.cache.expiry.ExpiryPolicy;
 import javax.cache.processor.EntryProcessorResult;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.TestDebugLog;
 import org.apache.ignite.binary.BinaryField;
 import org.apache.ignite.binary.BinaryObjectBuilder;
 import org.apache.ignite.cache.CacheInterceptor;
@@ -2043,6 +2044,10 @@ public class GridCacheContext<K, V> implements Externalizable
{
 
         GridDhtPartitionTopology top = topology();
 
+        TestDebugLog.addEntryMessage(part, top.rebalanceFinished(topVer), "hasPartition "
+ topVer);
+        TestDebugLog.addEntryMessage(part, top.partitionState(localNodeId(), part), "partState");
+        TestDebugLog.addEntryMessage(part, affNodes.contains(locNode), "affNode");
+
         return (top.rebalanceFinished(topVer) && (isReplicated() || affNodes.contains(locNode)))
             || (top.partitionState(localNodeId(), part) == OWNING);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/39f668e1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index edfa950..64c99bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -32,6 +32,7 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.TestDebugLog;
 import org.apache.ignite.cache.eviction.EvictableEntry;
 import org.apache.ignite.internal.pagemem.wal.StorageException;
 import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
@@ -1631,6 +1632,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter
impleme
     ) throws IgniteCheckedException, GridCacheEntryRemovedException, GridClosureException
{
         assert cctx.atomic() && !detached();
 
+        TestDebugLog.addEntryMessage(key.value(null, false), primary, "innerUpdate");
+
         AtomicCacheUpdateClosure c;
 
         if (!primary && !isNear())
@@ -2523,6 +2526,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter
impleme
     ) throws IgniteCheckedException, GridCacheEntryRemovedException {
         ensureFreeSpace();
 
+        TestDebugLog.addEntryMessage(key.value(null, false), val, "initialValue");
+
         synchronized (this) {
             checkObsolete();
 
@@ -3358,6 +3363,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter
impleme
                         return false;
 
                     if (!hasReaders() && markObsolete0(obsoleteVer, false, null))
{
+                        if (evictOffheap)
+                            TestDebugLog.addEntryMessage(key.value(null, false), val, "evictInternal");
+
                         // Nullify value after swap.
                         value(null);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/39f668e1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 35927dc..bf6c147 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -1807,6 +1807,9 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
      * @return {@code False} if need wait messages for merged exchanges.
      */
     public boolean mergeExchangesOnCoordinator(GridDhtPartitionsExchangeFuture curFut) {
+        if (true)
+            return true;
+
         AffinityTopologyVersion exchMergeTestWaitVer = this.exchMergeTestWaitVer;
 
         if (exchMergeTestWaitVer != null) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/39f668e1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
index 77cc642..82e08f7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.UUID;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.TestDebugLog;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -584,6 +585,8 @@ public class GridDhtCacheEntry extends GridDistributedCacheEntry {
                         ", entry=" + System.identityHashCode(this) +
                         ']');
                 }
+                
+                TestDebugLog.addEntryMessage(key.value(null, false), val, "clearInternal");
 
                 removeValue();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/39f668e1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 9da0594..d82d091 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -32,6 +32,7 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.TestDebugLog;
 import org.apache.ignite.cache.PartitionLossPolicy;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.events.DiscoveryEvent;
@@ -333,6 +334,8 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology
{
                         if (localNode(p, aff)) {
                             GridDhtLocalPartition locPart = createPartition(p);
 
+                            TestDebugLog.addPartMessage(locPart.id(), "first", "owned");
+
                             boolean owned = locPart.own();
 
                             assert owned : "Failed to own partition for oldest node [grp="
+ grp.cacheOrGroupName() +
@@ -581,6 +584,8 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology
{
 
                             // If there are no other owners, then become an owner.
                             if (F.isEmpty(owners)) {
+                                TestDebugLog.addPartMessage(locPart.id(), "no owners", "owned");
+
                                 boolean owned = locPart.own();
 
                                 assert owned : "Failed to own partition [grp=" + grp.cacheOrGroupName()
+ ", locPart=" +
@@ -949,11 +954,15 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology
{
 
                 }
 
+                TestDebugLog.addEntryMessage(p, nodes, "diff2");
+
                 return nodes;
             }
 
             Collection<UUID> diffIds = diffFromAffinity.get(p);
 
+            TestDebugLog.addEntryMessage(p, diffIds, "diff");
+
             if (!F.isEmpty(diffIds)) {
                 HashSet<UUID> affIds = affAssignment.getIds(p);
 
@@ -1632,6 +1641,8 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology
{
                     GridDhtLocalPartition locPart = localPartition(part, topVer, false);
 
                     if (locPart != null) {
+                        TestDebugLog.addPartMessage(locPart.id(), "lost", "owned");
+
                         boolean marked = plc == PartitionLossPolicy.IGNORE ? locPart.own()
: locPart.markLost();
 
                         if (marked)

http://git-wip-us.apache.org/repos/asf/ignite/blob/39f668e1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateFuture.java
index fb58e71..a292c55 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicAbstractUpdateFuture.java
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicReference;
 import javax.cache.processor.EntryProcessor;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.TestDebugLog;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.IgniteInternalFuture;
@@ -188,6 +189,9 @@ public abstract class GridDhtAtomicAbstractUpdateFuture extends GridCacheFutureA
         if (log.isDebugEnabled())
             log.debug("Mapping entry to DHT nodes [nodes=" + U.nodeIds(dhtNodes) + ", entry="
+ entry + ']');
 
+        TestDebugLog.addEntryMessage(entry.key().value(null, false),
+            F.nodeIds(dhtNodes), "dht mapped " + updateReq.topologyVersion() + " " + updateReq.affinityMapping());
+
         CacheWriteSynchronizationMode syncMode = updateReq.writeSynchronizationMode();
 
         addDhtKey(entry.key(), dhtNodes);

http://git-wip-us.apache.org/repos/asf/ignite/blob/39f668e1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
index f5d89c4..6f35275 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
@@ -23,7 +23,7 @@ import java.util.Map;
 import java.util.UUID;
 import javax.cache.expiry.ExpiryPolicy;
 import javax.cache.processor.EntryProcessor;
-import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.TestDebugLog;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.IgniteInternalFuture;
@@ -556,6 +556,9 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
             throw new ClusterTopologyServerNotFoundException("Failed to map keys for cache
(all partition nodes " +
                 "left the grid).");
 
+        TestDebugLog.addEntryMessage(cacheKey.value(null, false),
+            F.nodeIds(nodes), "near mapped " + topVer + " " + mappingKnown);
+
         ClusterNode primary = nodes.get(0);
 
         boolean needPrimaryRes = !mappingKnown || primary.isLocal() || nodes.size() == 1
|| nearEnabled;

http://git-wip-us.apache.org/repos/asf/ignite/blob/39f668e1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 248b739..d28cfca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -30,6 +30,7 @@ import java.util.UUID;
 import java.util.concurrent.atomic.AtomicReference;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.TestDebugLog;
 import org.apache.ignite.cache.CacheRebalanceMode;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -683,6 +684,8 @@ public class GridDhtPartitionDemander {
                                 if (supply.isClean(p))
                                     part.updateCounter(supply.last().get(p));
 
+                                TestDebugLog.addPartMessage(p, "last supply", "owned");
+
                                 top.own(part);
 
                                 fut.partitionDone(id, p);

http://git-wip-us.apache.org/repos/asf/ignite/blob/39f668e1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index bfe86bf..709909a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -37,6 +37,7 @@ import java.util.concurrent.locks.ReadWriteLock;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.TestDebugLog;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.events.CacheEvent;
@@ -485,6 +486,8 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
         if (isDone())
             return;
 
+        TestDebugLog.addMessage("start exchange " + initialVersion());
+
         assert !cctx.kernalContext().isDaemon();
 
         initTs = U.currentTimeMillis();
@@ -1399,6 +1402,8 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
         if (!done.compareAndSet(false, true))
             return false;
 
+        TestDebugLog.addMessage("done exchange " + initialVersion() + " " + res);
+
         log.info("Finish exchange future [startVer=" + initialVersion() +
             ", resVer=" + res +
             ", err=" + err + ']');
@@ -2235,13 +2240,20 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
                         GridDhtPartitionMap partMap = msg.partitions().get(grpId);
 
                         if (partMap == null || F.isEmpty(partMap.map())) {
+                            CacheGroupContext grp = cctx.cache().cacheGroup(grpId);
+
+                            GridDhtPartitionTopology top = grp != null ? grp.topology() :
+                                cctx.exchange().clientTopology(grpId, this);
+
                             if (partMap == null) {
                                 partMap = new GridDhtPartitionMap(nodeId,
-                                    1L,
+                                    top.updateSequence() + 1,
                                     resTopVer,
                                     new GridPartitionStateMap(),
                                     false);
                             }
+                            else
+                                partMap.updateSequence(partMap.updateSeq + 1, partMap.topologyVersion());
 
                             AffinityAssignment aff = cctx.affinity().affinity(grpId).cachedAffinity(resTopVer);
 
@@ -2250,12 +2262,9 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
                                     partMap.put(p, GridDhtPartitionState.MOVING);
                             }
 
-                            CacheGroupContext grp = cctx.cache().cacheGroup(grpId);
-
-                            GridDhtPartitionTopology top = grp != null ? grp.topology() :
-                                cctx.exchange().clientTopology(grpId, this);
+                            boolean update = top.update(exchId, partMap);
 
-                            top.update(exchId, partMap);
+                            assert update;
                         }
                     }
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/39f668e1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
----------------------------------------------------------------------
diff --git 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
index 95abd16..8f95b5e 100644
--- 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
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.TestDebugLog;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
@@ -290,6 +291,8 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
                     Collection<ClusterNode> picked = pickedOwners(p, topVer);
 
                     if (picked.isEmpty()) {
+                        TestDebugLog.addPartMessage(part.id(), "no picked", "owned");
+
                         top.own(part);
 
                         if (grp.eventRecordable(EVT_CACHE_REBALANCE_PART_DATA_LOST)) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/39f668e1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheExchangeMergeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheExchangeMergeTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheExchangeMergeTest.java
index 6d45ae8..0095e9b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheExchangeMergeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheExchangeMergeTest.java
@@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.TestDebugLog;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cluster.ClusterNode;
@@ -59,8 +60,7 @@ import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
 
 /**
@@ -77,7 +77,7 @@ public class CacheExchangeMergeTest extends GridCommonAbstractTest {
     private boolean testSpi;
 
     /** */
-    private static String[] cacheNames = {"c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8",
"c9", "c10"};
+    private static String[] cacheNames = {"c1"/*, "c2", "c3", "c4", "c5", "c6", "c7", "c8",
"c9", "c10"*/};
 
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws
Exception {
@@ -97,16 +97,17 @@ public class CacheExchangeMergeTest extends GridCommonAbstractTest {
         }
 
         cfg.setCacheConfiguration(
-            cacheConfiguration("c1", ATOMIC, PARTITIONED, 0),
-            cacheConfiguration("c2", ATOMIC, PARTITIONED, 1),
-            cacheConfiguration("c3", ATOMIC, PARTITIONED, 2),
-            cacheConfiguration("c4", ATOMIC, PARTITIONED, 10),
-            cacheConfiguration("c5", ATOMIC, REPLICATED, 0),
-            cacheConfiguration("c6", TRANSACTIONAL, PARTITIONED, 0),
-            cacheConfiguration("c7", TRANSACTIONAL, PARTITIONED, 1),
-            cacheConfiguration("c8", TRANSACTIONAL, PARTITIONED, 2),
-            cacheConfiguration("c9", TRANSACTIONAL, PARTITIONED, 10),
-            cacheConfiguration("c10", TRANSACTIONAL, REPLICATED, 0));
+            cacheConfiguration("c1", ATOMIC, PARTITIONED, 0)
+//            cacheConfiguration("c2", ATOMIC, PARTITIONED, 1),
+//            cacheConfiguration("c3", ATOMIC, PARTITIONED, 2),
+//            cacheConfiguration("c4", ATOMIC, PARTITIONED, 10),
+//            cacheConfiguration("c5", ATOMIC, REPLICATED, 0),
+//            cacheConfiguration("c6", TRANSACTIONAL, PARTITIONED, 0),
+//            cacheConfiguration("c7", TRANSACTIONAL, PARTITIONED, 1),
+//            cacheConfiguration("c8", TRANSACTIONAL, PARTITIONED, 2),
+//            cacheConfiguration("c9", TRANSACTIONAL, PARTITIONED, 10),
+//            cacheConfiguration("c10", TRANSACTIONAL, REPLICATED, 0)
+        );
 
         return cfg;
     }
@@ -172,13 +173,14 @@ public class CacheExchangeMergeTest extends GridCommonAbstractTest {
                     if (withClients)
                         client.set(ThreadLocalRandom.current().nextBoolean());
 
-                    Ignite node = startGrid(idx.incrementAndGet());
+                    Ignite node = startGrid(idx.getAndIncrement());
 
-                    checkNodeCaches(node);
+//                    if (getTestIgniteInstanceName(0).equals(node.name()))
+//                        checkNodeCaches(node);
 
                     return null;
                 }
-            }, 10, "start-node");
+            }, 2, "start-node");
 
             fut.get();
 
@@ -186,6 +188,8 @@ public class CacheExchangeMergeTest extends GridCommonAbstractTest {
 
             // TODO: stop by one, check caches - in all tests.
             stopAllGrids();
+
+            TestDebugLog.clear();
         }
     }
 
@@ -745,7 +749,19 @@ public class CacheExchangeMergeTest extends GridCommonAbstractTest {
 
                 cache.put(key, i);
 
-                assertEquals(err, i, cache.get(key));
+                Object val = cache.get(key);
+
+                if (!F.eq(i, val)) {
+                    TestDebugLog.addMessage(err + " val=" + val);
+
+                    TestDebugLog.printMessages(true, node.affinity(cacheName).partition(key));
+
+                    System.exit(100);
+                }
+
+                assertEquals(err, i, val);
+
+                TestDebugLog.clearEntries();
             }
         }
     }


Mime
View raw message