Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ private void prewarmCache(ActionListener<Void> listener, Supplier<Boolean> cance
}
recoveryState.getIndex().addFileDetail(file.physicalName(), file.length(), false);
try {
final IndexInput input = openInput(file.physicalName(), CachedBlobContainerIndexInput.CACHE_WARMING_CONTEXT);
final IndexInput input = openInput(file.physicalName(), IOContext.DEFAULT);
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this would be a behavior change? IOContext.DEFAULT uses DEFAULT_READADVICE which will use ReadAdvice.RANDOM unless the system property org.apache.lucene.store.defaultReadAdvice is set. The CachedBlobContainerIndexInput.CACHE_WARMING_CONTEXT instance was being created using ReadAdvice.NORMAL explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Doh, yes of course it is. Nevermind.

assert input instanceof CachedBlobContainerIndexInput : "expected cached index input but got " + input.getClass();
CachedBlobContainerIndexInput cachedIndexInput = (CachedBlobContainerIndexInput) input;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.ReadAdvice;
import org.elasticsearch.blobcache.BlobCacheUtils;
import org.elasticsearch.blobcache.common.ByteRange;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo;
Expand All @@ -31,13 +30,6 @@

public class CachedBlobContainerIndexInput extends MetadataCachingIndexInput {

/**
* Specific IOContext used for prewarming the cache. This context allows to write
* a complete part of the {@link #fileInfo} at once in the cache and should not be
* used for anything else than what the {@link #prefetchPart(int, Supplier)} method does.
*/
public static final IOContext CACHE_WARMING_CONTEXT = new IOContext(IOContext.Context.DEFAULT, null, null, ReadAdvice.NORMAL);

private static final Logger logger = LogManager.getLogger(CachedBlobContainerIndexInput.class);

public CachedBlobContainerIndexInput(
Expand Down Expand Up @@ -102,7 +94,6 @@ private CachedBlobContainerIndexInput(

@Override
protected void readWithoutBlobCache(ByteBuffer b) throws Exception {
ensureContext(ctx -> ctx != CACHE_WARMING_CONTEXT);
final long position = getAbsolutePosition();
final int length = b.remaining();

Expand Down Expand Up @@ -139,7 +130,6 @@ public long getPersistentCacheInitialLength() throws Exception {
* or {@code -1} if the prewarming was cancelled
*/
public long prefetchPart(final int part, Supplier<Boolean> isCancelled) throws IOException {
ensureContext(ctx -> ctx == CACHE_WARMING_CONTEXT);
if (part >= fileInfo.numberOfParts()) {
throw new IllegalArgumentException("Unexpected part number [" + part + "]");
}
Expand Down