Skip to content

Commit 72b7d53

Browse files
authored
[Backport] [2.x] Update to Gradle 8.5 (#1131) (#1132)
* Update to Gradle 8.5 (#1131) Signed-off-by: Andriy Redko <andriy.redko@aiven.io> (cherry picked from commit 7c0ce4c) Signed-off-by: Andriy Redko <andriy.redko@aiven.io> * Update Jackson to 2.16.1 Signed-off-by: Andriy Redko <andriy.redko@aiven.io> --------- Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
1 parent 871b1dd commit 72b7d53

File tree

68 files changed

+505
-754
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+505
-754
lines changed

.github/workflows/test_build_multi_platform.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
Build-ad-windows:
1717
strategy:
1818
matrix:
19-
java: [ 11, 17 ]
19+
java: [ 11, 17, 21 ]
2020
name: Build and Test Anomaly Detection Plugin on Windows
2121
runs-on: windows-latest
2222
env:
@@ -49,7 +49,7 @@ jobs:
4949
needs: Get-CI-Image-Tag
5050
strategy:
5151
matrix:
52-
java: [11,17]
52+
java: [11, 17, 21]
5353
fail-fast: false
5454
name: Build and Test Anomaly detection Plugin
5555
runs-on: ubuntu-latest
@@ -89,7 +89,7 @@ jobs:
8989
Build-ad-macos:
9090
strategy:
9191
matrix:
92-
java: [11,17,20]
92+
java: [11,17,21]
9393
fail-fast: false
9494

9595
name: Build and Test Anomaly detection Plugin

.github/workflows/test_bwc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
needs: Get-CI-Image-Tag
1818
strategy:
1919
matrix:
20-
java: [11,17]
20+
java: [11,17,21]
2121
fail-fast: false
2222

2323
name: Test Anomaly detection BWC

.github/workflows/test_security.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
Build-ad:
1212
strategy:
1313
matrix:
14-
java: [11,17]
14+
java: [11,17,21]
1515
fail-fast: false
1616

1717
name: Security test workflow for Anomaly Detection

build.gradle

+41-40
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ buildscript {
6161
}
6262

6363
plugins {
64-
id 'nebula.ospackage' version "8.3.0" apply false
65-
id "com.diffplug.gradle.spotless" version "3.26.1"
64+
id 'com.netflix.nebula.ospackage' version "11.6.0"
65+
id "com.diffplug.spotless" version "6.24.0"
6666
id 'java-library'
67-
// Gradle 7.6 support was added in test-retry 1.4.0.
68-
id 'org.gradle.test-retry' version '1.4.1'
67+
id 'org.gradle.test-retry' version '1.5.7'
6968
}
7069

7170
tasks.withType(JavaCompile) {
@@ -119,11 +118,16 @@ allprojects {
119118

120119
version = "${opensearch_build}"
121120

122-
plugins.withId('java') {
123-
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11
121+
plugins.withId('jacoco') {
122+
jacoco.toolVersion = '0.8.11'
124123
}
125124
}
126125

126+
java {
127+
targetCompatibility = JavaVersion.VERSION_11
128+
sourceCompatibility = JavaVersion.VERSION_11
129+
}
130+
127131
ext {
128132
projectSubstitutions = [:]
129133
licenseFile = rootProject.file('LICENSE.txt')
@@ -146,10 +150,10 @@ configurations.all {
146150
force "org.apache.httpcomponents:httpcore:${versions.httpcore}"
147151
force "commons-codec:commons-codec:${versions.commonscodec}"
148152

149-
force "org.mockito:mockito-core:2.25.0"
150-
force "org.objenesis:objenesis:3.0.1"
151-
force "net.bytebuddy:byte-buddy:1.9.15"
152-
force "net.bytebuddy:byte-buddy-agent:1.9.15"
153+
force "org.mockito:mockito-core:5.9.0"
154+
force "org.objenesis:objenesis:3.3"
155+
force "net.bytebuddy:byte-buddy:1.14.9"
156+
force "net.bytebuddy:byte-buddy-agent:1.14.9"
153157
force "com.google.code.gson:gson:2.8.9"
154158
force "junit:junit:4.13.2"
155159
}
@@ -727,8 +731,8 @@ jacocoTestCoverageVerification {
727731

728732
jacocoTestReport {
729733
reports {
730-
xml.enabled = true
731-
html.enabled = true
734+
xml.required = true
735+
html.required = true
732736
}
733737
}
734738

@@ -755,8 +759,8 @@ dependencies {
755759
implementation 'software.amazon.randomcutforest:randomcutforest-core:3.8.0'
756760

757761
// force Jackson version to avoid version conflict issue
758-
implementation "com.fasterxml.jackson.core:jackson-databind:2.14.1"
759-
implementation "com.fasterxml.jackson.core:jackson-annotations:2.14.1"
762+
implementation "com.fasterxml.jackson.core:jackson-databind:2.16.1"
763+
implementation "com.fasterxml.jackson.core:jackson-annotations:2.16.1"
760764

761765
// used for serializing/deserializing rcf models.
762766
implementation group: 'io.protostuff', name: 'protostuff-core', version: '1.8.0'
@@ -773,31 +777,21 @@ dependencies {
773777
}
774778

775779
testImplementation group: 'pl.pragmatists', name: 'JUnitParams', version: '1.1.1'
776-
testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.25.0'
777-
testImplementation group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.2'
778-
testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.2'
779-
testImplementation group: 'org.powermock', name: 'powermock-module-junit4-common', version: '2.0.2'
780-
testImplementation group: 'org.powermock', name: 'powermock-core', version: '2.0.2'
781-
testImplementation group: 'org.powermock', name: 'powermock-api-support', version: '2.0.2'
782-
testImplementation group: 'org.powermock', name: 'powermock-reflect', version: '2.0.2'
783-
testImplementation group: 'org.objenesis', name: 'objenesis', version: '3.0.1'
784-
testImplementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.9.15'
785-
testImplementation group: 'net.bytebuddy', name: 'byte-buddy-agent', version: '1.9.15'
780+
testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.9.0'
781+
testImplementation group: 'org.objenesis', name: 'objenesis', version: '3.3'
782+
testImplementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.14.9'
783+
testImplementation group: 'net.bytebuddy', name: 'byte-buddy-agent', version: '1.14.9'
786784
testCompileOnly 'org.apiguardian:apiguardian-api:1.1.0'
787-
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
788-
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.2'
789-
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
790-
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.7.2'
785+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
786+
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
787+
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
788+
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.8.2'
791789
testCompileOnly 'junit:junit:4.13.2'
792790
}
793791

794792
compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
795793

796-
test {
797-
useJUnitPlatform()
798-
}
799-
800-
apply plugin: 'nebula.ospackage'
794+
apply plugin: 'com.netflix.nebula.ospackage'
801795

802796
// This is afterEvaluate because the bundlePlugin ZIP task is updated afterEvaluate and changes the ZIP name to match the plugin name
803797
afterEvaluate {
@@ -838,9 +832,8 @@ afterEvaluate {
838832
task renameRpm(type: Copy) {
839833
from("$buildDir/distributions")
840834
into("$buildDir/distributions")
841-
include archiveName
842-
rename archiveName, "${packageName}-${version}.rpm"
843-
doLast { delete file("$buildDir/distributions/$archiveName") }
835+
rename "$archiveFileName", "${packageName}-${archiveVersion}.rpm"
836+
doLast { delete file("$buildDir/distributions/$archiveFileName") }
844837
}
845838
}
846839

@@ -851,9 +844,8 @@ afterEvaluate {
851844
task renameDeb(type: Copy) {
852845
from("$buildDir/distributions")
853846
into("$buildDir/distributions")
854-
include archiveName
855-
rename archiveName, "${packageName}-${version}.deb"
856-
doLast { delete file("$buildDir/distributions/$archiveName") }
847+
rename "$archiveFileName", "${packageName}-${archiveVersion}.deb"
848+
doLast { delete file("$buildDir/distributions/$archiveFileName") }
857849
}
858850
}
859851

@@ -898,4 +890,13 @@ task updateVersion {
898890
// Include the required files that needs to be updated with new Version
899891
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
900892
}
901-
}
893+
}
894+
895+
tasks.withType(AbstractPublishToMaven) {
896+
def predicate = provider {
897+
publication.name == "pluginZip"
898+
}
899+
onlyIf("Publishing only ZIP distributions") {
900+
predicate.get()
901+
}
902+
}

gradle/wrapper/gradle-wrapper.jar

2.1 KB
Binary file not shown.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

gradlew

+17-12
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ done
8383
# This is normally unused
8484
# shellcheck disable=SC2034
8585
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
9088

9189
# Use the maximum available, or set MAX_FD != -1 to use that value.
9290
MAX_FD=maximum
@@ -133,26 +131,29 @@ location of your Java installation."
133131
fi
134132
else
135133
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137137
138138
Please set the JAVA_HOME variable in your environment to match the
139139
location of your Java installation."
140+
fi
140141
fi
141142

142143
# Increase the maximum file descriptors if we can.
143144
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144145
case $MAX_FD in #(
145146
max*)
146147
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147-
# shellcheck disable=SC3045
148+
# shellcheck disable=SC2039,SC3045
148149
MAX_FD=$( ulimit -H -n ) ||
149150
warn "Could not query maximum file descriptor limit"
150151
esac
151152
case $MAX_FD in #(
152153
'' | soft) :;; #(
153154
*)
154155
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155-
# shellcheck disable=SC3045
156+
# shellcheck disable=SC2039,SC3045
156157
ulimit -n "$MAX_FD" ||
157158
warn "Could not set maximum file descriptor limit to $MAX_FD"
158159
esac
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
197198
done
198199
fi
199200

200-
# Collect all arguments for the java command;
201-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202-
# shell script including quotes and variable substitutions, so put them in
203-
# double quotes to make sure that they get re-expanded; and
204-
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
205210

206211
set -- \
207212
"-Dorg.gradle.appname=$APP_BASE_NAME" \

src/main/java/org/opensearch/ad/AnomalyDetectorJobRunner.java

+8-37
Original file line numberDiff line numberDiff line change
@@ -304,38 +304,11 @@ private void runAnomalyDetectionJob(
304304
detectionStartTime.toEpochMilli(),
305305
executionStartTime.toEpochMilli()
306306
);
307-
client
308-
.execute(
309-
AnomalyResultAction.INSTANCE,
310-
request,
311-
ActionListener
312-
.wrap(
313-
response -> {
314-
indexAnomalyResult(
315-
jobParameter,
316-
lockService,
317-
lock,
318-
detectionStartTime,
319-
executionStartTime,
320-
response,
321-
recorder,
322-
detector
323-
);
324-
},
325-
exception -> {
326-
handleAdException(
327-
jobParameter,
328-
lockService,
329-
lock,
330-
detectionStartTime,
331-
executionStartTime,
332-
exception,
333-
recorder,
334-
detector
335-
);
336-
}
337-
)
338-
);
307+
client.execute(AnomalyResultAction.INSTANCE, request, ActionListener.wrap(response -> {
308+
indexAnomalyResult(jobParameter, lockService, lock, detectionStartTime, executionStartTime, response, recorder, detector);
309+
}, exception -> {
310+
handleAdException(jobParameter, lockService, lock, detectionStartTime, executionStartTime, exception, recorder, detector);
311+
}));
339312
} catch (Exception e) {
340313
indexAnomalyResultException(
341314
jobParameter,
@@ -669,11 +642,9 @@ private void releaseLock(AnomalyDetectorJob jobParameter, LockService lockServic
669642
lockService
670643
.release(
671644
lock,
672-
ActionListener
673-
.wrap(
674-
released -> { log.info("Released lock for AD job {}", jobParameter.getName()); },
675-
exception -> { log.error("Failed to release lock for AD job: " + jobParameter.getName(), exception); }
676-
)
645+
ActionListener.wrap(released -> { log.info("Released lock for AD job {}", jobParameter.getName()); }, exception -> {
646+
log.error("Failed to release lock for AD job: " + jobParameter.getName(), exception);
647+
})
677648
);
678649
}
679650
}

src/main/java/org/opensearch/ad/AnomalyDetectorRunner.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,9 @@ public void executeDetector(
8383
listener.onResponse(Collections.emptyList());
8484
return;
8585
}
86-
ActionListener<EntityAnomalyResult> entityAnomalyResultListener = ActionListener
87-
.wrap(
88-
entityAnomalyResult -> { listener.onResponse(entityAnomalyResult.getAnomalyResults()); },
89-
e -> onFailure(e, listener, detector.getDetectorId())
90-
);
86+
ActionListener<EntityAnomalyResult> entityAnomalyResultListener = ActionListener.wrap(entityAnomalyResult -> {
87+
listener.onResponse(entityAnomalyResult.getAnomalyResults());
88+
}, e -> onFailure(e, listener, detector.getDetectorId()));
9189
MultiResponsesDelegateActionListener<EntityAnomalyResult> multiEntitiesResponseListener =
9290
new MultiResponsesDelegateActionListener<EntityAnomalyResult>(
9391
entityAnomalyResultListener,

src/main/java/org/opensearch/ad/caching/PriorityCache.java

+11-18
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,9 @@ public PriorityCache(
133133
Duration inactiveEntityTtl = DateUtils.toDuration(checkpointTtl.get(settings));
134134

135135
this.inActiveEntities = createInactiveCache(inactiveEntityTtl, maxInactiveStates);
136-
clusterService
137-
.getClusterSettings()
138-
.addSettingsUpdateConsumer(
139-
checkpointTtl,
140-
it -> { this.inActiveEntities = createInactiveCache(DateUtils.toDuration(it), maxInactiveStates); }
141-
);
136+
clusterService.getClusterSettings().addSettingsUpdateConsumer(checkpointTtl, it -> {
137+
this.inActiveEntities = createInactiveCache(DateUtils.toDuration(it), maxInactiveStates);
138+
});
142139

143140
this.threadPool = threadPool;
144141
this.random = new Random(42);
@@ -163,19 +160,15 @@ public ModelState<EntityModel> get(String modelId, AnomalyDetector detector) {
163160
// during maintenance period, stop putting new entries
164161
if (!maintenanceLock.isLocked() && modelState == null) {
165162
if (EnabledSetting.isDoorKeeperInCacheEnabled()) {
166-
DoorKeeper doorKeeper = doorKeepers
167-
.computeIfAbsent(
168-
detectorId,
169-
id -> {
170-
// reset every 60 intervals
171-
return new DoorKeeper(
172-
AnomalyDetectorSettings.DOOR_KEEPER_FOR_CACHE_MAX_INSERTION,
173-
AnomalyDetectorSettings.DOOR_KEEPER_FAULSE_POSITIVE_RATE,
174-
detector.getDetectionIntervalDuration().multipliedBy(AnomalyDetectorSettings.DOOR_KEEPER_MAINTENANCE_FREQ),
175-
clock
176-
);
177-
}
163+
DoorKeeper doorKeeper = doorKeepers.computeIfAbsent(detectorId, id -> {
164+
// reset every 60 intervals
165+
return new DoorKeeper(
166+
AnomalyDetectorSettings.DOOR_KEEPER_FOR_CACHE_MAX_INSERTION,
167+
AnomalyDetectorSettings.DOOR_KEEPER_FAULSE_POSITIVE_RATE,
168+
detector.getDetectionIntervalDuration().multipliedBy(AnomalyDetectorSettings.DOOR_KEEPER_MAINTENANCE_FREQ),
169+
clock
178170
);
171+
});
179172

180173
// first hit, ignore
181174
// since door keeper may get reset during maintenance, it is possible

0 commit comments

Comments
 (0)