This is an automated email from the ASF dual-hosted git repository. amashenkov pushed a commit to branch gg-21368 in repository https://gitbox.apache.org/repos/asf/ignite.git
commit 4b045f5a0f04ce89a3266f825bebd3136af5c0b0 Author: ktkalenko <ktkale...@gridgain.com> AuthorDate: Wed Jul 17 11:54:50 2019 +0300 GG-19117 GridCacheProcessor should add info about cache in exception message, if applicable. --- .../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 7399123..ee17408 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 @@ -35,6 +35,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; @@ -240,6 +241,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); @@ -4052,8 +4059,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(); @@ -4202,8 +4211,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; @@ -4305,8 +4322,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); @@ -4338,8 +4357,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()); @@ -4425,7 +4446,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); @@ -4440,11 +4461,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) { @@ -5640,6 +5664,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.