You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/07/25 15:10:05 UTC

[1/5] ignite git commit: IGNITE-5123 Reorder ignite plugin provider on Ignite start callback call

Repository: ignite
Updated Branches:
  refs/heads/ignite-5578 ccb855ea0 -> 84562b86e


IGNITE-5123 Reorder ignite plugin provider on Ignite start callback call


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

Branch: refs/heads/ignite-5578
Commit: 24e4d5d31cc494c8c55000aafefd119cc9d879a4
Parents: aeb9336
Author: Evgeniy Ignatiev <ev...@epam.com>
Authored: Mon Jul 24 15:45:10 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Jul 24 15:45:10 2017 +0300

----------------------------------------------------------------------
 .../main/java/org/apache/ignite/internal/IgniteKernal.java   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/24e4d5d3/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 00c1d73..5186409 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -1015,10 +1015,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
             // Notify IO manager the second so further components can send and receive messages.
             ctx.io().onKernalStart(active);
 
-            // Start plugins.
-            for (PluginProvider provider : ctx.plugins().allProviders())
-                provider.onIgniteStart();
-
             boolean recon = false;
 
             // Callbacks.
@@ -1049,6 +1045,10 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                 }
             }
 
+            // Start plugins.
+            for (PluginProvider provider : ctx.plugins().allProviders())
+                provider.onIgniteStart();
+
             if (recon)
                 reconnectState.waitFirstReconnect();
 


[5/5] ignite git commit: 5578

Posted by sb...@apache.org.
5578


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

Branch: refs/heads/ignite-5578
Commit: 84562b86ecde8fccf3f16f2ec08d1fa4390b02ba
Parents: ccf6a6b
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jul 25 12:01:02 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jul 25 15:34:58 2017 +0300

----------------------------------------------------------------------
 .../discovery/GridDiscoveryManager.java         | 10 +-
 .../affinity/GridAffinityAssignmentCache.java   |  4 +
 .../cache/CacheAffinitySharedManager.java       | 96 +++++++++++++++-----
 .../cache/ExchangeDiscoveryEvents.java          |  1 -
 .../GridCachePartitionExchangeManager.java      |  4 +-
 .../dht/GridClientPartitionTopology.java        |  4 +-
 .../GridDhtPartitionsExchangeFuture.java        | 78 +++++++++-------
 .../cache/transactions/IgniteTxAdapter.java     |  2 +-
 .../distributed/CachePartitionStateTest.java    | 10 +-
 9 files changed, 139 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/84562b86/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 8d309ed..f3eb266 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -696,8 +696,12 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
                 // There is no race possible between history maintenance and concurrent discovery
                 // event notifications, since SPI notifies manager about all events from this listener.
                 if (verChanged) {
-                    if (discoCache == null)
-                        discoCache = createDiscoCache(nextTopVer,ctx.state().clusterState(), locNode, topSnapshot);
+                    if (discoCache == null) {
+                        discoCache = createDiscoCache(nextTopVer,
+                            ctx.state().clusterState(),
+                            locNode,
+                            topSnapshot);
+                    }
 
                     discoCacheHist.put(nextTopVer, discoCache);
 
@@ -768,7 +772,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
                     topHist.clear();
 
                     topSnap.set(new Snapshot(AffinityTopologyVersion.ZERO,
-                        createDiscoCache(AffinityTopologyVersion.ZERO,ctx.state().clusterState(), locNode, Collections.<ClusterNode>emptySet())));
+                        createDiscoCache(AffinityTopologyVersion.ZERO, ctx.state().clusterState(), locNode, Collections.<ClusterNode>emptySet())));
                 }
                 else if (type == EVT_CLIENT_NODE_RECONNECTED) {
                     assert locNode.isClient() : locNode;

http://git-wip-us.apache.org/repos/asf/ignite/blob/84562b86/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index 1142c8e..c60a690 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -472,6 +472,10 @@ public class GridAffinityAssignmentCache {
         return false;
     }
 
