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/05/17 10:32:40 UTC

[01/17] ignite git commit: Added IO latency test + made it available from MBean

Repository: ignite
Updated Branches:
  refs/heads/ignite-5075 e519adf88 -> 5bbd7c447


Added IO latency test + made it available from MBean


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

Branch: refs/heads/ignite-5075
Commit: 8195ae0655255979d02d425a6ca11fb720d460d3
Parents: ed4a7a1
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Mon May 15 18:03:07 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Mon May 15 18:03:07 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |  14 ++
 .../managers/communication/GridIoManager.java   | 206 ++++++++++++++++++-
 .../org/apache/ignite/mxbean/IgniteMXBean.java  |  44 ++++
 3 files changed, 263 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8195ae06/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 8ba6a88..2c8c964 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
@@ -3960,6 +3960,20 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
     }
 
     /** {@inheritDoc} */
+    @Override public void runIoTest(
+        long warmup,
+        long duration,
+        int threads,
+        long maxLatency,
+        int rangesCnt,
+        int payLoadSize,
+        boolean procFromNioThread
+    ) {
+        ctx.io().runIoTest(warmup, duration, threads, maxLatency, rangesCnt, payLoadSize, procFromNioThread,
+            new ArrayList(ctx.cluster().get().forServers().forRemotes().nodes()));
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgniteKernal.class, this);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8195ae06/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index 9d35c75..fc94667 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -21,17 +21,23 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Queue;
 import java.util.UUID;
+import java.util.concurrent.BrokenBarrierException;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedDeque;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
@@ -86,6 +92,7 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
 import org.jsr166.ConcurrentLinkedDeque8;
+import org.jsr166.LongAdder8;
 
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
 import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
@@ -99,11 +106,11 @@ import static org.apache.ignite.internal.managers.communication.GridIoPolicy.IGF
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.MANAGEMENT_POOL;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.P2P_POOL;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.PUBLIC_POOL;
+import static org.apache.ignite.internal.managers.communication.GridIoPolicy.QUERY_POOL;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SCHEMA_POOL;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SERVICE_POOL;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.UTILITY_CACHE_POOL;
-import static org.apache.ignite.internal.managers.communication.GridIoPolicy.QUERY_POOL;
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.isReservedGridIoPolicy;
 import static org.apache.ignite.internal.util.nio.GridNioBackPressureControl.threadProcessingMessage;
 import static org.jsr166.ConcurrentLinkedHashMap.QueuePolicy.PER_SEGMENT_Q_OPTIMIZED_RMV;
@@ -433,6 +440,203 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
         return map;
     }
 
+    /**
+     * @param warmup Warmup duration in milliseconds.
+     * @param duration Test duration in milliseconds.
+     * @param threads Thread count.
+     * @param maxLatency Max latency in nanoseconds.
+     * @param rangesCnt Ranges count in resulting histogram.
+     * @param payLoadSize Payload size in bytes.
+     * @param procFromNioThread {@code True} to process requests in NIO threads.
+     * @param nodes Nodes participating in test.
+     */
+    public void runIoTest(
+        final long warmup,
+        final long duration,
+        final int threads,
+        final long maxLatency,
+        final int rangesCnt,
+        final int payLoadSize,
+        final boolean procFromNioThread,
+        final List<ClusterNode> nodes
+    ) {
+        ExecutorService svc = Executors.newFixedThreadPool(threads + 1);
+
+        final AtomicBoolean warmupFinished = new AtomicBoolean();
+        final AtomicBoolean done = new AtomicBoolean();
+        final CyclicBarrier bar = new CyclicBarrier(threads + 1);
+        final LongAdder8 cnt = new LongAdder8();
+        final long sleepDuration = 5000;
+        final byte[] payLoad = new byte[payLoadSize];
+        final Map<UUID, long[]>[] res = new Map[threads];
+
+        boolean failed = true;
+
+        try {
+            svc.execute(new Runnable() {
+                @Override public void run() {
+                    boolean failed = true;
+
+                    try {
+                        bar.await();
+
+                        long start = System.currentTimeMillis();
+
+                        if (log.isInfoEnabled())
+                            log.info("IO test started " +
+                                "[warmup=" + warmup +
+                                ", duration=" + duration +
+                                ", threads=" + threads +
+                                ", maxLatency=" + maxLatency +
+                                ", rangesCnt=" + rangesCnt +
+                                ", payLoadSize=" + payLoadSize +
+                                ", procFromNioThreads=" + procFromNioThread + ']'
+                            );
+
+                        for (;;) {
+                            if (!warmupFinished.get() && System.currentTimeMillis() - start > warmup) {
+                                if (log.isInfoEnabled())
+                                    log.info("IO test warmup finished.");
+
+                                warmupFinished.set(true);
+
+                                start = System.currentTimeMillis();
+                            }
+
+                            if (warmupFinished.get() && System.currentTimeMillis() - start > duration) {
+                                if (log.isInfoEnabled())
+                                    log.info("IO test finished, will wait for all threads to finish.");
+
+                                done.set(true);
+
+                                bar.await();
+
+                                failed = false;
+
+                                break;
+                            }
+
+                            if (log.isInfoEnabled())
+                                log.info("IO test [opsCnt/sec=" + (cnt.sumThenReset() * 1000 / sleepDuration) +
+                                    ", warmup=" + !warmupFinished.get() +
+                                    ", elapsed=" + (System.currentTimeMillis() - start) + ']');
+
+                            Thread.sleep(sleepDuration);
+                        }
+
+                        // At this point all threads have finished the test and stored data to the result map.
+                        Map<UUID, long[]> res0 = new HashMap<>();
+
+                        for (Map<UUID, long[]> r : res) {
+                            for (Entry<UUID, long[]> e : r.entrySet()) {
+                                long[] r0 = res0.get(e.getKey());
+
+                                if (r0 == null)
+                                    res0.put(e.getKey(), e.getValue());
+                                else {
+                                    for (int i = 0; i < rangesCnt + 1; i++)
+                                        r0[i] += e.getValue()[i];
+                                }
+                            }
+                        }
+
+                        StringBuilder b = new StringBuilder("IO test results " +
+                            "[range=" + (maxLatency / (1000 * rangesCnt)) + "mcs]");
+
+                        b.append(U.nl());
+
+                        for (Entry<UUID, long[]> e : res0.entrySet()) {
+                            ClusterNode node = ctx.discovery().node(e.getKey());
+
+                            b.append("    ").append(e.getKey()).append(" (addrs=")
+                                .append(node != null ? node.addresses().toString() : "n/a").append(')')
+                                .append(Arrays.toString(e.getValue())).append(U.nl());
+                        }
+
+                        if (log.isInfoEnabled())
+                            log.info(b.toString());
+                    }
+                    catch (InterruptedException | BrokenBarrierException e) {
+                        U.error(log, "IO test failed.", e);
+                    }
+                    finally {
+                        if (failed)
+                            bar.reset();
+                    }
+                }
+            });
+
+            for (int i = 0; i < threads; i++) {
+                final int i0 = i;
+
+                res[i] = U.newHashMap(nodes.size());
+
+                svc.execute(new Runnable() {
+                    @Override public void run() {
+                        boolean failed = true;
+                        ThreadLocalRandom rnd = ThreadLocalRandom.current();
+                        int size = nodes.size();
+                        Map<UUID, long[]> res0 = res[i0];
+
+                        try {
+                            boolean warmupFinished0 = false;
+
+                            bar.await();
+
+                            for (;;) {
+                                if (done.get())
+                                    break;
+
+                                if (!warmupFinished0)
+                                    warmupFinished0 = warmupFinished.get();
+
+                                ClusterNode node = nodes.get(rnd.nextInt(size));
+
+                                long start = System.nanoTime();
+
+                                sendIoTest(node, payLoad, procFromNioThread).get();
+
+                                long latency = System.nanoTime() - start;
+
+                                cnt.increment();
+
+                                long[] latencies = res0.get(node.id());
+
+                                if (latencies == null)
+                                    res0.put(node.id(), latencies = new long[rangesCnt + 1]);
+
+                                if (latency >= maxLatency)
+                                    latencies[rangesCnt]++; // Timed out.
+                                else {
+                                    int idx = (int)Math.floor((1.0 * latency) / ((1.0 * maxLatency) / rangesCnt));
+
+                                    latencies[idx]++;
+                                }
+                            }
+
+                            bar.await();
+
+                            failed = false;
+                        }
+                        catch (Exception e) {
+                            U.error(log, "IO test worker thread failed.", e);
+                        }
+                        finally {
+                            if (failed)
+                                bar.reset();
+                        }
+                    }
+                });
+            }
+
+            failed = false;
+        }
+        finally {
+            if (failed)
+                U.shutdownNow(GridIoManager.class, svc, log);
+        }
+    }
+
     /** {@inheritDoc} */
     @SuppressWarnings({"deprecation", "SynchronizationOnLocalVariableOrMethodParameter"})
     @Override public void onKernalStart0() throws IgniteCheckedException {

http://git-wip-us.apache.org/repos/asf/ignite/blob/8195ae06/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java b/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java
index bf84b0d..ce63e4f 100644
--- a/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java
@@ -385,4 +385,48 @@ public interface IgniteMXBean {
      */
     @MXBeanDescription("Dumps debug information for the current node.")
     public void dumpDebugInfo();
+
+    /**
+     * Runs IO latency test against all remote server nodes in cluster.
+     *
+     * @param warmup Warmup duration in milliseconds.
+     * @param duration Test duration in milliseconds.
+     * @param threads Thread count.
+     * @param maxLatency Max latency in nanoseconds.
+     * @param rangesCnt Ranges count in resulting histogram.
+     * @param payLoadSize Payload size in bytes.
+     * @param procFromNioThread {@code True} to process requests in NIO threads.
+     */
+    @MXBeanDescription("Runs IO latency test against all remote server nodes in cluster.")
+    @MXBeanParametersNames(
+        {
+            "warmup",
+            "duration",
+            "threads",
+            "maxLatency",
+            "rangesCnt",
+            "payLoadSize",
+            "procFromNioThread"
+        }
+    )
+    @MXBeanParametersDescriptions(
+        {
+            "Warmup duration (millis).",
+            "Test duration (millis).",
+            "Threads count.",
+            "Maximum latency expected (nanos).",
+            "Ranges count for histogram.",
+            "Payload size (bytes).",
+            "Process requests in NIO-threads flag."
+        }
+    )
+    void runIoTest(
+        long warmup,
+        long duration,
+        int threads,
+        long maxLatency,
+        int rangesCnt,
+        int payLoadSize,
+        boolean procFromNioThread
+    );
 }


[09/17] ignite git commit: IGNITE-5050 .NET: IIgnite.GetMemoryMetrics

Posted by sb...@apache.org.
IGNITE-5050 .NET: IIgnite.GetMemoryMetrics


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

Branch: refs/heads/ignite-5075
Commit: 73fc01c4f021854e3fdc5c9a3bfe9a0650a77055
Parents: 1fef59c
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Tue May 16 19:32:48 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Tue May 16 19:32:48 2017 +0300

----------------------------------------------------------------------
 .../platform/cluster/PlatformClusterGroup.java  |  20 +++
 .../utils/PlatformConfigurationUtils.java       |   4 +-
 .../Apache.Ignite.Core.Tests.csproj             |   1 +
 .../Cache/MemoryMetricsTest.cs                  | 134 +++++++++++++++++++
 .../IgniteConfigurationSerializerTest.cs        |   6 +-
 .../IgniteConfigurationTest.cs                  |   4 +-
 .../Apache.Ignite.Core.csproj                   |   2 +
 .../Configuration/MemoryPolicyConfiguration.cs  |   9 ++
 .../Apache.Ignite.Core/Cache/IMemoryMetrics.cs  |  55 ++++++++
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |   7 +
 .../IgniteConfigurationSection.xsd              |   5 +
 .../Impl/Cache/MemoryMetrics.cs                 |  62 +++++++++
 .../Impl/Cluster/ClusterGroupImpl.cs            |  27 +++-
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |   6 +
 14 files changed, 337 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
index 3e14e7a..5a5ebfd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cluster/PlatformClusterGroup.java
@@ -24,6 +24,7 @@ import java.util.UUID;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteCluster;
+import org.apache.ignite.MemoryMetrics;
 import org.apache.ignite.cluster.ClusterMetrics;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.internal.cluster.ClusterGroupEx;
@@ -108,6 +109,9 @@ public class PlatformClusterGroup extends PlatformAbstractTarget {
     /** */
     private static final int OP_RESET_LOST_PARTITIONS = 25;
 
+    /** */
+    private static final int OP_MEMORY_METRICS = 26;
+
     /** Projection. */
     private final ClusterGroupEx prj;
 
@@ -132,6 +136,22 @@ public class PlatformClusterGroup extends PlatformAbstractTarget {
 
                 break;
 
+            case OP_MEMORY_METRICS:
+                Collection<MemoryMetrics> metrics = prj.ignite().memoryMetrics();
+
+                writer.writeInt(metrics.size());
+
+                for (MemoryMetrics m : metrics) {
+                    writer.writeString(m.getName());
+                    writer.writeLong(m.getTotalAllocatedPages());
+                    writer.writeFloat(m.getAllocationRate());
+                    writer.writeFloat(m.getEvictionRate());
+                    writer.writeFloat(m.getLargeEntriesPagesPercentage());
+                    writer.writeFloat(m.getPagesFillFactor());
+                }
+
+                break;
+
             default:
                 super.processOutStream(type, writer);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index 98b438d..6ba88d9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -1350,7 +1350,8 @@ public class PlatformConfigurationUtils {
                         .setSwapFilePath(in.readString())
                         .setPageEvictionMode(DataPageEvictionMode.values()[in.readInt()])
                         .setEvictionThreshold(in.readDouble())
-                        .setEmptyPagesPoolSize(in.readInt());
+                        .setEmptyPagesPoolSize(in.readInt())
+                        .setMetricsEnabled(in.readBoolean());
 
                 plcs[i] = cfg;
             }
@@ -1394,6 +1395,7 @@ public class PlatformConfigurationUtils {
                 w.writeInt(plc.getPageEvictionMode().ordinal());
                 w.writeDouble(plc.getEvictionThreshold());
                 w.writeInt(plc.getEmptyPagesPoolSize());
+                w.writeBoolean(plc.isMetricsEnabled());
             }
         }
         else {

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 1c84a4d..13e4889 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -94,6 +94,7 @@
     <Compile Include="Cache\CacheMetricsTest.cs" />
     <Compile Include="Cache\CacheResultTest.cs" />
     <Compile Include="Cache\CacheTestKey.cs" />
+    <Compile Include="Cache\MemoryMetricsTest.cs" />
     <Compile Include="Cache\NonSerializableCacheEntryProcessor.cs" />
     <Compile Include="Cache\NonSerializableException.cs" />
     <Compile Include="Cache\PartitionLossTest.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/MemoryMetricsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/MemoryMetricsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/MemoryMetricsTest.cs
new file mode 100644
index 0000000..07b596a
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/MemoryMetricsTest.cs
@@ -0,0 +1,134 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache
+{
+    using System.Linq;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Configuration;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Memory metrics tests.
+    /// </summary>
+    public class MemoryMetricsTest
+    {
+        /** */
+        private const string MemoryPolicyWithMetrics = "plcWithMetrics";
+
+        /** */
+        private const string MemoryPolicyNoMetrics = "plcNoMetrics";
+
+        /// <summary>
+        /// Tests the memory metrics.
+        /// </summary>
+        [Test]
+        public void TestMemoryMetrics()
+        {
+            var ignite = StartIgniteWithTwoPolicies();
+
+            // Verify metrics.
+            var metrics = ignite.GetMemoryMetrics().ToArray();
+            Assert.AreEqual(3, metrics.Length);  // two defined plus system.
+
+            var sysMetrics = metrics[0];
+            Assert.AreEqual("sysMemPlc", sysMetrics.Name);
+            AssertMetricsAreEmpty(sysMetrics);
+
+            var memMetrics = metrics[1];
+            Assert.AreEqual(MemoryPolicyWithMetrics, memMetrics.Name);
+            Assert.Greater(memMetrics.AllocationRate, 0);
+            Assert.AreEqual(0, memMetrics.EvictionRate);
+            Assert.AreEqual(0, memMetrics.LargeEntriesPagesPercentage);
+            Assert.Greater(memMetrics.PageFillFactor, 0);
+            Assert.Greater(memMetrics.TotalAllocatedPages, 1000);
+
+            var emptyMetrics = metrics[2];
+            Assert.AreEqual(MemoryPolicyNoMetrics, emptyMetrics.Name);
+            AssertMetricsAreEmpty(emptyMetrics);
+        }
+
+        /// <summary>
+        /// Asserts that metrics are empty.
+        /// </summary>
+        private static void AssertMetricsAreEmpty(IMemoryMetrics metrics)
+        {
+            Assert.AreEqual(0, metrics.AllocationRate);
+            Assert.AreEqual(0, metrics.EvictionRate);
+            Assert.AreEqual(0, metrics.LargeEntriesPagesPercentage);
+            Assert.AreEqual(0, metrics.PageFillFactor);
+            Assert.AreEqual(0, metrics.TotalAllocatedPages);
+        }
+
+        /// <summary>
+        /// Starts the ignite with two policies.
+        /// </summary>
+        private static IIgnite StartIgniteWithTwoPolicies()
+        {
+            var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                MemoryConfiguration = new MemoryConfiguration
+                {
+                    DefaultMemoryPolicyName = MemoryPolicyWithMetrics,
+                    MemoryPolicies = new[]
+                    {
+                        new MemoryPolicyConfiguration
+                        {
+                            Name = MemoryPolicyWithMetrics,
+                            MetricsEnabled = true
+                        },
+                        new MemoryPolicyConfiguration
+                        {
+                            Name = MemoryPolicyNoMetrics,
+                            MetricsEnabled = false
+                        }
+                    }
+                }
+            };
+
+            var ignite = Ignition.Start(cfg);
+
+            // Create caches and do some things with them.
+            var cacheNoMetrics = ignite.CreateCache<int, int>(new CacheConfiguration("cacheNoMetrics")
+            {
+                MemoryPolicyName = MemoryPolicyNoMetrics
+            });
+
+            cacheNoMetrics.Put(1, 1);
+            cacheNoMetrics.Get(1);
+
+            var cacheWithMetrics = ignite.CreateCache<int, int>(new CacheConfiguration("cacheWithMetrics")
+            {
+                MemoryPolicyName = MemoryPolicyWithMetrics
+            });
+
+            cacheWithMetrics.Put(1, 1);
+            cacheWithMetrics.Get(1);
+
+            return ignite;
+        }
+
+        /// <summary>
+        /// Tears down the test.
+        /// </summary>
+        [TearDown]
+        public void TearDown()
+        {
+            Ignition.StopAll(true);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index bc0321e..5bbf722 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -136,7 +136,7 @@ namespace Apache.Ignite.Core.Tests
                             <eventStorageSpi type='MemoryEventStorageSpi' expirationTimeout='00:00:23.45' maxEventCount='129' />
                             <memoryConfiguration concurrencyLevel='3' defaultMemoryPolicyName='dfPlc' pageSize='45' systemCacheInitialSize='67' systemCacheMaxSize='68'>
                                 <memoryPolicies>
-                                    <memoryPolicyConfiguration emptyPagesPoolSize='1' evictionThreshold='0.2' name='dfPlc' pageEvictionMode='RandomLru' initialSize='89' maxSize='98' swapFilePath='abc' />
+                                    <memoryPolicyConfiguration emptyPagesPoolSize='1' evictionThreshold='0.2' name='dfPlc' pageEvictionMode='RandomLru' initialSize='89' maxSize='98' swapFilePath='abc' metricsEnabled='true' />
                                 </memoryPolicies>
                             </memoryConfiguration>
                         </igniteConfig>";
@@ -272,6 +272,7 @@ namespace Apache.Ignite.Core.Tests
             Assert.AreEqual("abc", memPlc.SwapFilePath);
             Assert.AreEqual(89, memPlc.InitialSize);
             Assert.AreEqual(98, memPlc.MaxSize);
+            Assert.IsTrue(memPlc.MetricsEnabled);
         }
 
         /// <summary>
@@ -826,7 +827,8 @@ namespace Apache.Ignite.Core.Tests
                             PageEvictionMode = DataPageEvictionMode.RandomLru,
                             EvictionThreshold = 0.77,
                             EmptyPagesPoolSize = 66,
-                            SwapFilePath = "somePath2"
+                            SwapFilePath = "somePath2",
+                            MetricsEnabled = true
                         }
                     }
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
index ebca7c4..ae82d8a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -594,6 +594,7 @@ namespace Apache.Ignite.Core.Tests
                         {
                             Name = "myDefaultPlc",
                             PageEvictionMode = DataPageEvictionMode.Random2Lru,
+                            InitialSize = 340 * 1024 * 1024,
                             MaxSize = 345 * 1024 * 1024,
                             EvictionThreshold = 0.88,
                             EmptyPagesPoolSize = 77,
@@ -606,7 +607,8 @@ namespace Apache.Ignite.Core.Tests
                             MaxSize = 456 * 1024 * 1024,
                             EvictionThreshold = 0.77,
                             EmptyPagesPoolSize = 66,
-                            SwapFilePath = "somePath2"
+                            SwapFilePath = "somePath2",
+                            MetricsEnabled = true
                         } 
                     }
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 7cf79dd..fd6e5ec 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -95,6 +95,7 @@
     <Compile Include="Cache\Configuration\DataPageEvictionMode.cs" />
     <Compile Include="Cache\Configuration\MemoryPolicyConfiguration.cs" />
     <Compile Include="Cache\Configuration\PartitionLossPolicy.cs" />
+    <Compile Include="Cache\IMemoryMetrics.cs" />
     <Compile Include="Common\ExceptionFactory.cs" />
     <Compile Include="Events\IEventStorageSpi.cs" />
     <Compile Include="Events\MemoryEventStorageSpi.cs" />
@@ -196,6 +197,7 @@
     <Compile Include="Impl\Binary\ReflectionUtils.cs" />
     <Compile Include="Cache\Affinity\AffinityFunctionBase.cs" />
     <Compile Include="Impl\Binary\TypeNameParser.cs" />
+    <Compile Include="Impl\Cache\MemoryMetrics.cs" />
     <Compile Include="Impl\Cache\Store\CacheStore.cs" />
     <Compile Include="Impl\Cache\Store\ICacheStoreInternal.cs" />
     <Compile Include="Impl\Transactions\CacheTransactionManager.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
index e6e9153..1db9ea9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
@@ -71,6 +71,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
             PageEvictionMode = (DataPageEvictionMode) reader.ReadInt();
             EvictionThreshold = reader.ReadDouble();
             EmptyPagesPoolSize = reader.ReadInt();
+            MetricsEnabled = reader.ReadBoolean();
         }
 
         /// <summary>
