ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [16/19] ignite git commit: ignite-5155
Date Sat, 10 Jun 2017 06:20:47 GMT
ignite-5155


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

Branch: refs/heads/ignite-5155
Commit: 96c8ec097fefe66a1318330ea7b585887f3c1bde
Parents: e28efb1
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Jun 9 18:09:24 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Jun 9 18:13:44 2017 +0300

----------------------------------------------------------------------
 .../IgniteDiagnosticPrepareContext.java         |   7 ++
 .../GridCachePartitionExchangeManager.java      |  36 +++++--
 .../managers/IgniteDiagnosticMessagesTest.java  | 101 +++++++++++++++++--
 3 files changed, 130 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/96c8ec09/modules/core/src/main/java/org/apache/ignite/internal/IgniteDiagnosticPrepareContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteDiagnosticPrepareContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/IgniteDiagnosticPrepareContext.java
index 856510a..b55199a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteDiagnosticPrepareContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteDiagnosticPrepareContext.java
@@ -110,6 +110,13 @@ public class IgniteDiagnosticPrepareContext {
     }
 
     /**
+     * @return {@code True} if there are no added closures.
+     */
+    public boolean empty() {
+        return cls.isEmpty();
+    }
+
+    /**
      * @param ctx Grid context.
      * @param lsnr Optional listener (used in test).
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/96c8ec09/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index d418aac..ef21bf1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -1439,12 +1439,15 @@ public class GridCachePartitionExchangeManager<K, V> extends
GridCacheSharedMana
 
         GridCacheMvccManager mvcc = cctx.mvcc();
 
+        final IgniteDiagnosticPrepareContext diagCtx = cctx.kernalContext().cluster().diagnosticEnabled()
?
+            new IgniteDiagnosticPrepareContext(cctx.localNodeId()) : null;
+
         if (tm != null) {
             for (IgniteInternalTx tx : tm.activeTransactions()) {
                 if (curTime - tx.startTime() > timeout) {
                     found = true;
 
-                    U.warn(log, "Found long running transaction [startTime=" + formatTime(tx.startTime())
+
+                    U.warn(diagnosticLog, "Found long running transaction [startTime=" +
formatTime(tx.startTime()) +
                         ", curTime=" + formatTime(curTime) + ", tx=" + tx + ']');
                 }
             }
@@ -1455,8 +1458,11 @@ public class GridCachePartitionExchangeManager<K, V> extends
GridCacheSharedMana
                 if (curTime - fut.startTime() > timeout) {
                     found = true;
 
-                    U.warn(log, "Found long running cache future [startTime=" + formatTime(fut.startTime())
+
+                    U.warn(diagnosticLog, "Found long running cache future [startTime=" +
formatTime(fut.startTime()) +
                         ", curTime=" + formatTime(curTime) + ", fut=" + fut + ']');
+
+                    if (diagCtx != null && fut instanceof IgniteDiagnosticAware)
+                        ((IgniteDiagnosticAware)fut).addDiagnosticRequest(diagCtx);
                 }
             }
 
@@ -1464,12 +1470,28 @@ public class GridCachePartitionExchangeManager<K, V> extends
GridCacheSharedMana
                 if (curTime - fut.startTime() > timeout) {
                     found = true;
 
-                    U.warn(log, "Found long running cache future [startTime=" + formatTime(fut.startTime())
+
+                    U.warn(diagnosticLog, "Found long running cache future [startTime=" +
formatTime(fut.startTime()) +
                         ", curTime=" + formatTime(curTime) + ", fut=" + fut + ']');
+
+                    if (diagCtx != null && fut instanceof IgniteDiagnosticAware)
+                        ((IgniteDiagnosticAware)fut).addDiagnosticRequest(diagCtx);
                 }
             }
         }
 
+        if (diagCtx != null && !diagCtx.empty()) {
+            try {
+                cctx.kernalContext().closure().runLocal(new Runnable() {
+                    @Override public void run() {
+                        diagCtx.send(cctx.kernalContext(), null);
+                    }
+                }, SYSTEM_POOL);
+            }
+            catch (IgniteCheckedException e) {
+                U.error(diagnosticLog, "Failed to submit diagnostic closure: " + e, e);
+            }
+        }
+
         return found;
     }
 
@@ -1491,13 +1513,13 @@ public class GridCachePartitionExchangeManager<K, V> extends
GridCacheSharedMana
                 nextLongRunningOpsDumpTime = U.currentTimeMillis() + nextDumpTimeout(longRunningOpsDumpStep++,
timeout);
 
                 if (IgniteSystemProperties.getBoolean(IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT,
false)) {
-                    U.warn(log, "Found long running cache operations, dump threads.");
+                    U.warn(diagnosticLog, "Found long running cache operations, dump threads.");
 
-                    U.dumpThreads(log);
+                    U.dumpThreads(diagnosticLog);
                 }
 
                 if (IgniteSystemProperties.getBoolean(IGNITE_IO_DUMP_ON_TIMEOUT, false))
{
-                    U.warn(log, "Found long running cache operations, dump IO statistics.");
+                    U.warn(diagnosticLog, "Found long running cache operations, dump IO statistics.");
 
                     // Dump IO manager statistics.
                     cctx.gridIO().dumpStats();
@@ -1509,7 +1531,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
             }
         }
         catch (Exception e) {
-            U.error(log, "Failed to dump debug information: " + e, e);
+            U.error(diagnosticLog, "Failed to dump debug information: " + e, e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/96c8ec09/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java
index 011fdc9..08dbc66 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/IgniteDiagnosticMessagesTest.java
@@ -17,25 +17,34 @@
 
 package org.apache.ignite.internal.managers;
 
+import java.util.UUID;
+import java.util.concurrent.Callable;
 import java.util.concurrent.ThreadLocalRandom;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteDiagnosticPrepareContext;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.TestRecordingCommunicationSpi;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetResponse;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
 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.testframework.GridStringLogger;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT;
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
 
 /**
@@ -51,24 +60,31 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest
{
     /** */
     private Integer connectionsPerNode;
 
