Skip to content

Commit ea97e17

Browse files
authored
Refactor CacheStats to Stats across all relevant classes and tests (elastic#131784)
1 parent c4558ec commit ea97e17

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public int count() {
120120
* @return Current stats about this cache
121121
*/
122122
public CacheStats getCacheStats() {
123-
Cache.CacheStats stats = cache.stats();
123+
Cache.Stats stats = cache.stats();
124124
return new CacheStats(
125125
cache.count(),
126126
stats.getHits(),

server/src/main/java/org/elasticsearch/common/cache/Cache.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,16 +746,16 @@ public void remove() {
746746
*
747747
* @return the current cache statistics
748748
*/
749-
public CacheStats stats() {
750-
return new CacheStats(this.hits.sum(), misses.sum(), evictions.sum());
749+
public Stats stats() {
750+
return new Stats(this.hits.sum(), misses.sum(), evictions.sum());
751751
}
752752

753-
public static class CacheStats {
753+
public static class Stats {
754754
private final long hits;
755755
private final long misses;
756756
private final long evictions;
757757

758-
public CacheStats(long hits, long misses, long evictions) {
758+
public Stats(long hits, long misses, long evictions) {
759759
this.hits = hits;
760760
this.misses = misses;
761761
this.evictions = evictions;

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/FieldPermissionsCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public FieldPermissionsCache(Settings settings) {
4949
.build();
5050
}
5151

52-
public Cache.CacheStats getCacheStats() {
52+
public Cache.Stats getCacheStats() {
5353
return cache.stats();
5454
}
5555

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/RoleDescriptorTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ public void testParsingFieldPermissionsUsesCache() throws IOException {
578578
FieldPermissionsCache fieldPermissionsCache = new FieldPermissionsCache(Settings.EMPTY);
579579
RoleDescriptor.setFieldPermissionsCache(fieldPermissionsCache);
580580

581-
final Cache.CacheStats beforeStats = fieldPermissionsCache.getCacheStats();
581+
final Cache.Stats beforeStats = fieldPermissionsCache.getCacheStats();
582582

583583
final String json = """
584584
{
@@ -604,7 +604,7 @@ public void testParsingFieldPermissionsUsesCache() throws IOException {
604604
RoleDescriptor.parserBuilder().build().parse("test", new BytesArray(json), XContentType.JSON);
605605

606606
final int numberOfFieldSecurityBlocks = 2;
607-
final Cache.CacheStats betweenStats = fieldPermissionsCache.getCacheStats();
607+
final Cache.Stats betweenStats = fieldPermissionsCache.getCacheStats();
608608
assertThat(betweenStats.getMisses(), equalTo(beforeStats.getMisses() + numberOfFieldSecurityBlocks));
609609
assertThat(betweenStats.getHits(), equalTo(beforeStats.getHits()));
610610

@@ -613,7 +613,7 @@ public void testParsingFieldPermissionsUsesCache() throws IOException {
613613
RoleDescriptor.parserBuilder().build().parse("test", new BytesArray(json), XContentType.JSON);
614614
}
615615

616-
final Cache.CacheStats afterStats = fieldPermissionsCache.getCacheStats();
616+
final Cache.Stats afterStats = fieldPermissionsCache.getCacheStats();
617617
assertThat(afterStats.getMisses(), equalTo(betweenStats.getMisses()));
618618
assertThat(afterStats.getHits(), equalTo(beforeStats.getHits() + numberOfFieldSecurityBlocks * iterations));
619619
}

x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void put(CacheKey cacheKey, CacheValue cacheValue) {
137137
}
138138

139139
public EnrichStatsAction.Response.CacheStats getStats(String localNodeId) {
140-
Cache.CacheStats cacheStats = cache.stats();
140+
Cache.Stats cacheStats = cache.stats();
141141
return new EnrichStatsAction.Response.CacheStats(
142142
localNodeId,
143143
cache.count(),

0 commit comments

Comments
 (0)