alex-plekhanov commented on a change in pull request #6845: IGNITE-12145: 
Monitoring list engine.
URL: https://github.com/apache/ignite/pull/6845#discussion_r323591700
 
 

 ##########
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/metric/GridMetricManager.java
 ##########
 @@ -265,45 +378,116 @@ 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();
+    public <R extends MonitoringRow, D> void list(String name, String 
description,
+        Class<R> rowClazz, Supplier<ConcurrentMap<?, D>> data, Function<D, R> 
rowFunc, Consumer<D> clearer) {
+
+        Supplier<MonitoringList<R>> listCreator = () -> list(name, () -> new 
MonitoringListAdapter<>(name,
+            description,
+            rowClazz,
+            (MonitoringRowAttributeWalker<R>)walkers.get(rowClazz),
+            data.get(),
+            rowFunc));
+
+        //Create new instance of the list.
+        listCreator.get();
+
+        ctx.metric().addEnableListListener(listenOnlyEqual(name, identity(), n 
-> listCreator.get()));
+        ctx.metric().addRemoveListListener(l -> 
data.get().values().forEach(clearer));
     }
 
-    /** {@inheritDoc} */
-    @Override public void 
addMetricRegistryCreationListener(Consumer<MetricRegistry> lsnr) {
-        metricRegCreationLsnrs.add(lsnr);
+    /**
+     * @param name Name of the list.
+     * @return List.
+     */
+    @Nullable public <R extends MonitoringRow> MonitoringList<R> list(String 
name) {
+        return (MonitoringList<R>)lists.get(name);
+    }
+
+    /**
+     * Gets or creates {@link MonitoringList}.
+     *
+     * @param name Name of the list.
+     * @param listSupplier List supplier.
+     * @param <R> Type of the row.
+     * @return Monitoring list.
+     */
+    private <R extends MonitoringRow> MonitoringList<R> list(String name,
 
 Review comment:
   Let's don't introduce any functional prematurely, follow-up PRs also can 
have some fixes after review, so it's not a fact that this method will be 
needed.
   
   And here is naming problem again. You have overloaded `registerList` 
methods, one of it register some listeners, another one creates the list after 
enabling.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to