xiaoyuyao commented on a change in pull request #943:
URL: https://github.com/apache/hadoop-ozone/pull/943#discussion_r428987504



##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerDoubleBuffer.java
##########
@@ -286,30 +301,45 @@ private void flushTransactions() {
     }
   }
 
-  private void cleanupCache(List<Long> lastRatisTransactionIndex) {
-    // As now only volume and bucket transactions are handled only called
-    // cleanupCache on bucketTable.
-    // TODO: After supporting all write operations we need to call
-    //  cleanupCache on the tables only when buffer has entries for that table.
-    omMetadataManager.getBucketTable().cleanupCache(lastRatisTransactionIndex);
-    omMetadataManager.getVolumeTable().cleanupCache(lastRatisTransactionIndex);
-    omMetadataManager.getUserTable().cleanupCache(lastRatisTransactionIndex);
-
-    //TODO: Optimization we can do here is for key transactions we can only
-    // cleanup cache when it is key commit transaction. In this way all
-    // intermediate transactions for a key will be read from in-memory cache.
-    
omMetadataManager.getOpenKeyTable().cleanupCache(lastRatisTransactionIndex);
-    omMetadataManager.getKeyTable().cleanupCache(lastRatisTransactionIndex);
-    
omMetadataManager.getDeletedTable().cleanupCache(lastRatisTransactionIndex);
-    omMetadataManager.getS3Table().cleanupCache(lastRatisTransactionIndex);
-    omMetadataManager.getMultipartInfoTable().cleanupCache(
-        lastRatisTransactionIndex);
-    omMetadataManager.getS3SecretTable().cleanupCache(
-        lastRatisTransactionIndex);
-    omMetadataManager.getDelegationTokenTable().cleanupCache(
-        lastRatisTransactionIndex);
-    omMetadataManager.getPrefixTable().cleanupCache(lastRatisTransactionIndex);
+  /**
+   * Set cleanup epoch for the DoubleBufferEntry.
+   * @param entry
+   * @param cleanupEpochs
+   */
+  private void setCleanupEpoch(DoubleBufferEntry entry, Map<String,
+      List<Long>> cleanupEpochs) {
+    // Add epochs depending on operated tables. In this way
+    // cleanup will be called only when required.
+
+    // As bucket and volume table is full cache add cleanup
+    // epochs only when request is delete to cleanup deleted
+    // entries.
+
+    String opName =
+        entry.getResponse().getOMResponse().getCmdType().name();
+
+    if (opName.toLowerCase().contains(VOLUME) ||
+        opName.toLowerCase().contains(BUCKET)) {
+      if (DeleteBucket.name().equals(opName)
+          || DeleteVolume.name().equals(opName)) {
+        entry.getResponse().operatedTables().forEach(
+            table -> cleanupEpochs.get(table)
+                .add(entry.getTrxLogIndex()));
+      }
+    } else {
+      entry.getResponse().operatedTables().forEach(

Review comment:
       What are the difference is the operation is not volume bucket delete? It 
seems the txIndex are added the same anyway. 




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



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

Reply via email to