Skip to content

Commit 77828c9

Browse files
committed
nits
1 parent 77696aa commit 77828c9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/blobstore/cache/SearchableSnapshotsBlobStoreCacheIntegTests.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsConstants.SNAPSHOT_BLOB_CACHE_INDEX;
6363
import static org.hamcrest.Matchers.equalTo;
6464
import static org.hamcrest.Matchers.greaterThan;
65+
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
6566

6667
public class SearchableSnapshotsBlobStoreCacheIntegTests extends BaseSearchableSnapshotsIntegTestCase {
6768

@@ -154,8 +155,7 @@ public void testBlobStoreCache() throws Exception {
154155
() -> systemClient().admin().indices().prepareGetIndex().addIndices(SNAPSHOT_BLOB_CACHE_INDEX).get()
155156
);
156157

157-
// TODO randomize this with FULL_COPY too when cold tier also handle blob cache for footers
158-
final Storage storage = Storage.SHARED_CACHE;
158+
final Storage storage = randomFrom(Storage.values());
159159
logger.info(
160160
"--> mount snapshot [{}] as an index for the first time [storage={}, max length={}]",
161161
snapshot,
@@ -264,7 +264,13 @@ public void testBlobStoreCache() throws Exception {
264264
new SearchableSnapshotsStatsRequest()
265265
).actionGet().getStats()) {
266266
for (final SearchableSnapshotShardStats.CacheIndexInputStats indexInputStats : shardStats.getStats()) {
267-
assertThat(Strings.toString(indexInputStats), indexInputStats.getBlobStoreBytesRequested().getCount(), equalTo(0L));
267+
assertThat(
268+
Strings.toString(indexInputStats),
269+
indexInputStats.getBlobStoreBytesRequested().getCount(),
270+
storage == Storage.SHARED_CACHE ? equalTo(0L)
271+
: indexInputStats.getFileExt().equals("cfs") ? greaterThanOrEqualTo(0L)
272+
: equalTo(0L)
273+
);
268274
}
269275
}
270276

@@ -308,7 +314,13 @@ public Settings onNodeStopped(String nodeName) throws Exception {
308314
new SearchableSnapshotsStatsRequest()
309315
).actionGet().getStats()) {
310316
for (final SearchableSnapshotShardStats.CacheIndexInputStats indexInputStats : shardStats.getStats()) {
311-
assertThat(Strings.toString(indexInputStats), indexInputStats.getBlobStoreBytesRequested().getCount(), equalTo(0L));
317+
assertThat(
318+
Strings.toString(indexInputStats),
319+
indexInputStats.getBlobStoreBytesRequested().getCount(),
320+
storage == Storage.SHARED_CACHE ? equalTo(0L)
321+
: indexInputStats.getFileExt().equals("cfs") ? greaterThanOrEqualTo(0L)
322+
: equalTo(0L)
323+
);
312324
}
313325
}
314326

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/index/store/cache/FrozenIndexInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ protected void doReadInternal(ByteBuffer b) throws IOException {
323323
if (indexCacheMiss != null) {
324324

325325
fillIndexCache(fileName, indexCacheMiss);
326-
if (compoundFileOffset > 0
326+
if (compoundFileOffset > 0L
327327
&& indexCacheMiss.equals(headerBlobCacheByteRange)
328328
&& footerBlobCacheByteRange != ByteRange.EMPTY) {
329329
fillIndexCache(fileName, footerBlobCacheByteRange);

0 commit comments

Comments
 (0)