forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Stats rework (1/3): Interfaces and implementations for tiers #24
Open
peteralfonsi
wants to merge
34
commits into
ehcache-disk-integ-base
Choose a base branch
from
reworked-stats-tiers
base: ehcache-disk-integ-base
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 19 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
641abf1
CacheStats interface and SingleDimensionCacheStats impl
937ca51
First attempt to integrate new stats with EhcacheDiskCache
21b1078
Adds Serializer interface and impls for Key and BytesReference
a460acd
Adds ICacheKey serializer impl
31ee9ae
Added more icachekey serializer tests
9069077
Attempts to fix ehcache hits
18ddb23
Fixed unexpected misses by implementing hashCode for ICacheKey and Ca…
8618458
Adds memory tracking to disk tier
46b3e49
Updated other tests
51ea583
Added partial memory tests
17cf26a
Changed cache stats API to get values by dimension list
be5eece
Cleanup
a6b0899
Redid memory tracking to use already implemented weigher fn
9b1e66c
Split CacheStats into CacheStats and CacheStatsBase, which can't upda…
01e04a8
Readded BytesReferenceSerializer impl as ICacheKeySerializerTests dep…
3777e3f
Changed SingleDimensionCacheStats to use ConcurrentMap
6059680
Made SingleDimensionCacheStats also take in tier dimensions
7f5a455
Added overall CacheStatsResponse object packaging all 5 metrics
36c600d
Removed skeleton TSC stats implementation
27fdfe1
Merge remote-tracking branch 'sgup432/ehcache_disk_integ' into rework…
c8dc1b3
Modified factories to take new arguments
4abd602
added utilitly fns to CacheStatsResponse
2586fa1
Making TieredCachePlugin constructor public
sgup432 6a2b374
Fixing CacheService unit test
sgup432 3e7ea26
Added multi dimension cache stats impl
b4c83e7
Removed SingleDimensionCacheStats
d579c51
Adds IRC key serializer
c34c218
Addressed Sagar's other comment
2f4bd4f
Merge remote-tracking branch 'sgup432/ehcache_disk_integ' into rework…
a61f033
Fixed on heap stats integration, added tests
2483981
Optimized multi dimension stats
2aeaa53
Added reset() to CacheStats
60df761
Fixed reset impl for multi dim stats
ea33af8
spotlessApply
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
272 changes: 153 additions & 119 deletions
272
plugins/cache-ehcache/src/main/java/org/opensearch/cache/store/disk/EhcacheDiskCache.java
Large diffs are not rendered by default.
Oops, something went wrong.
350 changes: 263 additions & 87 deletions
350
...ns/cache-ehcache/src/test/java/org/opensearch/cache/store/disk/EhCacheDiskCacheTests.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
server/src/main/java/org/opensearch/common/cache/ICacheKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.common.cache; | ||
|
||
|
||
import org.opensearch.common.cache.stats.CacheStatsDimension; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class ICacheKey<K> { | ||
public final K key; // K must implement equals() | ||
public final List<CacheStatsDimension> dimensions; | ||
|
||
public ICacheKey(K key, List<CacheStatsDimension> dimensions) { | ||
this.key = key; | ||
this.dimensions = dimensions; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (o == this) { | ||
return true; | ||
} | ||
if (o == null) { | ||
return false; | ||
} | ||
if (o.getClass() != ICacheKey.class) { | ||
return false; | ||
} | ||
ICacheKey other = (ICacheKey) o; | ||
return key.equals(other.key) && dimensions.equals(other.dimensions); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(key, dimensions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
server/src/main/java/org/opensearch/common/cache/stats/CacheStatsDimension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.common.cache.stats; | ||
|
||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.common.io.stream.Writeable; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class CacheStatsDimension implements Writeable { | ||
// Values for tier dimensions, that are reused across CacheStats implementations | ||
public static final String TIER_DIMENSION_NAME = "tier"; | ||
public static final String TIER_DIMENSION_VALUE_ON_HEAP = "on_heap"; | ||
public static final String TIER_DIMENSION_VALUE_DISK = "disk"; | ||
public final String dimensionName; | ||
public final String dimensionValue; | ||
public CacheStatsDimension(String dimensionName, String dimensionValue) { | ||
this.dimensionName = dimensionName; | ||
this.dimensionValue = dimensionValue; | ||
} | ||
|
||
public CacheStatsDimension(StreamInput in) throws IOException { | ||
this.dimensionName = in.readString(); | ||
this.dimensionValue = in.readString(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(dimensionName); | ||
out.writeString(dimensionValue); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (o == this) { | ||
return true; | ||
} | ||
if (o == null) { | ||
return false; | ||
} | ||
if (o.getClass() != CacheStatsDimension.class) { | ||
return false; | ||
} | ||
CacheStatsDimension other = (CacheStatsDimension) o; | ||
if (other.dimensionName == null || other.dimensionValue == null) { | ||
return false; | ||
} | ||
return other.dimensionName.equals(dimensionName) && other.dimensionValue.equals(dimensionValue); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(dimensionName, dimensionValue); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
server/src/main/java/org/opensearch/common/cache/stats/CacheStatsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.common.cache.stats; | ||
|
||
/** | ||
* A class containing the 5 metrics tracked by a CacheStats object. | ||
*/ | ||
public class CacheStatsResponse { // TODO: Make this extend ToXContent. | ||
public final long hits; | ||
public final long misses; | ||
public final long evictions; | ||
public final long memorySize; | ||
public final long entries; | ||
|
||
public CacheStatsResponse(long hits, long misses, long evictions, long memorySize, long entries) { | ||
this.hits = hits; | ||
this.misses = misses; | ||
this.evictions = evictions; | ||
this.memorySize = memorySize; | ||
this.entries = entries; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This should not be declared here. Should be present in respective caches.