Cache stop request batching - Fixes
@@ -2775,15 +2775,35 @@ public class GridCacheProcessor extends GridProcessorAdapter {
List<DynamicCacheChangeRequest> reqs = new ArrayList<>(cacheNames.size());
for (String cacheName : cacheNames) {
+ reqs.add(createStopRequest(cacheName, restart, destroy));
+ }
+
+ return dynamicChangeCaches(reqs);
+ }
+
+ /**
+ * Prepares cache stop request.
+ * @param cacheName Cache names to destroy.
+ * @param restart Restart flag.
+ * @param destroy Cache data destroy flag. Setting to {@code true} will cause removing all cache data from store.
+ * @return Future that will be completed when cache is destroyed.
+ */
+ @NotNull public DynamicCacheChangeRequest createStopRequest(String cacheName, boolean restart, boolean destroy) {
DynamicCacheChangeRequest req = DynamicCacheChangeRequest.stopRequest(ctx, cacheName, false, true);
req.stop(true);
req.destroy(destroy);
req.restart(restart);
- reqs.add(req);
+ return req;
}
+ /**
+ * Starts cache stop request as cache change batch.
+ * @param reqs cache stop requests.
+ * @return compound future.
+ */
+ @NotNull public IgniteInternalFuture<?> dynamicChangeCaches(List<DynamicCacheChangeRequest> reqs) {
GridCompoundFuture<?, ?> compoundFut = new GridCompoundFuture<>();
for (DynamicCacheStartFuture fut : initiateCacheChanges(reqs))
@@ -3770,9 +3790,11 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
/**
+ * Method checks that current thread does not have active transactions.
+ *
* @throws IgniteException If transaction exist.
*/
- private void checkEmptyTransactions() throws IgniteException {
+ public void checkEmptyTransactions() throws IgniteException {
if (transactions().tx() != null || sharedCtx.lockedTopologyVersion(null) != null)
throw new IgniteException("Cannot start/stop cache within lock or transaction.");
}
