This is an automated email from the ASF dual-hosted git repository.

irakov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 76b4a11  IGNITE-10761 GridCacheProcessor should add info about cache 
in excecption message, if applicable. - Fixes #6697.
76b4a11 is described below

commit 76b4a112ce4c035db83ab43b7e2f66973d15eb62
Author: Kirill Tkalenko <tkalkir...@yandex.ru>
AuthorDate: Tue Jul 23 22:16:00 2019 +0300

    IGNITE-10761 GridCacheProcessor should add info about cache in excecption 
message, if applicable. - Fixes #6697.
    
    Signed-off-by: Ivan Rakov <ira...@apache.org>
---
 .../processors/cache/GridCacheProcessor.java       | 63 ++++++++++++++++++----
 1 file changed, 52 insertions(+), 11 deletions(-)

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 baf4c84..daa2992 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
@@ -36,6 +36,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import javax.cache.configuration.FactoryBuilder;
@@ -241,6 +242,12 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
         "(encryption settings are different for cache '%s' : local=%s, 
remote=%s.)";
 
     /** */
+    private static final String CACHE_NAME_AND_OPERATION_FORMAT = 
"[cacheName=%s, operation=%s]";
+
+    /** */
+    private static final String CACHE_NAMES_AND_OPERATION_FORMAT = 
"[cacheNames=%s, operation=%s]";
+
+    /** */
     private final boolean startClientCaches =
         
IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_START_CACHES_ON_JOIN,
 false);
 
@@ -4056,8 +4063,10 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
     ) {
         assert cacheName != null;
 
-        if (checkThreadTx)
-            checkEmptyTransactions();
+        if (checkThreadTx) {
+            checkEmptyTransactionsEx(() -> 
String.format(CACHE_NAME_AND_OPERATION_FORMAT, cacheName,
+                "dynamicStartCache"));
+        }
 
         GridPlainClosure<Collection<byte[]>, IgniteInternalFuture<Boolean>> 
startCacheClsr = (grpKeys) -> {
             assert ccfg == null || !ccfg.isEncryptionEnabled() || 
!grpKeys.isEmpty();
@@ -4206,8 +4215,16 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
         boolean disabledAfterStart,
         IgniteUuid restartId
     ) {
-        if (checkThreadTx)
-            checkEmptyTransactions();
+        if (checkThreadTx) {
+            checkEmptyTransactionsEx(() -> {
+                List<String> cacheNames = storedCacheDataList.stream()
+                    .map(StoredCacheData::config)
+                    .map(CacheConfiguration::getName)
+                    .collect(Collectors.toList());
+
+                return String.format(CACHE_NAMES_AND_OPERATION_FORMAT, 
cacheNames, "dynamicStartCachesByStoredConf");
+            });
+        }
 
         GridPlainClosure<Collection<byte[]>, IgniteInternalFuture<Boolean>> 
startCacheClsr = (grpKeys) -> {
             List<DynamicCacheChangeRequest> srvReqs = null;
@@ -4309,8 +4326,10 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
     ) {
         assert cacheName != null;
 
-        if (checkThreadTx)
-            checkEmptyTransactions();
+        if (checkThreadTx) {
+            checkEmptyTransactionsEx(() -> 
String.format(CACHE_NAME_AND_OPERATION_FORMAT, cacheName,
+                "dynamicDestroyCache"));
+        }
 
         DynamicCacheChangeRequest req = 
DynamicCacheChangeRequest.stopRequest(ctx, cacheName, sql, true);
 
@@ -4342,8 +4361,10 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
         boolean checkThreadTx,
         boolean destroy
     ) {
-        if (checkThreadTx)
-            checkEmptyTransactions();
+        if (checkThreadTx) {
+            checkEmptyTransactionsEx(() -> 
String.format(CACHE_NAMES_AND_OPERATION_FORMAT, cacheNames,
+                "dynamicDestroyCaches"));
+        }
 
         List<DynamicCacheChangeRequest> reqs = new 
ArrayList<>(cacheNames.size());
 
@@ -4429,7 +4450,7 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
         if (proxy == null || proxy.isProxyClosed())
             return new GridFinishedFuture<>(); // No-op.
 
-        checkEmptyTransactions();
+        checkEmptyTransactionsEx(() -> 
String.format(CACHE_NAME_AND_OPERATION_FORMAT, cacheName, "dynamicCloseCache"));
 
         if (proxy.context().isLocal())
             return dynamicDestroyCache(cacheName, false, true, false, null);
@@ -4444,11 +4465,14 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
      * @return Future that will be completed when state is changed for all 
caches.
      */
     public IgniteInternalFuture<?> resetCacheState(Collection<String> 
cacheNames) {
-        checkEmptyTransactions();
-
         if (F.isEmpty(cacheNames))
             cacheNames = cachesInfo.registeredCaches().keySet();
 
+        Collection<String> forCheckCacheNames = cacheNames;
+
+        checkEmptyTransactionsEx(() -> 
String.format(CACHE_NAME_AND_OPERATION_FORMAT, forCheckCacheNames,
+            "resetCacheState"));
+
         Collection<DynamicCacheChangeRequest> reqs = new 
ArrayList<>(cacheNames.size());
 
         for (String cacheName : cacheNames) {
@@ -5644,6 +5668,23 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
     }
 
     /**
+     * Method invoke {@link #checkEmptyTransactions()} and add message in case 
exception.
+     *
+     * @param eMsgSupplier supplier additional text message
+     * @throws IgniteException If {@link #checkEmptyTransactions()} throw 
{@link IgniteException}
+     * */
+    private void checkEmptyTransactionsEx(final Supplier<String> eMsgSupplier) 
throws IgniteException {
+        assert eMsgSupplier != null;
+
+        try {
+            checkEmptyTransactions();
+        }
+        catch (IgniteException e) {
+            throw new IgniteException(e.getMessage() + ' ' + 
eMsgSupplier.get(), e);
+        }
+    }
+
+    /**
      * @param val Object to check.
      * @return Configuration copy.
      * @throws IgniteCheckedException If validation failed.

Reply via email to