@@ -85,6 +86,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
             writer.WriteInt((int) PageEvictionMode);
             writer.WriteDouble(EvictionThreshold);
             writer.WriteInt(EmptyPagesPoolSize);
+            writer.WriteBoolean(MetricsEnabled);
         }
 
         /// <summary>
@@ -140,5 +142,12 @@ namespace Apache.Ignite.Core.Cache.Configuration
         /// </summary>
         [DefaultValue(DefaultEmptyPagesPoolSize)]
         public int EmptyPagesPoolSize { get;set; }
+
+        /// <summary>
+        /// Gets or sets a value indicating whether memory metrics should be enabled.
+        /// <para />
+        /// Metrics can be retrieved with <see cref="IIgnite.GetMemoryMetrics"/> method.
+        /// </summary>
+        public bool MetricsEnabled { get; set; }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/platforms/dotnet/Apache.Ignite.Core/Cache/IMemoryMetrics.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/IMemoryMetrics.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/IMemoryMetrics.cs
new file mode 100644
index 0000000..0298c1f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/IMemoryMetrics.cs
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Cache
+{
+    /// <summary>
+    /// Memory usage metrics.
+    /// </summary>
+    public interface IMemoryMetrics
+    {
+        /// <summary>
+        /// Gets the memory policy name.
+        /// </summary>
+        string Name { get; }
+
+        /// <summary>
+        /// Gets the count of allocated pages.
+        /// </summary>
+        long TotalAllocatedPages { get; }
+
+        /// <summary>
+        /// Gets the allocation rate, in pages per second.
+        /// </summary>
+        float AllocationRate { get; }
+
+        /// <summary>
+        /// Gets the eviction rate, in pages per second.
+        /// </summary>
+        float EvictionRate { get; }
+
+        /// <summary>
+        /// Gets the percentage of pages fully occupied by entries that are larger than page.
+        /// </summary>
+        float LargeEntriesPagesPercentage { get; }
+
+        /// <summary>
+        /// Gets the page fill factor: free space to overall size ratio across all pages.
+        /// </summary>
+        float PageFillFactor { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
index 05a8ae3..863952b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -330,5 +330,12 @@ namespace Apache.Ignite.Core
         /// </summary>
         /// <param name="cacheNames">Names of caches to reset partitions for.</param>
         void ResetLostPartitions(params string[] cacheNames);
+
+        /// <summary>
+        /// Gets a collection of memory metrics, one for each <see cref="MemoryConfiguration.MemoryPolicies"/>.
+        /// <para />
+        /// Memory metrics should be enabled with <see cref="MemoryPolicyConfiguration.MetricsEnabled"/>.
+        /// </summary>
+        ICollection<IMemoryMetrics> GetMemoryMetrics();
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
index 253a33e..ad92661 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -1193,6 +1193,11 @@
                                                         <xs:documentation>Path to the memory-mapped file the memory region defined by this memory policy will be mapped to.</xs:documentation>
                                                     </xs:annotation>
                                                 </xs:attribute>
+                                                <xs:attribute name="metricsEnabled" type="xs:boolean">
+                                                    <xs:annotation>
+                                                        <xs:documentation>Enable memory metrics.</xs:documentation>
+                                                    </xs:annotation>
+                                                </xs:attribute>
                                             </xs:complexType>
                                         </xs:element>
                                     </xs:sequence>

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/MemoryMetrics.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/MemoryMetrics.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/MemoryMetrics.cs
new file mode 100644
index 0000000..ae9f85c
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/MemoryMetrics.cs
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Cache
+{
+    using System.Diagnostics;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Cache;
+
+    /// <summary>
+    /// Memory metrics.
+    /// </summary>
+    internal class MemoryMetrics : IMemoryMetrics
+    {
+        /// <summary>
+        /// Initializes a new instance of the <see cref="MemoryMetrics"/> class.
+        /// </summary>
+        public MemoryMetrics(IBinaryRawReader reader)
+        {
+            Debug.Assert(reader != null);
+
+            Name = reader.ReadString();
+            TotalAllocatedPages = reader.ReadLong();
+            AllocationRate = reader.ReadFloat();
+            EvictionRate = reader.ReadFloat();
+            LargeEntriesPagesPercentage = reader.ReadFloat();
+            PageFillFactor = reader.ReadFloat();
+        }
+
+        /** <inheritdoc /> */
+        public string Name { get; private set; }
+
+        /** <inheritdoc /> */
+        public long TotalAllocatedPages { get; private set; }
+
+        /** <inheritdoc /> */
+        public float AllocationRate { get; private set; }
+        
+        /** <inheritdoc /> */
+        public float EvictionRate { get; private set; }
+
+        /** <inheritdoc /> */
+        public float LargeEntriesPagesPercentage { get; private set; }
+
+        /** <inheritdoc /> */
+        public float PageFillFactor { get; private set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
index 7e97852..ad180ee 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
@@ -117,7 +117,10 @@ namespace Apache.Ignite.Core.Impl.Cluster
         
         /** */
         private const int OpResetLostPartitions = 25;
-        
+
+        /** */
+        private const int OpMemoryMetrics = 26;
+
         /** Initial Ignite instance. */
         private readonly Ignite _ignite;
         
@@ -553,6 +556,28 @@ namespace Apache.Ignite.Core.Impl.Cluster
         }
 
         /// <summary>
+        /// Gets the memory metrics.
+        /// </summary>
+        public ICollection<IMemoryMetrics> GetMemoryMetrics()
+        {
+            return DoInOp(OpMemoryMetrics, stream =>
+            {
+                IBinaryRawReader reader = Marshaller.StartUnmarshal(stream, false);
+
+                var cnt = reader.ReadInt();
+
+                var res = new List<IMemoryMetrics>(cnt);
+
+                for (int i = 0; i < cnt; i++)
+                {
+                    res.Add(new MemoryMetrics(reader));
+                }
+
+                return res;
+            });
+        }
+
+        /// <summary>
         /// Creates new Cluster Group from given native projection.
         /// </summary>
         /// <param name="prj">Native projection.</param>

http://git-wip-us.apache.org/repos/asf/ignite/blob/73fc01c4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index 8fa1f6a..b392f9c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -731,6 +731,12 @@ namespace Apache.Ignite.Core.Impl
             ResetLostPartitions((IEnumerable<string>) cacheNames);
         }
 
+        /** <inheritdoc /> */
+        public ICollection<IMemoryMetrics> GetMemoryMetrics()
+        {
+            return _prj.GetMemoryMetrics();
+        }
+
         /// <summary>
         /// Gets or creates near cache.
         /// </summary>


[02/17] ignite git commit: Merge remote-tracking branch 'origin/master'

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


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

Branch: refs/heads/ignite-5075
Commit: 5b16b51c8779ed3d129ac45621e73dd903fe65dd
Parents: 8195ae0 feda3ff
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Mon May 15 18:03:30 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Mon May 15 18:03:30 2017 +0300

----------------------------------------------------------------------
 .../DistributedRegressionExample.java           | 149 ++++++++++++
 .../processors/cache/GridCacheAdapter.java      |  71 +-----
 .../cache/GridCacheConcurrentMap.java           |   7 +-
 .../cache/GridCacheConcurrentMapImpl.java       |  30 +--
 .../processors/cache/GridCacheProxyImpl.java    |  60 -----
 .../processors/cache/GridNoStorageCacheMap.java |   7 +-
 .../processors/cache/IgniteInternalCache.java   |  61 -----
 .../dht/GridCachePartitionedConcurrentMap.java  |  13 +-
 .../distributed/dht/GridDhtCacheAdapter.java    | 162 -------------
 .../distributed/dht/GridDhtLocalPartition.java  |   4 +-
 .../dht/GridDhtPartitionTopologyImpl.java       |   2 +-
 .../distributed/near/GridNearCacheAdapter.java  |  17 --
 .../processors/cache/GridCacheLeakTest.java     |   4 +-
 .../GridCachePartitionedFullApiSelfTest.java    |  18 --
 .../cache/eviction/EvictionAbstractTest.java    |  13 +-
 .../IgniteCacheClientNearCacheExpiryTest.java   |   2 +-
 .../hadoop/jobtracker/HadoopJobTracker.java     |  20 +-
 .../cache/hibernate/HibernateCacheProxy.java    |  25 --
 .../apache/ignite/ml/math/util/MatrixUtil.java  |   3 +-
 .../org/apache/ignite/ml/IgniteMLTestSuite.java |  35 +++
 .../ml/math/MathImplDistributedTestSuite.java   |   2 +-
 .../ignite/ml/math/MathImplLocalTestSuite.java  |   7 +-
 .../ignite/ml/math/MathImplMainTestSuite.java   |   2 +-
 .../OLSMultipleLinearRegressionTest.java        |   7 +
 .../ml/regressions/RegressionsTestSuite.java    |  32 +++
 .../Binary/BinarySelfTest.cs                    |  26 ++
 .../Impl/Binary/BinaryReflectiveActions.cs      |   6 +-
 .../BinaryReflectiveSerializerInternal.cs       |   9 +-
 .../Impl/Binary/BinaryUtils.cs                  |   9 -
 .../Binary/DeserializationCallbackProcessor.cs  |  11 +
 .../Impl/Binary/SerializableSerializer.cs       |  10 +-
 .../activities-user-dialog.tpl.pug              |  33 +--
 .../components/web-console-header/style.scss    |   9 -
 .../frontend/app/primitives/btn/index.scss      | 235 +++++++++++++++++++
 .../frontend/app/primitives/index.js            |   2 +
 .../frontend/app/primitives/modal/index.scss    | 179 ++++++++++++++
 .../frontend/app/primitives/table/index.scss    |  91 +++++++
 .../frontend/public/stylesheets/style.scss      |  99 ++------
 .../frontend/public/stylesheets/variables.scss  |   4 +
 .../frontend/views/includes/header-right.pug    |   4 +-
 .../web-console/frontend/views/signin.tpl.pug   |   2 +-
 41 files changed, 864 insertions(+), 618 deletions(-)
----------------------------------------------------------------------



[13/17] ignite git commit: Merge remote-tracking branch 'remotes/origin/master' into ignite-5075-cacheStart

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


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

Branch: refs/heads/ignite-5075
Commit: 335216b0a581afda26fe6aa1c7a587659b36df48
Parents: 664b749 7a4a194
Author: sboikov <sb...@gridgain.com>
Authored: Wed May 17 10:57:49 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed May 17 10:57:49 2017 +0300

----------------------------------------------------------------------
 .../frontend/app/components/web-console-footer/style.scss | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------



[04/17] ignite git commit: IGNITE-5225: Fix NPE caused by changes in IGNITE-4577.

Posted by sb...@apache.org.
IGNITE-5225: Fix NPE caused by changes in IGNITE-4577.

(cherry picked from commit d463840)


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

Branch: refs/heads/ignite-5075
Commit: 95850b47bde6df109ecd029d6a3a59b8e3772f81
Parents: dacf973
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Mon May 15 20:24:10 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Tue May 16 12:27:26 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/util/IgniteUtils.java   |  4 ++--
 .../spi/communication/tcp/TcpCommunicationSpi.java | 17 +++++++++++------
 2 files changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/95850b47/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 bef7b98..0668708 100644
--- 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
@@ -1858,11 +1858,11 @@ public abstract class IgniteUtils {
      * @return List of reachable addresses.
      */
     public static List<InetAddress> filterReachable(Collection<InetAddress> addrs) {
-        final int reachTimeout = 2000;
-
         if (addrs.isEmpty())
             return Collections.emptyList();
 
+        final int reachTimeout = 2000;
+
         if (addrs.size() == 1) {
             InetAddress addr = F.first(addrs);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/95850b47/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 be897d6..769a02e 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
@@ -2885,22 +2885,27 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
 
         Set<InetAddress> allInetAddrs = U.newHashSet(addrs.size());
 
-        for (InetSocketAddress addr : addrs)
-            allInetAddrs.add(addr.getAddress());
+        for (InetSocketAddress addr : addrs) {
+            // Skip unresolved as addr.getAddress() can return null.
+            if(!addr.isUnresolved())
+                allInetAddrs.add(addr.getAddress());
+        }
 
         List<InetAddress> reachableInetAddrs = U.filterReachable(allInetAddrs);
 
         if (reachableInetAddrs.size() < allInetAddrs.size()) {
             LinkedHashSet<InetSocketAddress> addrs0 = U.newLinkedHashSet(addrs.size());
 
+            List<InetSocketAddress> unreachableInetAddr = new ArrayList<>(allInetAddrs.size() - reachableInetAddrs.size());
+
             for (InetSocketAddress addr : addrs) {
                 if (reachableInetAddrs.contains(addr.getAddress()))
                     addrs0.add(addr);
+                else
+                    unreachableInetAddr.add(addr);
             }
-            for (InetSocketAddress addr : addrs) {
-                if (!reachableInetAddrs.contains(addr.getAddress()))
-                    addrs0.add(addr);
-            }
+
+            addrs0.addAll(unreachableInetAddr);
 
             addrs = addrs0;
         }


[05/17] ignite git commit: DirectByteBufferStreamImpl: converted asserts into exceptions.

Posted by sb...@apache.org.
DirectByteBufferStreamImpl: converted asserts into exceptions.

(cherry picked from commit 560ef60)


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

Branch: refs/heads/ignite-5075
Commit: 88593b6dd872a5ce7d157d75ece907b628736a99
Parents: 95850b4
Author: sboikov <sb...@gridgain.com>
Authored: Tue May 16 11:30:29 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue May 16 13:29:36 2017 +0300

----------------------------------------------------------------------
 .../stream/v2/DirectByteBufferStreamImplV2.java | 27 +++++++++++++-------
 1 file changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/88593b6d/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
index 9464186..c92c470 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
@@ -1,4 +1,4 @@
-/*
+ /*
  * 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.
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.RandomAccess;
 import java.util.UUID;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
 import org.apache.ignite.internal.util.GridUnsafe;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -80,7 +81,8 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** */
     private static final ArrayCreator<byte[]> BYTE_ARR_CREATOR = new ArrayCreator<byte[]>() {
         @Override public byte[] create(int len) {
-            assert len >= 0;
+            if (len < 0)
+                throw new IgniteException("Read invalid byte array length: " + len);
 
             switch (len) {
                 case 0:
@@ -95,7 +97,8 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** */
     private static final ArrayCreator<short[]> SHORT_ARR_CREATOR = new ArrayCreator<short[]>() {
         @Override public short[] create(int len) {
-            assert len >= 0;
+            if (len < 0)
+                throw new IgniteException("Read invalid short array length: " + len);
 
             switch (len) {
                 case 0:
@@ -110,7 +113,8 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** */
     private static final ArrayCreator<int[]> INT_ARR_CREATOR = new ArrayCreator<int[]>() {
         @Override public int[] create(int len) {
-            assert len >= 0;
+            if (len < 0)
+                throw new IgniteException("Read invalid int array length: " + len);
 
             switch (len) {
                 case 0:
@@ -125,7 +129,8 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** */
     private static final ArrayCreator<long[]> LONG_ARR_CREATOR = new ArrayCreator<long[]>() {
         @Override public long[] create(int len) {
-            assert len >= 0;
+            if (len < 0)
+                throw new IgniteException("Read invalid long array length: " + len);
 
             switch (len) {
                 case 0:
@@ -140,7 +145,8 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** */
     private static final ArrayCreator<float[]> FLOAT_ARR_CREATOR = new ArrayCreator<float[]>() {
         @Override public float[] create(int len) {
-            assert len >= 0;
+            if (len < 0)
+                throw new IgniteException("Read invalid float array length: " + len);
 
             switch (len) {
                 case 0:
@@ -155,7 +161,8 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** */
     private static final ArrayCreator<double[]> DOUBLE_ARR_CREATOR = new ArrayCreator<double[]>() {
         @Override public double[] create(int len) {
-            assert len >= 0;
+            if (len < 0)
+                throw new IgniteException("Read invalid double array length: " + len);
 
             switch (len) {
                 case 0:
@@ -170,7 +177,8 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** */
     private static final ArrayCreator<char[]> CHAR_ARR_CREATOR = new ArrayCreator<char[]>() {
         @Override public char[] create(int len) {
-            assert len >= 0;
+            if (len < 0)
+                throw new IgniteException("Read invalid char array length: " + len);
 
             switch (len) {
                 case 0:
@@ -185,7 +193,8 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
     /** */
     private static final ArrayCreator<boolean[]> BOOLEAN_ARR_CREATOR = new ArrayCreator<boolean[]>() {
         @Override public boolean[] create(int len) {
-            assert len >= 0;
+            if (len < 0)
+                throw new IgniteException("Read invalid boolean array length: " + len);
 
             switch (len) {
                 case 0:


[03/17] ignite git commit: Fixed thread pools incorrect shutdown.

Posted by sb...@apache.org.
Fixed thread pools incorrect shutdown.


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

Branch: refs/heads/ignite-5075
Commit: dacf973ef8580ff649fc2dafd5a55a420edf7759
Parents: 5b16b51
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Mon May 15 17:39:52 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Tue May 16 12:25:44 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      | 12 +++---
 .../ignite/internal/util/IgniteUtils.java       | 45 +++++++++++---------
 2 files changed, 30 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dacf973e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 0ad383b..ee7af80 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -1062,14 +1062,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         if (!F.isEmpty(jobs)) {
             ExecutorService execSvc = null;
 
-            if (jobs.size() > 1) {
-                execSvc = Executors.newFixedThreadPool(jobs.size() - 1);
+            try {
+                if (jobs.size() > 1) {
+                    execSvc = Executors.newFixedThreadPool(jobs.size() - 1);
 
-                for (int i = 1; i < jobs.size(); i++)
-                    execSvc.execute(jobs.get(i));
-            }
+                    for (int i = 1; i < jobs.size(); i++)
+                        execSvc.execute(jobs.get(i));
+                }
 
-            try {
                 jobs.get(0).run();
             }
             finally {

http://git-wip-us.apache.org/repos/asf/ignite/blob/dacf973e/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 6f8728c..bef7b98 100644
--- 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
@@ -1878,33 +1878,36 @@ public abstract class IgniteUtils {
 
         ExecutorService executor = Executors.newFixedThreadPool(Math.min(10, addrs.size()));
 
-        for (final InetAddress addr : addrs) {
-            futs.add(executor.submit(new Runnable() {
-                @Override public void run() {
-                    if (reachable(addr, reachTimeout)) {
-                        synchronized (res) {
-                            res.add(addr);
+        try {
+            for (final InetAddress addr : addrs) {
+                futs.add(executor.submit(new Runnable() {
+                    @Override public void run() {
+                        if (reachable(addr, reachTimeout)) {
+                            synchronized (res) {
+                                res.add(addr);
+                            }
                         }
                     }
-                }
-            }));
-        }
-
-        for (Future<?> fut : futs) {
-            try {
-                fut.get();
+                }));
             }
-            catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
 
-                throw new IgniteException("Thread has been interrupted.", e);
-            }
-            catch (ExecutionException e) {
-                throw new IgniteException(e);
+            for (Future<?> fut : futs) {
+                try {
+                    fut.get();
+                }
+                catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+
+                    throw new IgniteException("Thread has been interrupted.", e);
+                }
+                catch (ExecutionException e) {
+                    throw new IgniteException(e);
+                }
             }
         }
-
-        executor.shutdown();
+        finally {
+            executor.shutdown();
+        }
 
         return res;
     }


[17/17] ignite git commit: ignite-5075

Posted by sb...@apache.org.
ignite-5075


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

Branch: refs/heads/ignite-5075
Commit: 5bbd7c4475a3375bb6b7b83e605980a3421f334e
Parents: 3ef96bc
Author: sboikov <sb...@gridgain.com>
Authored: Wed May 17 13:32:22 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed May 17 13:32:22 2017 +0300

----------------------------------------------------------------------
 .../discovery/GridDiscoveryManager.java         |   8 +
 .../cache/CacheAffinitySharedManager.java       |   2 +-
 .../processors/cache/CacheGroupData.java        |  10 ++
 .../processors/cache/CacheGroupDescriptor.java  |  32 +++-
 .../processors/cache/ClusterCachesInfo.java     |  65 +++++--
 .../processors/cache/GridCacheContext.java      |   9 +
 .../processors/cache/GridCacheIoManager.java    |  28 ++-
 .../processors/cache/GridCacheProcessor.java    |  26 +--
 .../distributed/dht/GridDhtLocalPartition.java  |   4 +-
 .../dht/preloader/GridDhtPartitionDemander.java |   2 +-
 .../processors/cache/IgniteCacheGroupsTest.java | 178 +++++++++++++++----
 .../CacheDiscoveryDataConcurrentJoinTest.java   |  17 ++
 .../CacheLateAffinityAssignmentTest.java        |   2 +-
 .../junits/common/GridCommonAbstractTest.java   |  64 +++++++
 14 files changed, 360 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/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 c3d12c6..a46f616 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
@@ -304,6 +304,14 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
     }
 
     /**
+     *
+     */
+    public void onLocalNodeJoin() {
+        registeredCacheGrps.clear();
+        registeredCaches.clear();
+    }
+
+    /**
      * @param grpDesc Cache group descriptor.
      * @param filter Node filter.
      * @param cacheMode Cache mode.

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/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 a20719d..55f56e75 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
@@ -133,7 +133,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
 
             lastAffVer = null;
 
-            for (CacheGroupDescriptor desc : cctx.cache().cacheGroupDescriptors())
+            for (CacheGroupDescriptor desc : cctx.cache().cacheGroupDescriptors().values())
                 registeredGrps.put(desc.groupId(), desc);
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java
index 7cf7349..96525a0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
 import java.util.Map;
 import java.util.UUID;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteUuid;
@@ -40,6 +41,9 @@ public class CacheGroupData implements Serializable {
     private final int grpId;
 
     /** */
+    private AffinityTopologyVersion startTopVer;
+
+    /** */
     private final UUID rcvdFrom;
 
     /** */
@@ -65,6 +69,7 @@ public class CacheGroupData implements Serializable {
         @Nullable String grpName,
         int grpId,
         UUID rcvdFrom,
+        AffinityTopologyVersion startTopVer,
         IgniteUuid deploymentId,
         Map<String, Integer> caches) {
         assert cacheCfg != null;
@@ -75,10 +80,15 @@ public class CacheGroupData implements Serializable {
         this.grpName = grpName;
         this.grpId = grpId;
         this.rcvdFrom = rcvdFrom;
+        this.startTopVer = startTopVer;
         this.deploymentId = deploymentId;
         this.caches = caches;
     }
 
+    public AffinityTopologyVersion startTopologyVersion() {
+        return startTopVer;
+    }
+
     public UUID receivedFrom() {
         return rcvdFrom;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java
index e503f4c..9ac9584 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupDescriptor.java
@@ -21,6 +21,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteUuid;
@@ -49,6 +50,12 @@ public class CacheGroupDescriptor {
     /** */
     private final UUID rcvdFrom;
 
+    /** */
+    private AffinityTopologyVersion startTopVer;
+
+    /** */
+    private AffinityTopologyVersion rcvdFromVer;
+
     /**
      * @param cacheCfg Cache configuration.
      * @param grpName Group name.
@@ -62,6 +69,7 @@ public class CacheGroupDescriptor {
         @Nullable String grpName,
         int grpId,
         UUID rcvdFrom,
+        AffinityTopologyVersion startTopVer,
         IgniteUuid deploymentId,
         Map<String, Integer> caches) {
         assert cacheCfg != null;
@@ -70,6 +78,7 @@ public class CacheGroupDescriptor {
         this.grpName = grpName;
         this.grpId = grpId;
         this.rcvdFrom = rcvdFrom;
+        this.startTopVer = startTopVer;
         this.deploymentId = deploymentId;
         this.cacheCfg = cacheCfg;
         this.caches = caches;
@@ -127,10 +136,31 @@ public class CacheGroupDescriptor {
         return cacheCfg;
     }
 
-    Map<String, Integer> caches() {
+    public Map<String, Integer> caches() {
         return caches;
     }
 
+    /**
+     * @return Topology version when node provided cache configuration was started.
+     */
+    @Nullable public AffinityTopologyVersion receivedFromStartVersion() {
+        return rcvdFromVer;
+    }
+
+    /**
+     * @param rcvdFromVer Topology version when node provided cache configuration was started.
+     */
+    public void receivedFromStartVersion(AffinityTopologyVersion rcvdFromVer) {
+        this.rcvdFromVer = rcvdFromVer;
+    }
+
+    /**
+     * @return Start topology version.
+     */
+    @Nullable public AffinityTopologyVersion startTopologyVersion() {
+        return startTopVer;
+    }
+
     @Override public String toString() {
         return S.toString(CacheGroupDescriptor.class, this);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index 2f489ab..395e0d1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@ -144,6 +144,9 @@ class ClusterCachesInfo {
         CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "cacheMode", "Cache mode",
             locAttr.cacheMode(), rmtAttr.cacheMode(), true);
 
+        CU.checkAttributeMismatch(log, rmtCfg.getGroupName(), rmt, "groupName", "Group name",
+            locCfg.getGroupName(), rmtCfg.getGroupName(), true);
+
         if (rmtAttr.cacheMode() != LOCAL) {
             CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "interceptor", "Cache Interceptor",
                 locAttr.interceptorClassName(), rmtAttr.interceptorClassName(), true);
@@ -294,6 +297,7 @@ class ClusterCachesInfo {
                         int cacheId = CU.cacheId(req.cacheName());
 
                         CacheGroupDescriptor grpDesc = registerCacheGroup(exchangeActions,
+                            topVer,
                             ccfg,
                             cacheId,
                             req.initiatingNodeId(),
@@ -574,6 +578,11 @@ class ClusterCachesInfo {
      */
     void onDiscoveryEvent(int type, ClusterNode node, AffinityTopologyVersion topVer) {
         if (type == EVT_NODE_JOINED && !ctx.isDaemon()) {
+            for (CacheGroupDescriptor desc : registeredCacheGrps.values()) {
+                if (node.id().equals(desc.receivedFrom()))
+                    desc.receivedFromStartVersion(topVer);
+            }
+
             for (DynamicCacheDescriptor desc : registeredCaches.values()) {
                 if (node.id().equals(desc.receivedFrom()))
                     desc.receivedFromStartVersion(topVer);
@@ -609,6 +618,20 @@ class ClusterCachesInfo {
      * @return Information about started caches.
      */
     private CacheNodeCommonDiscoveryData collectCommonDiscoveryData() {
+        Map<Integer, CacheGroupData> cacheGrps = new HashMap<>();
+
+        for (CacheGroupDescriptor grpDesc : registeredCacheGrps.values()) {
+            CacheGroupData grpData = new CacheGroupData(grpDesc.config(),
+                grpDesc.groupName(),
+                grpDesc.groupId(),
+                grpDesc.receivedFrom(),
+                grpDesc.startTopologyVersion(),
+                grpDesc.deploymentId(),
+                grpDesc.caches());
+
+            cacheGrps.put(grpDesc.groupId(), grpData);
+        }
+
         Map<String, CacheData> caches = new HashMap<>();
 
         for (DynamicCacheDescriptor desc : registeredCaches.values()) {
@@ -626,19 +649,6 @@ class ClusterCachesInfo {
             caches.put(desc.cacheName(), cacheData);
         }
 
-        Map<Integer, CacheGroupData> cacheGrps = new HashMap<>();
-
-        for (CacheGroupDescriptor grpDesc : registeredCacheGrps.values()) {
-            CacheGroupData grpData = new CacheGroupData(grpDesc.config(),
-                grpDesc.groupName(),
-                grpDesc.groupId(),
-                grpDesc.receivedFrom(),
-                grpDesc.deploymentId(),
-                grpDesc.caches());
-
-            cacheGrps.put(grpDesc.groupId(), grpData);
-        }
-
         Map<String, CacheData> templates = new HashMap<>();
 
         for (DynamicCacheDescriptor desc : registeredTemplates.values()) {
@@ -679,12 +689,17 @@ class ClusterCachesInfo {
 
         assert cacheGrpIdGen > 0 : cacheGrpIdGen;
 
+        registeredCaches.clear();
+        registeredCacheGrps.clear();
+        ctx.discovery().onLocalNodeJoin();
+
         for (CacheGroupData grpData : cachesData.cacheGroups().values()) {
             CacheGroupDescriptor grpDesc = new CacheGroupDescriptor(
                 grpData.config(),
                 grpData.groupName(),
                 grpData.groupId(),
                 grpData.receivedFrom(),
+                grpData.startTopologyVersion(),
                 grpData.deploymentId(),
                 grpData.caches());
 
@@ -780,6 +795,7 @@ class ClusterCachesInfo {
                     DynamicCacheDescriptor desc0 = new DynamicCacheDescriptor(ctx,
                             locCfg.config(),
                             desc.cacheType(),
+                            desc.groupDescriptor(),
                             desc.template(),
                             desc.receivedFrom(),
                             desc.staticallyConfigured(),
@@ -872,11 +888,17 @@ class ClusterCachesInfo {
                 int cacheId = CU.cacheId(cfg.getName());
 
                 CacheGroupDescriptor grpDesc = registerCacheGroup(null,
+                    null,
                     cfg,
                     cacheId,
                     nodeId,
                     joinData.cacheDeploymentId());
 
+                ctx.discovery().setCacheFilter(
+                    grpDesc.groupId(),
+                    cfg.getName(),
+                    cfg.getNearConfiguration() != null);
+
                 DynamicCacheDescriptor desc = new DynamicCacheDescriptor(ctx,
                     cfg,
                     cacheInfo.cacheType(),
@@ -890,11 +912,6 @@ class ClusterCachesInfo {
                 DynamicCacheDescriptor old = registeredCaches.put(cfg.getName(), desc);
 
                 assert old == null : old;
-
-                ctx.discovery().setCacheFilter(
-                    grpDesc.groupId(),
-                    cfg.getName(),
-                    cfg.getNearConfiguration() != null);
             }
 
             ctx.discovery().addClientNode(cfg.getName(), nodeId, cfg.getNearConfiguration() != null);
@@ -939,8 +956,17 @@ class ClusterCachesInfo {
         return null;
     }
 
+    /**
+     * @param exchActions
+     * @param startedCacheCfg
+     * @param cacheId
+     * @param rcvdFrom
+     * @param deploymentId
+     * @return
+     */
     private CacheGroupDescriptor registerCacheGroup(
-        ExchangeActions exchActions,
+        @Nullable ExchangeActions exchActions,
+        @Nullable AffinityTopologyVersion curTopVer,
         CacheConfiguration startedCacheCfg,
         Integer cacheId,
         UUID rcvdFrom,
@@ -964,6 +990,7 @@ class ClusterCachesInfo {
             startedCacheCfg.getGroupName(),
             grpId,
             rcvdFrom,
+            curTopVer != null ? curTopVer.nextMinorVersion() : null,
             deploymentId,
             caches);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/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 47ff283..2d5a046 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
@@ -860,6 +860,15 @@ public class GridCacheContext<K, V> implements Externalizable {
         return topology(cache);
     }
 
+    public GridDhtCacheAdapter dhtCache() {
+        GridCacheAdapter<K, V> cache = this.cache;
+
+        if (cache == null)
+            throw new IllegalStateException("Cache stopped: " + cacheName);
+
+        return isNear() ? ((GridNearCacheAdapter<K, V>)cache).dht() : dht();
+    }
+
     /**
      * @return Topology version future.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index 3c1ab93..c4462c9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -139,24 +139,20 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
 
             if (cacheMsg.partitionExchangeMessage()) {
                 if (cacheMsg instanceof GridDhtAffinityAssignmentRequest) {
+                    GridDhtAffinityAssignmentRequest msg0 = (GridDhtAffinityAssignmentRequest)cacheMsg;
+
                     assert cacheMsg.topologyVersion() != null : cacheMsg;
 
-                    // TODO IGNITE-5075.
-                    AffinityTopologyVersion startTopVer = null;//cctx.affinity().localStartVersion(((GridDhtAffinityAssignmentRequest) cacheMsg).groupId());
-
-                    if (startTopVer == null)
-                        startTopVer = new AffinityTopologyVersion(cctx.localNode().order());
-
-//                    AffinityTopologyVersion startTopVer = new AffinityTopologyVersion(cctx.localNode().order());
-//
-//                    DynamicCacheDescriptor cacheDesc = cctx.cache().cacheDescriptor(cacheMsg.cacheId());
-//
-//                    if (cacheDesc != null) {
-//                        if (cacheDesc.startTopologyVersion() != null)
-//                            startTopVer = cacheDesc.startTopologyVersion();
-//                        else if (cacheDesc.receivedFromStartVersion() != null)
-//                            startTopVer = cacheDesc.receivedFromStartVersion();
-//                    }
+                    AffinityTopologyVersion startTopVer = new AffinityTopologyVersion(cctx.localNode().order());
+
+                    CacheGroupDescriptor desc = cctx.cache().cacheGroupDescriptors().get(msg0.groupId());
+
+                    if (desc != null) {
+                        if (desc.startTopologyVersion() != null)
+                            startTopVer = desc.startTopologyVersion();
+                        else if (desc.receivedFromStartVersion() != null)
+                            startTopVer = desc.receivedFromStartVersion();
+                    }
 
                     // Need to wait for exchange to avoid race between cache start and affinity request.
                     fut = cctx.exchange().affinityReadyFuture(startTopVer);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 8c55cc9..ef9a2cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -827,7 +827,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 for (CacheConfiguration conf : ctx.config().getCacheConfiguration()) {
                     assert conf.getName() != null;
 
-                    for (DynamicCacheDescriptor desc : cacheDescriptors()) {
+                    for (DynamicCacheDescriptor desc : cacheDescriptors().values()) {
                         CacheConfiguration c = desc.cacheConfiguration();
                         IgnitePredicate filter = c.getNodeFilter();
 
@@ -1217,8 +1217,12 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         cacheCtx.onStarted();
 
-        if (log.isInfoEnabled())
-            log.info("Started cache [name=" + U.maskName(cfg.getName()) + ", memoryPolicyName=" + cfg.getMemoryPolicyName() + ", mode=" + cfg.getCacheMode() + ']');
+        if (log.isInfoEnabled()) {
+            log.info("Started cache [name=" + cfg.getName() +
+                (cfg.getGroupName() != null ? ", group=" + cfg.getGroupName() : "") +
+                ", memoryPolicyName=" + cfg.getMemoryPolicyName() +
+                ", mode=" + cfg.getCacheMode() + ']');
+        }
     }
 
     /**
@@ -1684,7 +1688,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @return Collection of started cache names.
      */
     public Collection<String> cacheNames() {
-        return F.viewReadOnly(cacheDescriptors(), new IgniteClosure<DynamicCacheDescriptor, String>() {
+        return F.viewReadOnly(cacheDescriptors().values(), new IgniteClosure<DynamicCacheDescriptor, String>() {
             @Override public String apply(DynamicCacheDescriptor desc) {
                 return desc.cacheConfiguration().getName();
             }
@@ -1733,7 +1737,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @return Collection of currently started public cache names
      */
     public Collection<String> publicCacheNames() {
-        return F.viewReadOnly(cacheDescriptors(),
+        return F.viewReadOnly(cacheDescriptors().values(),
             new IgniteClosure<DynamicCacheDescriptor, String>() {
                 @Override public String apply(DynamicCacheDescriptor desc) {
                     return desc.cacheConfiguration().getName();
@@ -2809,7 +2813,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      */
     @Nullable private IgniteNodeValidationResult validateHashIdResolvers(ClusterNode node) {
         if (!node.isClient()) {
-            for (DynamicCacheDescriptor desc : cacheDescriptors()) {
+            for (DynamicCacheDescriptor desc : cacheDescriptors().values()) {
                 CacheConfiguration cfg = desc.cacheConfiguration();
 
                 if (cfg.getAffinity() instanceof RendezvousAffinityFunction) {
@@ -3086,12 +3090,12 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     /**
      * @return Cache descriptors.
      */
-    public Collection<DynamicCacheDescriptor> cacheDescriptors() {
-        return cachesInfo.registeredCaches().values();
+    public Map<String, DynamicCacheDescriptor> cacheDescriptors() {
+        return cachesInfo.registeredCaches();
     }
 
-    public Collection<CacheGroupDescriptor> cacheGroupDescriptors() {
-        return cachesInfo.registeredCacheGroups().values();
+    public Map<Integer, CacheGroupDescriptor> cacheGroupDescriptors() {
+        return cachesInfo.registeredCacheGroups();
     }
 
     /**
@@ -3099,7 +3103,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @return Cache descriptor.
      */
     @Nullable public DynamicCacheDescriptor cacheDescriptor(int cacheId) {
-        for (DynamicCacheDescriptor cacheDesc : cacheDescriptors()) {
+        for (DynamicCacheDescriptor cacheDesc : cacheDescriptors().values()) {
             CacheConfiguration ccfg = cacheDesc.cacheConfiguration();
 
             assert ccfg != null : cacheDesc;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 72f67f7..5cb48ad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -1015,7 +1015,7 @@ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements
         }
 
         if (!grp.allowFastEviction()) {
-            GridCacheContext cctx = grp.sharedGroup() ? null : grp.singleCacheContext();
+            GridCacheContext cctx = grp.sharedGroup() ? null : grp.singleCacheContext().dhtCache().context();
 
             try {
                 GridIterator<CacheDataRow> it0 = grp.offheap().partitionIterator(id);
@@ -1027,7 +1027,7 @@ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements
                         CacheDataRow row = it0.next();
 
                         if (grp.sharedGroup() && (cctx == null || cctx.cacheId() != row.cacheId()))
-                            cctx = ctx.cacheContext(row.cacheId());
+                            cctx = ctx.cacheContext(row.cacheId()).dhtCache().context();
 
                         GridCacheMapEntry cached = putEntryIfObsoleteOrAbsent(cctx,
                             grp.affinity().lastVersion(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/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 fbe0aaa..1e24ec3 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
@@ -740,7 +740,7 @@ public class GridDhtPartitionDemander {
             try {
                 GridCacheContext cctx = grp.sharedGroup() ? ctx.cacheContext(entry.cacheId()) : grp.singleCacheContext();
 
-                cached = cctx.dht().entryEx(entry.key());
+                cached = cctx.dhtCache().entryEx(entry.key());
 
                 if (log.isDebugEnabled())
                     log.debug("Rebalancing key [key=" + entry.key() + ", part=" + p + ", node=" + pick.id() + ']');

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
index 601ebed..aa1fcff 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
@@ -37,6 +37,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CachePeekMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
@@ -78,6 +79,9 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
     /** */
     private boolean client;
 
+    /** */
+    private CacheConfiguration[] ccfgs;
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -90,6 +94,12 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
 
         cfg.setMarshaller(null);
 
+        if (ccfgs != null) {
+            cfg.setCacheConfiguration(ccfgs);
+
+            ccfgs = null;
+        }
+
         return cfg;
     }
 
@@ -155,6 +165,8 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
     private void createDestroyCaches(int srvs) throws Exception {
         startGridsMultiThreaded(srvs);
 
+        checkCacheDiscoveryDataConsistent();
+
         Ignite srv0 = ignite(0);
 
         for (int i = 0; i < srvs; i++)
@@ -165,6 +177,8 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
 
             srv0.createCache(cacheConfiguration(GROUP1, "cache1", PARTITIONED, ATOMIC, 2, false));
 
+            checkCacheDiscoveryDataConsistent();
+
             for (int i = 0; i < srvs; i++) {
                 checkCacheGroup(i, GROUP1, true);
 
@@ -173,6 +187,8 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
 
             srv0.createCache(cacheConfiguration(GROUP1, "cache2", PARTITIONED, ATOMIC, 2, false));
 
+            checkCacheDiscoveryDataConsistent();
+
             for (int i = 0; i < srvs; i++) {
                 checkCacheGroup(i, GROUP1, true);
 
@@ -181,6 +197,8 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
 
             srv0.destroyCache("cache1");
 
+            checkCacheDiscoveryDataConsistent();
+
             for (int i = 0; i < srvs; i++) {
                 checkCacheGroup(i, GROUP1, true);
 
@@ -189,6 +207,8 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
 
             srv0.destroyCache("cache2");
 
+            checkCacheDiscoveryDataConsistent();
+
             for (int i = 0; i < srvs; i++)
                 checkCacheGroup(i, GROUP1, false);
         }
@@ -213,66 +233,154 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @return Cache configurations.
+     */
+    private CacheConfiguration[] staticConfigurations1(boolean cache3) {
+        CacheConfiguration[] ccfgs = new CacheConfiguration[cache3 ? 3 : 2];
+
+        ccfgs[0] = cacheConfiguration(null, "cache1", PARTITIONED, ATOMIC, 2, false);
+        ccfgs[1] = cacheConfiguration(GROUP1, "cache2", PARTITIONED, ATOMIC, 2, false);
+
+        if (cache3)
+            ccfgs[2] = cacheConfiguration(GROUP1, "cache3", PARTITIONED, ATOMIC, 2, false);
+
+        return ccfgs;
+    }
+
+    /**
      * @throws Exception If failed.
      */
-    public void testCreateCache1() throws Exception {
+    public void testDiscoveryDataConsistency1() throws Exception {
+        ccfgs = staticConfigurations1(true);
         Ignite srv0 = startGrid(0);
 
-        {
-            IgniteCache<Object, Object> cache1 =
-                srv0.createCache(cacheConfiguration("grp1", "cache1", PARTITIONED, ATOMIC, 2, false));
-            IgniteCache<Object, Object> cache2 =
-                srv0.createCache(cacheConfiguration("grp1", "cache2", PARTITIONED, ATOMIC, 2, false));
+        ccfgs = staticConfigurations1(true);
+        startGrid(1);
 
-            cache1.put(new Key1(1), 1);
-            assertEquals(1, cache1.get(new Key1(1)));
+        checkCacheDiscoveryDataConsistent();
 
-            assertEquals(1, cache1.size());
-            assertEquals(0, cache2.size());
-            //assertFalse(cache2.iterator().hasNext());
+        ccfgs = null;
+        startGrid(2);
 
-            cache2.put(new Key2(1), 2);
-            assertEquals(2, cache2.get(new Key2(1)));
+        checkCacheDiscoveryDataConsistent();
 
-            assertEquals(1, cache1.size());
-            assertEquals(1, cache2.size());
-        }
+        srv0.createCache(cacheConfiguration(null, "cache4", PARTITIONED, ATOMIC, 2, false));
 
-        Ignite srv1 = startGrid(1);
+        checkCacheDiscoveryDataConsistent();
 
-        awaitPartitionMapExchange();
+        ccfgs = staticConfigurations1(true);
+        startGrid(3);
+
+        checkCacheDiscoveryDataConsistent();
+
+        srv0.createCache(cacheConfiguration(GROUP1, "cache5", PARTITIONED, ATOMIC, 2, false));
+
+        ccfgs = staticConfigurations1(true);
+        startGrid(4);
+
+        checkCacheDiscoveryDataConsistent();
+
+        for (int i = 0; i < 5; i++)
+            checkCacheGroup(i, GROUP1, true);
+
+        srv0.destroyCache("cache1");
+        srv0.destroyCache("cache2");
+        srv0.destroyCache("cache3");
+
+        checkCacheDiscoveryDataConsistent();
 
-        IgniteCache<Object, Object> cache1 = srv1.cache("cache1");
-        IgniteCache<Object, Object> cache2 = srv1.cache("cache2");
+        ccfgs = staticConfigurations1(true);
+        startGrid(5);
 
-        assertEquals(1, cache1.localPeek(new Key1(1)));
-        assertEquals(2, cache2.localPeek(new Key2(1)));
+        checkCacheDiscoveryDataConsistent();
 
-        assertEquals(1, cache1.localSize());
-        assertEquals(1, cache2.localSize());
+        for (int i = 0; i < 6; i++)
+            checkCacheGroup(i, GROUP1, true);
+
+        srv0.destroyCache("cache1");
+        srv0.destroyCache("cache2");
+        srv0.destroyCache("cache3");
+        srv0.destroyCache("cache4");
+        srv0.destroyCache("cache5");
+
+        ccfgs = staticConfigurations1(true);
+        startGrid(6);
+
+        checkCacheDiscoveryDataConsistent();
+
+        srv0.createCache(cacheConfiguration(null, "cache4", PARTITIONED, ATOMIC, 2, false));
+        srv0.createCache(cacheConfiguration(GROUP1, "cache5", PARTITIONED, ATOMIC, 2, false));
+
+        checkCacheDiscoveryDataConsistent();
+
+        ccfgs = staticConfigurations1(false);
+        startGrid(7);
+
+        checkCacheDiscoveryDataConsistent();
+
+        awaitPartitionMapExchange();
     }
 
     /**
      * @throws Exception If failed.
      */
-    public void testCreateCache2() throws Exception {
+    public void testRebalance1() throws Exception {
         Ignite srv0 = startGrid(0);
 
-        {
-            IgniteCache<Object, Object> cache1 =
-                srv0.createCache(cacheConfiguration(GROUP1, "cache1", PARTITIONED, ATOMIC, 0, false));
-            IgniteCache<Object, Object> cache2 =
-                srv0.createCache(cacheConfiguration(GROUP1, "cache2", PARTITIONED, ATOMIC, 0, false));
+        IgniteCache<Object, Object> srv0Cache1 =
+            srv0.createCache(cacheConfiguration(GROUP1, "cache1", PARTITIONED, ATOMIC, 2, false));
+        IgniteCache<Object, Object> srv0Cache2 =
+            srv0.createCache(cacheConfiguration(GROUP1, "cache2", PARTITIONED, ATOMIC, 2, false));
 
-            for (int i = 0; i < 10; i++) {
-                cache1.put(new Key1(i), 1);
-                cache2.put(new Key2(i), 2);
-            }
-        }
+        for (int i = 0; i < 10; i++)
+            srv0Cache1.put(new Key1(i), i);
+
+        assertEquals(10, srv0Cache1.size());
+        assertEquals(10, srv0Cache1.localSize());
+        assertEquals(0, srv0Cache2.size());
 
         Ignite srv1 = startGrid(1);
 
         awaitPartitionMapExchange();
+
+        IgniteCache<Object, Object> srv1Cache1 = srv1.cache("cache1");
+        IgniteCache<Object, Object> srv1Cache2 = srv1.cache("cache2");
+
+        assertEquals(20, srv0Cache1.size(CachePeekMode.ALL));
+        assertEquals(10, srv0Cache1.localSize(CachePeekMode.ALL));
+        assertEquals(0, srv0Cache2.size(CachePeekMode.ALL));
+        assertEquals(0, srv0Cache2.localSize(CachePeekMode.ALL));
+
+        assertEquals(20, srv1Cache1.size(CachePeekMode.ALL));
+        assertEquals(10, srv1Cache1.localSize(CachePeekMode.ALL));
+        assertEquals(0, srv1Cache2.size(CachePeekMode.ALL));
+        assertEquals(0, srv1Cache2.localSize(CachePeekMode.ALL));
+
+        for (int i = 0; i < 10; i++) {
+            assertEquals(i, srv0Cache1.localPeek(new Key1(i)));
+            assertEquals(i, srv1Cache1.localPeek(new Key1(i)));
+        }
+
+        for (int i = 0; i < 20; i++)
+            srv0Cache2.put(new Key1(i), i + 1);
+
+        Ignite srv2 = startGrid(2);
+
+        awaitPartitionMapExchange();
+
+        IgniteCache<Object, Object> srv2Cache1 = srv2.cache("cache1");
+        IgniteCache<Object, Object> srv2Cache2 = srv2.cache("cache2");
+
+        assertEquals(30, srv2Cache1.size(CachePeekMode.ALL));
+        assertEquals(10, srv2Cache1.localSize(CachePeekMode.ALL));
+        assertEquals(60, srv2Cache2.size(CachePeekMode.ALL));
+        assertEquals(20, srv1Cache2.localSize(CachePeekMode.ALL));
+
+        for (int i = 0; i < 10; i++)
+            assertEquals(i, srv2Cache1.localPeek(new Key1(i)));
+
+        for (int i = 0; i < 20; i++)
+            assertEquals(i + 1, srv2Cache2.localPeek(new Key1(i)));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java
index 2f11c86..9031499 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java
@@ -58,6 +58,9 @@ public class CacheDiscoveryDataConcurrentJoinTest extends GridCommonAbstractTest
     /** */
     private ThreadLocal<Integer> staticCaches = new ThreadLocal<>();
 
+    /** */
+    private boolean withCacheGrp;
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -159,11 +162,22 @@ public class CacheDiscoveryDataConcurrentJoinTest extends GridCommonAbstractTest
                 }
             }
 
+            checkCacheDiscoveryDataConsistent();
+
             stopAllGrids();
         }
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testConcurrentJoinCacheWithGroup() throws Exception {
+        withCacheGrp = true;
+
+        testConcurrentJoin();
+    }
+
+    /**
      * @param caches Number of caches.
      * @return Cache configurations.
      */
@@ -187,6 +201,9 @@ public class CacheDiscoveryDataConcurrentJoinTest extends GridCommonAbstractTest
         ccfg.setAtomicityMode(TRANSACTIONAL);
         ccfg.setAffinity(new RendezvousAffinityFunction(false, 16));
 
+        if (withCacheGrp)
+            ccfg.setGroupName("group1");
+
         return ccfg;
     }
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
index ffb3e69..20cef30 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
@@ -2422,7 +2422,7 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest {
 
         Collection<ClusterNode> allNodes = ctx.discovery().cacheNodes(topVer0);
 
-        for (DynamicCacheDescriptor cacheDesc : ctx.cache().cacheDescriptors()) {
+        for (DynamicCacheDescriptor cacheDesc : ctx.cache().cacheDescriptors().values()) {
             if (assignments.get(cacheDesc.cacheId()) != null)
                 continue;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5bbd7c44/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index cf68c3c..306e298 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -65,6 +65,8 @@ import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl;
+import org.apache.ignite.internal.processors.cache.CacheGroupDescriptor;
+import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheExplicitLockSpan;
@@ -1731,4 +1733,66 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
 
         return U.field(tm, "completedVersHashMap");
     }
+
+    /**
+     *
+     */
+    protected final void checkCacheDiscoveryDataConsistent() {
+        Map<Integer, CacheGroupDescriptor> cacheGrps = null;
+        Map<String, DynamicCacheDescriptor> caches = null;
+
+        for (Ignite node : G.allGrids()) {
+            Map<Integer, CacheGroupDescriptor> cacheGrps0 =
+                ((IgniteKernal)node).context().cache().cacheGroupDescriptors();
+            Map<String, DynamicCacheDescriptor> caches0 =
+                ((IgniteKernal)node).context().cache().cacheDescriptors();
+
+            assertNotNull(cacheGrps0);
+            assertNotNull(caches0);
+
+            if (cacheGrps == null) {
+                cacheGrps = cacheGrps0;
+                caches = caches0;
+            }
+            else {
+                assertEquals(cacheGrps.size(), cacheGrps0.size());
+
+                for (Map.Entry<Integer, CacheGroupDescriptor> e : cacheGrps.entrySet()) {
+                    CacheGroupDescriptor desc = e.getValue();
+                    CacheGroupDescriptor desc0 = cacheGrps0.get(e.getKey());
+
+                    assertNotNull(desc0);
+                    checkGroupDescriptorsData(desc, desc0);
+                }
+
+                for (Map.Entry<String, DynamicCacheDescriptor> e : caches.entrySet()) {
+                    DynamicCacheDescriptor desc = e.getValue();
+                    DynamicCacheDescriptor desc0 = caches.get(e.getKey());
+
+                    assertNotNull(desc0);
+                    assertEquals(desc.deploymentId(), desc0.deploymentId());
+                    assertEquals(desc.receivedFrom(), desc0.receivedFrom());
+                    assertEquals(desc.startTopologyVersion(), desc0.startTopologyVersion());
+                    assertEquals(desc.cacheConfiguration().getName(), desc0.cacheConfiguration().getName());
+                    assertEquals(desc.cacheConfiguration().getGroupName(), desc0.cacheConfiguration().getGroupName());
+                    checkGroupDescriptorsData(desc.groupDescriptor(), desc0.groupDescriptor());
+                }
+            }
+        }
+    }
+
+    /**
+     * @param desc First descriptor.
+     * @param desc0 Second descriptor.
+     */
+    private void checkGroupDescriptorsData(CacheGroupDescriptor desc, CacheGroupDescriptor desc0) {
+        assertEquals(desc.groupName(), desc0.groupName());
+        assertEquals(desc.sharedGroup(), desc0.sharedGroup());
+        assertEquals(desc.deploymentId(), desc0.deploymentId());
+        assertEquals(desc.receivedFrom(), desc0.receivedFrom());
+        assertEquals(desc.startTopologyVersion(), desc0.startTopologyVersion());
+        assertEquals(desc.config().getName(), desc0.config().getName());
+        assertEquals(desc.config().getGroupName(), desc0.config().getGroupName());
+        assertEquals(desc.caches(), desc0.caches());
+    }
 }


[11/17] ignite git commit: ignite-5075

Posted by sb...@apache.org.
ignite-5075


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

Branch: refs/heads/ignite-5075
Commit: 664b7492a7eb4c37847d42345abdd575500062e8
Parents: d282808
Author: sboikov <se...@inria.fr>
Authored: Wed May 17 01:07:21 2017 +0300
Committer: sboikov <se...@inria.fr>
Committed: Wed May 17 01:07:21 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/ClusterCachesInfo.java     | 111 ++++++-----
 .../CacheDiscoveryDataConcurrentJoinTest.java   | 199 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite4.java       |  14 +-
 3 files changed, 260 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/664b7492/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index da36470..7d1e1a6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@ -98,6 +98,8 @@ class ClusterCachesInfo {
      */
     void onStart(CacheJoinNodeDiscoveryData joinDiscoData) {
         this.joinDiscoData = joinDiscoData;
+
+        processJoiningNode(joinDiscoData, ctx.localNodeId());
     }
 
     /**
@@ -528,52 +530,6 @@ class ClusterCachesInfo {
      */
     void onDiscoveryEvent(int type, ClusterNode node, AffinityTopologyVersion topVer) {
         if (type == EVT_NODE_JOINED && !ctx.isDaemon()) {
-            if (node.id().equals(ctx.discovery().localNode().id())) {
-                if (gridData == null) { // First node starts.
-                    assert registeredCaches.isEmpty();
-                    assert registeredTemplates.isEmpty();
-                    assert joinDiscoData != null || !ctx.state().active();
-                }
-
-                assert locJoinStartCaches == null;
-
-                locJoinStartCaches = new ArrayList<>();
-
-                if (!disconnectedState() && joinDiscoData != null) {
-                    processJoiningNode(joinDiscoData, node.id());
-
-                    for (DynamicCacheDescriptor desc : registeredCaches.values()) {
-                        CacheConfiguration cfg = desc.cacheConfiguration();
-
-                        CacheJoinNodeDiscoveryData.CacheInfo locCfg = joinDiscoData.caches().get(cfg.getName());
-
-                        NearCacheConfiguration nearCfg = null;
-
-                        if (locCfg != null) {
-                            nearCfg = locCfg.config().getNearConfiguration();
-
-                            DynamicCacheDescriptor desc0 = new DynamicCacheDescriptor(ctx,
-                                locCfg.config(),
-                                desc.cacheType(),
-                                desc.template(),
-                                desc.deploymentId(),
-                                desc.schema());
-
-                            desc0.startTopologyVersion(desc.startTopologyVersion());
-                            desc0.receivedFromStartVersion(desc.receivedFromStartVersion());
-                            desc0.clientCacheStartVersion(desc.clientCacheStartVersion());
-                            desc0.receivedFrom(desc.receivedFrom());
-                            desc0.staticallyConfigured(desc.staticallyConfigured());
-
-                            desc = desc0;
-                        }
-
-                        if (locCfg != null || joinDiscoData.startCaches() || CU.affinityNode(ctx.discovery().localNode(), cfg.getNodeFilter()))
-                            locJoinStartCaches.add(new T2<>(desc, nearCfg));
-                    }
-                }
-            }
-
             for (DynamicCacheDescriptor desc : registeredCaches.values()) {
                 if (node.id().equals(desc.receivedFrom()))
                     desc.receivedFromStartVersion(topVer);
@@ -583,6 +539,14 @@ class ClusterCachesInfo {
                 if (node.id().equals(desc.receivedFrom()))
                     desc.receivedFromStartVersion(topVer);
             }
+
+            if (node.id().equals(ctx.discovery().localNode().id())) {
+                if (gridData == null) { // First node starts.
+                    assert joinDiscoData != null || !ctx.state().active();
+
+                    initStartCachesForLocalJoin(true);
+                }
+            }
         }
     }
 
@@ -660,9 +624,7 @@ class ClusterCachesInfo {
             desc.receivedFrom(cacheData.receivedFrom());
             desc.staticallyConfigured(cacheData.staticallyConfigured());
 
-            DynamicCacheDescriptor old = registeredTemplates.put(cacheData.cacheConfiguration().getName(), desc);
-
-            assert old == null;
+            registeredTemplates.put(cacheData.cacheConfiguration().getName(), desc);
         }
 
         for (CacheData cacheData : cachesData.caches().values()) {
@@ -679,9 +641,7 @@ class ClusterCachesInfo {
             desc.receivedFrom(cacheData.receivedFrom());
             desc.staticallyConfigured(cacheData.staticallyConfigured());
 
-            DynamicCacheDescriptor old = registeredCaches.put(cacheData.cacheConfiguration().getName(), desc);
-
-            assert old == null;
+            registeredCaches.put(cacheData.cacheConfiguration().getName(), desc);
 
             ctx.discovery().setCacheFilter(
                 cfg.getName(),
@@ -700,6 +660,53 @@ class ClusterCachesInfo {
         }
 
         gridData = cachesData;
+
+        if (!disconnectedState())
+            initStartCachesForLocalJoin(false);
+    }
+
+    /**
+     * @param firstNode {@code True} if first node in cluster starts.
+     */
+    private void initStartCachesForLocalJoin(boolean firstNode) {
+        assert locJoinStartCaches == null;
+
+        locJoinStartCaches = new ArrayList<>();
+
+        if (joinDiscoData != null) {
+            for (DynamicCacheDescriptor desc : registeredCaches.values()) {
+                if (firstNode && !joinDiscoData.caches().containsKey(desc.cacheName()))
+                    continue;
+
+                CacheConfiguration cfg = desc.cacheConfiguration();
+
+                CacheJoinNodeDiscoveryData.CacheInfo locCfg = joinDiscoData.caches().get(cfg.getName());
+
+                NearCacheConfiguration nearCfg = null;
+
+                if (locCfg != null) {
+                    nearCfg = locCfg.config().getNearConfiguration();
+
+                    DynamicCacheDescriptor desc0 = new DynamicCacheDescriptor(ctx,
+                            locCfg.config(),
+                            desc.cacheType(),
+                            desc.template(),
+                            desc.deploymentId(),
+                            desc.schema());
+
+                    desc0.startTopologyVersion(desc.startTopologyVersion());
+                    desc0.receivedFromStartVersion(desc.receivedFromStartVersion());
+                    desc0.clientCacheStartVersion(desc.clientCacheStartVersion());
+                    desc0.receivedFrom(desc.receivedFrom());
+                    desc0.staticallyConfigured(desc.staticallyConfigured());
+
+                    desc = desc0;
+                }
+
+                if (locCfg != null || joinDiscoData.startCaches() || CU.affinityNode(ctx.discovery().localNode(), cfg.getNodeFilter()))
+                    locJoinStartCaches.add(new T2<>(desc, nearCfg));
+            }
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/664b7492/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java
new file mode 100644
index 0000000..2f11c86
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheDiscoveryDataConcurrentJoinTest.java
@@ -0,0 +1,199 @@
+/*
+ * 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.internal.processors.cache.distributed;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.util.GridAtomicInteger;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryJoinRequestMessage;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+
+/**
+ *
+ */
+@SuppressWarnings("unchecked")
+public class CacheDiscoveryDataConcurrentJoinTest extends GridCommonAbstractTest {
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** Iteration. */
+    private static final int ITERATIONS = 3;
+
+    /** */
+    private boolean client;
+
+    /** */
+    private ThreadLocal<Integer> staticCaches = new ThreadLocal<>();
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        TcpDiscoverySpi testSpi = new TcpDiscoverySpi() {
+            /** */
+            private boolean delay = true;
+
+            @Override protected void startMessageProcess(TcpDiscoveryAbstractMessage msg) {
+                if (getTestIgniteInstanceName(0).equals(ignite.name())) {
+                    if (msg instanceof TcpDiscoveryJoinRequestMessage) {
+                        TcpDiscoveryJoinRequestMessage msg0 = (TcpDiscoveryJoinRequestMessage)msg;
+
+                        if (delay) {
+                            log.info("Delay join processing: " + msg0);
+
+                            delay = false;
+
+                            doSleep(5000);
+                        }
+                    }
+                }
+
+                super.startMessageProcess(msg);
+            }
+        };
+
+        testSpi.setIpFinder(ipFinder);
+        testSpi.setJoinTimeout(60_000);
+
+        cfg.setDiscoverySpi(testSpi);
+
+        cfg.setClientMode(client);
+
+        Integer caches = staticCaches.get();
+
+        if (caches != null) {
+            cfg.setCacheConfiguration(cacheConfigurations(caches).toArray(new CacheConfiguration[caches]));
+
+            staticCaches.remove();
+        }
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return 10 * 60 * 1000L;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        super.afterTest();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testConcurrentJoin() throws Exception {
+        for (int iter = 0; iter < ITERATIONS; iter++) {
+            log.info("Iteration: " + iter);
+
+            final int NODES = 6;
+            final int MAX_CACHES = 10;
+
+            final GridAtomicInteger caches = new GridAtomicInteger();
+
+            startGrid(0);
+
+            final AtomicInteger idx = new AtomicInteger(1);
+
+            GridTestUtils.runMultiThreaded(new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    int c = ThreadLocalRandom.current().nextInt(MAX_CACHES) + 1;
+
+                    staticCaches.set(c);
+
+                    startGrid(idx.getAndIncrement());
+
+                    caches.setIfGreater(c);
+
+                    return null;
+                }
+            }, NODES - 1, "start-node");
+
+            assertTrue(caches.get() > 0);
+
+            for (int i = 0; i < NODES; i++) {
+                Ignite node = ignite(i);
+
+                for (int c = 0; c < caches.get(); c++) {
+                    Collection<ClusterNode> nodes = node.cluster().forCacheNodes("cache-" + c).nodes();
+
+                    assertEquals(NODES, nodes.size());
+
+                    checkCache(node, "cache-" + c);
+                }
+            }
+
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @param caches Number of caches.
+     * @return Cache configurations.
+     */
+    private Collection<CacheConfiguration> cacheConfigurations(int caches) {
+        List<CacheConfiguration> ccfgs = new ArrayList<>();
+
+        for (int i = 0; i < caches; i++)
+            ccfgs.add(cacheConfiguration("cache-" + i));
+
+        return ccfgs;
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @return Cache configuration.
+     */
+    private CacheConfiguration cacheConfiguration(String cacheName) {
+        CacheConfiguration ccfg = new CacheConfiguration(cacheName);
+
+        ccfg.setName(cacheName);
+        ccfg.setAtomicityMode(TRANSACTIONAL);
+        ccfg.setAffinity(new RendezvousAffinityFunction(false, 16));
+
+        return ccfg;
+    }
+    /**
+     * @param node Node.
+     * @param cacheName Cache name.
+     */
+    private void checkCache(Ignite node, final String cacheName) {
+        assertNotNull(((IgniteKernal)node).context().cache().cache(cacheName));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/664b7492/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index 64ee3fb..4a5d2d8 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -82,18 +82,7 @@ import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransaction
 import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransactionSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteSystemCacheOnClientTest;
 import org.apache.ignite.internal.processors.cache.MarshallerCacheJobRunNodeRestartTest;
-import org.apache.ignite.internal.processors.cache.distributed.CacheAffinityEarlyTest;
-import org.apache.ignite.internal.processors.cache.distributed.CacheAtomicPrimarySyncBackPressureTest;
-import org.apache.ignite.internal.processors.cache.distributed.CacheGetFutureHangsSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.CacheNoValueClassOnServerNodeTest;
-import org.apache.ignite.internal.processors.cache.distributed.CacheStartOnJoinTest;
-import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheCreatePutMultiNodeSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheCreatePutTest;
-import org.apache.ignite.internal.processors.cache.distributed.IgniteCachePrimarySyncTest;
-import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheReadFromBackupTest;
-import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheSingleGetMessageTest;
-import org.apache.ignite.internal.processors.cache.distributed.IgniteTxCachePrimarySyncTest;
-import org.apache.ignite.internal.processors.cache.distributed.IgniteTxCacheWriteSynchronizationModesMultithreadedTest;
+import org.apache.ignite.internal.processors.cache.distributed.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtTxPreloadSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheLockFailoverSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheMultiTxLockSelfTest;
@@ -224,6 +213,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
         suite.addTestSuite(IgniteCacheCreatePutMultiNodeSelfTest.class);
         suite.addTestSuite(IgniteCacheCreatePutTest.class);
         suite.addTestSuite(CacheStartOnJoinTest.class);
+        suite.addTestSuite(CacheDiscoveryDataConcurrentJoinTest.class);
 
         suite.addTestSuite(GridCacheTxLoadFromStoreOnLockSelfTest.class);
 


[10/17] ignite git commit: Merge remote-tracking branch 'remotes/origin/master' into ignite-5075-cacheStart

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


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

Branch: refs/heads/ignite-5075
Commit: d282808baa39a7ab67722fb146ffc2330d9156a7
Parents: f9aa769 73fc01c
Author: sboikov <se...@inria.fr>
Authored: Tue May 16 23:26:45 2017 +0300
Committer: sboikov <se...@inria.fr>
Committed: Tue May 16 23:26:45 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |  14 ++
 .../stream/v2/DirectByteBufferStreamImplV2.java |  27 ++-
 .../managers/communication/GridIoManager.java   | 206 ++++++++++++++++++-
 .../processors/cache/GridCacheAdapter.java      |  12 +-
 .../platform/cluster/PlatformClusterGroup.java  |  20 ++
 .../utils/PlatformConfigurationUtils.java       |   4 +-
 .../ignite/internal/util/IgniteUtils.java       |  49 ++---
 .../org/apache/ignite/mxbean/IgniteMXBean.java  |  44 ++++
 .../communication/tcp/TcpCommunicationSpi.java  |  17 +-
 .../ignite/spi/discovery/tcp/ClientImpl.java    |  20 ++
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  57 ++++-
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     |   7 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   4 +
 .../spi/discovery/tcp/TcpDiscoverySpiMBean.java |  22 ++
 .../TcpDiscoveryRingLatencyCheckMessage.java    |  77 +++++++
 .../Apache.Ignite.Core.Tests.csproj             |   1 +
 .../Binary/BinaryBuilderSelfTest.cs             |  21 +-
 .../Binary/EnumsTest.cs                         |   2 +
 .../Cache/MemoryMetricsTest.cs                  | 134 ++++++++++++
 .../IgniteConfigurationSerializerTest.cs        |   6 +-
 .../IgniteConfigurationTest.cs                  |   4 +-
 .../Apache.Ignite.Core.csproj                   |   2 +
 .../Configuration/MemoryPolicyConfiguration.cs  |   9 +
 .../Apache.Ignite.Core/Cache/IMemoryMetrics.cs  |  55 +++++
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |   7 +
 .../IgniteConfigurationSection.xsd              |   5 +
 .../Impl/Binary/BinaryEnum.cs                   |  22 +-
 .../Impl/Cache/MemoryMetrics.cs                 |  62 ++++++
 .../Impl/Cluster/ClusterGroupImpl.cs            |  27 ++-
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |   6 +
 .../web-console/backend/app/agentsHandler.js    |  28 +--
 .../web-console/backend/app/browsersHandler.js  |  24 ++-
 .../app/modules/agent/AgentManager.service.js   | 170 +++++++++------
 .../frontend/app/modules/sql/sql.controller.js  |   2 +-
 .../frontend/app/primitives/modal/index.scss    |  21 +-
 modules/web-console/frontend/package.json       |   1 +
 .../frontend/views/includes/header-left.pug     |   4 +-
 .../console/agent/handlers/ClusterListener.java |  90 +++++---
 .../console/agent/handlers/RestListener.java    |   7 +
 .../ignite/console/agent/rest/RestExecutor.java |  19 +-
 40 files changed, 1125 insertions(+), 184 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d282808b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------


[16/17] ignite git commit: Merge remote-tracking branch 'remotes/origin/ignite-5075-cacheStart' into ignite-5075

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

# Conflicts:
#	modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
#	modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java


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

Branch: refs/heads/ignite-5075
Commit: 3ef96bc5c3158561f53ed40a90e9001ac82e2658
Parents: e519adf 6f194b3
Author: sboikov <sb...@gridgain.com>
Authored: Wed May 17 11:26:04 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed May 17 11:26:04 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |  14 ++
 .../stream/v2/DirectByteBufferStreamImplV2.java |  27 ++-
 .../managers/communication/GridIoManager.java   | 206 ++++++++++++++++++-
 .../processors/cache/ClusterCachesInfo.java     | 147 ++++++-------
 .../cache/DynamicCacheDescriptor.java           |  26 +--
 .../processors/cache/GridCacheAdapter.java      |  12 +-
 .../platform/cluster/PlatformClusterGroup.java  |  20 ++
 .../utils/PlatformConfigurationUtils.java       |   4 +-
 .../ignite/internal/util/IgniteUtils.java       |  49 ++---
 .../org/apache/ignite/mxbean/IgniteMXBean.java  |  44 ++++
 .../communication/tcp/TcpCommunicationSpi.java  |  17 +-
 .../ignite/spi/discovery/tcp/ClientImpl.java    |  20 ++
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  57 ++++-
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     |   7 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   4 +
 .../spi/discovery/tcp/TcpDiscoverySpiMBean.java |  22 ++
 .../TcpDiscoveryRingLatencyCheckMessage.java    |  77 +++++++
 .../CacheDiscoveryDataConcurrentJoinTest.java   | 199 ++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite4.java       |  14 +-
 .../Apache.Ignite.Core.Tests.csproj             |   1 +
 .../Binary/BinaryBuilderSelfTest.cs             |  21 +-
 .../Binary/EnumsTest.cs                         |   2 +
 .../Cache/MemoryMetricsTest.cs                  | 134 ++++++++++++
 .../IgniteConfigurationSerializerTest.cs        |   6 +-
 .../IgniteConfigurationTest.cs                  |   4 +-
 .../Apache.Ignite.Core.csproj                   |   2 +
 .../Configuration/MemoryPolicyConfiguration.cs  |   9 +
 .../Apache.Ignite.Core/Cache/IMemoryMetrics.cs  |  55 +++++
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |   7 +
 .../IgniteConfigurationSection.xsd              |   5 +
 .../Impl/Binary/BinaryEnum.cs                   |  22 +-
 .../Impl/Cache/MemoryMetrics.cs                 |  62 ++++++
 .../Impl/Cluster/ClusterGroupImpl.cs            |  27 ++-
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |   6 +
 .../web-console/backend/app/agentsHandler.js    |  28 +--
 .../web-console/backend/app/browsersHandler.js  |  24 ++-
 .../components/web-console-footer/style.scss    |  10 +
 .../app/modules/agent/AgentManager.service.js   | 170 +++++++++------
 .../frontend/app/modules/sql/sql.controller.js  |   2 +-
 .../frontend/app/primitives/modal/index.scss    |  21 +-
 modules/web-console/frontend/package.json       |   1 +
 .../frontend/views/includes/header-left.pug     |   4 +-
 .../console/agent/handlers/ClusterListener.java |  90 +++++---
 .../console/agent/handlers/RestListener.java    |   7 +
 .../ignite/console/agent/rest/RestExecutor.java |  19 +-
 45 files changed, 1421 insertions(+), 284 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3ef96bc5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index d90cf7f,45eca44..2f489ab
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@@ -249,8 -246,9 +254,10 @@@ class ClusterCachesInfo 
                      DynamicCacheDescriptor templateDesc = new DynamicCacheDescriptor(ctx,
                          ccfg,
                          req.cacheType(),
 +                        null,
                          true,
+                         req.initiatingNodeId(),
+                         false,
                          req.deploymentId(),
                          req.schema());
  
@@@ -297,8 -285,9 +302,10 @@@
                          DynamicCacheDescriptor startDesc = new DynamicCacheDescriptor(ctx,
                              ccfg,
                              req.cacheType(),
 +                            grpDesc,
                              false,
+                             req.initiatingNodeId(),
+                             false,
                              req.deploymentId(),
                              req.schema());
  
@@@ -736,8 -620,9 +702,10 @@@
                  ctx,
                  cacheData.cacheConfiguration(),
                  cacheData.cacheType(),
 +                null,
                  true,
+                 cacheData.receivedFrom(),
+                 cacheData.staticallyConfigured(),
                  cacheData.deploymentId(),
                  cacheData.schema());
  
@@@ -760,22 -636,19 +723,19 @@@
                  ctx,
                  cacheData.cacheConfiguration(),
                  cacheData.cacheType(),
 +                grpDesc,
                  false,
+                 cacheData.receivedFrom(),
+                 cacheData.staticallyConfigured(),
                  cacheData.deploymentId(),
                  cacheData.schema());
  
-             desc.receivedFrom(cacheData.receivedFrom());
-             desc.staticallyConfigured(cacheData.staticallyConfigured());
- 
-             DynamicCacheDescriptor old = registeredCaches.put(cacheData.cacheConfiguration().getName(), desc);
- 
-             assert old == null;
+             registeredCaches.put(cacheData.cacheConfiguration().getName(), desc);
  
              ctx.discovery().setCacheFilter(
 +                grpDesc.groupId(),
                  cfg.getName(),
 -                cfg.getNodeFilter(),
 -                cfg.getNearConfiguration() != null,
 -                cfg.getCacheMode());
 +                cfg.getNearConfiguration() != null);
          }
  
          if (!F.isEmpty(cachesData.clientNodesMap())) {
@@@ -843,8 -765,9 +852,10 @@@
                  DynamicCacheDescriptor desc = new DynamicCacheDescriptor(ctx,
                      cfg,
                      cacheInfo.cacheType(),
 +                    null,
                      true,
+                     nodeId,
+                     true,
                      joinData.cacheDeploymentId(),
                      new QuerySchema(cfg.getQueryEntities()));
  
@@@ -872,8 -784,9 +880,10 @@@
                  DynamicCacheDescriptor desc = new DynamicCacheDescriptor(ctx,
                      cfg,
                      cacheInfo.cacheType(),
 +                    grpDesc,
                      false,
+                     nodeId,
+                     true,
                      joinData.cacheDeploymentId(),
                      new QuerySchema(cfg.getQueryEntities()));
  

http://git-wip-us.apache.org/repos/asf/ignite/blob/3ef96bc5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
index 881077f,366ea7d..d51d622
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
@@@ -101,8 -100,9 +103,10 @@@ public class DynamicCacheDescriptor 
      public DynamicCacheDescriptor(GridKernalContext ctx,
          CacheConfiguration cacheCfg,
          CacheType cacheType,
 +        CacheGroupDescriptor grpDesc,
          boolean template,
+         UUID rcvdFrom,
+         boolean staticCfg,
          IgniteUuid deploymentId,
          QuerySchema schema) {
          assert cacheCfg != null;
@@@ -117,8 -116,9 +121,10 @@@
  
          this.cacheCfg = cacheCfg;
          this.cacheType = cacheType;
 +        this.grpDesc = grpDesc;
          this.template = template;
+         this.rcvdFrom = rcvdFrom;
+         this.staticCfg = staticCfg;
          this.deploymentId = deploymentId;
  
          pluginMgr = new CachePluginManager(ctx, cacheCfg);

http://git-wip-us.apache.org/repos/asf/ignite/blob/3ef96bc5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------


[07/17] ignite git commit: IGNITE-5191 .NET: BinaryEnum.ToString

Posted by sb...@apache.org.
IGNITE-5191 .NET: BinaryEnum.ToString


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

Branch: refs/heads/ignite-5075
Commit: 256a4a3abd4683c86343a6ba9674b4612d7801de
Parents: be012d8
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Tue May 16 15:35:07 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Tue May 16 15:35:07 2017 +0300

----------------------------------------------------------------------
 .../Binary/BinaryBuilderSelfTest.cs             | 21 ++++++++++++++++---
 .../Binary/EnumsTest.cs                         |  2 ++
 .../Impl/Binary/BinaryEnum.cs                   | 22 +++++++++++++-------
 3 files changed, 34 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/256a4a3a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
index 951f5d2..a7794c6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
@@ -1645,17 +1645,22 @@ namespace Apache.Ignite.Core.Tests.Binary
             Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
         }
 
+        /// <summary>
+        /// Tests the enum builder.
+        /// </summary>
         [Test]
         public void TestBuildEnum()
         {
             var binary = _grid.GetBinary();
 
-            int val = (int) TestEnumRegistered.Two;
+            int val = (int)TestEnumRegistered.Two;
+            var typeName = GetTypeName(typeof(TestEnumRegistered));
+            var typeId = BinaryUtils.GetStringHashCode(typeName);
 
             var binEnums = new[]
             {
                 binary.BuildEnum(typeof (TestEnumRegistered), val),
-                binary.BuildEnum(GetTypeName(typeof (TestEnumRegistered)), val)
+                binary.BuildEnum(typeName, val)
             };
 
             foreach (var binEnum in binEnums)
@@ -1664,11 +1669,21 @@ namespace Apache.Ignite.Core.Tests.Binary
 
                 Assert.AreEqual(val, binEnum.EnumValue);
 
-                Assert.AreEqual((TestEnumRegistered) val, binEnum.Deserialize<TestEnumRegistered>());
+                Assert.AreEqual(string.Format("{0} [typeId={1}, enumValue={2}, enumValueName={3}]",
+                    typeName, typeId, val, (TestEnumRegistered) val), binEnum.ToString());
+
+                Assert.AreEqual((TestEnumRegistered)val, binEnum.Deserialize<TestEnumRegistered>());
             }
 
             Assert.AreEqual(binEnums[0], binEnums[1]);
             Assert.AreEqual(binEnums[0].GetHashCode(), binEnums[1].GetHashCode());
+            
+            Assert.IsFalse(binEnums[0].Equals(null));
+            Assert.IsFalse(binEnums[0].Equals(new object()));
+            Assert.IsTrue(binEnums[0].Equals(binEnums[1]));
+
+            var ex = Assert.Throws<NotSupportedException>(() => binEnums[1].ToBuilder());
+            Assert.AreEqual("Builder cannot be created for enum.", ex.Message);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/256a4a3a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/EnumsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/EnumsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/EnumsTest.cs
index f896ef4..ab54f16 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/EnumsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/EnumsTest.cs
@@ -76,6 +76,8 @@ namespace Apache.Ignite.Core.Tests.Binary
             if (isBinaryEnum)
             {
                 Assert.AreEqual(TypeCaster<int>.Cast(val), binRes.EnumValue);
+                Assert.AreEqual(string.Format("BinaryEnum [typeId={0}, enumValue={1}]",
+                    BinaryUtils.GetStringHashCode(typeof(T).FullName), binRes.EnumValue), binRes.ToString());
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/ignite/blob/256a4a3a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs
index 50b2eb8..710cf17 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEnum.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Impl.Binary
     using System;
     using System.Diagnostics;
     using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Impl.Binary.Metadata;
 
     /// <summary>
     /// Represents a typed enum in binary form.
@@ -89,7 +90,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         /** <inheritdoc /> */
         public IBinaryObjectBuilder ToBuilder()
         {
-            return _marsh.Ignite.GetBinary().GetBuilder(this);
+            throw new NotSupportedException("Builder cannot be created for enum.");
         }
 
         /** <inheritdoc /> */
@@ -126,15 +127,20 @@ namespace Apache.Ignite.Core.Impl.Binary
         }
 
         /** <inheritdoc /> */
-        public static bool operator ==(BinaryEnum left, BinaryEnum right)
+        public override string ToString()
         {
-            return Equals(left, right);
-        }
+            var meta = GetBinaryType();
 
-        /** <inheritdoc /> */
-        public static bool operator !=(BinaryEnum left, BinaryEnum right)
-        {
-            return !Equals(left, right);
+            if (meta == null || meta == BinaryType.Empty)
+            {
+                return string.Format("BinaryEnum [typeId={0}, enumValue={1}]", _typeId, _enumValue);
+            }
+
+            var desc = _marsh.GetDescriptor(true, _typeId);
+            var enumValueName = desc != null && desc.Type != null ? Enum.GetName(desc.Type, _enumValue) : null;
+
+            return string.Format("{0} [typeId={1}, enumValue={2}, enumValueName={3}]",
+                meta.TypeName, _typeId, _enumValue, enumValueName);
         }
     }
 }


[06/17] ignite git commit: IGNITE-5231 Web Console: Add support for Ignite 2.0 cluster on Queries screen.

Posted by sb...@apache.org.
IGNITE-5231 Web Console: Add support for Ignite 2.0 cluster on Queries screen.


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

Branch: refs/heads/ignite-5075
Commit: be012d82be955e37ab93ab4b0c17574fae50ce95
Parents: 88593b6
Author: Andrey Novikov <an...@gridgain.com>
Authored: Tue May 16 18:01:09 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Tue May 16 18:01:09 2017 +0700

----------------------------------------------------------------------
 .../web-console/backend/app/agentsHandler.js    |  28 +--
 .../web-console/backend/app/browsersHandler.js  |  24 ++-
 .../app/modules/agent/AgentManager.service.js   | 170 ++++++++++++-------
 .../frontend/app/modules/sql/sql.controller.js  |   2 +-
 .../frontend/app/primitives/modal/index.scss    |  21 +--
 modules/web-console/frontend/package.json       |   1 +
 .../frontend/views/includes/header-left.pug     |   4 +-
 .../console/agent/handlers/ClusterListener.java |  90 +++++++---
 .../console/agent/handlers/RestListener.java    |   7 +
 .../ignite/console/agent/rest/RestExecutor.java |  19 ++-
 10 files changed, 245 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/be012d82/modules/web-console/backend/app/agentsHandler.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/app/agentsHandler.js b/modules/web-console/backend/app/agentsHandler.js
index d24cef8..a4ae385 100644
--- a/modules/web-console/backend/app/agentsHandler.js
+++ b/modules/web-console/backend/app/agentsHandler.js
@@ -81,7 +81,7 @@ module.exports.factory = function(_, fs, path, JSZip, socketio, settings, mongo,
     }
 
     class Cluster {
-        constructor(nids) {
+        constructor(top) {
             let d = new Date().getTime();
 
             this.id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
@@ -92,15 +92,19 @@ module.exports.factory = function(_, fs, path, JSZip, socketio, settings, mongo,
                 return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
             });
 
-            this.nids = nids;
+            this.nids = top.nids;
+
+            this.clusterVersion = top.clusterVersion;
         }
 
-        same(nids) {
-            return _.intersection(this.nids, nids).length > 0;
+        isSameCluster(top) {
+            return _.intersection(this.nids, top.nids).length > 0;
         }
 
-        updateTopology(nids) {
-            this.nids = nids;
+        update(top) {
+            this.clusterVersion = top.clusterVersion;
+
+            this.nids = top.nids;
         }
     }
 
@@ -187,11 +191,11 @@ module.exports.factory = function(_, fs, path, JSZip, socketio, settings, mongo,
                 });
         }
 
-        getOrCreateCluster(nids) {
-            const cluster = _.find(this.clusters, (c) => c.same(nids));
+        getOrCreateCluster(top) {
+            const cluster = _.find(this.clusters, (c) => c.isSameCluster(top));
 
             if (_.isNil(cluster))
-                this.clusters.push(new Cluster(nids));
+                this.clusters.push(new Cluster(top));
 
             return cluster;
         }
@@ -216,8 +220,8 @@ module.exports.factory = function(_, fs, path, JSZip, socketio, settings, mongo,
                 });
             });
 
-            sock.on('cluster:topology', (nids) => {
-                const cluster = this.getOrCreateCluster(nids);
+            sock.on('cluster:topology', (top) => {
+                const cluster = this.getOrCreateCluster(top);
 
                 if (_.isNil(agentSocket.cluster)) {
                     agentSocket.cluster = cluster;
@@ -227,7 +231,7 @@ module.exports.factory = function(_, fs, path, JSZip, socketio, settings, mongo,
                     });
                 }
                 else
-                    cluster.updateTopology(nids);
+                    cluster.update(top);
             });
 
             sock.on('cluster:collector', (top) => {

http://git-wip-us.apache.org/repos/asf/ignite/blob/be012d82/modules/web-console/backend/app/browsersHandler.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/app/browsersHandler.js b/modules/web-console/backend/app/browsersHandler.js
index 66ac5f8..f5937fe 100644
--- a/modules/web-console/backend/app/browsersHandler.js
+++ b/modules/web-console/backend/app/browsersHandler.js
@@ -114,11 +114,8 @@ module.exports.factory = (_, socketio, configure, errors) => {
                         acc.count += 1;
                         acc.hasDemo |= _.get(agentSock, 'demo.enabled');
 
-                        if (agentSock.cluster) {
-                            acc.clusters.push({
-                                id: agentSock.cluster.id
-                            });
-                        }
+                        if (agentSock.cluster)
+                            acc.clusters.push(agentSock.cluster);
 
                         return acc;
                     }, {count: 0, hasDemo: false, clusters: []});
@@ -199,10 +196,19 @@ module.exports.factory = (_, socketio, configure, errors) => {
 
             const internalVisor = (postfix) => `org.apache.ignite.internal.visor.${postfix}`;
 
-            this.registerVisorTask('querySql', internalVisor('query.VisorQueryTask'), internalVisor('query.VisorQueryTaskArg'));
-            this.registerVisorTask('queryScan', internalVisor('query.VisorScanQueryTask'), internalVisor('query.VisorScanQueryTaskArg'));
-            this.registerVisorTask('queryFetch', internalVisor('query.VisorQueryNextPageTask'), internalVisor('query.VisorQueryNextPageTaskArg'));
-            this.registerVisorTask('queryClose', internalVisor('query.VisorQueryCleanupTask'), internalVisor('query.VisorQueryCleanupTaskArg'));
+            this.registerVisorTask('querySql', internalVisor('query.VisorQueryTask'), internalVisor('query.VisorQueryArg'));
+            this.registerVisorTask('querySqlV2', internalVisor('query.VisorQueryTask'), internalVisor('query.VisorQueryArgV2'));
+            this.registerVisorTask('querySqlV3', internalVisor('query.VisorQueryTask'), internalVisor('query.VisorQueryArgV3'));
+            this.registerVisorTask('querySqlX2', internalVisor('query.VisorQueryTask'), internalVisor('query.VisorQueryTaskArg'));
+
+            this.registerVisorTask('queryScanX2', internalVisor('query.VisorScanQueryTask'), internalVisor('query.VisorScanQueryTaskArg'));
+
+            this.registerVisorTask('queryFetch', internalVisor('query.VisorQueryNextPageTask'), 'org.apache.ignite.lang.IgniteBiTuple', 'java.lang.String', 'java.lang.Integer');
+            this.registerVisorTask('queryFetchX2', internalVisor('query.VisorQueryNextPageTask'), internalVisor('query.VisorQueryNextPageTaskArg'));
+
+            this.registerVisorTask('queryClose', internalVisor('query.VisorQueryCleanupTask'), 'java.util.Map', 'java.util.UUID', 'java.util.Set');
+            this.registerVisorTask('queryCloseX2', internalVisor('query.VisorQueryCleanupTask'), internalVisor('query.VisorQueryCleanupTaskArg'));
+
 
             // Return command result from grid to browser.
             sock.on('node:visor', (clusterId, taskId, nids, ...args) => {

http://git-wip-us.apache.org/repos/asf/ignite/blob/be012d82/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
index cb77832..c511242 100644
--- a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
+++ b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
@@ -17,6 +17,8 @@
 
 import io from 'socket.io-client'; // eslint-disable-line no-unused-vars
 
+import { BehaviorSubject } from 'rxjs/BehaviorSubject';
+
 const maskNull = (val) => _.isNil(val) ? 'null' : val;
 
 const State = {
@@ -39,17 +41,26 @@ export default class IgniteAgentManager {
          */
         this.AgentModal = AgentModal;
 
-        this.clusters = [];
+        this.promises = new Set();
 
         $root.$on('$stateChangeSuccess', () => this.stopWatch());
 
+        this.ignite2x = false;
+
+        $root.$watch(() => _.get(this, 'cluster.clusterVersion'), (ver) => {
+            if (_.isEmpty(ver))
+                return;
+
+            this.ignite2x = ver.startsWith('2.');
+        }, true);
+
         /**
          * Connection to backend.
          * @type {Socket}
          */
         this.socket = null;
 
-        this.connectionState = State.INIT;
+        this.connectionState = new BehaviorSubject(State.INIT);
 
         /**
          * Has agent with enabled demo mode.
@@ -111,11 +122,11 @@ export default class IgniteAgentManager {
             }
 
             if (count === 0)
-                self.connectionState = State.AGENT_DISCONNECTED;
-            else {
-                self.connectionState = self.$root.IgniteDemoMode || _.get(self.cluster, 'disconnect') === false ?
-                    State.CONNECTED : State.CLUSTER_DISCONNECTED;
-            }
+                self.connectionState.next(State.AGENT_DISCONNECTED);
+            else if (self.$root.IgniteDemoMode || _.get(self.cluster, 'disconnect') === false)
+                self.connectionState.next(State.CONNECTED);
+            else
+                self.connectionState.next(State.CLUSTER_DISCONNECTED);
         });
     }
 
@@ -132,17 +143,23 @@ export default class IgniteAgentManager {
      * @returns {Promise}
      */
     awaitConnectionState(...states) {
-        this.latchAwaitStates = this.$q.defer();
+        const defer = this.$q.defer();
 
-        this.offAwaitAgent = this.$root.$watch(() => this.connectionState, (state) => {
-            if (_.includes(states, state)) {
-                this.offAwaitAgent();
+        this.promises.add(defer);
 
-                this.latchAwaitStates.resolve();
+        const subscription = this.connectionState.subscribe({
+            next: (state) => {
+                if (_.includes(states, state))
+                    defer.resolve();
             }
         });
 
-        return this.latchAwaitStates.promise;
+        return defer.promise
+            .finally(() => {
+                subscription.unsubscribe();
+
+                this.promises.delete(defer);
+            });
     }
 
     awaitCluster() {
@@ -167,24 +184,26 @@ export default class IgniteAgentManager {
         if (_.nonEmpty(self.clusters) && _.get(self.cluster, 'disconnect') === true) {
             self.cluster = _.head(self.clusters);
 
-            self.connectionState = State.CONNECTED;
+            self.connectionState.next(State.CONNECTED);
         }
 
-        self.offStateWatch = this.$root.$watch(() => self.connectionState, (state) => {
-            switch (state) {
-                case State.CONNECTED:
-                case State.CLUSTER_DISCONNECTED:
-                    this.AgentModal.hide();
+        self.modalSubscription = this.connectionState.subscribe({
+            next: (state) => {
+                switch (state) {
+                    case State.CONNECTED:
+                    case State.CLUSTER_DISCONNECTED:
+                        this.AgentModal.hide();
 
-                    break;
+                        break;
 
-                case State.AGENT_DISCONNECTED:
-                    this.AgentModal.agentDisconnected(self.backText, self.backState);
+                    case State.AGENT_DISCONNECTED:
+                        this.AgentModal.agentDisconnected(self.backText, self.backState);
 
-                    break;
+                        break;
 
-                default:
+                    default:
                     // Connection to backend is not established yet.
+                }
             }
         });
 
@@ -205,28 +224,30 @@ export default class IgniteAgentManager {
         if (_.nonEmpty(self.clusters) && _.get(self.cluster, 'disconnect') === true) {
             self.cluster = _.head(self.clusters);
 
-            self.connectionState = State.CONNECTED;
+            self.connectionState.next(State.CONNECTED);
         }
 
-        self.offStateWatch = this.$root.$watch(() => self.connectionState, (state) => {
-            switch (state) {
-                case State.CONNECTED:
-                    this.AgentModal.hide();
+        self.modalSubscription = this.connectionState.subscribe({
+            next: (state) => {
+                switch (state) {
+                    case State.CONNECTED:
+                        this.AgentModal.hide();
 
-                    break;
+                        break;
 
-                case State.AGENT_DISCONNECTED:
-                    this.AgentModal.agentDisconnected(self.backText, self.backState);
+                    case State.AGENT_DISCONNECTED:
+                        this.AgentModal.agentDisconnected(self.backText, self.backState);
 
-                    break;
+                        break;
 
-                case State.CLUSTER_DISCONNECTED:
-                    self.AgentModal.clusterDisconnected(self.backText, self.backState);
+                    case State.CLUSTER_DISCONNECTED:
+                        self.AgentModal.clusterDisconnected(self.backText, self.backState);
 
-                    break;
+                        break;
 
-                default:
+                    default:
                     // Connection to backend is not established yet.
+                }
             }
         });
 
@@ -234,18 +255,11 @@ export default class IgniteAgentManager {
     }
 
     stopWatch() {
-        if (!_.isFunction(this.offStateWatch))
-            return;
-
-        this.offStateWatch();
+        this.modalSubscription && this.modalSubscription.unsubscribe();
 
         this.AgentModal.hide();
 
-        if (this.latchAwaitStates) {
-            this.offAwaitAgent();
-
-            this.latchAwaitStates.reject('Agent watch stopped.');
-        }
+        this.promises.forEach((promise) => promise.reject('Agent watch stopped.'));
     }
 
     /**
@@ -460,12 +474,33 @@ export default class IgniteAgentManager {
      * @returns {Promise}
      */
     querySql(nid, cacheName, query, nonCollocatedJoins, enforceJoinOrder, replicatedOnly, local, pageSz) {
-        return this.visorTask('querySql', nid, cacheName, query, nonCollocatedJoins, enforceJoinOrder, replicatedOnly, local, pageSz)
-            .then(({error, result}) => {
-                if (_.isEmpty(error))
-                    return result;
+        if (this.ignite2x) {
+            return this.visorTask('querySqlX2', nid, cacheName, query, nonCollocatedJoins, enforceJoinOrder, replicatedOnly, local, pageSz)
+                .then(({error, result}) => {
+                    if (_.isEmpty(error))
+                        return result;
+
+                    return Promise.reject(error);
+                });
+        }
+
+        cacheName = _.isEmpty(cacheName) ? null : cacheName;
+
+        let queryPromise;
 
-                return Promise.reject(error);
+        if (enforceJoinOrder)
+            queryPromise = this.visorTask('querySqlV3', nid, cacheName, query, nonCollocatedJoins, enforceJoinOrder, local, pageSz);
+        else if (nonCollocatedJoins)
+            queryPromise = this.visorTask('querySqlV2', nid, cacheName, query, nonCollocatedJoins, local, pageSz);
+        else
+            queryPromise = this.visorTask('querySql', nid, cacheName, query, local, pageSz);
+
+        return queryPromise
+            .then(({key, value}) => {
+                if (_.isEmpty(key))
+                    return value;
+
+                return Promise.reject(key);
             });
     }
 
@@ -517,8 +552,12 @@ export default class IgniteAgentManager {
      * @returns {Promise}
      */
     queryClose(nid, queryId) {
-        return this.visorTask('queryClose', nid, 'java.util.Map', 'java.util.UUID', 'java.util.Collection',
-            nid + '=' + queryId);
+        if (this.ignite2x) {
+            return this.visorTask('queryClose', nid, 'java.util.Map', 'java.util.UUID', 'java.util.Collection',
+                nid + '=' + queryId);
+        }
+
+        return this.visorTask('queryClose', nid, queryId);
     }
 
     /**
@@ -533,13 +572,26 @@ export default class IgniteAgentManager {
      * @returns {Promise}
      */
     queryScan(nid, cacheName, filter, regEx, caseSensitive, near, local, pageSize) {
-        return this.visorTask('queryScan', nid, cacheName, filter, regEx, caseSensitive, near, local, pageSize)
-            .then(({error, result}) => {
-                if (_.isEmpty(error))
-                    return result;
+        if (this.ignite2x) {
+            return this.visorTask('queryScanX2', nid, cacheName, filter, regEx, caseSensitive, near, local, pageSize)
+                .then(({error, result}) => {
+                    if (_.isEmpty(error))
+                        return result;
 
-                return Promise.reject(error);
-            });
+                    return Promise.reject(error);
+                });
+        }
+
+        /** Prefix for node local key for SCAN near queries. */
+        const SCAN_CACHE_WITH_FILTER = 'VISOR_SCAN_CACHE_WITH_FILTER';
+
+        /** Prefix for node local key for SCAN near queries. */
+        const SCAN_CACHE_WITH_FILTER_CASE_SENSITIVE = 'VISOR_SCAN_CACHE_WITH_FILTER_CASE_SENSITIVE';
+
+        const prefix = caseSensitive ? SCAN_CACHE_WITH_FILTER_CASE_SENSITIVE : SCAN_CACHE_WITH_FILTER;
+        const query = `${prefix}${filter}`;
+
+        return this.querySql(nid, cacheName, query, false, false, false, local, pageSize);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/be012d82/modules/web-console/frontend/app/modules/sql/sql.controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/sql/sql.controller.js b/modules/web-console/frontend/app/modules/sql/sql.controller.js
index 3806351..cf9f917 100644
--- a/modules/web-console/frontend/app/modules/sql/sql.controller.js
+++ b/modules/web-console/frontend/app/modules/sql/sql.controller.js
@@ -1628,7 +1628,7 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
 
             return Promise.resolve(args.localNid || _chooseNode(args.cacheName, false))
                 .then((nid) => args.type === 'SCAN'
-                    ? agentMgr.queryScanGetAll(nid, args.cacheName, args.filter, !!args.regEx, !!args.caseSensitive, !!args.near, !!args.localNid)
+                    ? agentMgr.queryScanGetAll(nid, args.cacheName, args.query, !!args.regEx, !!args.caseSensitive, !!args.near, !!args.localNid)
                     : agentMgr.querySqlGetAll(nid, args.cacheName, args.query, !!args.nonCollocatedJoins, !!args.enforceJoinOrder, false, !!args.localNid))
                 .then((res) => _export(paragraph.name + '-all.csv', paragraph.gridOptions.columnDefs, res.columns, res.rows))
                 .catch(Messages.showError)

http://git-wip-us.apache.org/repos/asf/ignite/blob/be012d82/modules/web-console/frontend/app/primitives/modal/index.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/modal/index.scss b/modules/web-console/frontend/app/primitives/modal/index.scss
index dc0dfee..c1c1fbf 100644
--- a/modules/web-console/frontend/app/primitives/modal/index.scss
+++ b/modules/web-console/frontend/app/primitives/modal/index.scss
@@ -32,18 +32,18 @@
 .modal-header {
     border-top-left-radius: 6px;
     border-top-right-radius: 6px;
-}
 
-// Close icon
-.modal-header .close {
-    margin-right: -2px;
-}
+    // Close icon
+    .close {
+        margin-right: -2px;
+    }
 
-// Modal icon
-.modal-header h4 > i.fa {
-    cursor: default;
-    float: left;
-    line-height: $modal-title-line-height;
+    // Modal icon
+    h4 > i {
+        cursor: default;
+        float: left;
+        line-height: $modal-title-line-height;
+    }
 }
 
 .modal .modal-dialog {
@@ -95,6 +95,7 @@
 
 .modal-body-with-scroll {
     max-height: 420px;
+    overflow-y: auto;
     overflow-y: overlay;
     margin: 0;
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/be012d82/modules/web-console/frontend/package.json
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/package.json b/modules/web-console/frontend/package.json
index fccc944..43cf0c9 100644
--- a/modules/web-console/frontend/package.json
+++ b/modules/web-console/frontend/package.json
@@ -60,6 +60,7 @@
     "nvd3": "1.8.4",
     "raleway-webfont": "3.0.1",
     "roboto-font": "0.1.0",
+    "rxjs": "5.4.0",
     "socket.io-client": "1.7.3",
     "ui-router-metatags": "1.0.3"
   },

http://git-wip-us.apache.org/repos/asf/ignite/blob/be012d82/modules/web-console/frontend/views/includes/header-left.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/includes/header-left.pug b/modules/web-console/frontend/views/includes/header-left.pug
index 7578705..4dda1cc 100644
--- a/modules/web-console/frontend/views/includes/header-left.pug
+++ b/modules/web-console/frontend/views/includes/header-left.pug
@@ -27,8 +27,8 @@
             span.caret
 
 .wch-nav-item(ng-controller='notebookController')
-    div(ng-if='IgniteDemoMode' ng-class='{active: $state.includes("base.sql")}')
-        a(ui-sref='base.sql.demo') Queries
+    div(ng-if='IgniteDemoMode' ui-sref='base.sql.demo' ng-class='{active: $state.includes("base.sql")}')
+        span Queries
 
     div(ng-if='!IgniteDemoMode')
         div(ng-if='!notebooks.length' ng-class='{active: $state.includes("base.sql")}')

http://git-wip-us.apache.org/repos/asf/ignite/blob/be012d82/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java
index 939b35a..27f5317 100644
--- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java
@@ -37,10 +37,12 @@ import org.apache.ignite.internal.processors.rest.protocols.http.jetty.GridJetty
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteProductVersion;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.apache.ignite.console.agent.AgentUtils.toJSON;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_BUILD_VER;
 import static org.apache.ignite.internal.processors.rest.GridRestResponse.STATUS_SUCCESS;
 
 /**
@@ -65,8 +67,8 @@ public class ClusterListener {
     /** JSON object mapper. */
     private static final ObjectMapper mapper = new GridJettyObjectMapper();
 
-    /** Nids. */
-    private Collection<UUID> latestNids = Collections.emptyList();
+    /** Latest topology snapshot. */
+    private TopologySnapshot top;
 
     /** */
     private final WatchTask watchTask = new WatchTask();
@@ -132,14 +134,14 @@ public class ClusterListener {
      * Callback on disconnect from cluster.
      */
     private void clusterDisconnect() {
-        if (latestNids.isEmpty())
+        if (top == null)
             return;
-        
-        latestNids = Collections.emptyList();
+
+        top = null;
 
         log.info("Connection to cluster was lost");
 
-        client.emit(EVENT_CLUSTER_DISCONNECTED, latestNids);
+        client.emit(EVENT_CLUSTER_DISCONNECTED);
     }
 
     /**
@@ -188,30 +190,68 @@ public class ClusterListener {
     }
 
     /** */
+    private class TopologySnapshot {
+        /** */
+        private Collection<UUID> nids;
+
+        /** */
+        private String clusterVersion;
+
+        /**
+         * @param nodes Nodes.
+         */
+        TopologySnapshot(Collection<GridClientNodeBean> nodes) {
+            nids = F.viewReadOnly(nodes, NODE2ID);
+
+            Collection<IgniteProductVersion> vers = F.transform(nodes,
+                new IgniteClosure<GridClientNodeBean, IgniteProductVersion>() {
+                    @Override public IgniteProductVersion apply(GridClientNodeBean bean) {
+                        return IgniteProductVersion.fromString((String)bean.getAttributes().get(ATTR_BUILD_VER));
+                    }
+                });
+
+            clusterVersion = Collections.min(vers).toString();
+        }
+
+        /**  */
+        Collection<String> nid8() {
+            return F.viewReadOnly(nids, ID2ID8);
+        }
+
+        /**  */
+        boolean isSameCluster(TopologySnapshot snapshot) {
+            if (snapshot == null || F.isEmpty(snapshot.nids))
+                return false;
+
+            return Collections.disjoint(nids, snapshot.nids);
+        }
+    }
+
+    /** */
     private class WatchTask implements Runnable {
         /** {@inheritDoc} */
         @Override public void run() {
             try {
-                RestResult top = restExecutor.topology(false, false);
+                RestResult res = restExecutor.topology(false, false);
 
-                switch (top.getStatus()) {
+                switch (res.getStatus()) {
                     case STATUS_SUCCESS:
-                        List<GridClientNodeBean> nodes = mapper.readValue(top.getData(),
+                        List<GridClientNodeBean> nodes = mapper.readValue(res.getData(),
                             new TypeReference<List<GridClientNodeBean>>() {});
 
-                        Collection<UUID> nids = F.viewReadOnly(nodes, NODE2ID);
+                        TopologySnapshot newTop = new TopologySnapshot(nodes);
 
-                        if (Collections.disjoint(latestNids, nids))
-                            log.info("Connection successfully established to cluster with nodes: {}", F.viewReadOnly(nids, ID2ID8));
+                        if (newTop.isSameCluster(top))
+                            log.info("Connection successfully established to cluster with nodes: {}", newTop.nid8());
 
-                        client.emit(EVENT_CLUSTER_TOPOLOGY, nids);
+                        top = newTop;
 
-                        latestNids = nids;
+                        client.emit(EVENT_CLUSTER_TOPOLOGY, toJSON(top));
 
                         break;
 
                     default:
-                        log.warn(top.getError());
+                        log.warn(res.getError());
 
                         clusterDisconnect();
                 }
@@ -227,31 +267,31 @@ public class ClusterListener {
         /** {@inheritDoc} */
         @Override public void run() {
             try {
-                RestResult top = restExecutor.topology(false, true);
+                RestResult res = restExecutor.topology(false, true);
 
-                switch (top.getStatus()) {
+                switch (res.getStatus()) {
                     case STATUS_SUCCESS:
-                        List<GridClientNodeBean> nodes = mapper.readValue(top.getData(),
+                        List<GridClientNodeBean> nodes = mapper.readValue(res.getData(),
                             new TypeReference<List<GridClientNodeBean>>() {});
 
-                        Collection<UUID> nids = F.viewReadOnly(nodes, NODE2ID);
-
-                        if (Collections.disjoint(latestNids, nids)) {
-                            clusterConnect(nids);
+                        TopologySnapshot newTop = new TopologySnapshot(nodes);
 
+                        if (top == null || top.isSameCluster(newTop)) {
                             clusterDisconnect();
 
+                            log.info("Connection successfully established to cluster with nodes: {}", newTop.nid8());
+
                             watch();
                         }
 
-                        latestNids = nids;
+                        top = newTop;
 
-                        client.emit(EVENT_CLUSTER_TOPOLOGY, top.getData());
+                        client.emit(EVENT_CLUSTER_TOPOLOGY, res.getData());
 
                         break;
 
                     default:
-                        log.warn(top.getError());
+                        log.warn(res.getError());
 
                         clusterDisconnect();
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/be012d82/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java
index 2588e8e..c70514d 100644
--- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/RestListener.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.console.agent.handlers;
 
 import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import org.apache.ignite.console.agent.rest.RestExecutor;
 
 /**
@@ -35,6 +37,11 @@ public class RestListener extends AbstractListener {
     }
 
     /** {@inheritDoc} */
+    @Override protected ExecutorService newThreadPool() {
+        return Executors.newCachedThreadPool();
+    }
+
+    /** {@inheritDoc} */
     @Override public Object execute(Map<String, Object> args) throws Exception {
         if (log.isDebugEnabled())
             log.debug("Start parse REST command args: " + args);

http://git-wip-us.apache.org/repos/asf/ignite/blob/be012d82/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java
index 904b2b8..bfeef58 100644
--- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/rest/RestExecutor.java
@@ -23,6 +23,8 @@ import java.io.IOException;
 import java.net.ConnectException;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import okhttp3.Dispatcher;
 import okhttp3.FormBody;
 import okhttp3.HttpUrl;
 import okhttp3.MediaType;
@@ -60,15 +62,26 @@ public class RestExecutor {
     public RestExecutor(String nodeUrl) {
         this.nodeUrl = nodeUrl;
 
-        httpClient = new OkHttpClient.Builder().build();
+        Dispatcher dispatcher = new Dispatcher();
+        
+        dispatcher.setMaxRequests(Integer.MAX_VALUE);
+        dispatcher.setMaxRequestsPerHost(Integer.MAX_VALUE);
+
+        httpClient = new OkHttpClient.Builder()
+            .readTimeout(0, TimeUnit.MILLISECONDS)
+            .dispatcher(dispatcher)
+            .build();
     }
 
     /**
      * Stop HTTP client.
      */
     public void stop() {
-        if (httpClient != null)
+        if (httpClient != null) {
             httpClient.dispatcher().executorService().shutdown();
+
+            httpClient.dispatcher().cancelAll();
+        }
     }
 
     /** */
@@ -189,7 +202,7 @@ public class RestExecutor {
         Map<String, Object> params = new HashMap<>(3);
 
         params.put("cmd", "top");
-        params.put("attr", full);
+        params.put("attr", true);
         params.put("mtr", full);
 
         return sendRequest(demo, "ignite", params, "GET", null, null);


[08/17] ignite git commit: Added discovery ring latency test + made it available from MBean

Posted by sb...@apache.org.
Added discovery ring latency test + made it available from MBean


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

Branch: refs/heads/ignite-5075
Commit: 1fef59c75e8b2e17a043d47abf24884a26a1644d
Parents: 256a4a3
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue May 16 18:16:42 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue May 16 18:16:42 2017 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ClientImpl.java    | 20 +++++
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 57 ++++++++++++++-
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     |  7 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |  4 +
 .../spi/discovery/tcp/TcpDiscoverySpiMBean.java | 22 ++++++
 .../TcpDiscoveryRingLatencyCheckMessage.java    | 77 ++++++++++++++++++++
 6 files changed, 185 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1fef59c7/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 4c7199c..619b4cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -97,6 +97,7 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeFailedMessag
 import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeLeftMessage;
 import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryPingRequest;
 import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryPingResponse;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryRingLatencyCheckMessage;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jsr166.ConcurrentHashMap8;
@@ -831,6 +832,16 @@ class ClientImpl extends TcpDiscoveryImpl {
     }
 
     /** {@inheritDoc} */
+    @Override public void checkRingLatency(int maxHops) {
+        TcpDiscoveryRingLatencyCheckMessage msg = new TcpDiscoveryRingLatencyCheckMessage(getLocalNodeId(), maxHops);
+
+        if (log.isInfoEnabled())
+            log.info("Latency check initiated: " + msg.id());
+
+        sockWriter.sendMessage(msg);
+    }
+
+    /** {@inheritDoc} */
     @Override protected IgniteSpiThread workerThread() {
         return msgWorker;
     }
@@ -1221,6 +1232,12 @@ class ClientImpl extends TcpDiscoveryImpl {
                         msg,
                         sockTimeout);
 
+                    IgniteUuid latencyCheckId = msg instanceof TcpDiscoveryRingLatencyCheckMessage ?
+                        msg.id() : null;
+
+                    if (latencyCheckId != null && log.isInfoEnabled())
+                        log.info("Latency check message has been written to socket: " + latencyCheckId);
+
                     msg = null;
 
                     if (ack) {
@@ -1248,6 +1265,9 @@ class ClientImpl extends TcpDiscoveryImpl {
 
                             throw new IOException("Failed to get acknowledge for message: " + unacked);
                         }
+
+                        if (latencyCheckId != null && log.isInfoEnabled())
+                            log.info("Latency check message has been acked: " + latencyCheckId);
                     }
                 }
                 catch (InterruptedException ignored) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/1fef59c7/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 5961b8d..fce6fe2 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
@@ -126,6 +126,7 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeLeftMessage;
 import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryPingRequest;
 import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryPingResponse;
 import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryRedirectToClient;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryRingLatencyCheckMessage;
 import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryStatusCheckMessage;
 import org.apache.ignite.thread.IgniteThreadPoolExecutor;
 import org.jetbrains.annotations.Nullable;
@@ -1584,6 +1585,16 @@ class ServerImpl extends TcpDiscoveryImpl {
     }
 
     /** {@inheritDoc} */
+    @Override public void checkRingLatency(int maxHops) {
+        TcpDiscoveryRingLatencyCheckMessage msg = new TcpDiscoveryRingLatencyCheckMessage(getLocalNodeId(), maxHops);
+
+        if (log.isInfoEnabled())
+            log.info("Latency check initiated: " + msg.id());
+
+        msgWorker.addMessage(msg);
+    }
+
+    /** {@inheritDoc} */
     @Override void simulateNodeFailure() {
         U.warn(log, "Simulating node failure: " + getLocalNodeId());
 
@@ -2575,6 +2586,9 @@ class ServerImpl extends TcpDiscoveryImpl {
             else if (msg instanceof TcpDiscoveryClientPingRequest)
                 processClientPingRequest((TcpDiscoveryClientPingRequest)msg);
 
+            else if (msg instanceof TcpDiscoveryRingLatencyCheckMessage)
+                processRingLatencyCheckMessage((TcpDiscoveryRingLatencyCheckMessage)msg);
+
             else
                 assert false : "Unknown message type: " + msg.getClass().getSimpleName();
 
@@ -2973,12 +2987,20 @@ class ServerImpl extends TcpDiscoveryImpl {
                                     }
                                 }
 
+                                boolean latencyCheck = msg instanceof TcpDiscoveryRingLatencyCheckMessage;
+
+                                if (latencyCheck && log.isInfoEnabled())
+                                    log.info("Latency check message has been written to socket: " + msg.id());
+
                                 spi.writeToSocket(sock, out, msg, timeoutHelper.nextTimeoutChunk(spi.getSocketTimeout()));
 
                                 long tstamp0 = U.currentTimeMillis();
 
                                 int res = spi.readReceipt(sock, timeoutHelper.nextTimeoutChunk(ackTimeout0));
 
+                                if (latencyCheck && log.isInfoEnabled())
+                                    log.info("Latency check message has been acked: " + msg.id());
+
                                 spi.stats.onMessageSent(msg, tstamp0 - tstamp);
 
                                 onMessageExchanged();
@@ -4375,6 +4397,33 @@ class ServerImpl extends TcpDiscoveryImpl {
         }
 
         /**
+         * Processes latency check message.
+         *
+         * @param msg Latency check message.
+         */
+        private void processRingLatencyCheckMessage(TcpDiscoveryRingLatencyCheckMessage msg) {
+            assert msg != null;
+
+            if (msg.maxHopsReached()) {
+                if (log.isInfoEnabled())
+                    log.info("Latency check has been discarded (max hops reached) [id=" + msg.id() +
+                        ", maxHops=" + msg.maxHops() + ']');
+
+                return;
+            }
+
+            if (log.isInfoEnabled())
+                log.info("Latency check processing: " + msg.id());
+
+            if (sendMessageToRemotes(msg))
+                sendMessageAcrossRing(msg);
+            else {
+                if (log.isInfoEnabled())
+                    log.info("Latency check has been discarded (no remote nodes): " + msg.id());
+            }
+        }
+
+        /**
          * Processes node left message.
          *
          * @param msg Node left message.
@@ -5956,7 +6005,7 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                             continue;
                         }
-                        if (msg instanceof TcpDiscoveryPingResponse) {
+                        else if (msg instanceof TcpDiscoveryPingResponse) {
                             assert msg.client() : msg;
 
                             ClientMessageWorker clientWorker = clientMsgWorkers.get(msg.creatorNodeId());
@@ -5966,6 +6015,12 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                             continue;
                         }
+                        else if (msg instanceof TcpDiscoveryRingLatencyCheckMessage) {
+                            if (log.isInfoEnabled())
+                                log.info("Latency check message has been read: " + msg.id());
+
+                            ((TcpDiscoveryRingLatencyCheckMessage)msg).onRead();
+                        }
 
                         TcpDiscoveryClientMetricsUpdateMessage metricsUpdateMsg = null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/1fef59c7/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
index 66667aa..b31e2e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
@@ -29,7 +29,6 @@ import java.util.concurrent.ConcurrentLinkedDeque;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.util.typedef.internal.LT;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -39,6 +38,7 @@ import org.apache.ignite.spi.IgniteSpiThread;
 import org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage;
 import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
 import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryRingLatencyCheckMessage;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -292,6 +292,11 @@ abstract class TcpDiscoveryImpl {
     public abstract void brakeConnection();
 
     /**
+     * @param maxHops Maximum hops for {@link TcpDiscoveryRingLatencyCheckMessage}.
+     */
+    public abstract void checkRingLatency(int maxHops);
+
+    /**
      * <strong>FOR TEST ONLY!!!</strong>
      *
      * @return Worker thread.

http://git-wip-us.apache.org/repos/asf/ignite/blob/1fef59c7/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 46ede4d..cc581e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -2344,5 +2344,9 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
         @Override public long getCoordinatorSinceTimestamp() {
             return TcpDiscoverySpi.this.getCoordinatorSinceTimestamp();
         }
+
+        @Override public void checkRingLatency(int maxHops) {
+            TcpDiscoverySpi.this.impl.checkRingLatency(maxHops);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/1fef59c7/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
index a05ecde..fc78451 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
@@ -20,6 +20,8 @@ package org.apache.ignite.spi.discovery.tcp;
 import java.util.Map;
 import java.util.UUID;
 import org.apache.ignite.mxbean.MXBeanDescription;
+import org.apache.ignite.mxbean.MXBeanParametersDescriptions;
+import org.apache.ignite.mxbean.MXBeanParametersNames;
 import org.apache.ignite.spi.IgniteSpiManagementMBean;
 import org.jetbrains.annotations.Nullable;
 
@@ -257,4 +259,24 @@ public interface TcpDiscoverySpiMBean extends IgniteSpiManagementMBean {
      */
     @MXBeanDescription("Client mode.")
     public boolean isClientMode() throws IllegalStateException;
+
+    /**
+     * Diagnosis method for determining ring message latency.
+     * On this method call special message will be sent across the ring
+     * and stats about the message will appear in the logs of each node.
+     *
+     * @param maxHops Maximum hops for the message (3 * TOTAL_NODE_CNT is recommended).
+     */
+    @MXBeanDescription("Check ring latency.")
+    @MXBeanParametersNames(
+        {
+            "maxHops"
+        }
+    )
+    @MXBeanParametersDescriptions(
+        {
+            "Maximum hops for the message (3 * TOTAL_NODE_CNT is recommended)."
+        }
+    )
+    public void checkRingLatency(int maxHops);
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/1fef59c7/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryRingLatencyCheckMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryRingLatencyCheckMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryRingLatencyCheckMessage.java
new file mode 100644
index 0000000..d8c1145
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryRingLatencyCheckMessage.java
@@ -0,0 +1,77 @@
+/*
+ * 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.spi.discovery.tcp.messages;
+
+import java.util.UUID;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+/**
+ *
+ */
+public class TcpDiscoveryRingLatencyCheckMessage extends TcpDiscoveryAbstractMessage {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** */
+    private int maxHops;
+
+    /** */
+    private int curHop;
+
+    /**
+     * @param creatorNodeId Creator node ID.
+     * @param maxHops Max hops for this message.
+     */
+    public TcpDiscoveryRingLatencyCheckMessage(
+        UUID creatorNodeId,
+        int maxHops
+    ) {
+        super(creatorNodeId);
+
+        assert maxHops > 0;
+
+        this.maxHops = maxHops;
+    }
+
+    /**
+     *
+     */
+    public void onRead() {
+        curHop++;
+    }
+
+    /**
+     * @return Max hops.
+     */
+    public int maxHops() {
+        return maxHops;
+    }
+
+    /**
+     * @return {@code True} if max hops has been reached.
+     */
+    public boolean maxHopsReached() {
+        return curHop == maxHops;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(TcpDiscoveryRingLatencyCheckMessage.class, this, "super", super.toString());
+    }
+}


[14/17] ignite git commit: ignite-5075

Posted by sb...@apache.org.
ignite-5075


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

Branch: refs/heads/ignite-5075
Commit: cc3141588ef8e9b6acee5ff92b5996a4ee916ba5
Parents: 335216b
Author: sboikov <sb...@gridgain.com>
Authored: Wed May 17 11:17:03 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed May 17 11:17:03 2017 +0300

----------------------------------------------------------------------
 .../cache/CacheAffinitySharedManager.java       |  2 ++
 .../processors/cache/ClusterCachesInfo.java     | 34 +++++++++-----------
 .../cache/DynamicCacheDescriptor.java           | 26 +++++----------
 3 files changed, 26 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cc314158/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 e10d385..cdc83ec 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
@@ -339,6 +339,8 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
                     req.startCacheConfiguration(),
                     req.cacheType(),
                     false,
+                    action.descriptor().receivedFrom(),
+                    action.descriptor().staticallyConfigured(),
                     req.deploymentId(),
                     req.schema());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/cc314158/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index 7d1e1a6..5552841 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@ -244,11 +244,11 @@ class ClusterCachesInfo {
                         ccfg,
                         req.cacheType(),
                         true,
+                        req.initiatingNodeId(),
+                        false,
                         req.deploymentId(),
                         req.schema());
 
-                    templateDesc.receivedFrom(req.initiatingNodeId());
-
                     DynamicCacheDescriptor old = registeredTemplates().put(ccfg.getName(), templateDesc);
 
                     assert old == null;
@@ -283,11 +283,11 @@ class ClusterCachesInfo {
                             ccfg,
                             req.cacheType(),
                             false,
+                            req.initiatingNodeId(),
+                            false,
                             req.deploymentId(),
                             req.schema());
 
-                        startDesc.receivedFrom(req.initiatingNodeId());
-
                         DynamicCacheDescriptor old = registeredCaches.put(ccfg.getName(), startDesc);
 
                         assert old == null;
@@ -618,12 +618,11 @@ class ClusterCachesInfo {
                 cacheData.cacheConfiguration(),
                 cacheData.cacheType(),
                 true,
+                cacheData.receivedFrom(),
+                cacheData.staticallyConfigured(),
                 cacheData.deploymentId(),
                 cacheData.schema());
 
-            desc.receivedFrom(cacheData.receivedFrom());
-            desc.staticallyConfigured(cacheData.staticallyConfigured());
-
             registeredTemplates.put(cacheData.cacheConfiguration().getName(), desc);
         }
 
@@ -635,12 +634,11 @@ class ClusterCachesInfo {
                 cacheData.cacheConfiguration(),
                 cacheData.cacheType(),
                 false,
+                cacheData.receivedFrom(),
+                cacheData.staticallyConfigured(),
                 cacheData.deploymentId(),
                 cacheData.schema());
 
-            desc.receivedFrom(cacheData.receivedFrom());
-            desc.staticallyConfigured(cacheData.staticallyConfigured());
-
             registeredCaches.put(cacheData.cacheConfiguration().getName(), desc);
 
             ctx.discovery().setCacheFilter(
@@ -663,6 +661,8 @@ class ClusterCachesInfo {
 
         if (!disconnectedState())
             initStartCachesForLocalJoin(false);
+        else
+            locJoinStartCaches = Collections.emptyList();
     }
 
     /**
@@ -691,14 +691,14 @@ class ClusterCachesInfo {
                             locCfg.config(),
                             desc.cacheType(),
                             desc.template(),
+                            desc.receivedFrom(),
+                            desc.staticallyConfigured(),
                             desc.deploymentId(),
                             desc.schema());
 
                     desc0.startTopologyVersion(desc.startTopologyVersion());
                     desc0.receivedFromStartVersion(desc.receivedFromStartVersion());
                     desc0.clientCacheStartVersion(desc.clientCacheStartVersion());
-                    desc0.receivedFrom(desc.receivedFrom());
-                    desc0.staticallyConfigured(desc.staticallyConfigured());
 
                     desc = desc0;
                 }
@@ -763,12 +763,11 @@ class ClusterCachesInfo {
                     cfg,
                     cacheInfo.cacheType(),
                     true,
+                    nodeId,
+                    true,
                     joinData.cacheDeploymentId(),
                     new QuerySchema(cfg.getQueryEntities()));
 
-                desc.staticallyConfigured(true);
-                desc.receivedFrom(nodeId);
-
                 DynamicCacheDescriptor old = registeredTemplates.put(cfg.getName(), desc);
 
                 assert old == null : old;
@@ -783,12 +782,11 @@ class ClusterCachesInfo {
                     cfg,
                     cacheInfo.cacheType(),
                     false,
+                    nodeId,
+                    true,
                     joinData.cacheDeploymentId(),
                     new QuerySchema(cfg.getQueryEntities()));
 
-                desc.staticallyConfigured(true);
-                desc.receivedFrom(nodeId);
-
                 DynamicCacheDescriptor old = registeredCaches.put(cfg.getName(), desc);
 
                 assert old == null : old;

http://git-wip-us.apache.org/repos/asf/ignite/blob/cc314158/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
index cec1828..366ea7d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
@@ -46,7 +46,7 @@ public class DynamicCacheDescriptor {
     private CacheConfiguration cacheCfg;
 
     /** Statically configured flag. */
-    private boolean staticCfg;
+    private final boolean staticCfg;
 
     /** Cache type. */
     private CacheType cacheType;
@@ -64,7 +64,7 @@ public class DynamicCacheDescriptor {
     private Integer cacheId;
 
     /** */
-    private UUID rcvdFrom;
+    private final UUID rcvdFrom;
 
     /** Mutex. */
     private final Object mux = new Object();
@@ -92,6 +92,8 @@ public class DynamicCacheDescriptor {
      * @param cacheCfg Cache configuration.
      * @param cacheType Cache type.
      * @param template {@code True} if this is template configuration.
+     * @param rcvdFrom ID of node provided cache configuration
+     * @param staticCfg {@code True} if cache statically configured.
      * @param deploymentId Deployment ID.
      */
     @SuppressWarnings("unchecked")
@@ -99,6 +101,8 @@ public class DynamicCacheDescriptor {
         CacheConfiguration cacheCfg,
         CacheType cacheType,
         boolean template,
+        UUID rcvdFrom,
+        boolean staticCfg,
         IgniteUuid deploymentId,
         QuerySchema schema) {
         assert cacheCfg != null;
@@ -113,6 +117,8 @@ public class DynamicCacheDescriptor {
         this.cacheCfg = cacheCfg;
         this.cacheType = cacheType;
         this.template = template;
+        this.rcvdFrom = rcvdFrom;
+        this.staticCfg = staticCfg;
         this.deploymentId = deploymentId;
 
         pluginMgr = new CachePluginManager(ctx, cacheCfg);
@@ -160,13 +166,6 @@ public class DynamicCacheDescriptor {
     }
 
     /**
-     * @param staticCfg {@code True} if statically configured.
-     */
-    public void staticallyConfigured(boolean staticCfg) {
-        this.staticCfg = staticCfg;
-    }
-
-    /**
      * @return Cache name.
      */
     public String cacheName() {
@@ -220,15 +219,6 @@ public class DynamicCacheDescriptor {
     }
 
     /**
-     * @param nodeId ID of node provided cache configuration in discovery data.
-     */
-    public void receivedFrom(UUID nodeId) {
-        assert nodeId != null;
-
-        rcvdFrom = nodeId;
-    }
-
-    /**
      * @return ID of node provided cache configuration in discovery data.
      */
     @Nullable public UUID receivedFrom() {


[12/17] ignite git commit: IGNITE-5082 Change footer links color in order to improve readability.

Posted by sb...@apache.org.
IGNITE-5082 Change footer links color in order to improve readability.


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

Branch: refs/heads/ignite-5075
Commit: 7a4a1940e14ea9809740eeb8d25261f58e005452
Parents: 73fc01c
Author: Ilya Borisov <ib...@gridgain.com>
Authored: Wed May 17 14:00:50 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Wed May 17 14:00:50 2017 +0700

----------------------------------------------------------------------
 .../frontend/app/components/web-console-footer/style.scss | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7a4a1940/modules/web-console/frontend/app/components/web-console-footer/style.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/web-console-footer/style.scss b/modules/web-console/frontend/app/components/web-console-footer/style.scss
index 962b4f3..c6193b8 100644
--- a/modules/web-console/frontend/app/components/web-console-footer/style.scss
+++ b/modules/web-console/frontend/app/components/web-console-footer/style.scss
@@ -42,4 +42,14 @@ web-console-footer {
     ignite-powered-by-apache {
         margin-left: auto;
     }
+
+    a {
+        color: #ee8e89;
+
+        &:hover, &.hover,
+        &:focus, &.focus {
+            color: #ee2b27;
+            text-decoration: none;
+        }
+    }
 }
\ No newline at end of file


[15/17] ignite git commit: ignite-5075

Posted by sb...@apache.org.
ignite-5075


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

Branch: refs/heads/ignite-5075
Commit: 6f194b398e696379291a1bd92853783214458d72
Parents: cc31415
Author: sboikov <sb...@gridgain.com>
Authored: Wed May 17 11:21:16 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed May 17 11:21:16 2017 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/cache/ClusterCachesInfo.java     | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6f194b39/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index 5552841..45eca44 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@ -146,7 +146,10 @@ class ClusterCachesInfo {
             CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "cachePreloadMode",
                 "Cache preload mode", locAttr.cacheRebalanceMode(), rmtAttr.cacheRebalanceMode(), true);
 
-            if (CU.affinityNode(ctx.discovery().localNode(), locCfg.getNodeFilter())) {
+            ClusterNode rmtNode = ctx.discovery().node(rmt);
+
+            if (CU.affinityNode(ctx.discovery().localNode(), locCfg.getNodeFilter())
+                && rmtNode != null && CU.affinityNode(rmtNode, rmtCfg.getNodeFilter())) {
                 CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "storeFactory", "Store factory",
                     locAttr.storeFactoryClassName(), rmtAttr.storeFactoryClassName(), true);
             }