This is an automated email from the ASF dual-hosted git repository.
xiangfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new c0f237b344 Allow delete local files with special characters (#11664)
c0f237b344 is described below
commit c0f237b3440124a5fb8334cbd70e66db6d5732a9
Author: Xiang Fu <[email protected]>
AuthorDate: Sun Sep 24 20:03:14 2023 -0700
Allow delete local files with special characters (#11664)
---
.../controller/helix/core/SegmentDeletionManager.java | 7 ++++---
.../helix/core/util/SegmentDeletionManagerTest.java | 14 ++++++++------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/SegmentDeletionManager.java
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/SegmentDeletionManager.java
index 49a47ec9bd..8fcaff84f0 100644
---
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/SegmentDeletionManager.java
+++
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/SegmentDeletionManager.java
@@ -291,13 +291,14 @@ public class SegmentDeletionManager {
for (String tableNameDir : tableNameDirs) {
String tableName = URIUtils.getLastPart(tableNameDir);
if (leadControllerManager.isLeaderForTable(tableName)) {
- URI tableNameURI = URIUtils.getUri(tableNameDir);
+ URI tableNameURI = URIUtils.getUri(deletedDirURI.toString(),
URIUtils.encode(tableName));
// Get files that are aged
final String[] targetFiles = pinotFS.listFiles(tableNameURI,
false);
int numFilesDeleted = 0;
for (String targetFile : targetFiles) {
- URI targetURI = URIUtils.getUri(targetFile);
- long deletionTimeMs = getDeletionTimeMsFromFile(targetFile,
pinotFS.lastModified(targetURI));
+ URI targetURI =
+ URIUtils.getUri(tableNameURI.toString(),
URIUtils.encode(URIUtils.getLastPart(targetFile)));
+ long deletionTimeMs =
getDeletionTimeMsFromFile(targetURI.toString(),
pinotFS.lastModified(targetURI));
if (System.currentTimeMillis() >= deletionTimeMs) {
if (!pinotFS.delete(targetURI, true)) {
LOGGER.warn("Cannot remove file {} from deleted directory.",
targetURI);
diff --git
a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/util/SegmentDeletionManagerTest.java
b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/util/SegmentDeletionManagerTest.java
index b4d0356c5a..4b585f35fc 100644
---
a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/util/SegmentDeletionManagerTest.java
+++
b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/util/SegmentDeletionManagerTest.java
@@ -244,11 +244,11 @@ public class SegmentDeletionManagerTest {
deletionManager.removeAgedDeletedSegments(leadControllerManager);
// Create dummy directories and files
- File dummyDir1 = new File(deletedDirectoryPath + File.separator +
"dummy1");
+ File dummyDir1 = new File(deletedDirectoryPath + File.separator + "dummy1
%");
dummyDir1.mkdir();
- File dummyDir2 = new File(deletedDirectoryPath + File.separator +
"dummy2");
+ File dummyDir2 = new File(deletedDirectoryPath + File.separator + "dummy2
%");
dummyDir2.mkdir();
- File dummyDir3 = new File(deletedDirectoryPath + File.separator +
"dummy3");
+ File dummyDir3 = new File(deletedDirectoryPath + File.separator + "dummy3
%");
dummyDir3.mkdir();
// Test delete when there is no files but some directories exist
@@ -264,13 +264,15 @@ public class SegmentDeletionManagerTest {
// Create dummy files
for (int i = 0; i < 3; i++) {
- createTestFileWithAge(dummyDir1.getAbsolutePath() + File.separator +
genDeletedSegmentName("file" + i, i, 1), i);
+ createTestFileWithAge(dummyDir1.getAbsolutePath() + File.separator +
genDeletedSegmentName("file %" + i, i, 1),
+ i);
}
for (int i = 2; i < 5; i++) {
- createTestFileWithAge(dummyDir2.getAbsolutePath() + File.separator +
genDeletedSegmentName("file" + i, i, 1), i);
+ createTestFileWithAge(dummyDir2.getAbsolutePath() + File.separator +
genDeletedSegmentName("file %" + i, i, 1),
+ i);
}
for (int i = 6; i < 9; i++) {
- createTestFileWithAge(dummyDir3.getAbsolutePath() + File.separator +
"file" + i, i);
+ createTestFileWithAge(dummyDir3.getAbsolutePath() + File.separator +
"file %" + i, i);
}
// Sleep 1 second to ensure the clock moves.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]