Skip to content

Commit 96437a8

Browse files
authored
Merge branch '9.0' into backport/9.0/pr-132932
2 parents 38d38c4 + fb06e67 commit 96437a8

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

docs/changelog/132922.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 132922
2+
summary: Change GeoIpCache and EnrichCache to LongAdder
3+
area: Ingest Node
4+
type: bug
5+
issues: []

gradle/verification-metadata.xml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,14 +1147,9 @@
11471147
<sha256 value="544fc92d2625332a9a8eeaa7a7274cf1af6703936a50afa80d92a78200a7de34" origin="Generated by Gradle"/>
11481148
</artifact>
11491149
</component>
1150-
<component group="com.sun.mail" name="jakarta.mail" version="1.6.3">
1151-
<artifact name="jakarta.mail-1.6.3.jar">
1152-
<sha256 value="018ffd5684fd758157886933cc74116996d7f5757cc6f104bb43a647a3815f8a" origin="Generated by Gradle"/>
1153-
</artifact>
1154-
</component>
1155-
<component group="com.sun.mail" name="jakarta.mail" version="1.6.4">
1156-
<artifact name="jakarta.mail-1.6.4.jar">
1157-
<sha256 value="65d4c18e15ea2b9eb129098ae92db4cf996d85179f30ac34f7d4db856ffaa3f9" origin="Generated by Gradle"/>
1150+
<component group="com.sun.mail" name="jakarta.mail" version="1.6.8">
1151+
<artifact name="jakarta.mail-1.6.8.jar">
1152+
<sha256 value="c83f1a1ed580a35878957de7367071be27026d02d34ace6267d0c3da23e193c2" origin="Generated by Gradle"/>
11581153
</artifact>
11591154
</component>
11601155
<component group="com.sun.xml.bind" name="jaxb-impl" version="2.2.3-1">

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import org.elasticsearch.ingest.geoip.stats.CacheStats;
1717

1818
import java.nio.file.Path;
19-
import java.util.concurrent.atomic.AtomicLong;
19+
import java.util.concurrent.atomic.LongAdder;
2020
import java.util.function.Function;
2121
import java.util.function.LongSupplier;
2222

