Skip to content

Commit

Permalink
Reduce Searchable Snapshots IndexInput resource descriptions (#69017)
Browse files Browse the repository at this point in the history
We noticed that the resource descriptions of the IndexInput
used for Searchable Snapshots can grow pretty large. This
is due to the fact that resource descriptions tend to
aggregate all kind of information, maybe more than really
useful, and also that description of slices are based on the
toString() computation rather than just picking up the
parent's index input description.

This commit reduces the length of the description at
various places.

Backport of #68968
  • Loading branch information
tlrx authored Feb 16, 2021
1 parent 25a545a commit f429fd9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ public BaseSearchableSnapshotIndexInput clone() {
return clone;
}

@Override
public String toString() {
return super.toString() + "[length=" + length() + ", file pointer=" + getFilePointer() + ", offset=" + offset + ']';
}

@Override
protected String getFullSliceDescription(String sliceDescription) {
final String resourceDesc = super.toString();
if (sliceDescription != null) {
return "slice(" + sliceDescription + ") of " + resourceDesc;
}
return resourceDesc;
}

protected void ensureOpen() throws IOException {
if (closed.get()) {
throw new IOException(toString() + " is closed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,8 @@ private boolean notOverwritingRealSegmentsFile(String name) throws IOException {
return name.startsWith("segments_") == false || Arrays.stream(realDirectory.listAll()).noneMatch(s -> s.equals(name));
}

@Override
public String toString() {
return "InMemoryNoOpCommitDirectory(" + "real=" + realDirectory + ", delegate=" + in + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public boolean isRecoveryFinalized() {

@Override
public String toString() {
return this.getClass().getSimpleName() + "@snapshotId=" + snapshotId + " lockFactory=" + lockFactory + " shard=" + shardId;
return this.getClass().getSimpleName() + "(snapshotId=" + snapshotId + ", indexId=" + indexId + " shardId=" + shardId + ')';
}

private void cleanExistingRegularShardFiles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,20 +748,20 @@ public IndexInput slice(String sliceDescription, long offset, long length) {

@Override
public String toString() {
return "CachedBlobContainerIndexInput{"
+ "cacheFileReference="
+ cacheFileReference
+ ", offset="
+ offset
+ ", length="
+ length()
+ ", position="
+ getFilePointer()
+ ", rangeSize="
+ getDefaultRangeSize()
+ ", directory="
+ directory
+ '}';
final CacheFile cacheFile = cacheFileReference.cacheFile.get();
return super.toString()
+ "[cache file="
+ (cacheFile != null
? String.join(
"/",
directory.getShardId().getIndex().getUUID(),
String.valueOf(directory.getShardId().getId()),
"snapshot_cache",
directory.getSnapshotId().getUUID(),
cacheFile.getFile().getFileName().toString()
)
: null)
+ ']';
}

private static class CacheFileReference implements CacheFile.EvictionListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public DirectBlobContainerIndexInput clone() {
public IndexInput slice(String sliceDescription, long offset, long length) throws IOException {
if ((offset >= 0L) && (length >= 0L) && (offset + length <= length())) {
final DirectBlobContainerIndexInput slice = new DirectBlobContainerIndexInput(
sliceDescription,
getFullSliceDescription(sliceDescription),
blobContainer,
fileInfo,
context,
Expand Down Expand Up @@ -325,18 +325,7 @@ public void innerClose() throws IOException {

@Override
public String toString() {
return "DirectBlobContainerIndexInput{"
+ "resourceDesc="
+ super.toString()
+ ", fileInfo="
+ fileInfo
+ ", offset="
+ offset
+ ", length="
+ length()
+ ", position="
+ position
+ '}';
return super.toString() + "[read seq=" + (streamForSequentialReads != null ? "yes" : "no") + ']';
}

private InputStream openBlobStream(int part, long pos, long length) throws IOException {
Expand Down

0 comments on commit f429fd9

Please sign in to comment.