ignite-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ignite] alex-plekhanov commented on a change in pull request #6845: IGNITE-12145: Monitoring list engine.
Date Thu, 12 Sep 2019 09:15:42 GMT
alex-plekhanov commented on a change in pull request #6845: IGNITE-12145: Monitoring list engine.
URL: https://github.com/apache/ignite/pull/6845#discussion_r323637032
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/metric/GridMetricManager.java
 ##########
 @@ -265,47 +379,127 @@ public MetricRegistry registry(String name) {
         return registries.computeIfAbsent(name, n -> {
             MetricRegistry mreg = new MetricRegistry(name, log);
 
-            notifyListeners(mreg, metricRegCreationLsnrs);
+            notifyListeners(mreg, metricRegCreationLsnrs, log);
 
             return mreg;
         });
     }
 
-    /** {@inheritDoc} */
-    @NotNull @Override public Iterator<MetricRegistry> iterator() {
-        return registries.values().iterator();
+    /**
+     * Registers list which exports {@link ConcurrentMap} content.
+     *
+     * @param name Name of the list.
+     * @param desc Description of the list.
+     * @param rowCls Row class.
+     * @param data Data of the list.
+     * @param rowFunc value to row function.
+     * @param rowClearer Function that clears data on list removal.
+     * @param <R> List row type.
+     * @param <D> Map data type.
+     */
+    public <R extends MonitoringRow, D> void registerList(String name, String desc,
+        Class<R> rowCls, ConcurrentMap<?, D> data, Function<D, R> rowFunc,
Consumer<D> rowClearer) {
+
+        Supplier<MonitoringList<R>> listCreator = () -> (MonitoringList<R>)lists.computeIfAbsent(name,
n -> {
+            MonitoringList<R> list = new MonitoringListAdapter<>(name,
+                desc,
+                rowCls,
+                (MonitoringRowAttributeWalker<R>)walkers.get(rowCls),
+                data,
+                rowFunc);
+
+            notifyListeners(list, listCreationLsnrs, log);
+
+            return list;
+        });
+
+        // Create new instance of the list.
+        listCreator.get();
+
+        ctx.metric().addEnableListListener(name, n -> listCreator.get());
 
 Review comment:
   Let's inline `listCreators.put()` here and pass `listCreators` as `Runnable` without creating
new lambda.
   Methods `addEnableListListener` and `addRemoveListListener` can be removed.

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


With regards,
Apache Git Services

Mime
View raw message