@@ -43,8 +43,8 @@ public String toString() {
4343

4444
private final LongSupplier relativeNanoTimeProvider;
4545
private final Cache<CacheKey, Object> cache;
46-
private final AtomicLong hitsTimeInNanos = new AtomicLong(0);
47-
private final AtomicLong missesTimeInNanos = new AtomicLong(0);
46+
private final LongAdder hitsTimeInNanos = new LongAdder();
47+
private final LongAdder missesTimeInNanos = new LongAdder();
4848

4949
// package private for testing
5050
GeoIpCache(long maxSize, LongSupplier relativeNanoTimeProvider) {
@@ -79,9 +79,9 @@ <RESPONSE> RESPONSE putIfAbsent(String ip, String databasePath, Function<String,
7979
// store the result or no-result in the cache
8080
cache.put(cacheKey, response);
8181
long databaseRequestAndCachePutTime = relativeNanoTimeProvider.getAsLong() - retrieveStart;
82-
missesTimeInNanos.addAndGet(cacheRequestTime + databaseRequestAndCachePutTime);
82+
missesTimeInNanos.add(cacheRequestTime + databaseRequestAndCachePutTime);
8383
} else {
84-
hitsTimeInNanos.addAndGet(cacheRequestTime);
84+
hitsTimeInNanos.add(cacheRequestTime);
8585
}
8686

8787
if (response == NO_RESULT) {
@@ -125,8 +125,8 @@ public CacheStats getCacheStats() {
125125
stats.getHits(),
126126
stats.getMisses(),
127127
stats.getEvictions(),
128-
TimeValue.nsecToMSec(hitsTimeInNanos.get()),
129-
TimeValue.nsecToMSec(missesTimeInNanos.get())
128+
TimeValue.nsecToMSec(hitsTimeInNanos.sum()),
129+
TimeValue.nsecToMSec(missesTimeInNanos.sum())
130130
);
131131
}
132132

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.util.Collections;
2323
import java.util.List;
2424
import java.util.Map;
25-
import java.util.concurrent.atomic.AtomicLong;
25+
import java.util.concurrent.atomic.LongAdder;
2626
import java.util.function.Consumer;
2727
import java.util.function.LongSupplier;
2828
import java.util.function.ToLongBiFunction;
@@ -46,9 +46,9 @@ public final class EnrichCache {
4646

4747
private final Cache<CacheKey, CacheValue> cache;
4848
private final LongSupplier relativeNanoTimeProvider;
49-
private final AtomicLong hitsTimeInNanos = new AtomicLong(0);
50-
private final AtomicLong missesTimeInNanos = new AtomicLong(0);
51-
private final AtomicLong sizeInBytes = new AtomicLong(0);
49+
private final LongAdder hitsTimeInNanos = new LongAdder();
50+
private final LongAdder missesTimeInNanos = new LongAdder();
51+
private final LongAdder sizeInBytes = new LongAdder();
5252

5353
EnrichCache(long maxSize) {
5454
this(maxSize, System::nanoTime);
@@ -71,7 +71,7 @@ public final class EnrichCache {
7171

7272
private Cache<CacheKey, CacheValue> createCache(long maxWeight, ToLongBiFunction<CacheKey, CacheValue> weigher) {
7373
var builder = CacheBuilder.<CacheKey, CacheValue>builder().setMaximumWeight(maxWeight).removalListener(notification -> {
74-
sizeInBytes.getAndAdd(-1 * notification.getValue().sizeInBytes);
74+
sizeInBytes.add(-1 * notification.getValue().sizeInBytes);
7575
});
7676
if (weigher != null) {
7777
builder.weigher(weigher);
@@ -102,7 +102,7 @@ public void computeIfAbsent(
102102
List<Map<?, ?>> response = get(cacheKey);
103103
long cacheRequestTime = relativeNanoTimeProvider.getAsLong() - cacheStart;
104104
if (response != null) {
105-
hitsTimeInNanos.addAndGet(cacheRequestTime);
105+
hitsTimeInNanos.add(cacheRequestTime);
106106
listener.onResponse(response);
107107
} else {
108108
final long retrieveStart = relativeNanoTimeProvider.getAsLong();
@@ -111,7 +111,7 @@ public void computeIfAbsent(
111111
put(cacheKey, cacheValue);
112112
List<Map<?, ?>> copy = deepCopy(cacheValue.hits, false);
113113
long databaseQueryAndCachePutTime = relativeNanoTimeProvider.getAsLong() - retrieveStart;
114-
missesTimeInNanos.addAndGet(cacheRequestTime + databaseQueryAndCachePutTime);
114+
missesTimeInNanos.add(cacheRequestTime + databaseQueryAndCachePutTime);
115115
listener.onResponse(copy);
116116
}, listener::onFailure));
117117
}
@@ -130,7 +130,7 @@ public void computeIfAbsent(
130130
// non-private for unit testing only
131131
void put(CacheKey cacheKey, CacheValue cacheValue) {
132132
cache.put(cacheKey, cacheValue);
133-
sizeInBytes.addAndGet(cacheValue.sizeInBytes);
133+
sizeInBytes.add(cacheValue.sizeInBytes);
134134
}
135135

136136
public EnrichStatsAction.Response.CacheStats getStats(String localNodeId) {
@@ -141,9 +141,9 @@ public EnrichStatsAction.Response.CacheStats getStats(String localNodeId) {
141141
cacheStats.getHits(),
142142
cacheStats.getMisses(),
143143
cacheStats.getEvictions(),
144-
TimeValue.nsecToMSec(hitsTimeInNanos.get()),
145-
TimeValue.nsecToMSec(missesTimeInNanos.get()),
146-
sizeInBytes.get()
144+
TimeValue.nsecToMSec(hitsTimeInNanos.sum()),
145+
TimeValue.nsecToMSec(missesTimeInNanos.sum()),
146+
sizeInBytes.sum()
147147
);
148148
}
149149

x-pack/plugin/security/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ dependencies {
8989
api "com.nimbusds:nimbus-jose-jwt:10.0.2"
9090
}
9191
api "com.nimbusds:lang-tag:1.7"
92-
api "com.sun.mail:jakarta.mail:1.6.3"
92+
api "com.sun.mail:jakarta.mail:1.6.8"
9393
api "net.jcip:jcip-annotations:1.0"
9494
api "net.minidev:json-smart:2.5.2"
9595
api "net.minidev:accessors-smart:2.5.2"

x-pack/plugin/watcher/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies {
3434
api 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20211018.2'
3535
runtimeOnly 'com.google.guava:guava:32.0.1-jre' // needed by watcher for the html sanitizer
3636
runtimeOnly 'com.google.guava:failureaccess:1.0.1'
37-
api 'com.sun.mail:jakarta.mail:1.6.4'
37+
api 'com.sun.mail:jakarta.mail:1.6.8'
3838
api 'com.sun.activation:jakarta.activation:1.2.1'
3939
compileOnly "org.apache.httpcomponents:httpclient:${versions.httpclient}"
4040
compileOnly "org.apache.httpcomponents:httpcore:${versions.httpcore}"

0 commit comments

Comments
 (0)