-
Notifications
You must be signed in to change notification settings - Fork 33
fix: remove parent directories to mimic s3 behaviour #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small comment + some tests would be nice
...src/main/java/io/aiven/kafka/tieredstorage/commons/storage/filesystem/FileSystemStorage.java
Outdated
Show resolved
Hide resolved
@@ -64,19 +72,33 @@ public InputStream fetch(final String key, final int from, final int to) throws | |||
throw new IllegalArgumentException("from cannot be more than to, from=" + from + ", to=" + to + " given"); | |||
} | |||
|
|||
final Path path = Path.of(fsRoot, key); | |||
final Path path = fsRoot.resolve(key); | |||
final long fileSize = Files.size(path); | |||
if (to > fileSize) { | |||
throw new IllegalArgumentException("to cannot be bigger than file size, to=" | |||
+ to + ", file size=" + fileSize + " given"); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if we should return until the end of the file.
S3 (even though I haven't found it in the docs) doesn't return failure when fetching by range, but returns until the end of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question but I believe we should not rely on this and this should be an error, it's better to fail fast then in the end trying to figure out why a part of the batch is missing.
...src/main/java/io/aiven/kafka/tieredstorage/commons/storage/filesystem/FileSystemStorage.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some test-related comments
...test/java/io/aiven/kafka/tieredstorage/commons/storage/filesystem/FileSystemStorageTest.java
Outdated
Show resolved
Hide resolved
...test/java/io/aiven/kafka/tieredstorage/commons/storage/filesystem/FileSystemStorageTest.java
Outdated
Show resolved
Hide resolved
...test/java/io/aiven/kafka/tieredstorage/commons/storage/filesystem/FileSystemStorageTest.java
Outdated
Show resolved
Hide resolved
...test/java/io/aiven/kafka/tieredstorage/commons/storage/filesystem/FileSystemStorageTest.java
Outdated
Show resolved
Hide resolved
...test/java/io/aiven/kafka/tieredstorage/commons/storage/filesystem/FileSystemStorageTest.java
Outdated
Show resolved
Hide resolved
...test/java/io/aiven/kafka/tieredstorage/commons/storage/filesystem/FileSystemStorageTest.java
Outdated
Show resolved
Hide resolved
...test/java/io/aiven/kafka/tieredstorage/commons/storage/filesystem/FileSystemStorageTest.java
Outdated
Show resolved
Hide resolved
...test/java/io/aiven/kafka/tieredstorage/commons/storage/filesystem/FileSystemStorageTest.java
Outdated
Show resolved
Hide resolved
...test/java/io/aiven/kafka/tieredstorage/commons/storage/filesystem/FileSystemStorageTest.java
Show resolved
Hide resolved
120173d
to
f4041d2
Compare
...src/main/java/io/aiven/kafka/tieredstorage/commons/storage/filesystem/FileSystemStorage.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
When a directory is emptied on S3, the parent keys are removed until an object is found