Skip to content
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

Refactor chunk cache #443

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Refactor chunk cache #443

wants to merge 1 commit into from

Conversation

ivanyu
Copy link
Contributor

@ivanyu ivanyu commented Nov 10, 2023

Before, the chunk cache(s) was a wrapper over DefaultChunkManager. In some situations, this is not very convenient and also the cache has more responsibilities than it should (like prefetching). This commit refactors the cache to be a pluggable mechanism in the chunk manager.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests were moved to AbstractChunkCacheTest and the prefetching tests, to DefaultChunkManagerTest.

.compute(chunkKey, (key, val) -> {
if (val == null) {
statsCounter.recordMiss();
// TODO do not put a failed future into the cache
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pre-existing problem, decided not to handle it in this PR

Comment on lines +99 to +100
// TODO do some logging if error
// TODO do not put a failed future into the cache
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are pre-existing problems, decided not to handle them in this PR


assertThat(chunkManager.getChunk(OBJECT_KEY, manifest, 0)).hasBinaryContent(TEST_CHUNK_CONTENT);
verify(storage).fetch(OBJECT_KEY, chunkIndex.chunks().get(0).range());
}

@Nested
class PrefetchTests {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From ChunkCacheTest.java

@ivanyu ivanyu changed the title Refactor chunk segment Refactor chunk cache Nov 10, 2023
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From ChunkCacheTest.java

Before, the chunk cache(s) was a wrapper over `DefaultChunkManager`. In some situations, this is not very convenient and also the cache has more responsibilities than it should (like prefetching). This commit refactors the cache to be a pluggable mechanism in the chunk manager.
@ivanyu ivanyu closed this Nov 11, 2023
@ivanyu ivanyu deleted the ivanyu/refactor-cache branch November 11, 2023 15:42
@ivanyu ivanyu restored the ivanyu/refactor-cache branch November 11, 2023 15:45
@ivanyu ivanyu reopened this Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant