Skip to content

Commit

Permalink
feat(store): set a min s3object ttl for prepareObject
Browse files Browse the repository at this point in the history
Signed-off-by: daniel-y <[email protected]>
  • Loading branch information
daniel-y committed Oct 9, 2023
1 parent 5d5ea60 commit 76da37c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

public class S3ObjectManager implements ObjectManager {
private static final Logger LOGGER = LoggerFactory.getLogger(S3ObjectManager.class);
static final int MIN_OBJECT_TTL_MINUTES = 10;
private final StoreMetadataService metaService;

public S3ObjectManager(StoreMetadataService metaService) {
Expand All @@ -54,6 +55,7 @@ public S3ObjectManager(StoreMetadataService metaService) {
public CompletableFuture<Long> prepareObject(int count, long ttl) {
// Covert ttl from milliseconds to minutes
int minutes = (int) TimeUnit.MILLISECONDS.toMinutes(ttl);
minutes = Math.max(minutes, MIN_OBJECT_TTL_MINUTES);
return metaService.prepareS3Objects(count, minutes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ void prepareObject() {
// 2 Minutes retention
CompletableFuture<Long> preparedObject = objectManager.prepareObject(10, 1000 * 60 * 2);
assertEquals(100L, preparedObject.join());
verify(metadataService).prepareS3Objects(10, Math.max(2, S3ObjectManager.MIN_OBJECT_TTL_MINUTES));

verify(metadataService).prepareS3Objects(10, 2);
preparedObject = objectManager.prepareObject(10, 1000 * 60 * 40);
assertEquals(100L, preparedObject.join());
verify(metadataService).prepareS3Objects(10, Math.max(40, S3ObjectManager.MIN_OBJECT_TTL_MINUTES));
}

@Test
Expand Down

0 comments on commit 76da37c

Please sign in to comment.