File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
server/src/main/java/org/opensearch/index/store/remote/utils Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1515import org .opensearch .index .store .remote .filecache .CachedIndexInput ;
1616import org .opensearch .index .store .remote .filecache .FileCache ;
1717import org .opensearch .index .store .remote .filecache .FileCachedIndexInput ;
18+ import org .opensearch .index .store .remote .utils .cache .CacheUsage ;
1819
1920import java .io .BufferedOutputStream ;
2021import java .io .IOException ;
@@ -95,6 +96,25 @@ public IndexInput fetchBlob(BlobFetchRequest blobFetchRequest) throws IOExceptio
9596 @ SuppressWarnings ("removal" )
9697 private static FileCachedIndexInput createIndexInput (FileCache fileCache , StreamReader streamReader , BlobFetchRequest request ) {
9798 try {
99+ // This local file cache is ref counted and may not strictly enforce capacity.
100+ // In our use case capacity directly relates to disk usage.
101+ // If we find available capacity is exceeded deny further BlobFetchRequests.
102+ if (fileCache .usage ().usage () > fileCache .capacity ()) {
103+ System .gc ();
104+
105+ // File reference cleanup is not immediate and is processed
106+ // in a dedicated thread.
107+ try {
108+ Thread .sleep (10 );
109+ } catch (InterruptedException e ) {
110+ Thread .currentThread ().interrupt ();
111+ }
112+
113+ fileCache .prune ();
114+ if (fileCache .usage ().usage () > fileCache .capacity ()) {
115+ throw new IOException ("Local file cache capacity exceeded - BlobFetchRequest failed: " + request .getFilePath ());
116+ }
117+ }
98118 if (Files .exists (request .getFilePath ()) == false ) {
99119 logger .trace ("Fetching from Remote in createIndexInput of Transfer Manager" );
100120 try (
You can’t perform that action at this time.
0 commit comments