umamaheswararao commented on a change in pull request #2973:
URL: https://github.com/apache/ozone/pull/2973#discussion_r784121077



##########
File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/common/helpers/ExcludeList.java
##########
@@ -34,31 +37,54 @@
  */
 public class ExcludeList {
 
-  private final Set<DatanodeDetails> datanodes;
+  private final Map<DatanodeDetails, Long> datanodes;
   private final Set<ContainerID> containerIds;
   private final Set<PipelineID> pipelineIds;
+  private long expiryTime = 0;
+  private java.time.Clock clock;
 
 
   public ExcludeList() {
-    datanodes = new HashSet<>();
+    datanodes = new HashMap<>();
     containerIds = new HashSet<>();
     pipelineIds = new HashSet<>();
   }
 
+  public ExcludeList(long autoExpiryTime, java.time.Clock clock) {
+    this();
+    this.expiryTime = autoExpiryTime;
+    this.clock = clock;
+  }
+
   public Set<ContainerID> getContainerIds() {
     return containerIds;
   }
 
   public Set<DatanodeDetails> getDatanodes() {
-    return datanodes;
+    if (expiryTime > 0) {
+      cleanExpiredNodes();
+    }
+    return new HashSet<>(datanodes.keySet());
+  }
+
+  private void cleanExpiredNodes() {
+    Iterator<Map.Entry<DatanodeDetails, Long>> iterator =
+        datanodes.entrySet().iterator();
+    while (iterator.hasNext()) {
+      Map.Entry<DatanodeDetails, Long> entry = iterator.next();
+      Long value = entry.getValue();
+      if (clock.millis() > value + expiryTime) {
+        iterator.remove(); // removing
+      }
+    }
   }
 
   public void addDatanodes(Collection<DatanodeDetails> dns) {
     dns.forEach(dn -> addDatanode(dn));
   }
 
   public void addDatanode(DatanodeDetails dn) {
-    datanodes.add(dn);
+    datanodes.put(dn, clock.millis());

Review comment:
       Yes, exactly it got strike  in my mind this morning too about this 
point. Doing that now.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to