ibessonov commented on code in PR #6961:
URL: https://github.com/apache/ignite-3/pull/6961#discussion_r2526056941


##########
modules/page-memory/src/test/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointerTest.java:
##########
@@ -515,11 +519,112 @@ void testNextCheckpointInterval() throws Exception {
         );
     }
 
+    @Test
+    void testIoSpeedLogsWrittenCorrectly() throws Exception {
+        var metrics = new TrackingCheckpointMetrics();
+
+        Checkpointer checkpointer = createCheckpointerWithPages(metrics);
+
+        CompletableFuture<String> statResult = new CompletableFuture<>();
+
+        logInspector.addHandler(new Handler(
+                event -> 
event.getMessage().getFormattedMessage().startsWith("Checkpoint finished ["),
+                event -> {
+                    String msg = event.getMessage().getFormattedMessage();
+
+                    String ioSpeed = 
IO_SPEED_PATTERN.matcher(msg).replaceAll("$1");
+
+                    statResult.complete(ioSpeed);
+                }
+        ));
+
+        assertDoesNotThrow(checkpointer::doCheckpoint);
+
+        await().until(statResult::isDone);
+
+        String ioSpeed = statResult.get(10, SECONDS);

Review Comment:
   If there's already an `await` on a previous line then you don't have to pass 
a timeout anymore, it is meaningless



##########
modules/page-memory/src/test/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointerTest.java:
##########
@@ -515,11 +519,112 @@ void testNextCheckpointInterval() throws Exception {
         );
     }
 
+    @Test
+    void testIoSpeedLogsWrittenCorrectly() throws Exception {
+        var metrics = new TrackingCheckpointMetrics();
+
+        Checkpointer checkpointer = createCheckpointerWithPages(metrics);
+
+        CompletableFuture<String> statResult = new CompletableFuture<>();
+
+        logInspector.addHandler(new Handler(
+                event -> 
event.getMessage().getFormattedMessage().startsWith("Checkpoint finished ["),
+                event -> {
+                    String msg = event.getMessage().getFormattedMessage();
+
+                    String ioSpeed = 
IO_SPEED_PATTERN.matcher(msg).replaceAll("$1");

Review Comment:
   Why don't you use a more traditional code, something like this?
   ```
           Matcher matcher = IO_SPEED_PATTERN.matcher(msg);
   
           assertTrue(matcher.find());
   
           String ioSpeed = matcher.group(1);
   ```



##########
modules/page-memory/src/test/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointerTest.java:
##########
@@ -578,4 +689,19 @@ private static FilePageStoreManager 
createFilePageStoreManager(Map<GroupPartitio
     private static DirtyFullPageId dirtyFullPageId(int grpId, int partId, int 
pageIdx) {
         return new DirtyFullPageId(pageId(partId, (byte) 0, pageIdx), grpId, 
1);
     }
+
+    private static class TrackingCheckpointMetrics extends CheckpointMetrics {
+        private CheckpointMetricsTracker tracker;

Review Comment:
   You could have gathered all the information from a `CheckpointMetricSource` 
instance that you pass into constructor. There's no need in new `Checkpointer` 
constructor and this particular class, it's too complicated now. Please call 
`CheckpointMetricSource#enable` and qcauire all required values by using 
`MetricSet#get`.
   
   Please revert all annecessary changes, thank you!



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