+    /**
+     * @param topVer Topology version.
+     * @return Assignment.
+     */
     public AffinityAssignment readyAffinity(AffinityTopologyVersion topVer) {
         AffinityAssignment cache = head.get();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/84562b86/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
index 5d243ea..2c091ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
@@ -32,7 +32,6 @@ import java.util.concurrent.ConcurrentMap;
 import javax.cache.CacheException;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteSystemProperties;
-import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cache.affinity.AffinityFunction;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -44,6 +43,7 @@ import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException
 import org.apache.ignite.internal.managers.discovery.DiscoCache;
 import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
+import org.apache.ignite.internal.processors.affinity.AffinityAssignment;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache;
 import org.apache.ignite.internal.processors.cache.distributed.dht.ClientCacheDhtTopologyFuture;
@@ -54,11 +54,13 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartit
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CacheGroupAffinityMessage;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
 import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage;
 import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState;
 import org.apache.ignite.internal.util.GridLongList;
+import org.apache.ignite.internal.util.GridPartitionStateMap;
 import org.apache.ignite.internal.util.future.GridCompoundFuture;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -782,7 +784,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
                 else {
                     CacheGroupContext grp = cctx.cache().cacheGroup(grpId);
 
-                    if (grp != null && !grp.isLocal() && grp.localStartVersion().equals(fut.topologyVersion())) {
+                    if (grp != null && !grp.isLocal() && grp.localStartVersion().equals(fut.initialVersion())) {
                         assert grp.affinity().lastVersion().equals(AffinityTopologyVersion.NONE) : grp.affinity().lastVersion();
 
                         initAffinity(caches.group(grp.groupId()), grp.affinity(), fut);
@@ -893,13 +895,13 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
         boolean crd,
         CacheAffinityChangeMessage msg) {
         if (log.isDebugEnabled()) {
-            log.debug("Process exchange affinity change message [exchVer=" + exchFut.topologyVersion() +
+            log.debug("Process exchange affinity change message [exchVer=" + exchFut.initialVersion() +
                 ", msg=" + msg + ']');
         }
 
         assert exchFut.exchangeId().equals(msg.exchangeId()) : msg;
 
-        final AffinityTopologyVersion topVer = exchFut.topologyVersion();
+        final AffinityTopologyVersion topVer = exchFut.initialVersion();
 
         final Map<Integer, Map<Integer, List<UUID>>> assignment = msg.assignmentChange();
 
@@ -997,7 +999,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
                             ", part=" + part +
                             ", cur=" + F.nodeIds(assignment.get(part)) +
                             ", new=" + F.nodeIds(nodes) +
-                            ", exchVer=" + exchFut.topologyVersion() +
+                            ", exchVer=" + exchFut.initialVersion() +
                             ", msgVer=" + msg.topologyVersion() +
                             ']';
 
@@ -1025,7 +1027,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
         if (!locJoin) {
             forAllCacheGroups(crd, new IgniteInClosureX<GridAffinityAssignmentCache>() {
                 @Override public void applyx(GridAffinityAssignmentCache aff) throws IgniteCheckedException {
-                    AffinityTopologyVersion topVer = fut.topologyVersion();
+                    AffinityTopologyVersion topVer = fut.initialVersion();
 
                     aff.clientEventTopologyChange(fut.discoveryEvent(), topVer);
                 }
@@ -1121,17 +1123,17 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
         if (grpHolder == null) {
             grpHolder = grp != null ?
                 new CacheGroupHolder1(grp, null) :
-                CacheGroupHolder2.create(cctx, grpDesc, fut.topologyVersion(), null);
+                CacheGroupHolder2.create(cctx, grpDesc, fut.initialVersion(), null);
 
             CacheGroupHolder old = grpHolders.put(grpId, grpHolder);
 
             assert old == null : old;
 
-            List<List<ClusterNode>> newAff = grpHolder.affinity().calculate(fut.topologyVersion(),
+            List<List<ClusterNode>> newAff = grpHolder.affinity().calculate(fut.initialVersion(),
                 fut.discoveryEvent(),
                 fut.discoCache());
 
-            grpHolder.affinity().initialize(fut.topologyVersion(), newAff);
+            grpHolder.affinity().initialize(fut.initialVersion(), newAff);
         }
         else if (grpHolder.client() && grp != null) {
             assert grpHolder.affinity().idealAssignment() != null;
@@ -1319,6 +1321,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
 
                     List<List<ClusterNode>> assignments = affMsg.createAssignments(nodesByOrder, evts.discoveryCache());
 
+                    // TODO 5578 transfer ideal for fairaffinity
                     // Calculate ideal assignments.
                     if (!aff.centralizedAffinityFunction())
                         aff.calculate(evts.topologyVersion(), evts.lastEvent(), evts.discoveryCache());
@@ -1343,7 +1346,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
 
         assert evts.serverJoin() && !evts.serverLeft();
 
-        WaitRebalanceInfo waitRebalanceInfo = initAffinityOnNodeJoin(evts, crd);
+        WaitRebalanceInfo waitRebalanceInfo = initAffinityOnNodeJoin(fut, crd);
 
         setWaitRebalanceInfo(waitRebalanceInfo, evts.waitRebalanceEventVersion(), crd);
     }
@@ -1409,7 +1412,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
                 fetchAffinityOnJoin(fut);
         }
         else
-            waitRebalanceInfo = initAffinityOnNodeJoin(fut.context().events(), crd);
+            waitRebalanceInfo = initAffinityOnNodeJoin(fut, crd);
 
         setWaitRebalanceInfo(waitRebalanceInfo, fut.initialVersion(), crd);
     }
@@ -1583,16 +1586,16 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
             // Need initialize CacheGroupHolders if this node become coordinator on this exchange.
             forAllRegisteredCacheGroups(new IgniteInClosureX<CacheGroupDescriptor>() {
                 @Override public void applyx(CacheGroupDescriptor desc) throws IgniteCheckedException {
-                    CacheGroupHolder cache = groupHolder(fut.topologyVersion(), desc);
+                    CacheGroupHolder cache = groupHolder(fut.initialVersion(), desc);
 
-                    cache.aff.calculate(fut.topologyVersion(), fut.discoveryEvent(), fut.discoCache());
+                    cache.aff.calculate(fut.initialVersion(), fut.discoveryEvent(), fut.discoCache());
                 }
             });
         }
         else {
             forAllCacheGroups(false, new IgniteInClosureX<GridAffinityAssignmentCache>() {
                 @Override public void applyx(GridAffinityAssignmentCache aff) throws IgniteCheckedException {
-                    aff.calculate(fut.topologyVersion(), fut.discoveryEvent(), fut.discoCache());
+                    aff.calculate(fut.initialVersion(), fut.discoveryEvent(), fut.discoCache());
                 }
             });
         }
@@ -1614,6 +1617,8 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
         final boolean newAff) throws IgniteCheckedException {
         final List<IgniteInternalFuture<AffinityTopologyVersion>> futs = new ArrayList<>();
 
+        final AffinityTopologyVersion topVer = fut.initialVersion();
+
         forAllRegisteredCacheGroups(new IgniteInClosureX<CacheGroupDescriptor>() {
             @Override public void applyx(CacheGroupDescriptor desc) throws IgniteCheckedException {
                 CacheGroupHolder grpHolder = grpHolders.get(desc.groupId());
@@ -1635,16 +1640,16 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
                         }
                     );
 
-                    grpHolder = CacheGroupHolder2.create(cctx, desc, fut.topologyVersion(), null);
+                    grpHolder = CacheGroupHolder2.create(cctx, desc, topVer, null);
 
                     final GridAffinityAssignmentCache aff = grpHolder.affinity();
 
                     if (newAff) {
-                        if (!aff.lastVersionEquals(fut.topologyVersion())) {
+                        if (!aff.lastVersionEquals(topVer)) {
                             List<List<ClusterNode>> assign =
-                                aff.calculate(fut.topologyVersion(), fut.discoveryEvent(), fut.discoCache());
+                                aff.calculate(topVer, fut.discoveryEvent(), fut.discoCache());
 
-                            aff.initialize(fut.topologyVersion(), assign);
+                            aff.initialize(topVer, assign);
                         }
                     }
                     else {
@@ -1663,7 +1668,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
                                 "prevAff=" + prev.topologyVersion() + ']');
                         }
 
-                        assert prev.topologyVersion().compareTo(fut.topologyVersion()) < 0 : prev;
+                        assert prev.topologyVersion().compareTo(topVer) < 0 : prev;
 
                         GridDhtAssignmentFetchFuture fetchFut = new GridDhtAssignmentFetchFuture(cctx,
                             desc.groupId(),
@@ -1683,7 +1688,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
                                     aff,
                                     (GridDhtAssignmentFetchFuture)fetchFut);
 
-                                aff.calculate(fut.topologyVersion(), fut.discoveryEvent(), fut.discoCache());
+                                aff.calculate(topVer, fut.discoveryEvent(), fut.discoCache());
 
                                 affFut.onDone(fut.topologyVersion());
                             }
@@ -1769,8 +1774,10 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
      * @throws IgniteCheckedException If failed.
      * @return Rabalance info.
      */
-    @Nullable private WaitRebalanceInfo initAffinityOnNodeJoin(final ExchangeDiscoveryEvents evts, boolean crd)
+    @Nullable private WaitRebalanceInfo initAffinityOnNodeJoin(final GridDhtPartitionsExchangeFuture fut, boolean crd)
         throws IgniteCheckedException {
+        final ExchangeDiscoveryEvents evts = fut.context().events();
+
         final Map<Object, List<List<ClusterNode>>> affCache = new HashMap<>();
 
         if (!crd) {
@@ -1799,12 +1806,25 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
 
                     boolean latePrimary = cache.rebalanceEnabled;
 
+                    boolean grpAdded = evts.groupAddedOnExchange(desc.groupId(), desc.receivedFrom());
+
                     initAffinityOnNodeJoin(evts,
-                        evts.groupAddedOnExchange(desc.groupId(), desc.receivedFrom()),
+                        grpAdded,
                         cache.affinity(),
                         waitRebalanceInfo,
                         latePrimary,
                         affCache);
+
+                    if (grpAdded) {
+                        AffinityAssignment aff = cache.aff.cachedAffinity(cache.aff.lastVersion());
+
+                        assert evts.topologyVersion().equals(aff.topologyVersion());
+
+                        Map<UUID, GridDhtPartitionMap> map = affinityFullMap(cache.topology(fut), aff);
+
+                        for (GridDhtPartitionMap map0 : map.values())
+                            cache.topology(fut).update(fut.exchangeId(), map0);
+                    }
                 }
             });
 
@@ -1812,6 +1832,32 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
         }
     }
 
+    private Map<UUID, GridDhtPartitionMap> affinityFullMap(GridDhtPartitionTopology top, AffinityAssignment aff) {
+        Map<UUID, GridDhtPartitionMap> map = new HashMap<>();
+
+        for (int p = 0; p < aff.assignment().size(); p++) {
+            HashSet<UUID> ids = aff.getIds(p);
+
+            for (UUID nodeId : ids) {
+                GridDhtPartitionMap partMap = map.get(nodeId);
+
+                if (partMap == null) {
+                    partMap = new GridDhtPartitionMap(nodeId,
+                        top.updateSequence() + 1,
+                        aff.topologyVersion(),
+                        new GridPartitionStateMap(),
+                        false);
+
+                    map.put(nodeId, partMap);
+                }
+
+                partMap.put(p, GridDhtPartitionState.OWNING);
+            }
+        }
+
+        return map;
+    }
+
     /**
      * @param aff Affinity.
      * @param rebalanceInfo Rebalance information.
@@ -1944,6 +1990,8 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
      */
     public IgniteInternalFuture<Map<Integer, Map<Integer, List<UUID>>>> initAffinityOnNodeLeft(
         final GridDhtPartitionsExchangeFuture fut) throws IgniteCheckedException {
+        assert !fut.context().mergeExchanges();
+
         IgniteInternalFuture<?> initFut = initCoordinatorCaches(fut, false);
 
         if (initFut != null && !initFut.isDone()) {
@@ -1952,7 +2000,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
             initFut.listen(new IgniteInClosure<IgniteInternalFuture<?>>() {
                 @Override public void apply(IgniteInternalFuture<?> initFut) {
                     try {
-                        resFut.onDone(initAffinityOnNodeLeft0(fut.topologyVersion(), fut, NODE_TO_ID, false));
+                        resFut.onDone(initAffinityOnNodeLeft0(fut.initialVersion(), fut, NODE_TO_ID, false));
                     }
                     catch (IgniteCheckedException e) {
                         resFut.onDone(e);
@@ -1963,7 +2011,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
             return resFut;
         }
         else
-            return new GridFinishedFuture<>(initAffinityOnNodeLeft0(fut.topologyVersion(), fut, NODE_TO_ID, false));
+            return new GridFinishedFuture<>(initAffinityOnNodeLeft0(fut.initialVersion(), fut, NODE_TO_ID, false));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/84562b86/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java
index e8a278f..4af5f10 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeDiscoveryEvents.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cache;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
 import java.util.UUID;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.events.DiscoveryEvent;

http://git-wip-us.apache.org/repos/asf/ignite/blob/84562b86/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 d991599..35927dc 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
@@ -28,7 +28,6 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.ListIterator;
 import java.util.Map;
 import java.util.NavigableMap;
 import java.util.TreeMap;
@@ -44,7 +43,6 @@ import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteSystemProperties;
-import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cache.affinity.AffinityFunction;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -1791,7 +1789,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
                     final GridDhtPartitionsSingleMessage pendingMsg = fut.mergeJoinExchangeOnDone(curFut);
 
                     if (pendingMsg != null)
-                        curFut.waitAndReplayToNode(evt.eventNode(), pendingMsg);
+                        curFut.waitAndReplyToNode(evt.eventNode(), pendingMsg);
                 }
 
                 exchWorker.futQ.remove(fut);

http://git-wip-us.apache.org/repos/asf/ignite/blob/84562b86/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
index b5b193b..167cea0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
@@ -128,7 +128,7 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
         this.grpId = grpId;
         this.similarAffKey = similarAffKey;
 
-        topVer = exchFut.topologyVersion();
+        topVer = exchFut.initialVersion();
 
         discoCache = exchFut.discoCache();
 
@@ -194,7 +194,7 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
         U.writeLock(lock);
 
         try {
-            AffinityTopologyVersion exchTopVer = exchFut.topologyVersion();
+            AffinityTopologyVersion exchTopVer = exchFut.initialVersion();
 
             assert exchTopVer.compareTo(topVer) > 0 : "Invalid topology version [topVer=" + topVer +
                 ", exchVer=" + exchTopVer + ']';

http://git-wip-us.apache.org/repos/asf/ignite/blob/84562b86/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 b5fc0e7..bfe86bf 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
@@ -289,6 +289,9 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
             log.debug("Creating exchange future [localNode=" + cctx.localNodeId() + ", fut=" + this + ']');
     }
 
+    /**
+     * @return Shared cache context.
+     */
     GridCacheSharedContext sharedContext() {
         return cctx;
     }
@@ -324,6 +327,9 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
         this.affChangeMsg = affChangeMsg;
     }
 
+    /**
+     * @return Initial exchange version.
+     */
     public AffinityTopologyVersion initialVersion() {
         return exchId.topologyVersion();
     }
@@ -472,6 +478,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
     /**
      * Starts activity.
      *
+     * @param newCrd {@code True} if node become coordinator on this exchange.
      * @throws IgniteInterruptedCheckedException If interrupted.
      */
     public void init(boolean newCrd) throws IgniteInterruptedCheckedException {
@@ -561,7 +568,8 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
                             onClientNodeEvent(crdNode);
 
                             exchange = ExchangeType.CLIENT;
-                        } else {
+                        }
+                        else {
                             onServerNodeEvent(crdNode);
 
                             exchange = ExchangeType.ALL_2;
@@ -591,45 +599,43 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
 
             updateTopologies(crdNode);
 
-            if (exchange != null) {
-                switch (exchange) {
-                    case ALL: {
-                        distributedExchange();
+            switch (exchange) {
+                case ALL: {
+                    distributedExchange();
 
-                        break;
-                    }
+                    break;
+                }
 
-                    case ALL_2: {
-                        distributedExchange2();
+                case ALL_2: {
+                    distributedExchange2();
 
-                        break;
-                    }
-
-                    case CLIENT: {
-                        if (!exchCtx.mergeExchanges())
-                            initTopologies();
+                    break;
+                }
 
-                        clientOnlyExchange();
+                case CLIENT: {
+                    if (!exchCtx.mergeExchanges())
+                        initTopologies();
 
-                        break;
-                    }
+                    clientOnlyExchange();
 
-                    case NONE: {
-                        initTopologies();
+                    break;
+                }
 
-                        onDone(topVer);
+                case NONE: {
+                    initTopologies();
 
-                        break;
-                    }
+                    onDone(topVer);
 
-                    default:
-                        assert false;
+                    break;
                 }
 
-                if (cctx.localNode().isClient())
-                    tryToPerformLocalSnapshotOperation();
+                default:
+                    assert false;
             }
 
+            if (cctx.localNode().isClient())
+                tryToPerformLocalSnapshotOperation();
+
             exchLog.info("Finished exchange init [topVer=" + topVer + ", crd=" + crdNode + ']');
         }
         catch (IgniteInterruptedCheckedException e) {
@@ -924,7 +930,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
      * @throws IgniteCheckedException If failed.
      */
     private void distributedExchange2() throws IgniteCheckedException {
-        if (crd.isLocal()) {
+        if (state == ExchangeLocalState.CRD) {
             if (remaining.isEmpty())
                 onAllReceived();
         }
@@ -1752,7 +1758,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
         });
     }
 
-    public void waitAndReplayToNode(final ClusterNode node, final GridDhtPartitionsSingleMessage msg) {
+    public void waitAndReplyToNode(final ClusterNode node, final GridDhtPartitionsSingleMessage msg) {
         listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
             @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> fut) {
                 FinishState finishState0;
@@ -2403,9 +2409,8 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
         ClusterNode node = cctx.node(nodeId);
 
         if (node != null) {
-            GridDhtPartitionsFullMessage fullMsg = finishState.msg;
-
-            fullMsg = fullMsg.copy();
+            GridDhtPartitionsFullMessage fullMsg = finishState.msg.copy();
+            fullMsg.exchangeId(msg.exchangeId());
 
             Collection<Integer> affReq = msg.cacheGroupsAffinityRequest();
 
@@ -2433,6 +2438,9 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
                 U.error(log, "Failed to send partitions [node=" + node + ']', e);
             }
         }
+        else if (log.isDebugEnabled())
+            log.debug("Failed to send partitions, node failed: " + nodeId);
+
     }
 
     /**
@@ -2629,11 +2637,13 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
                                 return;
                             }
                             else {
+                                AffinityTopologyVersion resVer = msg.resultTopologyVersion() != null ? msg.resultTopologyVersion() : initialVersion();
+
                                 log.info("Received full message, will finish exchange [node=" + node.id() +
-                                    ", resVer=" + msg.resultTopologyVersion() + ']');
+                                    ", resVer=" + resVer + ']');
 
                                 finishState = new FinishState(crd.id(),
-                                    msg.resultTopologyVersion() != null ? msg.resultTopologyVersion() : initialVersion(),
+                                    resVer,
                                     msg);
 
                                 state = ExchangeLocalState.DONE;

http://git-wip-us.apache.org/repos/asf/ignite/blob/84562b86/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index c734258..91ce3ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -474,7 +474,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
                     return topVer;
             }
 
-            return cctx.exchange().readyAffinityVersion();
+            return cctx.exchange().topologyVersion();
         }
 
         return res;

http://git-wip-us.apache.org/repos/asf/ignite/blob/84562b86/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePartitionStateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePartitionStateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePartitionStateTest.java
index c64ed0b..df8252e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePartitionStateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePartitionStateTest.java
@@ -303,7 +303,10 @@ public class CachePartitionStateTest extends GridCommonAbstractTest {
         nodeParts.addAll(assign.primaryPartitions(clusterNode.id()));
         nodeParts.addAll(assign.backupPartitions(clusterNode.id()));
 
-        log.info("Test state [node=" + clusterNode.id() + ", parts=" + nodeParts.size() + ", state=" + expState + ']');
+        log.info("Test state [node=" + clusterNode.id() +
+            ", cache=" + cacheName +
+            ", parts=" + nodeParts.size() +
+            ", state=" + expState + ']');
 
         if (grid(0).context().discovery().cacheAffinityNode(clusterNode, cacheName))
             assertFalse(nodeParts.isEmpty());
@@ -330,7 +333,10 @@ public class CachePartitionStateTest extends GridCommonAbstractTest {
                         if (partsMap != null) {
                             GridDhtPartitionState state = partsMap.get(p);
 
-                            assertTrue("Unexpected state: " + state, state == null || state == EVICTED);
+                            assertTrue("Unexpected state [checkNode=" + clusterNode.id() +
+                                    ", node=" + node.name() +
+                                    ", state=" + state + ']',
+                                state == null || state == EVICTED);
                         }
                     }
                 }

[2/5] ignite git commit: ignite-5805 Fixed some lgtm.com analysis alerts

Posted by sb...@apache.org.
ignite-5805 Fixed some lgtm.com analysis alerts


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

Branch: refs/heads/ignite-5578
Commit: 301943361bd29c9c33b7ba15e9567a0e05bf27e2
Parents: 24e4d5d
Author: sboikov <sb...@gridgain.com>
Authored: Mon Jul 24 23:46:57 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Jul 24 23:46:57 2017 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       |  5 --
 .../ignite/internal/MarshallerContextImpl.java  |  4 +-
 .../affinity/GridAffinityProcessor.java         |  2 +-
 .../cache/CacheAffinitySharedManager.java       |  8 +--
 .../binary/CacheObjectBinaryProcessorImpl.java  |  5 --
 .../dht/GridClientPartitionTopology.java        | 11 ++--
 .../cache/distributed/dht/GridDhtGetFuture.java | 14 ++---
 .../dht/atomic/GridDhtAtomicCache.java          |  2 +-
 .../cache/local/GridLocalLockFuture.java        |  5 --
 .../freelist/io/PagesListMetaIO.java            |  2 +-
 .../cache/transactions/IgniteTxHandler.java     | 66 ++++++++++----------
 .../cache/transactions/IgniteTxManager.java     |  2 +-
 .../processors/igfs/IgfsDataManager.java        |  2 +-
 .../string/GridRedisIncrDecrCommandHandler.java |  2 +-
 .../ignite/internal/util/IgniteUtils.java       | 16 ++---
 .../ignite/internal/util/nio/GridNioServer.java | 14 +++--
 .../cache/VisorCacheMetricsCollectorTask.java   |  2 +-
 .../communication/tcp/TcpCommunicationSpi.java  | 25 ++++++--
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  2 +-
 .../spi/failover/always/AlwaysFailoverSpi.java  |  2 +-
 .../apache/ignite/mesos/ClusterProperties.java  |  4 +-
 .../cache/websession/WebSessionFilter.java      |  2 +-
 22 files changed, 100 insertions(+), 97 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 670046f..708913a 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -2075,11 +2075,6 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
                 txtIdx.setName(idxEntry.getKey());
             }
             else {
-                Collection<String> grp = new ArrayList<>();
-
-                for (String fieldName : idx.fields())
-                    grp.add(idx.descending(fieldName) ? fieldName + " desc" : fieldName);
-
                 QueryIndex sortedIdx = new QueryIndex();
 
                 sortedIdx.setIndexType(idx.type());

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
index 6f15507..bb93354 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
@@ -197,9 +197,7 @@ public class MarshallerContextImpl implements MarshallerContext {
      * @throws IOException In case of error.
      */
     private void processResource(URL url) throws IOException {
-        try (InputStream in = url.openStream()) {
-            BufferedReader rdr = new BufferedReader(new InputStreamReader(in));
-
+        try (BufferedReader rdr = new BufferedReader(new InputStreamReader(url.openStream()))) {
             String line;
 
             while ((line = rdr.readLine()) != null) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
index b2989d3..4ee0502 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
@@ -471,7 +471,7 @@ public class GridAffinityProcessor extends GridProcessorAdapter {
                     continue;
                 }
 
-                affMap.remove(cacheName, fut0);
+                affMap.remove(key, fut0);
 
                 fut0.onDone(new IgniteCheckedException("Failed to get affinity mapping from node: " + n, e));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
index f519b4e..0f46a90 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
@@ -762,7 +762,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
         Set<Integer> gprs = new HashSet<>();
 
         for (ExchangeActions.CacheActionData action : exchActions.cacheStartRequests()) {
-            Integer grpId = action.descriptor().groupId();
+            int grpId = action.descriptor().groupId();
 
             if (gprs.add(grpId)) {
                 if (crd)
@@ -1109,7 +1109,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
         if (grpDesc.config().getCacheMode() == LOCAL)
             return;
 
-        Integer grpId = grpDesc.groupId();
+        int grpId = grpDesc.groupId();
 
         CacheGroupHolder grpHolder = grpHolders.get(grpId);
 
@@ -1360,7 +1360,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
         for (int i = 0; i < fetchFuts.size(); i++) {
             GridDhtAssignmentFetchFuture fetchFut = fetchFuts.get(i);
 
-            Integer grpId = fetchFut.groupId();
+            int grpId = fetchFut.groupId();
 
             fetchAffinity(fut.topologyVersion(),
                 fut.discoveryEvent(),
@@ -1472,7 +1472,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
                     return;
 
                 // Need initialize holders and affinity if this node became coordinator during this exchange.
-                final Integer grpId = desc.groupId();
+                int grpId = desc.groupId();
 
                 CacheGroupContext grp = cctx.cache().cacheGroup(grpId);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index c0f3515..6a1b6dc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -541,11 +541,6 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     @Override public Map<Integer, BinaryType> metadata(Collection<Integer> typeIds)
         throws BinaryObjectException {
         try {
-            Collection<BinaryMetadataKey> keys = new ArrayList<>(typeIds.size());
-
-            for (Integer typeId : typeIds)
-                keys.add(new BinaryMetadataKey(typeId));
-
             Map<Integer, BinaryType> res = U.newHashMap(metadataLocCache.size());
 
             for (Map.Entry<Integer, BinaryMetadataHolder> e : metadataLocCache.entrySet())

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
index 232ce38..b5b193b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
@@ -70,9 +70,6 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
     /** Flag to control amount of output for full map. */
     private static final boolean FULL_MAP_DEBUG = false;
 
-    /** */
-    private static final Long ZERO = 0L;
-
     /** Cache shared context. */
     private GridCacheSharedContext cctx;
 
@@ -1041,8 +1038,12 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
                 Map<Integer, T2<Long, Long>> res = U.newHashMap(cntrMap.size());
 
                 for (Map.Entry<Integer, T2<Long, Long>> e : cntrMap.entrySet()) {
-                    if (!e.getValue().equals(ZERO))
-                        res.put(e.getKey(), e.getValue());
+                    T2<Long, Long> val = e.getValue();
+
+                    if (val.get1() == 0L && val.get2() == 0L)
+                        continue;
+
+                    res.put(e.getKey(), e.getValue());
                 }
 
                 return res;

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
index 0ea48e3..8430f84 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
@@ -181,13 +181,13 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
             }
 
             fut.listen(new CI1<IgniteInternalFuture<Object>>() {
-            @Override public void apply(IgniteInternalFuture<Object> fut) {
-                try {
-                    fut.get();
-                }
-                catch (IgniteCheckedException e) {
-                    if (log.isDebugEnabled())
-                        log.debug("Failed to request keys from preloader [keys=" + keys + ", err=" + e + ']');
+                @Override public void apply(IgniteInternalFuture<Object> fut) {
+                    try {
+                        fut.get();
+                    }
+                    catch (IgniteCheckedException e) {
+                        if (log.isDebugEnabled())
+                            log.debug("Failed to request keys from preloader [keys=" + keys + ", err=" + e + ']');
 
                         onDone(e);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index e67dabf..712babd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -3493,7 +3493,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
         assert futIds != null && futIds.size() > 0 : futIds;
 
         for (int i = 0; i < futIds.size(); i++) {
-            Long id = futIds.get(i);
+            long id = futIds.get(i);
 
             GridDhtAtomicAbstractUpdateFuture updateFut = (GridDhtAtomicAbstractUpdateFuture)ctx.mvcc().atomicFuture(id);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalLockFuture.java
index e2311b8..0197acf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalLockFuture.java
@@ -448,11 +448,6 @@ public final class GridLocalLockFuture<K, V> extends GridCacheFutureAdapter<Bool
     }
 
     /** {@inheritDoc} */
-    @Override public int hashCode() {
-        return futId.hashCode();
-    }
-
-    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridLocalLockFuture.class, this);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListMetaIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListMetaIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListMetaIO.java
index 41e1bb5..1490a5c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListMetaIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/io/PagesListMetaIO.java
@@ -151,7 +151,7 @@ public class PagesListMetaIO extends PageIO {
         int off = offset(0);
 
         for (int i = 0; i < cnt; i++) {
-            Integer bucket = (int)PageUtils.getShort(pageAddr, off);
+            int bucket = (int)PageUtils.getShort(pageAddr, off);
             assert bucket >= 0 && bucket <= Short.MAX_VALUE : bucket;
 
             long tailId = PageUtils.getLong(pageAddr, off + 2);

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index c473bfe..34a9fc1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@ -1502,39 +1502,39 @@ public class IgniteTxHandler {
                                 entry.op() == TRANSFORM &&
                                 entry.oldValueOnPrimary() &&
                                 !entry.hasValue()) {
-                                while (true) {
-                                    try {
-                                        GridCacheEntryEx cached = entry.cached();
-
-                                        if (cached == null) {
-                                            cached = cacheCtx.cache().entryEx(entry.key(), req.topologyVersion());
-
-                                            entry.cached(cached);
-                                        }
-
-                                        CacheObject val = cached.innerGet(
-                                            /*ver*/null,
-                                            tx,
-                                            /*readThrough*/false,
-                                            /*updateMetrics*/false,
-                                            /*evt*/false,
-                                            tx.subjectId(),
-                                            /*transformClo*/null,
-                                            tx.resolveTaskName(),
-                                            /*expiryPlc*/null,
-                                            /*keepBinary*/true);
-
-                                        if (val == null)
-                                            val = cacheCtx.toCacheObject(cacheCtx.store().load(null, entry.key()));
-
-                                        if (val != null)
-                                            entry.readValue(val);
-
-                                    break;
-                                }
-                                catch (GridCacheEntryRemovedException ignored) {
-                                    if (log.isDebugEnabled())
-                                        log.debug("Got entry removed exception, will retry: " + entry.txKey());
+                                    while (true) {
+                                        try {
+                                            GridCacheEntryEx cached = entry.cached();
+
+                                            if (cached == null) {
+                                                cached = cacheCtx.cache().entryEx(entry.key(), req.topologyVersion());
+
+                                                entry.cached(cached);
+                                            }
+
+                                            CacheObject val = cached.innerGet(
+                                                /*ver*/null,
+                                                tx,
+                                                /*readThrough*/false,
+                                                /*updateMetrics*/false,
+                                                /*evt*/false,
+                                                tx.subjectId(),
+                                                /*transformClo*/null,
+                                                tx.resolveTaskName(),
+                                                /*expiryPlc*/null,
+                                                /*keepBinary*/true);
+
+                                            if (val == null)
+                                                val = cacheCtx.toCacheObject(cacheCtx.store().load(null, entry.key()));
+
+                                            if (val != null)
+                                                entry.readValue(val);
+
+                                        break;
+                                    }
+                                    catch (GridCacheEntryRemovedException ignored) {
+                                        if (log.isDebugEnabled())
+                                            log.debug("Got entry removed exception, will retry: " + entry.txKey());
 
                                         entry.cached(cacheCtx.cache().entryEx(entry.key(), req.topologyVersion()));
                                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 26a4a91..e4e0061 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -2159,7 +2159,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
                         }
                     }
                     // Special case for optimal sequence of nodes processing.
-                    else if (nearTxLoc && requestedKeys != null && requestedKeys.contains(txKey.key())) {
+                    else if (nearTxLoc && requestedKeys != null && requestedKeys.contains(txKey)) {
                         TxLock txLock = new TxLock(
                             tx.nearXidVersion(),
                             tx.nodeId(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index 4243074..e73fa6c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@ -202,7 +202,7 @@ public class IgfsDataManager extends IgfsManager {
         grpSize = mapper instanceof IgfsGroupDataBlocksKeyMapper ?
             ((IgfsGroupDataBlocksKeyMapper)mapper).getGroupSize() : 1;
 
-        grpBlockSize = igfsCtx.configuration().getBlockSize() * grpSize;
+        grpBlockSize = igfsCtx.configuration().getBlockSize() * (long)grpSize;
 
         assert grpBlockSize != 0;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisIncrDecrCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisIncrDecrCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisIncrDecrCommandHandler.java
index a57b82e..99453aa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisIncrDecrCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisIncrDecrCommandHandler.java
@@ -93,7 +93,7 @@ public class GridRedisIncrDecrCommandHandler extends GridRedisRestCommandHandler
             restReq.initial(0L);
         else {
             if (getResp.getResponse() instanceof String) {
-                Long init;
+                long init;
 
                 try {
                     init = Long.parseLong((String)getResp.getResponse());

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 54ffe41..acfd914 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -3380,18 +3380,18 @@ public abstract class IgniteUtils {
      * @throws IOException If error occurred.
      */
     public static String readFileToString(String fileName, String charset) throws IOException {
-        Reader input = new InputStreamReader(new FileInputStream(fileName), charset);
+        try (Reader input = new InputStreamReader(new FileInputStream(fileName), charset)) {
+            StringWriter output = new StringWriter();
 
-        StringWriter output = new StringWriter();
+            char[] buf = new char[4096];
 
-        char[] buf = new char[4096];
+            int n;
 
-        int n;
+            while ((n = input.read(buf)) != -1)
+                output.write(buf, 0, n);
 
-        while ((n = input.read(buf)) != -1)
-            output.write(buf, 0, n);
-
-        return output.toString();
+            return output.toString();
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
index ce7e7f3..3b8b22c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
@@ -2129,14 +2129,16 @@ public class GridNioServer<T> {
 
                     int cnt = 0;
 
-                for (SessionWriteRequest req : ses.writeQueue()) {
-                    Object msg = req.message();
+                    for (SessionWriteRequest req : ses.writeQueue()) {
+                        Object msg = req.message();
 
                         if (shortInfo && msg instanceof GridIoMessage)
-                            msg = ((GridIoMessage)msg).message().getClass().getSimpleName();if (cnt == 0)
-                        sb.append(",\n opQueue=[").append(msg);
-                    else
-                        sb.append(',').append(msg);
+                            msg = ((GridIoMessage)msg).message().getClass().getSimpleName();
+
+                        if (cnt == 0)
+                            sb.append(",\n opQueue=[").append(msg);
+                        else
+                            sb.append(',').append(msg);
 
                         if (++cnt == 5) {
                             sb.append(']');

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
index 5cc8154..8ce3c8c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
@@ -94,7 +94,7 @@ public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<VisorCach
         @Override protected Collection<VisorCacheMetrics> run(final VisorCacheMetricsCollectorTaskArg arg) {
             assert arg != null;
 
-            Boolean showSysCaches = arg.isShowSystemCaches();
+            boolean showSysCaches = arg.isShowSystemCaches();
 
             Collection<String> cacheNames = arg.getCacheNames();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 5b952e8..1b00b5d 100755
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -3260,14 +3260,17 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                     "operating system firewall is disabled on local and remote hosts) " +
                     "[addrs=" + addrs + ']');
 
-            if (enableForcibleNodeKill) {if (getSpiContext().node(node.id()) != null && (CU.clientNode(node) || !CU.clientNode(getLocalNode())) &&
-                X.hasCause(errs, ConnectException.class,HandshakeException.class, SocketTimeoutException.class, HandshakeTimeoutException.class,
-                    IgniteSpiOperationTimeoutException.class)) {String msg = "TcpCommunicationSpi failed to establish connection to node, node will be dropped from " +
+            if (enableForcibleNodeKill) {
+                if (getSpiContext().node(node.id()) != null
+                    && (CU.clientNode(node) ||  !CU.clientNode(getLocalNode())) &&
+                    connectionError(errs)) {
+                    String msg = "TcpCommunicationSpi failed to establish connection to node, node will be dropped from " +
                         "cluster [" + "rmtNode=" + node + ']';
 
-                if(enableTroubleshootingLog)U.error(log, msg, errs);
+                    if (enableTroubleshootingLog)
+                        U.error(log, msg, errs);
                     else
-                    U.warn(log, msg);
+                        U.warn(log, msg);
 
                     getSpiContext().failNode(node.id(), "TcpCommunicationSpi failed to establish connection to node [" +
                         "rmtNode=" + node +
@@ -3284,6 +3287,18 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
     }
 
     /**
+     * @param errs Error.
+     * @return {@code True} if error was caused by some connection IO error.
+     */
+    private static boolean connectionError(IgniteCheckedException errs) {
+        return X.hasCause(errs, ConnectException.class,
+            HandshakeException.class,
+            SocketTimeoutException.class,
+            HandshakeTimeoutException.class,
+            IgniteSpiOperationTimeoutException.class);
+    }
+
+    /**
      * Performs handshake in timeout-safe way.
      *
      * @param client Client.

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index d621fb3..e098787 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -6249,7 +6249,7 @@ class ServerImpl extends TcpDiscoveryImpl {
             else {
                 spi.stats.onMessageProcessingStarted(msg);
 
-                Integer res;
+                int res;
 
                 SocketAddress rmtAddr = sock.getRemoteSocketAddress();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/core/src/main/java/org/apache/ignite/spi/failover/always/AlwaysFailoverSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/failover/always/AlwaysFailoverSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/failover/always/AlwaysFailoverSpi.java
index 468a627..f074119 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/failover/always/AlwaysFailoverSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/failover/always/AlwaysFailoverSpi.java
@@ -237,7 +237,7 @@ public class AlwaysFailoverSpi extends IgniteSpiAdapter implements FailoverSpi {
         if (failedNodes == null)
             failedNodes = U.newHashSet(1);
 
-        Integer failoverCnt = failedNodes.size();
+        int failoverCnt = failedNodes.size();
 
         if (failoverCnt >= maxFailoverAttempts) {
             U.warn(log, "Job failover failed because number of maximum failover attempts is exceeded [failedJob=" +

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java
----------------------------------------------------------------------
diff --git a/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java b/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java
index 3c8f396..3e66cc6 100644
--- a/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java
+++ b/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java
@@ -478,7 +478,9 @@ public class ClusterProperties {
             if (cfg != null) {
                 props = new Properties();
 
-                props.load(new FileInputStream(cfg));
+                try (FileInputStream in = new FileInputStream(cfg)) {
+                    props.load(in);
+                }
             }
 
             ClusterProperties prop = new ClusterProperties();

http://git-wip-us.apache.org/repos/asf/ignite/blob/30194336/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
index 0644c0f..6cbf575 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
@@ -740,7 +740,7 @@ public class WebSessionFilter implements Filter {
     private <T> IgniteCache<String, T> cacheWithExpiryPolicy(final int maxInactiveInteval,
         final IgniteCache<String, T> cache) {
         if (maxInactiveInteval > 0) {
-            long ttl = maxInactiveInteval * 1000;
+            long ttl = maxInactiveInteval * 1000L;
 
             ExpiryPolicy plc = new ModifiedExpiryPolicy(new Duration(MILLISECONDS, ttl));
 


[3/5] ignite git commit: 5578

Posted by sb...@apache.org.
5578


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

Branch: refs/heads/ignite-5578
Commit: e11355a93a5a9c6eff3923bbcd572043aae4ccc1
Parents: ccb855e
Author: sboikov <sb...@gridgain.com>
Authored: Mon Jul 24 19:30:54 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jul 25 11:20:43 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/ExchangeContext.java       |  8 ++++-
 .../GridCachePartitionExchangeManager.java      |  6 +---
 .../GridDhtPartitionsExchangeFuture.java        | 12 ++++----
 .../distributed/CacheExchangeMergeTest.java     | 32 ++++++++++++--------
 4 files changed, 34 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e11355a9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeContext.java
index 1f5d3ba..70c896e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeContext.java
@@ -19,11 +19,13 @@ package org.apache.ignite.internal.processors.cache;
 
 import java.util.HashSet;
 import java.util.Set;
+import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
 import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT;
+import static org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager.exchangeProtocolVersion;
 
 /**
  *
@@ -45,7 +47,7 @@ public class ExchangeContext {
      * @param fut Exchange future.
      */
     public ExchangeContext(GridDhtPartitionsExchangeFuture fut) {
-        int protocolVer = GridCachePartitionExchangeManager.exchangeProtocolVersion(
+        int protocolVer = exchangeProtocolVersion(
             fut.discoCache().minimumNodeVersion());
 
         fetchAffOnJoin = protocolVer == 1;
@@ -55,6 +57,10 @@ public class ExchangeContext {
         evts = new ExchangeDiscoveryEvents(fut);
     }
 
+    boolean supportsMergeExchanges(ClusterNode node) {
+        return exchangeProtocolVersion(node.version()) > 1;
+    }
+
     /**
      * @return Discovery events.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/e11355a9/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 b2cf940..d991599 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
@@ -1748,10 +1748,6 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
             ((IgniteDiagnosticAware)fut).addDiagnosticRequest(ctx);
     }
 
-    private boolean supportsMergeExchanges(ClusterNode node) {
-        return exchangeProtocolVersion(node.version()) > 1;
-    }
-
     /** */
     private volatile AffinityTopologyVersion exchMergeTestWaitVer;
 
@@ -1870,7 +1866,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
 
                     ClusterNode node = evt.eventNode();
 
-                    if (!supportsMergeExchanges(node)) {
+                    if (!curFut.context().supportsMergeExchanges(node)) {
                         log.info("Stop merge, node does not support merge: " + node);
 
                         break;

http://git-wip-us.apache.org/repos/asf/ignite/blob/e11355a9/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 34ebe41..b5fc0e7 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
@@ -2181,14 +2181,14 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
 
                     grp.topology().beforeExchange(this, true);
                 }
-            }
 
-            synchronized (this) {
-                if (mergedJoinExchMsgs != null) {
-                    for (Map.Entry<UUID, GridDhtPartitionsSingleMessage> e : mergedJoinExchMsgs.entrySet()) {
-                        msgs.put(e.getKey(), e.getValue());
+                synchronized (this) {
+                    if (mergedJoinExchMsgs != null) {
+                        for (Map.Entry<UUID, GridDhtPartitionsSingleMessage> e : mergedJoinExchMsgs.entrySet()) {
+                            msgs.put(e.getKey(), e.getValue());
 
-                        updatePartitionSingleMap(e.getKey(), e.getValue());
+                            updatePartitionSingleMap(e.getKey(), e.getValue());
+                        }
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/e11355a9/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 7359bde..6d45ae8 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
@@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
@@ -59,6 +60,7 @@ 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.CacheWriteSynchronizationMode.FULL_SYNC;
 
 /**
@@ -74,6 +76,9 @@ public class CacheExchangeMergeTest extends GridCommonAbstractTest {
     /** */
     private boolean testSpi;
 
+    /** */
+    private static String[] cacheNames = {"c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10"};
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
@@ -92,14 +97,16 @@ public class CacheExchangeMergeTest extends GridCommonAbstractTest {
         }
 
         cfg.setCacheConfiguration(
-            cacheConfiguration("c1", ATOMIC, 0),
-            cacheConfiguration("c2", ATOMIC, 1),
-            cacheConfiguration("c3", ATOMIC, 2),
-            cacheConfiguration("c4", ATOMIC, 10),
-            cacheConfiguration("c5", TRANSACTIONAL, 0),
-            cacheConfiguration("c6", TRANSACTIONAL, 1),
-            cacheConfiguration("c7", TRANSACTIONAL, 2),
-            cacheConfiguration("c8", TRANSACTIONAL, 10));
+            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;
     }
@@ -117,12 +124,15 @@ public class CacheExchangeMergeTest extends GridCommonAbstractTest {
      * @param backups Number of backups.
      * @return Cache configuration.
      */
-    private CacheConfiguration cacheConfiguration(String name, CacheAtomicityMode atomicityMode, int backups) {
+    private CacheConfiguration cacheConfiguration(String name, CacheAtomicityMode atomicityMode, CacheMode cacheMode, int backups) {
         CacheConfiguration ccfg = new CacheConfiguration(name);
 
         ccfg.setAtomicityMode(atomicityMode);
         ccfg.setWriteSynchronizationMode(FULL_SYNC);
-        ccfg.setBackups(backups);
+        ccfg.setCacheMode(cacheMode);
+
+        if (cacheMode == PARTITIONED)
+            ccfg.setBackups(backups);
 
         return ccfg;
     }
@@ -713,8 +723,6 @@ public class CacheExchangeMergeTest extends GridCommonAbstractTest {
      * @param node Node.
      */
     private void checkNodeCaches(Ignite node) {
-        String[] cacheNames = {"c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8"};
-
         ThreadLocalRandom rnd = ThreadLocalRandom.current();
 
         for (String cacheName : cacheNames) {

[4/5] ignite git commit: Merge remote-tracking branch 'remotes/origin/master' into ignite-5578

Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-5578


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

Branch: refs/heads/ignite-5578
Commit: ccf6a6bf45bf763b13f6c036a0fa676acb2767c4
Parents: e11355a 3019433
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jul 25 11:20:58 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jul 25 11:20:58 2017 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       |  5 --
 .../apache/ignite/internal/IgniteKernal.java    |  8 +--
 .../ignite/internal/MarshallerContextImpl.java  |  4 +-
 .../affinity/GridAffinityProcessor.java         |  2 +-
 .../cache/CacheAffinitySharedManager.java       |  8 +--
 .../binary/CacheObjectBinaryProcessorImpl.java  |  5 --
 .../dht/GridClientPartitionTopology.java        | 11 ++--
 .../cache/distributed/dht/GridDhtGetFuture.java | 14 ++---
 .../dht/atomic/GridDhtAtomicCache.java          |  2 +-
 .../cache/local/GridLocalLockFuture.java        |  5 --
 .../freelist/io/PagesListMetaIO.java            |  2 +-
 .../cache/transactions/IgniteTxHandler.java     | 66 ++++++++++----------
 .../cache/transactions/IgniteTxManager.java     |  2 +-
 .../processors/igfs/IgfsDataManager.java        |  2 +-
 .../string/GridRedisIncrDecrCommandHandler.java |  2 +-
 .../ignite/internal/util/IgniteUtils.java       | 16 ++---
 .../ignite/internal/util/nio/GridNioServer.java | 14 +++--
 .../cache/VisorCacheMetricsCollectorTask.java   |  2 +-
 .../communication/tcp/TcpCommunicationSpi.java  | 25 ++++++--
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  2 +-
 .../spi/failover/always/AlwaysFailoverSpi.java  |  2 +-
 .../apache/ignite/mesos/ClusterProperties.java  |  4 +-
 .../cache/websession/WebSessionFilter.java      |  2 +-
 23 files changed, 104 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ccf6a6bf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
index 37bfa8a,0f46a90..5d243ea
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
@@@ -1511,9 -1360,9 +1511,9 @@@ public class CacheAffinitySharedManager
          for (int i = 0; i < fetchFuts.size(); i++) {
              GridDhtAssignmentFetchFuture fetchFut = fetchFuts.get(i);
  
-             Integer grpId = fetchFut.groupId();
+             int grpId = fetchFut.groupId();
  
 -            fetchAffinity(fut.topologyVersion(),
 +            fetchAffinity(topVer,
                  fut.discoveryEvent(),
                  fut.discoCache(),
                  cctx.cache().cacheGroup(grpId).affinity(),