diff --git a/core/client/fs/src/test/java/alluxio/client/file/options/OutStreamOptionsTest.java b/core/client/fs/src/test/java/alluxio/client/file/options/OutStreamOptionsTest.java index 839de3facc89..a8726f5c2b64 100644 --- a/core/client/fs/src/test/java/alluxio/client/file/options/OutStreamOptionsTest.java +++ b/core/client/fs/src/test/java/alluxio/client/file/options/OutStreamOptionsTest.java @@ -102,7 +102,7 @@ public void defaults() throws IOException { assertEquals(ModeUtils.applyFileUMask(Mode.defaults(), mConf.getString(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK)), options.getMode()); assertEquals(Constants.NO_TTL, options.getCommonOptions().getTtl()); - assertEquals(TtlAction.DELETE_ALLUXIO, options.getCommonOptions().getTtlAction()); + assertEquals(TtlAction.FREE, options.getCommonOptions().getTtlAction()); assertEquals(ufsType, options.getUnderStorageType()); assertEquals(WriteType.CACHE_THROUGH, options.getWriteType()); assertEquals(Constants.LAST_TIER, options.getWriteTier()); diff --git a/core/common/src/main/java/alluxio/conf/PropertyKey.java b/core/common/src/main/java/alluxio/conf/PropertyKey.java index dfba5626fe20..13483f439a8e 100755 --- a/core/common/src/main/java/alluxio/conf/PropertyKey.java +++ b/core/common/src/main/java/alluxio/conf/PropertyKey.java @@ -5772,9 +5772,9 @@ public String toString() { .build(); public static final PropertyKey USER_FILE_CREATE_TTL_ACTION = enumBuilder(Name.USER_FILE_CREATE_TTL_ACTION, TtlAction.class) - .setDefaultValue(TtlAction.DELETE_ALLUXIO) + .setDefaultValue(TtlAction.FREE) .setDescription("When file's ttl is expired, the action performs on it. Options: " - + "DELETE_ALLUXIO(default), FREE or DELETE") + + "FREE(default) or DELETE") .setScope(Scope.CLIENT) .build(); public static final PropertyKey USER_FILE_UFS_TIER_ENABLED = diff --git a/core/server/master/src/main/java/alluxio/master/ProtobufUtils.java b/core/server/master/src/main/java/alluxio/master/ProtobufUtils.java index 82897a147d58..4427b854e7ad 100644 --- a/core/server/master/src/main/java/alluxio/master/ProtobufUtils.java +++ b/core/server/master/src/main/java/alluxio/master/ProtobufUtils.java @@ -32,11 +32,9 @@ private ProtobufUtils() {} // prevent instantiation */ public static TtlAction fromProtobuf(PTtlAction pTtlAction) { if (pTtlAction == null) { - return TtlAction.DELETE_ALLUXIO; + return TtlAction.FREE; } switch (pTtlAction) { - case DELETE_ALLUXIO: - return TtlAction.DELETE_ALLUXIO; case DELETE: return TtlAction.DELETE; case FREE: @@ -54,11 +52,9 @@ public static TtlAction fromProtobuf(PTtlAction pTtlAction) { */ public static PTtlAction toProtobuf(TtlAction ttlAction) { if (ttlAction == null) { - return PTtlAction.DELETE_ALLUXIO; + return PTtlAction.FREE; } switch (ttlAction) { - case DELETE_ALLUXIO: - return PTtlAction.DELETE_ALLUXIO; case DELETE: return PTtlAction.DELETE; case FREE: diff --git a/core/server/master/src/main/java/alluxio/master/file/InodeTtlChecker.java b/core/server/master/src/main/java/alluxio/master/file/InodeTtlChecker.java index c1f467b21848..9e008eca973f 100644 --- a/core/server/master/src/main/java/alluxio/master/file/InodeTtlChecker.java +++ b/core/server/master/src/main/java/alluxio/master/file/InodeTtlChecker.java @@ -84,7 +84,7 @@ public void heartbeat() throws InterruptedException { TtlAction ttlAction = inode.getTtlAction(); LOG.info("Path {} TTL has expired, performing action {}", path.getPath(), ttlAction); switch (ttlAction) { - case FREE: + case FREE: // Default: FREE // public free method will lock the path, and check WRITE permission required at // parent of file if (inode.isDirectory()) { @@ -114,19 +114,6 @@ public void heartbeat() throws InterruptedException { mFileSystemMaster.delete(path, DeleteContext.defaults()); } break; - case DELETE_ALLUXIO: // Default: DELETE_ALLUXIO - // public delete method will lock the path, and check WRITE permission required at - // parent of file - if (inode.isDirectory()) { - mFileSystemMaster.delete(path, - DeleteContext.mergeFrom(DeletePOptions.newBuilder() - .setRecursive(true).setAlluxioOnly(true))); - } else { - mFileSystemMaster.delete(path, - DeleteContext.mergeFrom(DeletePOptions.newBuilder() - .setAlluxioOnly(true))); - } - break; default: LOG.error("Unknown ttl action {}", ttlAction); } diff --git a/core/server/master/src/test/java/alluxio/master/file/FileSystemMasterTest.java b/core/server/master/src/test/java/alluxio/master/file/FileSystemMasterTest.java index 4ac3bef41ae1..3b767b278ed3 100644 --- a/core/server/master/src/test/java/alluxio/master/file/FileSystemMasterTest.java +++ b/core/server/master/src/test/java/alluxio/master/file/FileSystemMasterTest.java @@ -625,7 +625,10 @@ public void ttlDirectoryDelete() throws Exception { FileInfo fileInfo = mFileSystemMaster.getFileInfo(dirId); assertEquals(fileInfo.getFileId(), dirId); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); - mThrown.expect(FileDoesNotExistException.class); + // TTL is set to 0, the directory should have been freed during last TTL check. + assertEquals(0, + mFileSystemMaster.getFileInfo(NESTED_DIR_URI, GET_STATUS_CONTEXT) + .getInAlluxioPercentage()); mFileSystemMaster.getFileInfo(dirId); } @@ -646,7 +649,10 @@ public void ttlDirectoryDeleteReplay() throws Exception { FileInfo fileInfo = mFileSystemMaster.getFileInfo(dirId); assertEquals(fileInfo.getFileId(), dirId); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); - mThrown.expect(FileDoesNotExistException.class); + // TTL is set to 0, the directory should have been freed during last TTL check. + assertEquals(0, + mFileSystemMaster.getFileInfo(NESTED_DIR_URI, GET_STATUS_CONTEXT) + .getInAlluxioPercentage()); mFileSystemMaster.getFileInfo(dirId); } @@ -764,8 +770,10 @@ public void setTtlForFileWithNoTtl() throws Exception { SetAttributeContext.mergeFrom(SetAttributePOptions.newBuilder() .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(0)))); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); - // TTL is set to 0, the file should have been deleted during last TTL check. - mThrown.expect(FileDoesNotExistException.class); + // TTL is set to 0, the file should have been freed during last TTL check. + assertEquals(0, + mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT) + .getInAlluxioPercentage()); mFileSystemMaster.getFileInfo(fileId); } @@ -791,8 +799,10 @@ public void setTtlForDirectoryWithNoTtl() throws Exception { SetAttributeContext.mergeFrom(SetAttributePOptions.newBuilder() .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(0)))); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); - // TTL is set to 0, the file should have been deleted during last TTL check. - mThrown.expect(FileDoesNotExistException.class); + // TTL is set to 0, the file should have been freed during last TTL check. + assertEquals(0, + mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT) + .getInAlluxioPercentage()); mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT); mFileSystemMaster.getFileInfo(NESTED_DIR_URI, GET_STATUS_CONTEXT); mFileSystemMaster.getFileInfo(NESTED_FILE_URI, GET_STATUS_CONTEXT); @@ -817,8 +827,10 @@ public void setSmallerTtlForFileWithTtl() throws Exception { SetAttributeContext.mergeFrom(SetAttributePOptions.newBuilder() .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(0)))); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); - // TTL is set to 0, the file should have been deleted during last TTL check. - mThrown.expect(FileDoesNotExistException.class); + // TTL is set to 0, the file should have been freed during last TTL check. + assertEquals(0, + mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT) + .getInAlluxioPercentage()); mFileSystemMaster.getFileInfo(fileId); } @@ -840,8 +852,10 @@ public void setSmallerTtlForDirectoryWithTtl() throws Exception { SetAttributeContext.mergeFrom(SetAttributePOptions.newBuilder() .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(0)))); HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); - // TTL is set to 0, the file should have been deleted during last TTL check. - mThrown.expect(FileDoesNotExistException.class); + // TTL is set to 0, the file should have been freed during last TTL check. + assertEquals(0, + mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT) + .getInAlluxioPercentage()); mFileSystemMaster.getFileInfo(NESTED_URI, GET_STATUS_CONTEXT); } diff --git a/core/transport/src/main/proto/grpc/common.proto b/core/transport/src/main/proto/grpc/common.proto index 94bf1db6f8e5..de020d5063ae 100644 --- a/core/transport/src/main/proto/grpc/common.proto +++ b/core/transport/src/main/proto/grpc/common.proto @@ -89,7 +89,6 @@ message ConfigProperty { enum TtlAction { DELETE = 0; // Delete the file after TTL expires. FREE = 1; // Free the file after TTL expires. - DELETE_ALLUXIO = 2; // Delete the data and metadata in Alluxio after TTL expires. } message Command { diff --git a/core/transport/src/main/proto/proto.lock b/core/transport/src/main/proto/proto.lock index 879b1f1a9af5..be8b18a9fb29 100644 --- a/core/transport/src/main/proto/proto.lock +++ b/core/transport/src/main/proto/proto.lock @@ -1601,10 +1601,6 @@ { "name": "FREE", "integer": 1 - }, - { - "name": "DELETE_ALLUXIO", - "integer": 2 } ] }, @@ -8701,10 +8697,6 @@ { "name": "FREE", "integer": 1 - }, - { - "name": "DELETE_ALLUXIO", - "integer": 2 } ] }, diff --git a/core/transport/src/main/proto/proto/journal/file.proto b/core/transport/src/main/proto/proto/journal/file.proto index 6d5b789723a9..c59840a2d2ec 100644 --- a/core/transport/src/main/proto/proto/journal/file.proto +++ b/core/transport/src/main/proto/proto/journal/file.proto @@ -172,7 +172,6 @@ message InodeDirectoryIdGeneratorEntry { enum PTtlAction { DELETE = 0; FREE = 1; - DELETE_ALLUXIO = 2; } // next available id: 30 diff --git a/tests/src/test/java/alluxio/client/fs/FileSystemMasterIntegrationTest.java b/tests/src/test/java/alluxio/client/fs/FileSystemMasterIntegrationTest.java index 9b8c1d33e9c6..c6d7bad60b65 100644 --- a/tests/src/test/java/alluxio/client/fs/FileSystemMasterIntegrationTest.java +++ b/tests/src/test/java/alluxio/client/fs/FileSystemMasterIntegrationTest.java @@ -187,7 +187,7 @@ public void clientFileInfoEmptyFile() throws Exception { assertFalse(fileInfo.isPersisted()); assertFalse(fileInfo.isPinned()); Assert.assertEquals(Constants.NO_TTL, fileInfo.getTtl()); - Assert.assertEquals(TtlAction.DELETE_ALLUXIO, fileInfo.getTtlAction()); + Assert.assertEquals(TtlAction.FREE, fileInfo.getTtlAction()); Assert.assertEquals(TEST_USER, fileInfo.getOwner()); Assert.assertEquals(0644, (short) fileInfo.getMode()); } diff --git a/tests/src/test/java/alluxio/client/fs/TtlIntegrationTest.java b/tests/src/test/java/alluxio/client/fs/TtlIntegrationTest.java index 03b5935348c6..a435cb1c96e8 100644 --- a/tests/src/test/java/alluxio/client/fs/TtlIntegrationTest.java +++ b/tests/src/test/java/alluxio/client/fs/TtlIntegrationTest.java @@ -79,45 +79,6 @@ public void before() throws Exception { Arrays.fill(mBuffer, (byte) 'A'); } - /** - * Tests that when many TTLs expire at the same time, files are deleted from alluxio properly. - */ - @Test - public void expireManyAfterDeleteAlluxio() throws Exception { - int numFiles = 100; - AlluxioURI[] files = new AlluxioURI[numFiles]; - for (int i = 0; i < numFiles; i++) { - files[i] = new AlluxioURI("/file" + i); - // Only the even-index files should expire. - long ttl = i % 2 == 0 ? TTL_INTERVAL_MS / 2 : TTL_INTERVAL_MS * 1000; - mOutStream = mFileSystem.createFile(files[i], - CreateFilePOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH) - .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(ttl)).build()); - mOutStream.write(mBuffer, 0, 10); - mOutStream.close(); - - // Delete some of the even files to make sure this doesn't trip up the TTL checker. - if (i % 20 == 0) { - mFileSystem.delete(files[i]); - } - } - CommonUtils.sleepMs(2 * TTL_INTERVAL_MS); - HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK); - for (int i = 0; i < numFiles; i++) { - if (i % 2 == 0) { - assertFalse(mFileSystem.exists(files[i])); - // Check Ufs file existence - if (i % 20 != 0) { - String fileName = "file" + i; - // Check Ufs file existence - assertTrue(Arrays.stream(mUfs.list()).anyMatch(s -> s.equals(fileName))); - } - } else { - assertTrue(mFileSystem.exists(files[i])); - } - } - } - /** * Tests that when many TTLs expire at the same time, files are freed properly. */ @@ -130,9 +91,9 @@ public void expireManyAfterFree() throws Exception { // Only the even-index files should expire. long ttl = i % 2 == 0 ? TTL_INTERVAL_MS / 2 : TTL_INTERVAL_MS * 1000; mOutStream = mFileSystem.createFile(files[i], - CreateFilePOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH) - .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(ttl) - .setTtlAction(TtlAction.FREE)).build()); + CreateFilePOptions.newBuilder().setWriteType(WritePType.CACHE_THROUGH) + .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(ttl)) + .build()); mOutStream.write(mBuffer, 0, 10); mOutStream.close();