+    /** */
+    private boolean testSpi;
+
+    /** */
+    private GridStringLogger strLog;
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
         ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
 
+        if (testSpi)
+            cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());
+
         if (connectionsPerNode != null)
             ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setConnectionsPerNode(connectionsPerNode);
 
         cfg.setClientMode(client);
 
-        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
-
-        ccfg.setWriteSynchronizationMode(FULL_SYNC);
-        ccfg.setCacheMode(CacheMode.REPLICATED);
-        ccfg.setAtomicityMode(TRANSACTIONAL);
+        if (strLog != null) {
+            cfg.setGridLogger(strLog);
 
-        cfg.setCacheConfiguration(ccfg);
+            strLog = null;
+        }
 
         return cfg;
     }
@@ -80,6 +96,7 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest
{
         super.afterTestsStopped();
     }
 
+
     /**
      * @throws Exception If failed.
      */
@@ -99,6 +116,68 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest
{
     /**
      * @throws Exception If failed.
      */
+    public void testLongRunning() throws Exception {
+        System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, "3500");
+
+        try {
+            testSpi = true;
+
+            startGrid(0);
+
+            GridStringLogger strLog = this.strLog = new GridStringLogger();
+
+            startGrid(1);
+
+            awaitPartitionMapExchange();
+
+            CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
+
+            ccfg.setWriteSynchronizationMode(FULL_SYNC);
+            ccfg.setCacheMode(PARTITIONED);
+            ccfg.setAtomicityMode(TRANSACTIONAL);
+
+            final Ignite node0 = ignite(0);
+
+            node0.createCache(ccfg);
+
+            final Ignite node1 = ignite(1);
+
+            UUID id0 = node0.cluster().localNode().id();
+            UUID id1 = node1.cluster().localNode().id();
+
+            TestRecordingCommunicationSpi.spi(node0).blockMessages(GridNearSingleGetResponse.class,
node1.name());
+
+            IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable<Void>()
{
+                @Override public Void call() throws Exception {
+                    Integer key = primaryKey(node0.cache(DEFAULT_CACHE_NAME));
+
+                    node1.cache(DEFAULT_CACHE_NAME).get(key);
+
+                    return null;
+                }
+            }, "get");
+
+            U.sleep(10_000);
+
+            assertFalse(fut.isDone());
+
+            TestRecordingCommunicationSpi.spi(node0).stopBlock();
+
+            fut.get();
+
+            String log = strLog.toString();
+
+            assertTrue(log.contains("GridPartitionedSingleGetFuture waiting for response
[node=" + id0));
+            assertTrue(log.contains("General node info [id=" + id0));
+        }
+        finally {
+            System.clearProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT);
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     private void checkBasicDiagnosticInfo() throws Exception {
         startGrids(3);
 
@@ -108,6 +187,14 @@ public class IgniteDiagnosticMessagesTest extends GridCommonAbstractTest
{
 
         startGrid(4);
 
+        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
+
+        ccfg.setWriteSynchronizationMode(FULL_SYNC);
+        ccfg.setCacheMode(REPLICATED);
+        ccfg.setAtomicityMode(TRANSACTIONAL);
+
+        ignite(0).createCache(ccfg);
+
         awaitPartitionMapExchange();
 
         sendDiagnostic();


Mime
View raw message