Copilot commented on code in PR #15210:
URL: https://github.com/apache/iotdb/pull/15210#discussion_r2015989616


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/RegionMigrateService.java:
##########
@@ -75,7 +75,42 @@ public class RegionMigrateService implements IService {
   private static final ConcurrentHashMap<Long, TRegionMigrateResult> 
taskResultMap =
       new ConcurrentHashMap<>();
 
-  private static final AtomicLong lastNotifyTime = new 
AtomicLong(Long.MIN_VALUE);
+  //  private static final AtomicLong lastNotifyTime = new 
AtomicLong(Long.MIN_VALUE);
+
+  private static class RegionOperationsCache {
+
+    private long logicalClock = -1;
+
+    private long timestamp = -1;
+
+    private List<TConsensusGroupId> regionOperations = Collections.emptyList();
+
+    private long lastNotifyTime = Long.MIN_VALUE;
+
+    public synchronized void update(
+        long newLogicalClock, long newTimestamp, List<TConsensusGroupId> 
currentRegionOperations) {
+      if (newLogicalClock < logicalClock) {
+        return;
+      }
+      if (newLogicalClock == logicalClock && timestamp >= newTimestamp) {
+        return;
+      }
+      logicalClock = newLogicalClock;
+      timestamp = newTimestamp;
+      regionOperations = currentRegionOperations;
+      lastNotifyTime = System.currentTimeMillis();

Review Comment:
   Consider using a consistent time measurement (for example, 
System.nanoTime()) for lastNotifyTime, as heartbeat timestamps are generated 
using nanoTime. This can help avoid potential discrepancies due to mixed time 
units.
   ```suggestion
         lastNotifyTime = System.nanoTime();
   ```



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