walterddr commented on a change in pull request #8077:
URL: https://github.com/apache/pinot/pull/8077#discussion_r793917739



##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/SegmentDeletionManager.java
##########
@@ -165,40 +167,55 @@ protected synchronized void 
deleteSegmentFromPropertyStoreAndLocal(String tableN
 
   public void removeSegmentsFromStore(String tableNameWithType, List<String> 
segments) {
     for (String segment : segments) {
-      removeSegmentFromStore(tableNameWithType, segment);
+      removeSegmentFromStore(tableNameWithType, segment, 
_controllerDefaultDeletedSegmentsRetentionInDays);

Review comment:
       ```suggestion
         removeSegmentFromStore(tableNameWithType, segment, 
_defaultDeletedSegmentsRetentionInDays);
   ```

##########
File path: 
pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/util/SegmentDeletionManagerTest.java
##########
@@ -277,19 +277,19 @@ public void createTestFileWithAge(String path, int age)
     public Set<String> _segmentsToRetry = new HashSet<>();
 
     FakeDeletionManager(HelixAdmin helixAdmin, ZkHelixPropertyStore<ZNRecord> 
propertyStore) {
-      super(null, helixAdmin, CLUSTER_NAME, propertyStore);
+      super(null, helixAdmin, CLUSTER_NAME, propertyStore, 0);
     }
 
     FakeDeletionManager(String localDiskDir, HelixAdmin helixAdmin, 
ZkHelixPropertyStore<ZNRecord> propertyStore) {
-      super(localDiskDir, helixAdmin, CLUSTER_NAME, propertyStore);
+      super(localDiskDir, helixAdmin, CLUSTER_NAME, propertyStore, 0);
     }
 
     public void deleteSegmentsFromPropertyStoreAndLocal(String tableName, 
Collection<String> segments) {
       super.deleteSegmentFromPropertyStoreAndLocal(tableName, segments, 0L);
     }
 
     @Override
-    protected void removeSegmentFromStore(String tableName, String segmentId) {
+    protected void removeSegmentFromStore(String tableName, String segmentId, 
int deletedSegmentsRetentionInDays) {

Review comment:
       ```suggestion
       protected void removeSegmentFromStore(String tableName, String 
segmentId) {
   ```

##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/SegmentDeletionManager.java
##########
@@ -165,40 +167,55 @@ protected synchronized void 
deleteSegmentFromPropertyStoreAndLocal(String tableN
 
   public void removeSegmentsFromStore(String tableNameWithType, List<String> 
segments) {
     for (String segment : segments) {
-      removeSegmentFromStore(tableNameWithType, segment);
+      removeSegmentFromStore(tableNameWithType, segment, 
_controllerDefaultDeletedSegmentsRetentionInDays);
     }
   }
 
-  protected void removeSegmentFromStore(String tableNameWithType, String 
segmentId) {
+  protected void removeSegmentFromStore(String tableNameWithType, String 
segmentId,
+      int deletedSegmentsRetentionInDays) {

Review comment:
       ```suggestion
     protected void removeSegmentFromStore(String tableNameWithType, String 
segmentId) {
   ```

##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/SegmentDeletionManager.java
##########
@@ -165,40 +167,55 @@ protected synchronized void 
deleteSegmentFromPropertyStoreAndLocal(String tableN
 
   public void removeSegmentsFromStore(String tableNameWithType, List<String> 
segments) {
     for (String segment : segments) {
-      removeSegmentFromStore(tableNameWithType, segment);
+      removeSegmentFromStore(tableNameWithType, segment, 
_controllerDefaultDeletedSegmentsRetentionInDays);
     }
   }
 
-  protected void removeSegmentFromStore(String tableNameWithType, String 
segmentId) {
+  protected void removeSegmentFromStore(String tableNameWithType, String 
segmentId,
+      int deletedSegmentsRetentionInDays) {
     // Ignore HLC segments as they are not stored in Pinot FS
     if (SegmentName.isHighLevelConsumerSegmentName(segmentId)) {
       return;
     }
     if (_dataDir != null) {
       String rawTableName = 
TableNameBuilder.extractRawTableName(tableNameWithType);
-      URI fileToMoveURI = URIUtils.getUri(_dataDir, rawTableName, 
URIUtils.encode(segmentId));
-      URI deletedSegmentDestURI = URIUtils.getUri(_dataDir, DELETED_SEGMENTS, 
rawTableName, URIUtils.encode(segmentId));
-      PinotFS pinotFS = PinotFSFactory.create(fileToMoveURI.getScheme());
-
-      try {
-        if (pinotFS.exists(fileToMoveURI)) {
-          // Overwrites the file if it already exists in the target directory.
-          if (pinotFS.move(fileToMoveURI, deletedSegmentDestURI, true)) {
-            // Updates last modified.
-            // Touch is needed here so that removeAgedDeletedSegments() works 
correctly.
-            pinotFS.touch(deletedSegmentDestURI);
-            LOGGER.info("Moved segment {} from {} to {}", segmentId, 
fileToMoveURI.toString(),
-                deletedSegmentDestURI.toString());
+      URI fileToDeleteURI = URIUtils.getUri(_dataDir, rawTableName, 
URIUtils.encode(segmentId));
+      PinotFS pinotFS = PinotFSFactory.create(fileToDeleteURI.getScheme());
+      if (deletedSegmentsRetentionInDays == 0) {

Review comment:
       ```suggestion
         if (_defaultDeletedSegmentsRetentionInDays == 0) {
   ```

##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/SegmentDeletionManager.java
##########
@@ -60,13 +60,15 @@
   private final String _helixClusterName;
   private final HelixAdmin _helixAdmin;
   private final ZkHelixPropertyStore<ZNRecord> _propertyStore;
+  private final int _controllerDefaultDeletedSegmentsRetentionInDays;
 
   public SegmentDeletionManager(String dataDir, HelixAdmin helixAdmin, String 
helixClusterName,
-      ZkHelixPropertyStore<ZNRecord> propertyStore) {
+      ZkHelixPropertyStore<ZNRecord> propertyStore, int 
deletedSegmentsRetentionInDays) {
     _dataDir = dataDir;
     _helixAdmin = helixAdmin;
     _helixClusterName = helixClusterName;
     _propertyStore = propertyStore;
+    _controllerDefaultDeletedSegmentsRetentionInDays = 
deletedSegmentsRetentionInDays;

Review comment:
       ```suggestion
       _defaultDeletedSegmentsRetentionInDays = deletedSegmentsRetentionInDays;
   ```




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