JAkutenshi commented on code in PR #6880:
URL: https://github.com/apache/ignite-3/pull/6880#discussion_r2498099239


##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/metrics/PlacementDriverMetricSource.java:
##########
@@ -33,122 +33,71 @@ public class PlacementDriverMetricSource extends 
AbstractMetricSource<Holder> {
     /** Source name. */
     public static final String SOURCE_NAME = "placement-driver";
 
-    private final IntSupplier activeLeaseSupplier;
-    private final IntSupplier leaseWithoutCandidatesSupplier;
-    private final IntSupplier currentStableAssignmentSizeSupplier;
-    private final IntSupplier currentPendingAssignmentSizeSupplier;
+    private final LeaseTracker leaseTracker;
+    private final AssignmentsTracker assignmentsTracker;
 
     /**
      * Constructor.
      *
-     * @param activeLeaseSupplier Supplier for active leases count.
-     * @param leaseWithoutCandidatesSupplier Supplier for leases without 
candidates count.
-     * @param currentStableAssignmentSizeSupplier Supplier for the stable 
assignments count.
-     * @param currentPendingAssignmentSizeSupplier Supplier for the pending 
assignments count.
+     * @param leaseTracker Lease tracker.
+     * @param assignmentsTracker Assignments tracker.
      */
     public PlacementDriverMetricSource(
-            IntSupplier activeLeaseSupplier,
-            IntSupplier leaseWithoutCandidatesSupplier,
-            IntSupplier currentStableAssignmentSizeSupplier,
-            IntSupplier currentPendingAssignmentSizeSupplier
+            LeaseTracker leaseTracker,
+            AssignmentsTracker assignmentsTracker
     ) {
         super(SOURCE_NAME, "Placement driver metrics.");
 
-        this.activeLeaseSupplier = activeLeaseSupplier;
-        this.leaseWithoutCandidatesSupplier = leaseWithoutCandidatesSupplier;
-        this.currentStableAssignmentSizeSupplier = 
currentStableAssignmentSizeSupplier;
-        this.currentPendingAssignmentSizeSupplier = 
currentPendingAssignmentSizeSupplier;
+        this.leaseTracker = leaseTracker;
+        this.assignmentsTracker = assignmentsTracker;
     }
 
     @Override
     protected Holder createHolder() {
         return new Holder();
     }
 
-    /**
-     * Is called on lease creation.
-     */
-    public void onLeaseCreate() {
-        Holder holder = holder();
-        if (holder != null) {
-            holder.leasesCreated.increment();
-        }
-    }
-
-    /**
-     * Is called on lease prolongation.
-     */
-    public void onLeaseProlong() {
-        Holder holder = holder();
-        if (holder != null) {
-            holder.leasesProlonged.increment();
-        }
-    }
-
-    /**
-     * Is called on lease publishing.
-     */
-    public void onLeasePublish() {
-        Holder holder = holder();
-        if (holder != null) {
-            holder.leasesPublished.increment();
-        }
-    }
-
     /** Holder. */
     protected class Holder implements AbstractMetricSource.Holder<Holder> {
-        private final LongAdderMetric leasesCreated = new LongAdderMetric(
-                "LeasesCreated",
-                "Total number of created leases."
-        );
-
-        private final LongAdderMetric leasesPublished = new LongAdderMetric(
-                "LeasesPublished",
-                "Total number of published leases."
-        );
-
-        private final LongAdderMetric leasesProlonged = new LongAdderMetric(
-                "LeasesProlonged",
-                "Total number of prolonged leases."
-        );
-
-        private final IntMetric activeLeaseCount = new IntGauge(
-                "ActiveLeasesCount",
-                "Number of currently active leases.",
-                activeLeaseSupplier
+        private final IntGauge acceptedLeases = new IntGauge(
+                "AcceptedLeases",
+                "Number of accepted leases.",
+                () -> numberOfLeases(true)
         );
 
-        private final IntMetric leaseWithoutCandidates = new IntGauge(
-                "LeasesWithoutCandidates",
-                "Number of leases without candidates currently existing.",
-                leaseWithoutCandidatesSupplier
+        private final IntGauge leaseNegotiations = new IntGauge(
+                "LeaseNegotiations",
+                "Number of leases under negotiation.",
+                () -> numberOfLeases(false)
         );
 
-        private final IntMetric currentStableAssignmentSize = new IntGauge(
-                "CurrentStableAssignmentsSize",
-                "Current size of stable assignments over all partitions.",
-                currentStableAssignmentSizeSupplier
-        );
-
-        private final IntMetric currentPendingAssignmentSize = new IntGauge(
-                "CurrentPendingAssignmentsSize",
-                "Current size of pending assignments over all partitions.",
-                currentPendingAssignmentSizeSupplier
+        private final IntGauge replicationGroups = new IntGauge(
+                "ReplicationGroups",
+                "Current number of replication groups.",
+                () -> assignmentsTracker.stableAssignments().size()
         );
 
         private final List<Metric> metrics = List.of(
-                leasesCreated,
-                leasesPublished,
-                leasesProlonged,
-                leaseWithoutCandidates,
-                activeLeaseCount,
-                currentStableAssignmentSize,
-                currentPendingAssignmentSize
+                acceptedLeases,
+                leaseNegotiations,
+                replicationGroups
         );
 
         @Override
         public Iterable<Metric> metrics() {
             return metrics;
         }
+
+        private int numberOfLeases(boolean accepted) {

Review Comment:
   I think yes, but if there is no any changes, I'd left as is.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to