Skip to content

Merge CacheDirectory into SearchableSnapshotDirectory #53917

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

Merged
merged 1 commit into from
Mar 24, 2020

Conversation

tlrx
Copy link
Member

@tlrx tlrx commented Mar 21, 2020

Following #53860 and #53879, this pull request now merges CacheDirectory into SearchableSnapshotDirectory.

I expect few more follow up pull requests, mostly to clean up things and move classes.

@tlrx tlrx added >non-issue :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs labels Mar 21, 2020
@tlrx tlrx requested a review from DaveCTurner March 21, 2020 13:46
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (:Distributed/Snapshot/Restore)

import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

public abstract class BaseSearchableSnapshotDirectory extends BaseDirectory {
Copy link
Member Author

Choose a reason for hiding this comment

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

This class has been merged down with SearchableSnapshotDirectory (it was useful to me for the 2 previous PRs)

}

@Nullable
public IndexInputStats getStats(String fileName) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Comes from the now removed CacheDirectory and made public as cache classes are in a different package

return new CacheBufferedIndexInput(this, fileInfo, context, inputStats);
} else {
long preferredLength = blobContainer.readBlobPreferredLength();
return new SearchableSnapshotIndexInput(blobContainer, fileInfo, context, preferredLength, BufferedIndexInput.BUFFER_SIZE);
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to rename this one to DirectBufferedIndexInput and to clean it up a bit in a follow up PR

@@ -47,13 +48,13 @@
// last seek position is kept around in order to detect forward/backward seeks for stats
private long lastSeekPosition;

CacheBufferedIndexInput(CacheDirectory directory, FileInfo fileInfo, IOContext context, IndexInputStats stats) {
public CacheBufferedIndexInput(SearchableSnapshotDirectory directory, FileInfo fileInfo, IOContext context, IndexInputStats stats) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Has to be public now it's instantiated by SearchableSnapshotDirectory from a different package.

@@ -27,7 +27,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.ReentrantReadWriteLock;

class CacheFile {
public class CacheFile {
Copy link
Member Author

Choose a reason for hiding this comment

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

Same here.

@@ -18,7 +18,7 @@
private final ShardId shardId;
private final String fileName;

CacheKey(SnapshotId snapshotId, IndexId indexId, ShardId shardId, String fileName) {
public CacheKey(SnapshotId snapshotId, IndexId indexId, ShardId shardId, String fileName) {
Copy link
Member Author

Choose a reason for hiding this comment

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

And same here.

@@ -380,10 +405,86 @@ private void testIndexInputs(final CheckedBiConsumer<IndexInput, IndexInput, Exc
});
}

public void testClearCache() throws Exception {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test comes from the now removed CacheDirectoryTests class with very few adjustments for the SearchableSnapshotDirectory instantiation.

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

LGTM

@tlrx tlrx merged commit 02aa32e into elastic:feature/searchable-snapshots Mar 24, 2020
@tlrx tlrx deleted the merge-directories branch March 24, 2020 11:33
@tlrx
Copy link
Member Author

tlrx commented Mar 24, 2020

Thanks David

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >non-issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants