alamar commented on a change in pull request #6168: IGNITE-6578 Too many 
diagnostic: Found long running cache future
URL: https://github.com/apache/ignite/pull/6168#discussion_r260224635
 
 

 ##########
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
 ##########
 @@ -3366,4 +3396,99 @@ private AffinityReadyFuture(AffinityTopologyVersion 
topVer) {
             return S.toString(AffinityReadyFuture.class, this, 
super.toString());
         }
     }
+
+    /**
+     * Class to print only limited number of warnings.
+     */
+    private static class WarningsGroup {
+        /** */
+        private final IgniteLogger log;
+
+        /** */
+        private final int warningsLimit;
+
+        /** */
+        private List<String> messages;
+
+        /** */
+        private int warningsTotal;
+
+        /**
+         * @param log Target logger.
+         * @param warningsLimit Warnings limit.
+         */
+        private WarningsGroup(IgniteLogger log, int warningsLimit) {
+            this.log = log;
+
+            this.warningsLimit = warningsLimit;
+        }
+
+        /**
+         * @param msg Warning message.
+         * @return {@code true} if message is added to list.
+         */
+        private boolean add(String msg) {
+            boolean added = false;
+
+            if (canAddMessage()) {
+                if (messages == null)
+                    messages = new ArrayList<>(warningsLimit);
+
+                messages.add(msg);
+
+                added = true;
+            }
+
+            warningsTotal++;
+
+            return added;
+        }
+
+        /**
+         * @return {@code true} if messages list size less than limit.
+         */
+        private boolean canAddMessage() {
+            return warningsTotal < warningsLimit;
+        }
+
+        /**
+         * Increase total number of warnings.
+         */
+        private void incTotal() {
+            warningsTotal++;
+        }
+
+        /**
+         * Print warnings block title and messages.
+         *
+         * @param title Title template.
+         */
+        private void flush(String title) {
 
 Review comment:
   Thus you can only keep one flush() method and simplify it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to