-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
Add simple cache for StoreStats #9709
Conversation
This looks great!, a few comments:
|
sure will do
the more I think about this the more I think we should try a different way. I wonder if we can use the Java 7 WatchService and register something on the data dir to get notifications if something has changed from the OS instead of this crazy caching here? |
if (needsRefresh()) { | ||
if(refreshLock.tryLock()) { | ||
try { | ||
cached = refresh(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need another needsRefresh check here?
I like this idea! |
left one minor comment. +1 on listening to file system changes. |
@@ -114,6 +119,11 @@ public Store(ShardId shardId, @IndexSettings Settings indexSettings, DirectorySe | |||
this.directory = new StoreDirectory(directoryService.newFromDistributor(distributor), Loggers.getLogger("index.store.deletes", indexSettings, shardId)); | |||
this.shardLock = shardLock; | |||
this.onClose = onClose; | |||
final TimeValue refreshInterval = indexSettings.getAsTime(INDEX_STORE_STATS_REFRESH_INTERVAL, TimeValue.timeValueSeconds(10)); | |||
this.statsCache = new StoreStatsCache(refreshInterval); | |||
statsCache.getOrRefresh(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to do this on the constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never mind - I see now we always rely on a valid cached object (because of the non blocking nature). In this case I wonder if we should force passing it to the constructor?
Looks much cleaner. I left some comments w.r.t the intialization logic of the cache, where the current semantics require the cached object to be non-null. Maybe we should lock in that case (instead of tryLock) |
@bleskes pushed a new commit - this requires a non-null obj in the ctor. |
+1 |
this commit tries to reduce the filesystem calls to fetch metadata by using a simple cache on top of the stats call. Relates to elastic#9683
d3e3c9f
to
85c611a
Compare
this commit tries to reduce the filesystem calls to fetch metadata by using a simple cache on top of the stats call. Relates to elastic#9683 Closes elastic#9709
this commit tries to reduce the filesystem calls to fetch metadata by using a simple cache on top of the stats call. Relates to elastic#9683 Closes elastic#9709
this commit tries to reduce the filesystem calls to fetch metadata
by using a simple cache on top of the stats call.
Relates to #9683