diff --git a/build.gradle b/build.gradle index 8ee857b438..6b1b4c6919 100644 --- a/build.gradle +++ b/build.gradle @@ -40,9 +40,9 @@ buildscript { } plugins { - id 'nebula.ospackage' version "8.3.0" + id 'com.netflix.nebula.ospackage' version "11.1.0" id 'java' - id "io.freefair.lombok" version "6.4.1" + id "io.freefair.lombok" version "8.0.1" id 'jacoco' } diff --git a/client/build.gradle b/client/build.gradle index 82f74ebd57..f4cf9f1900 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -47,18 +47,19 @@ jacocoTestCoverageVerification { } check.dependsOn jacocoTestCoverageVerification +tasks.named("jar").configure { dependsOn("publishShadowPublicationToMavenLocal") } shadowJar { archiveClassifier.set(null) } task sourcesJar(type: Jar) { - archiveClassifier.set 'sources' + archiveClassifier.set("sources") from sourceSets.main.allJava } task javadocJar(type: Jar) { - archiveClassifier.set 'javadoc' + archiveClassifier.set("javadoc") from javadoc.destinationDir dependsOn javadoc } diff --git a/common/build.gradle b/common/build.gradle index c583f4a6fc..e44eb95e33 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -21,8 +21,7 @@ dependencies { jacocoTestReport { reports { - xml.enabled false - csv.enabled false + html.required = true } dependsOn test @@ -45,5 +44,5 @@ jacocoTestCoverageVerification { } check.dependsOn jacocoTestCoverageVerification -lombok.config['lombok.nonNull.exceptionType'] = 'JDK' + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927a4d..c1962a79e2 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a7478f5747..2c3425d49e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,11 +1,7 @@ -# -# Copyright OpenSearch Contributors -# SPDX-License-Identifier: Apache-2.0 -# - -#Mon Jan 04 08:34:55 PST 2021 -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 6800c39f9e..aeb74cbb43 100755 --- a/gradlew +++ b/gradlew @@ -1,17 +1,69 @@ #!/bin/sh # -# Copyright OpenSearch Contributors -# SPDX-License-Identifier: Apache-2.0 +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link app_path=$0 @@ -28,16 +80,13 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" @@ -64,6 +113,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -90,12 +140,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -115,30 +169,35 @@ if "$cygwin" || "$msys" ; then CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in @@ -151,6 +210,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. @@ -177,9 +242,4 @@ eval "set -- $( tr '\n' ' ' )" '"$@"' -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 04754314d5..6689b85bee 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,10 +25,14 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -66,18 +70,21 @@ goto fail set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/lombok.config b/lombok.config index 189c0bef98..5af4cf6838 100644 --- a/lombok.config +++ b/lombok.config @@ -1,3 +1,880 @@ -# This file is generated by the 'io.freefair.lombok' Gradle plugin +## +## Key : config.stopBubbling +## Type: boolean +## +## Tell the configuration system it should stop looking for other configuration files (default: false). +## +## Examples: +# +# clear config.stopBubbling config.stopBubbling = true +# + +## +## Key : lombok.addLombokGeneratedAnnotation +## Type: boolean +## +## Generate @lombok.Generated on all generated code (default: false). +## +## Examples: +# +# clear lombok.addLombokGeneratedAnnotation lombok.addLombokGeneratedAnnotation = true +# + +## +## Key : lombok.nonNull.exceptionType +## Type: enum (lombok.core.configuration.NullCheckExceptionType) +## +## The type of the exception to throw if a passed-in argument is null (Default: NullPointerException). +## +## Examples: +# +# clear lombok.nonNull.exceptionType +# lombok.nonNull.exceptionType = [NullPointerException | IllegalArgumentException | Assertion | JDK | Guava] +lombok.nonNull.exceptionType = JDK +# + + +## +## Key : checkerframework +## Type: checkerframework-version +## +## If set with the version of checkerframework.org (in major.minor, or just 'true' for the latest supported version), create relevant checkerframework.org annotations for code lombok generates (default: false). +## +## Examples: +# +# clear checkerframework +# checkerframework = major.minor (example: 3.2 - and no higher than 4.0) or true or false +# + +## +## Key : lombok.accessors.chain +## Type: boolean +## +## Generate setters that return 'this' instead of 'void' (default: false). +## +## Examples: +# +# clear lombok.accessors.chain +# lombok.accessors.chain = [false | true] +# + +## +## Key : lombok.accessors.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Accessors is used. +## +## Examples: +# +# clear lombok.accessors.flagUsage +# lombok.accessors.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.accessors.fluent +## Type: boolean +## +## Generate getters and setters using only the field name (no get/set prefix) (default: false). +## +## Examples: +# +# clear lombok.accessors.fluent +# lombok.accessors.fluent = [false | true] +# + +## +## Key : lombok.accessors.prefix +## Type: list of string +## +## Strip this field prefix, like 'f' or 'm_', from the names of generated getters and setters. +## +## Examples: +# +# clear lombok.accessors.prefix +# lombok.accessors.prefix += +# lombok.accessors.prefix -= +# + +## +## Key : lombok.addGeneratedAnnotation +## Type: boolean +## +## Generate @jakarta.annotation.Generated on all generated code (default: false). Deprecated, use 'lombok.addJavaxGeneratedAnnotation' instead. +## +## Examples: +# +# clear lombok.addGeneratedAnnotation +# lombok.addGeneratedAnnotation = [false | true] +# + +## +## Key : lombok.addJavaxGeneratedAnnotation +## Type: boolean +## +## Generate @jakarta.annotation.Generated on all generated code (default: follow lombok.addGeneratedAnnotation). +## +## Examples: +# +# clear lombok.addJavaxGeneratedAnnotation +# lombok.addJavaxGeneratedAnnotation = [false | true] +# + +## +## Key : lombok.addNullAnnotations +## Type: nullity-annotation-library +## +## Generate some style of null annotation for generated code where this is relevant. (default: none). +## +## Examples: +# +# clear lombok.addNullAnnotations +# lombok.addNullAnnotations = none | javax | eclipse | jetbrains | netbeans | androidx | android.support | checkerframework | findbugs | spring | jml | CUSTOM:com.foo.my.nonnull.annotation:com.foo.my.nullable.annotation +# + +## +## Key : lombok.addSuppressWarnings +## Type: boolean +## +## Generate @java.lang.SuppressWarnings("all") on all generated code (default: true). +## +## Examples: +# +# clear lombok.addSuppressWarnings +# lombok.addSuppressWarnings = [false | true] +# + +## +## Key : lombok.allArgsConstructor.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @AllArgsConstructor is used. +## +## Examples: +# +# clear lombok.allArgsConstructor.flagUsage +# lombok.allArgsConstructor.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.anyConstructor.addConstructorProperties +## Type: boolean +## +## Generate @ConstructorProperties for generated constructors (default: false). +## +## Examples: +# +# clear lombok.anyConstructor.addConstructorProperties +# lombok.anyConstructor.addConstructorProperties = [false | true] +# + +## +## Key : lombok.anyConstructor.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if any of the XxxArgsConstructor annotations are used. +## +## Examples: +# +# clear lombok.anyConstructor.flagUsage +# lombok.anyConstructor.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.anyConstructor.suppressConstructorProperties +## Type: boolean +## +## Suppress the generation of @ConstructorProperties for generated constructors (default: false). +## +## Examples: +# +# clear lombok.anyConstructor.suppressConstructorProperties +# lombok.anyConstructor.suppressConstructorProperties = [false | true] +# + +## +## Key : lombok.builder.className +## Type: string +## +## Default name of the generated builder class. A * is replaced with the name of the relevant type (default = *Builder). +## +## Examples: +# +# clear lombok.builder.className +# lombok.builder.className = +# + +## +## Key : lombok.builder.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Builder is used. +## +## Examples: +# +# clear lombok.builder.flagUsage +# lombok.builder.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.cleanup.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Cleanup is used. +## +## Examples: +# +# clear lombok.cleanup.flagUsage +# lombok.cleanup.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.copyableAnnotations +## Type: list of type-name +## +## Copy these annotations to getters, setters, with methods, builder-setters, etc. +## +## Examples: +# +# clear lombok.copyableAnnotations +# lombok.copyableAnnotations += +# lombok.copyableAnnotations -= +# + +## +## Key : lombok.data.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Data is used. +## +## Examples: +# +# clear lombok.data.flagUsage +# lombok.data.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.delegate.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Delegate is used. +## +## Examples: +# +# clear lombok.delegate.flagUsage +# lombok.delegate.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.equalsAndHashCode.callSuper +## Type: enum (lombok.core.configuration.CallSuperType) +## +## When generating equals and hashCode for classes that extend something (other than Object), either automatically take into account superclass implementation (call), or don't (skip), or warn and don't (warn). (default = warn). +## +## Examples: +# +# clear lombok.equalsAndHashCode.callSuper +# lombok.equalsAndHashCode.callSuper = [CALL | SKIP | WARN] +# + +## +## Key : lombok.equalsAndHashCode.doNotUseGetters +## Type: boolean +## +## Don't call the getters but use the fields directly in the generated equals and hashCode method (default = false). +## +## Examples: +# +# clear lombok.equalsAndHashCode.doNotUseGetters +# lombok.equalsAndHashCode.doNotUseGetters = [false | true] +# + +## +## Key : lombok.equalsAndHashCode.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @EqualsAndHashCode is used. +## +## Examples: +# +# clear lombok.equalsAndHashCode.flagUsage +# lombok.equalsAndHashCode.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.experimental.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if an experimental feature is used. +## +## Examples: +# +# clear lombok.experimental.flagUsage +# lombok.experimental.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.extensionMethod.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @ExtensionMethod is used. +## +## Examples: +# +# clear lombok.extensionMethod.flagUsage +# lombok.extensionMethod.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.extern.findbugs.addSuppressFBWarnings +## Type: boolean +## +## Generate @edu.umd.cs.findbugs.annotations.SuppressFBWarnings on all generated code (default: false). +## +## Examples: +# +# clear lombok.extern.findbugs.addSuppressFBWarnings +# lombok.extern.findbugs.addSuppressFBWarnings = [false | true] +# + +## +## Key : lombok.fieldDefaults.defaultFinal +## Type: boolean +## +## If true, fields, in any file (lombok annotated or not) are marked as final. Use @NonFinal to override this. +## +## Examples: +# +# clear lombok.fieldDefaults.defaultFinal +# lombok.fieldDefaults.defaultFinal = [false | true] +# + +## +## Key : lombok.fieldDefaults.defaultPrivate +## Type: boolean +## +## If true, fields without any access modifier, in any file (lombok annotated or not) are marked as private. Use @PackagePrivate or an explicit modifier to override this. +## +## Examples: +# +# clear lombok.fieldDefaults.defaultPrivate +# lombok.fieldDefaults.defaultPrivate = [false | true] +# + +## +## Key : lombok.fieldDefaults.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @FieldDefaults is used. +## +## Examples: +# +# clear lombok.fieldDefaults.flagUsage +# lombok.fieldDefaults.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.fieldNameConstants.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @FieldNameConstants is used. +## +## Examples: +# +# clear lombok.fieldNameConstants.flagUsage +# lombok.fieldNameConstants.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.fieldNameConstants.innerTypeName +## Type: identifier-name +## +## The default name of the inner type generated by @FieldNameConstants. (default: 'Fields'). +## +## Examples: +# +# clear lombok.fieldNameConstants.innerTypeName +# lombok.fieldNameConstants.innerTypeName = +# + +## +## Key : lombok.fieldNameConstants.uppercase +## Type: boolean +## +## The default name of the constants inside the inner type generated by @FieldNameConstants follow the variable name precisely. If this config key is true, lombok will uppercase them as best it can. (default: false). +## +## Examples: +# +# clear lombok.fieldNameConstants.uppercase +# lombok.fieldNameConstants.uppercase = [false | true] +# + +## +## Key : lombok.getter.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Getter is used. +## +## Examples: +# +# clear lombok.getter.flagUsage +# lombok.getter.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.getter.lazy.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Getter(lazy=true) is used. +## +## Examples: +# +# clear lombok.getter.lazy.flagUsage +# lombok.getter.lazy.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.getter.noIsPrefix +## Type: boolean +## +## If true, generate and use getFieldName() for boolean getters instead of isFieldName(). +## +## Examples: +# +# clear lombok.getter.noIsPrefix +# lombok.getter.noIsPrefix = [false | true] +# + +## +## Key : lombok.helper.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Helper is used. +## +## Examples: +# +# clear lombok.helper.flagUsage +# lombok.helper.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.jacksonized.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Jacksonized is used. +## +## Examples: +# +# clear lombok.jacksonized.flagUsage +# lombok.jacksonized.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.log.apacheCommons.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @CommonsLog is used. +## +## Examples: +# +# clear lombok.log.apacheCommons.flagUsage +# lombok.log.apacheCommons.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.log.custom.declaration +## Type: custom-log-declaration +## +## Define the generated custom logger field. +## +## Examples: +# +# clear lombok.log.custom.declaration +# lombok.log.custom.declaration = my.cool.Logger my.cool.LoggerFactory.createLogger()(TOPIC,TYPE) +# + +## +## Key : lombok.log.custom.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @CustomLog is used. +## +## Examples: +# +# clear lombok.log.custom.flagUsage +# lombok.log.custom.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.log.fieldIsStatic +## Type: boolean +## +## Make the generated logger fields static (default: true). +## +## Examples: +# +# clear lombok.log.fieldIsStatic +# lombok.log.fieldIsStatic = [false | true] +# + +## +## Key : lombok.log.fieldName +## Type: identifier-name +## +## Use this name for the generated logger fields (default: 'log'). +## +## Examples: +# +# clear lombok.log.fieldName +# lombok.log.fieldName = +# + +## +## Key : lombok.log.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if any of the log annotations is used. +## +## Examples: +# +# clear lombok.log.flagUsage +# lombok.log.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.log.flogger.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Flogger is used. +## +## Examples: +# +# clear lombok.log.flogger.flagUsage +# lombok.log.flogger.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.log.javaUtilLogging.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Log is used. +## +## Examples: +# +# clear lombok.log.javaUtilLogging.flagUsage +# lombok.log.javaUtilLogging.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.log.jbosslog.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @JBossLog is used. +## +## Examples: +# +# clear lombok.log.jbosslog.flagUsage +# lombok.log.jbosslog.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.log.log4j.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Log4j is used. +## +## Examples: +# +# clear lombok.log.log4j.flagUsage +# lombok.log.log4j.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.log.log4j2.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Log4j2 is used. +## +## Examples: +# +# clear lombok.log.log4j2.flagUsage +# lombok.log.log4j2.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.log.slf4j.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Slf4j is used. +## +## Examples: +# +# clear lombok.log.slf4j.flagUsage +# lombok.log.slf4j.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.log.xslf4j.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @XSlf4j is used. +## +## Examples: +# +# clear lombok.log.xslf4j.flagUsage +# lombok.log.xslf4j.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.noArgsConstructor.extraPrivate +## Type: boolean +## +## Generate a private no-args constructor for @Data and @Value (default: false). +## +## Examples: +# +# clear lombok.noArgsConstructor.extraPrivate +# lombok.noArgsConstructor.extraPrivate = [false | true] +# + +## +## Key : lombok.noArgsConstructor.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @NoArgsConstructor is used. +## +## Examples: +# +# clear lombok.noArgsConstructor.flagUsage +# lombok.noArgsConstructor.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.nonNull.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @NonNull is used. +## +## Examples: +# +# clear lombok.nonNull.flagUsage +# lombok.nonNull.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.onX.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if onX is used. +## +## Examples: +# +# clear lombok.onX.flagUsage +# lombok.onX.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.requiredArgsConstructor.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @RequiredArgsConstructor is used. +## +## Examples: +# +# clear lombok.requiredArgsConstructor.flagUsage +# lombok.requiredArgsConstructor.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.setter.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Setter is used. +## +## Examples: +# +# clear lombok.setter.flagUsage +# lombok.setter.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.singular.auto +## Type: boolean +## +## If true (default): Automatically singularize the assumed-to-be-plural name of your variable/parameter when using @Singular. +## +## Examples: +# +# clear lombok.singular.auto +# lombok.singular.auto = [false | true] +# + +## +## Key : lombok.singular.useGuava +## Type: boolean +## +## Generate backing immutable implementations for @Singular on java.util.* types by using guava's ImmutableList, etc. Normally java.util's mutable types are used and wrapped to make them immutable. +## +## Examples: +# +# clear lombok.singular.useGuava +# lombok.singular.useGuava = [false | true] +# + +## +## Key : lombok.sneakyThrows.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @SneakyThrows is used. +## +## Examples: +# +# clear lombok.sneakyThrows.flagUsage +# lombok.sneakyThrows.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.superBuilder.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @SuperBuilder is used. +## +## Examples: +# +# clear lombok.superBuilder.flagUsage +# lombok.superBuilder.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.synchronized.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Synchronized is used. +## +## Examples: +# +# clear lombok.synchronized.flagUsage +# lombok.synchronized.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.toString.callSuper +## Type: enum (lombok.core.configuration.CallSuperType) +## +## When generating toString for classes that extend something (other than Object), either automatically take into account superclass implementation (call), or don't (skip), or warn and don't (warn). (default = skip). +## +## Examples: +# +# clear lombok.toString.callSuper +# lombok.toString.callSuper = [CALL | SKIP | WARN] +# + +## +## Key : lombok.toString.doNotUseGetters +## Type: boolean +## +## Don't call the getters but use the fields directly in the generated toString method (default = false). +## +## Examples: +# +# clear lombok.toString.doNotUseGetters +# lombok.toString.doNotUseGetters = [false | true] +# + +## +## Key : lombok.toString.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @ToString is used. +## +## Examples: +# +# clear lombok.toString.flagUsage +# lombok.toString.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.toString.includeFieldNames +## Type: boolean +## +## Include the field names in the generated toString method (default = true). +## +## Examples: +# +# clear lombok.toString.includeFieldNames +# lombok.toString.includeFieldNames = [false | true] +# + +## +## Key : lombok.utilityClass.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @UtilityClass is used. +## +## Examples: +# +# clear lombok.utilityClass.flagUsage +# lombok.utilityClass.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.val.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if 'val' is used. +## +## Examples: +# +# clear lombok.val.flagUsage +# lombok.val.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.value.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @Value is used. +## +## Examples: +# +# clear lombok.value.flagUsage +# lombok.value.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.var.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if 'var' is used. +## +## Examples: +# +# clear lombok.var.flagUsage +# lombok.var.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.with.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @With is used. +## +## Examples: +# +# clear lombok.with.flagUsage +# lombok.with.flagUsage = [WARNING | ERROR | ALLOW] +# + +## +## Key : lombok.withBy.flagUsage +## Type: enum (lombok.core.configuration.FlagUsageType) +## +## Emit a warning or error if @WithBy is used. +## +## Examples: +# +# clear lombok.withBy.flagUsage +# lombok.withBy.flagUsage = [WARNING | ERROR | ALLOW] +# + diff --git a/ml-algorithms/src/test/java/org/opensearch/ml/engine/algorithms/anomalylocalization/AnomalyLocalizerImplTests.java b/ml-algorithms/src/test/java/org/opensearch/ml/engine/algorithms/anomalylocalization/AnomalyLocalizerImplTests.java index 1085f7d99d..1930bc5fea 100644 --- a/ml-algorithms/src/test/java/org/opensearch/ml/engine/algorithms/anomalylocalization/AnomalyLocalizerImplTests.java +++ b/ml-algorithms/src/test/java/org/opensearch/ml/engine/algorithms/anomalylocalization/AnomalyLocalizerImplTests.java @@ -37,7 +37,6 @@ import org.opensearch.cluster.node.DiscoveryNodeRole; import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.common.settings.Settings; import org.opensearch.common.transport.TransportAddress; import org.opensearch.index.IndexNotFoundException; @@ -438,19 +437,17 @@ private ClusterState setupTestClusterState() { new TransportAddress(TransportAddress.META_ADDRESS, portGenerator.incrementAndGet()), new HashMap<>(), roleSet, Version.CURRENT); - Metadata metadata = new Metadata.Builder() - .indices(ImmutableOpenMap - .builder() - .fPut(indexName, IndexMetadata.builder("test") - .settings(Settings.builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 1) - .put("index.version.created", Version.CURRENT.id)) - .build()) - .build()).build(); + Settings.Builder indexSettings = Settings.builder() + .put("index.number_of_shards", 1) + .put("index.number_of_replicas", 1) + .put("index.version.created", Version.CURRENT.id); + IndexMetadata indexMetaData = IndexMetadata.builder("test").settings(indexSettings).build(); + final Map indices = Collections.unmodifiableMap(Map.of(indexName, indexMetaData)); + Metadata metadata = new Metadata.Builder().indices(indices).build(); + return new ClusterState(new ClusterName(clusterName), 123l, "111111", metadata, null, DiscoveryNodes.builder().add(node).build(), - null, null, 0, false); + null, new HashMap<>(), 0, false); } } diff --git a/plugin/build.gradle b/plugin/build.gradle index 93f9bf9516..ef9c300e62 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -9,11 +9,11 @@ import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask plugins { id 'java' - id 'nebula.ospackage' + id 'com.netflix.nebula.ospackage' id "io.freefair.lombok" id 'jacoco' id 'java-library' - id "com.diffplug.gradle.spotless" version "3.26.1" + id 'com.diffplug.spotless' version '6.18.0' id 'checkstyle' } @@ -307,7 +307,7 @@ configurations.all { resolutionStrategy.force 'com.google.protobuf:protobuf-java:3.21.9' } -apply plugin: 'nebula.ospackage' +apply plugin: 'com.netflix.nebula.ospackage' // This is afterEvaluate because the bundlePlugin ZIP task is updated afterEvaluate and changes the ZIP name to match the plugin name afterEvaluate { @@ -344,27 +344,11 @@ afterEvaluate { buildRpm { arch = 'NOARCH' dependsOn 'assemble' - finalizedBy 'renameRpm' - task renameRpm(type: Copy) { - from("$buildDir/distributions") - into("$buildDir/distributions") - include archiveName - rename archiveName, "${packageName}-${version}.rpm" - doLast { delete file("$buildDir/distributions/$archiveName") } - } } buildDeb { arch = 'all' dependsOn 'assemble' - finalizedBy 'renameDeb' - task renameDeb(type: Copy) { - from("$buildDir/distributions") - into("$buildDir/distributions") - include archiveName - rename archiveName, "${packageName}-${version}.deb" - doLast { delete file("$buildDir/distributions/$archiveName") } - } } task buildPackages(type: GradleBuild) { diff --git a/plugin/src/main/java/org/opensearch/ml/action/deploy/TransportDeployModelAction.java b/plugin/src/main/java/org/opensearch/ml/action/deploy/TransportDeployModelAction.java index 1725bb97b4..978372a3fa 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/deploy/TransportDeployModelAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/deploy/TransportDeployModelAction.java @@ -22,8 +22,6 @@ import java.util.Set; import java.util.stream.Collectors; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.support.ActionFilters; @@ -63,6 +61,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class TransportDeployModelAction extends HandledTransportAction { TransportService transportService; diff --git a/plugin/src/main/java/org/opensearch/ml/action/deploy/TransportDeployModelOnNodeAction.java b/plugin/src/main/java/org/opensearch/ml/action/deploy/TransportDeployModelOnNodeAction.java index 898b15d5e2..689d51f58c 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/deploy/TransportDeployModelOnNodeAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/deploy/TransportDeployModelOnNodeAction.java @@ -13,8 +13,6 @@ import java.util.List; import java.util.Map; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.FailedNodeException; @@ -50,6 +48,8 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class TransportDeployModelOnNodeAction extends TransportNodesAction { @@ -141,10 +141,9 @@ private MLDeployModelNodeResponse createDeployModelNodeResponse(MLDeployModelNod String localNodeId = clusterService.localNode().getId(); ActionListener taskDoneListener = ActionListener - .wrap( - res -> { log.info("deploy model task done " + taskId); }, - ex -> { logException("Deploy model task failed: " + taskId, ex, log); } - ); + .wrap(res -> { log.info("deploy model task done " + taskId); }, ex -> { + logException("Deploy model task failed: " + taskId, ex, log); + }); deployModel(modelId, modelContentHash, mlTask.getFunctionName(), localNodeId, coordinatingNodeId, mlTask, ActionListener.wrap(r -> { MLForwardInput mlForwardInput = MLForwardInput diff --git a/plugin/src/main/java/org/opensearch/ml/action/execute/TransportExecuteTaskAction.java b/plugin/src/main/java/org/opensearch/ml/action/execute/TransportExecuteTaskAction.java index 5b6a70b732..d0bb728ed1 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/execute/TransportExecuteTaskAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/execute/TransportExecuteTaskAction.java @@ -5,10 +5,6 @@ package org.opensearch.ml.action.execute; -import lombok.AccessLevel; -import lombok.experimental.FieldDefaults; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.support.ActionFilters; @@ -22,6 +18,10 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; +import lombok.AccessLevel; +import lombok.experimental.FieldDefaults; +import lombok.extern.log4j.Log4j2; + @Log4j2 @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) public class TransportExecuteTaskAction extends HandledTransportAction { diff --git a/plugin/src/main/java/org/opensearch/ml/action/forward/TransportForwardAction.java b/plugin/src/main/java/org/opensearch/ml/action/forward/TransportForwardAction.java index 08db3548e3..8783e37b44 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/forward/TransportForwardAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/forward/TransportForwardAction.java @@ -13,10 +13,6 @@ import java.util.Arrays; import java.util.Set; -import lombok.AccessLevel; -import lombok.experimental.FieldDefaults; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.support.ActionFilters; @@ -46,6 +42,10 @@ import com.google.common.collect.ImmutableMap; +import lombok.AccessLevel; +import lombok.experimental.FieldDefaults; +import lombok.extern.log4j.Log4j2; + @FieldDefaults(level = AccessLevel.PRIVATE) @Log4j2 public class TransportForwardAction extends HandledTransportAction { diff --git a/plugin/src/main/java/org/opensearch/ml/action/handler/MLSearchHandler.java b/plugin/src/main/java/org/opensearch/ml/action/handler/MLSearchHandler.java index 652ea24690..e6298d25af 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/handler/MLSearchHandler.java +++ b/plugin/src/main/java/org/opensearch/ml/action/handler/MLSearchHandler.java @@ -8,8 +8,6 @@ import static org.opensearch.rest.RestStatus.BAD_REQUEST; import static org.opensearch.rest.RestStatus.INTERNAL_SERVER_ERROR; -import lombok.extern.log4j.Log4j2; - import org.opensearch.OpenSearchStatusException; import org.opensearch.action.ActionListener; import org.opensearch.action.search.SearchRequest; @@ -25,6 +23,8 @@ import com.google.common.base.Throwables; +import lombok.extern.log4j.Log4j2; + /** * Handle general get and search request in ml common. */ diff --git a/plugin/src/main/java/org/opensearch/ml/action/models/DeleteModelTransportAction.java b/plugin/src/main/java/org/opensearch/ml/action/models/DeleteModelTransportAction.java index 097d882d15..653c0d5f2e 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/models/DeleteModelTransportAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/models/DeleteModelTransportAction.java @@ -11,10 +11,6 @@ import static org.opensearch.ml.utils.MLNodeUtils.createXContentParserFromRegistry; import static org.opensearch.ml.utils.RestActionUtils.getFetchSourceContext; -import lombok.AccessLevel; -import lombok.experimental.FieldDefaults; -import lombok.extern.log4j.Log4j2; - import org.opensearch.OpenSearchStatusException; import org.opensearch.ResourceNotFoundException; import org.opensearch.action.ActionListener; @@ -46,6 +42,10 @@ import com.google.common.annotations.VisibleForTesting; +import lombok.AccessLevel; +import lombok.experimental.FieldDefaults; +import lombok.extern.log4j.Log4j2; + @Log4j2 @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) public class DeleteModelTransportAction extends HandledTransportAction { diff --git a/plugin/src/main/java/org/opensearch/ml/action/models/GetModelTransportAction.java b/plugin/src/main/java/org/opensearch/ml/action/models/GetModelTransportAction.java index 5617022e8a..ca5b7d45fa 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/models/GetModelTransportAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/models/GetModelTransportAction.java @@ -10,10 +10,6 @@ import static org.opensearch.ml.utils.MLNodeUtils.createXContentParserFromRegistry; import static org.opensearch.ml.utils.RestActionUtils.getFetchSourceContext; -import lombok.AccessLevel; -import lombok.experimental.FieldDefaults; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.get.GetRequest; @@ -34,6 +30,10 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; +import lombok.AccessLevel; +import lombok.experimental.FieldDefaults; +import lombok.extern.log4j.Log4j2; + @Log4j2 @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) public class GetModelTransportAction extends HandledTransportAction { diff --git a/plugin/src/main/java/org/opensearch/ml/action/models/SearchModelTransportAction.java b/plugin/src/main/java/org/opensearch/ml/action/models/SearchModelTransportAction.java index d4b6f94aec..999b0b7dfe 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/models/SearchModelTransportAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/models/SearchModelTransportAction.java @@ -5,8 +5,6 @@ package org.opensearch.ml.action.models; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; @@ -18,6 +16,8 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class SearchModelTransportAction extends HandledTransportAction { private MLSearchHandler mlSearchHandler; diff --git a/plugin/src/main/java/org/opensearch/ml/action/prediction/TransportPredictionTaskAction.java b/plugin/src/main/java/org/opensearch/ml/action/prediction/TransportPredictionTaskAction.java index f2c08a2493..4eb0a95bb9 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/prediction/TransportPredictionTaskAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/prediction/TransportPredictionTaskAction.java @@ -5,10 +5,6 @@ package org.opensearch.ml.action.prediction; -import lombok.AccessLevel; -import lombok.experimental.FieldDefaults; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.support.ActionFilters; @@ -23,6 +19,10 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; +import lombok.AccessLevel; +import lombok.experimental.FieldDefaults; +import lombok.extern.log4j.Log4j2; + @Log4j2 @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) public class TransportPredictionTaskAction extends HandledTransportAction { diff --git a/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileModelResponse.java b/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileModelResponse.java index 4804e308ff..1b8e970ae6 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileModelResponse.java +++ b/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileModelResponse.java @@ -11,10 +11,6 @@ import java.util.HashMap; import java.util.Map; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; @@ -23,6 +19,10 @@ import org.opensearch.ml.common.MLTask; import org.opensearch.ml.profile.MLModelProfile; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + @Getter @NoArgsConstructor public class MLProfileModelResponse implements ToXContentFragment, Writeable { diff --git a/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileNodeRequest.java b/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileNodeRequest.java index b00625a861..d2bca9f79b 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileNodeRequest.java +++ b/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileNodeRequest.java @@ -7,12 +7,12 @@ import java.io.IOException; -import lombok.Getter; - import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.transport.TransportRequest; +import lombok.Getter; + public class MLProfileNodeRequest extends TransportRequest { @Getter private MLProfileRequest mlProfileRequest; diff --git a/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileNodeResponse.java b/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileNodeResponse.java index 8c992beb59..a18e1d5d7f 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileNodeResponse.java +++ b/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileNodeResponse.java @@ -8,8 +8,6 @@ import java.io.IOException; import java.util.Map; -import lombok.Getter; - import org.opensearch.action.support.nodes.BaseNodeResponse; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.io.stream.StreamInput; @@ -19,6 +17,8 @@ import org.opensearch.ml.common.MLTask; import org.opensearch.ml.profile.MLModelProfile; +import lombok.Getter; + @Getter public class MLProfileNodeResponse extends BaseNodeResponse implements ToXContentFragment { diff --git a/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileRequest.java b/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileRequest.java index a11ff5b667..8d859821dc 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileRequest.java +++ b/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileRequest.java @@ -7,13 +7,13 @@ import java.io.IOException; -import lombok.Getter; - import org.opensearch.action.support.nodes.BaseNodesRequest; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.ml.profile.MLProfileInput; +import lombok.Getter; + public class MLProfileRequest extends BaseNodesRequest { @Getter diff --git a/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileTransportAction.java b/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileTransportAction.java index 7defefed1a..f4da1afbbc 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileTransportAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/profile/MLProfileTransportAction.java @@ -12,8 +12,6 @@ import java.util.Map; import java.util.Set; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.nodes.TransportNodesAction; @@ -30,6 +28,8 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class MLProfileTransportAction extends TransportNodesAction { diff --git a/plugin/src/main/java/org/opensearch/ml/action/register/TransportRegisterModelAction.java b/plugin/src/main/java/org/opensearch/ml/action/register/TransportRegisterModelAction.java index 6163671550..4b63a37a90 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/register/TransportRegisterModelAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/register/TransportRegisterModelAction.java @@ -15,8 +15,6 @@ import java.util.Arrays; import java.util.regex.Pattern; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.ActionRequest; @@ -55,6 +53,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class TransportRegisterModelAction extends HandledTransportAction { TransportService transportService; diff --git a/plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodeRequest.java b/plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodeRequest.java index b038c17e34..a357ce8c4d 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodeRequest.java +++ b/plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodeRequest.java @@ -7,12 +7,12 @@ import java.io.IOException; -import lombok.Getter; - import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.transport.TransportRequest; +import lombok.Getter; + public class MLStatsNodeRequest extends TransportRequest { @Getter private MLStatsNodesRequest mlStatsNodesRequest; diff --git a/plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodesRequest.java b/plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodesRequest.java index 281e0e1766..66c1302d52 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodesRequest.java +++ b/plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodesRequest.java @@ -8,8 +8,6 @@ import java.io.IOException; import java.util.Set; -import lombok.Getter; - import org.opensearch.action.support.nodes.BaseNodesRequest; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.io.stream.StreamInput; @@ -18,6 +16,8 @@ import org.opensearch.ml.stats.MLStatLevel; import org.opensearch.ml.stats.MLStatsInput; +import lombok.Getter; + public class MLStatsNodesRequest extends BaseNodesRequest { @Getter diff --git a/plugin/src/main/java/org/opensearch/ml/action/syncup/TransportSyncUpOnNodeAction.java b/plugin/src/main/java/org/opensearch/ml/action/syncup/TransportSyncUpOnNodeAction.java index a35ea27ec7..a63e38ed6c 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/syncup/TransportSyncUpOnNodeAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/syncup/TransportSyncUpOnNodeAction.java @@ -16,8 +16,6 @@ import java.util.Map; import java.util.Set; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.nodes.TransportNodesAction; @@ -48,6 +46,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class TransportSyncUpOnNodeAction extends TransportNodesAction { diff --git a/plugin/src/main/java/org/opensearch/ml/action/tasks/DeleteTaskTransportAction.java b/plugin/src/main/java/org/opensearch/ml/action/tasks/DeleteTaskTransportAction.java index fb07081a38..26b808faa9 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/tasks/DeleteTaskTransportAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/tasks/DeleteTaskTransportAction.java @@ -9,8 +9,6 @@ import static org.opensearch.ml.common.CommonValue.ML_TASK_INDEX; import static org.opensearch.ml.utils.MLNodeUtils.createXContentParserFromRegistry; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.delete.DeleteRequest; @@ -31,6 +29,8 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class DeleteTaskTransportAction extends HandledTransportAction { diff --git a/plugin/src/main/java/org/opensearch/ml/action/tasks/GetTaskTransportAction.java b/plugin/src/main/java/org/opensearch/ml/action/tasks/GetTaskTransportAction.java index c87828ef58..0124c75352 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/tasks/GetTaskTransportAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/tasks/GetTaskTransportAction.java @@ -9,8 +9,6 @@ import static org.opensearch.ml.common.CommonValue.ML_TASK_INDEX; import static org.opensearch.ml.utils.MLNodeUtils.createXContentParserFromRegistry; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.get.GetRequest; @@ -30,6 +28,8 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class GetTaskTransportAction extends HandledTransportAction { diff --git a/plugin/src/main/java/org/opensearch/ml/action/training/TransportTrainingTaskAction.java b/plugin/src/main/java/org/opensearch/ml/action/training/TransportTrainingTaskAction.java index 550a09fbb4..bd1feb6e30 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/training/TransportTrainingTaskAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/training/TransportTrainingTaskAction.java @@ -5,8 +5,6 @@ package org.opensearch.ml.action.training; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.support.ActionFilters; @@ -20,6 +18,8 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class TransportTrainingTaskAction extends HandledTransportAction { MLTaskRunner mlTrainingTaskRunner; diff --git a/plugin/src/main/java/org/opensearch/ml/action/undeploy/TransportUndeployModelAction.java b/plugin/src/main/java/org/opensearch/ml/action/undeploy/TransportUndeployModelAction.java index a9ccd6debe..80740d7200 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/undeploy/TransportUndeployModelAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/undeploy/TransportUndeployModelAction.java @@ -19,8 +19,6 @@ import java.util.Map; import java.util.Set; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.FailedNodeException; import org.opensearch.action.bulk.BulkRequest; @@ -51,6 +49,8 @@ import com.google.common.collect.ImmutableMap; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class TransportUndeployModelAction extends TransportNodesAction { @@ -146,17 +146,13 @@ protected MLUndeployModelNodesResponse newResponse( updateRequest.index(ML_MODEL_INDEX).id(modelId).doc(ImmutableMap.of(MODEL_STATE_FIELD, mlModelState)); bulkRequest.add(updateRequest); } - ActionListener actionListenr = ActionListener - .wrap( - r -> { - log - .debug( - "updated model state as undeployed for : {}", - Arrays.toString(removedNodeMap.keySet().toArray(new String[0])) - ); - }, - e -> { log.error("Failed to update model state as undeployed", e); } - ); + ActionListener actionListenr = ActionListener.wrap(r -> { + log + .debug( + "updated model state as undeployed for : {}", + Arrays.toString(removedNodeMap.keySet().toArray(new String[0])) + ); + }, e -> { log.error("Failed to update model state as undeployed", e); }); client.bulk(bulkRequest, ActionListener.runAfter(actionListenr, () -> { syncUpUndeployedModels(syncUpRequest); })); } else { syncUpUndeployedModels(syncUpRequest); diff --git a/plugin/src/main/java/org/opensearch/ml/action/upload_chunk/MLModelChunkUploader.java b/plugin/src/main/java/org/opensearch/ml/action/upload_chunk/MLModelChunkUploader.java index 7e45c46e8b..62329a3427 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/upload_chunk/MLModelChunkUploader.java +++ b/plugin/src/main/java/org/opensearch/ml/action/upload_chunk/MLModelChunkUploader.java @@ -11,8 +11,6 @@ import java.util.Base64; import java.util.concurrent.Semaphore; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.get.GetRequest; import org.opensearch.action.index.IndexRequest; @@ -34,6 +32,8 @@ import org.opensearch.ml.engine.ModelHelper; import org.opensearch.ml.indices.MLIndicesHandler; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class MLModelChunkUploader { diff --git a/plugin/src/main/java/org/opensearch/ml/action/upload_chunk/TransportRegisterModelMetaAction.java b/plugin/src/main/java/org/opensearch/ml/action/upload_chunk/TransportRegisterModelMetaAction.java index e9962f55c2..20cddb5aaf 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/upload_chunk/TransportRegisterModelMetaAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/upload_chunk/TransportRegisterModelMetaAction.java @@ -5,8 +5,6 @@ package org.opensearch.ml.action.upload_chunk; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.support.ActionFilters; @@ -21,6 +19,8 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class TransportRegisterModelMetaAction extends HandledTransportAction { @@ -40,14 +40,11 @@ public TransportRegisterModelMetaAction(TransportService transportService, Actio protected void doExecute(Task task, ActionRequest request, ActionListener listener) { MLRegisterModelMetaRequest registerModelMetaRequest = MLRegisterModelMetaRequest.fromActionRequest(request); MLRegisterModelMetaInput mlUploadInput = registerModelMetaRequest.getMlRegisterModelMetaInput(); - mlModelManager - .registerModelMeta( - mlUploadInput, - ActionListener - .wrap(modelId -> { listener.onResponse(new MLRegisterModelMetaResponse(modelId, MLTaskState.CREATED.name())); }, ex -> { - log.error("Failed to init model index", ex); - listener.onFailure(ex); - }) - ); + mlModelManager.registerModelMeta(mlUploadInput, ActionListener.wrap(modelId -> { + listener.onResponse(new MLRegisterModelMetaResponse(modelId, MLTaskState.CREATED.name())); + }, ex -> { + log.error("Failed to init model index", ex); + listener.onFailure(ex); + })); } } diff --git a/plugin/src/main/java/org/opensearch/ml/action/upload_chunk/TransportUploadModelChunkAction.java b/plugin/src/main/java/org/opensearch/ml/action/upload_chunk/TransportUploadModelChunkAction.java index cd5a861d55..7de6d791a8 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/upload_chunk/TransportUploadModelChunkAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/upload_chunk/TransportUploadModelChunkAction.java @@ -5,8 +5,6 @@ package org.opensearch.ml.action.upload_chunk; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.support.ActionFilters; @@ -19,6 +17,8 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class TransportUploadModelChunkAction extends HandledTransportAction { TransportService transportService; diff --git a/plugin/src/main/java/org/opensearch/ml/breaker/MLCircuitBreakerService.java b/plugin/src/main/java/org/opensearch/ml/breaker/MLCircuitBreakerService.java index bd42c7d841..07d1902e3d 100644 --- a/plugin/src/main/java/org/opensearch/ml/breaker/MLCircuitBreakerService.java +++ b/plugin/src/main/java/org/opensearch/ml/breaker/MLCircuitBreakerService.java @@ -9,13 +9,13 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import lombok.extern.log4j.Log4j2; - import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; import org.opensearch.monitor.jvm.JvmService; import org.opensearch.monitor.os.OsService; +import lombok.extern.log4j.Log4j2; + /** * This service registers internal system breakers and provide API for users to register their own breakers. */ diff --git a/plugin/src/main/java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java b/plugin/src/main/java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java index 0709490b7c..6dcfc1269b 100644 --- a/plugin/src/main/java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java +++ b/plugin/src/main/java/org/opensearch/ml/cluster/DiscoveryNodeHelper.java @@ -15,8 +15,6 @@ import java.util.Set; import java.util.function.Predicate; -import lombok.extern.log4j.Log4j2; - import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; @@ -25,6 +23,8 @@ import org.opensearch.ml.common.CommonValue; import org.opensearch.ml.utils.MLNodeUtils; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class DiscoveryNodeHelper { private final ClusterService clusterService; diff --git a/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterEventListener.java b/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterEventListener.java index ab707f5ba0..6659700601 100644 --- a/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterEventListener.java +++ b/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterEventListener.java @@ -10,8 +10,6 @@ import java.util.Set; import java.util.stream.Collectors; -import lombok.extern.log4j.Log4j2; - import org.opensearch.cluster.ClusterChangedEvent; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateListener; @@ -23,6 +21,8 @@ import org.opensearch.ml.model.MLModelManager; import org.opensearch.ml.task.MLTaskManager; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class MLCommonsClusterEventListener implements ClusterStateListener { diff --git a/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterManagerEventListener.java b/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterManagerEventListener.java index be2f42195f..050d475dd2 100644 --- a/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterManagerEventListener.java +++ b/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterManagerEventListener.java @@ -8,8 +8,6 @@ import static org.opensearch.ml.plugin.MachineLearningPlugin.GENERAL_THREAD_POOL; import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_SYNC_UP_JOB_INTERVAL_IN_SECONDS; -import lombok.extern.log4j.Log4j2; - import org.opensearch.client.Client; import org.opensearch.cluster.LocalNodeClusterManagerListener; import org.opensearch.cluster.service.ClusterService; @@ -20,6 +18,8 @@ import org.opensearch.threadpool.Scheduler; import org.opensearch.threadpool.ThreadPool; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class MLCommonsClusterManagerEventListener implements LocalNodeClusterManagerListener { diff --git a/plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java b/plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java index fa2ba95533..0ba118bd29 100644 --- a/plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java +++ b/plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java @@ -18,8 +18,6 @@ import java.util.concurrent.Semaphore; import java.util.stream.Collectors; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.bulk.BulkRequest; import org.opensearch.action.search.SearchRequest; @@ -42,6 +40,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class MLSyncUpCron implements Runnable { @@ -129,22 +129,16 @@ public void run() { .execute( MLSyncUpAction.INSTANCE, syncUpRequest, - ActionListener - .wrap( - re -> { log.debug("sync model routing job finished"); }, - ex -> { log.error("Failed to sync model routing", ex); } - ) + ActionListener.wrap(re -> { log.debug("sync model routing job finished"); }, ex -> { + log.error("Failed to sync model routing", ex); + }) ); // refresh model status mlIndicesHandler - .initModelIndexIfAbsent( - ActionListener - .wrap( - res -> { refreshModelState(modelWorkerNodes, deployingModels); }, - e -> { log.error("Failed to init model index", e); } - ) - ); + .initModelIndexIfAbsent(ActionListener.wrap(res -> { refreshModelState(modelWorkerNodes, deployingModels); }, e -> { + log.error("Failed to init model index", e); + })); }, e -> { log.error("Failed to sync model routing", e); })); } diff --git a/plugin/src/main/java/org/opensearch/ml/indices/MLIndicesHandler.java b/plugin/src/main/java/org/opensearch/ml/indices/MLIndicesHandler.java index bbe76e21f1..422f6b0d3a 100644 --- a/plugin/src/main/java/org/opensearch/ml/indices/MLIndicesHandler.java +++ b/plugin/src/main/java/org/opensearch/ml/indices/MLIndicesHandler.java @@ -14,11 +14,6 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; -import lombok.AccessLevel; -import lombok.RequiredArgsConstructor; -import lombok.experimental.FieldDefaults; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.admin.indices.create.CreateIndexResponse; @@ -31,6 +26,11 @@ import org.opensearch.ml.common.CommonValue; import org.opensearch.ml.common.exception.MLException; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import lombok.experimental.FieldDefaults; +import lombok.extern.log4j.Log4j2; + @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @RequiredArgsConstructor @Log4j2 diff --git a/plugin/src/main/java/org/opensearch/ml/indices/MLInputDatasetHandler.java b/plugin/src/main/java/org/opensearch/ml/indices/MLInputDatasetHandler.java index 0cd578dfa2..709202c056 100644 --- a/plugin/src/main/java/org/opensearch/ml/indices/MLInputDatasetHandler.java +++ b/plugin/src/main/java/org/opensearch/ml/indices/MLInputDatasetHandler.java @@ -9,11 +9,6 @@ import java.util.List; import java.util.Map; -import lombok.AccessLevel; -import lombok.RequiredArgsConstructor; -import lombok.experimental.FieldDefaults; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.search.SearchRequest; import org.opensearch.client.Client; @@ -26,6 +21,11 @@ import org.opensearch.search.SearchHit; import org.opensearch.search.SearchHits; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import lombok.experimental.FieldDefaults; +import lombok.extern.log4j.Log4j2; + /** * Convert MLInputDataset to Dataframe */ diff --git a/plugin/src/main/java/org/opensearch/ml/model/MLModelCache.java b/plugin/src/main/java/org/opensearch/ml/model/MLModelCache.java index e505b77671..a746e38d2e 100644 --- a/plugin/src/main/java/org/opensearch/ml/model/MLModelCache.java +++ b/plugin/src/main/java/org/opensearch/ml/model/MLModelCache.java @@ -13,11 +13,6 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.stream.DoubleStream; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.Setter; -import lombok.extern.log4j.Log4j2; - import org.opensearch.ml.common.FunctionName; import org.opensearch.ml.common.model.MLModelState; import org.opensearch.ml.engine.Predictable; @@ -25,6 +20,11 @@ import com.google.common.math.Quantiles; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class MLModelCache { private @Setter(AccessLevel.PROTECTED) @Getter(AccessLevel.PROTECTED) MLModelState modelState; diff --git a/plugin/src/main/java/org/opensearch/ml/model/MLModelCacheHelper.java b/plugin/src/main/java/org/opensearch/ml/model/MLModelCacheHelper.java index 19390db73f..0514b594f7 100644 --- a/plugin/src/main/java/org/opensearch/ml/model/MLModelCacheHelper.java +++ b/plugin/src/main/java/org/opensearch/ml/model/MLModelCacheHelper.java @@ -15,8 +15,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -import lombok.extern.log4j.Log4j2; - import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.settings.Settings; import org.opensearch.ml.common.FunctionName; @@ -25,6 +23,8 @@ import org.opensearch.ml.engine.Predictable; import org.opensearch.ml.profile.MLModelProfile; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class MLModelCacheHelper { private final Map modelCaches; diff --git a/plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java b/plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java index baaf21d8cb..8b9a5a6e70 100644 --- a/plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java +++ b/plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java @@ -52,8 +52,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.delete.DeleteRequest; import org.opensearch.action.get.GetRequest; @@ -109,6 +107,8 @@ import com.google.common.collect.ImmutableSet; import com.google.common.io.Files; +import lombok.extern.log4j.Log4j2; + /** * Manager class for ML models. It contains ML model related operations like register, deploy model etc. */ @@ -404,15 +404,12 @@ private void registerModel( private void registerPrebuiltModel(MLRegisterModelInput registerModelInput, MLTask mlTask) { String taskId = mlTask.getTaskId(); - modelHelper - .downloadPrebuiltModelConfig( - taskId, - registerModelInput, - ActionListener.wrap(mlRegisterModelInput -> { registerModelFromUrl(mlRegisterModelInput, mlTask); }, e -> { - log.error("Failed to register prebuilt model", e); - handleException(registerModelInput.getFunctionName(), taskId, e); - }) - ); + modelHelper.downloadPrebuiltModelConfig(taskId, registerModelInput, ActionListener.wrap(mlRegisterModelInput -> { + registerModelFromUrl(mlRegisterModelInput, mlTask); + }, e -> { + log.error("Failed to register prebuilt model", e); + handleException(registerModelInput.getFunctionName(), taskId, e); + })); } private ThreadedActionListener threadedActionListener(String threadPoolName, ActionListener listener) { diff --git a/plugin/src/main/java/org/opensearch/ml/permission/AccessController.java b/plugin/src/main/java/org/opensearch/ml/permission/AccessController.java index 7ffa0677ec..bb8c1b445e 100644 --- a/plugin/src/main/java/org/opensearch/ml/permission/AccessController.java +++ b/plugin/src/main/java/org/opensearch/ml/permission/AccessController.java @@ -5,12 +5,12 @@ package org.opensearch.ml.permission; -import lombok.extern.log4j.Log4j2; - import org.opensearch.client.Client; import org.opensearch.commons.ConfigConstants; import org.opensearch.commons.authuser.User; +import lombok.extern.log4j.Log4j2; + /** * AccessController has common code for backend roles based permission check. */ diff --git a/plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java b/plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java index 09dd74c8f8..d51b75a446 100644 --- a/plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java +++ b/plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java @@ -15,8 +15,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.Supplier; -import lombok.SneakyThrows; - import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionResponse; import org.opensearch.client.Client; @@ -146,6 +144,8 @@ import com.google.common.collect.ImmutableList; +import lombok.SneakyThrows; + public class MachineLearningPlugin extends Plugin implements ActionPlugin { public static final String ML_THREAD_POOL_PREFIX = "thread_pool.ml_commons."; public static final String GENERAL_THREAD_POOL = "opensearch_ml_general"; diff --git a/plugin/src/main/java/org/opensearch/ml/profile/MLModelProfile.java b/plugin/src/main/java/org/opensearch/ml/profile/MLModelProfile.java index 385a1c91ce..686f1dee8a 100644 --- a/plugin/src/main/java/org/opensearch/ml/profile/MLModelProfile.java +++ b/plugin/src/main/java/org/opensearch/ml/profile/MLModelProfile.java @@ -7,10 +7,6 @@ import java.io.IOException; -import lombok.Builder; -import lombok.Getter; -import lombok.extern.log4j.Log4j2; - import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; @@ -18,6 +14,10 @@ import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.ml.common.model.MLModelState; +import lombok.Builder; +import lombok.Getter; +import lombok.extern.log4j.Log4j2; + @Getter @Log4j2 public class MLModelProfile implements ToXContentFragment, Writeable { diff --git a/plugin/src/main/java/org/opensearch/ml/profile/MLPredictRequestStats.java b/plugin/src/main/java/org/opensearch/ml/profile/MLPredictRequestStats.java index 076b01f6d9..efa94e8b80 100644 --- a/plugin/src/main/java/org/opensearch/ml/profile/MLPredictRequestStats.java +++ b/plugin/src/main/java/org/opensearch/ml/profile/MLPredictRequestStats.java @@ -7,16 +7,16 @@ import java.io.IOException; -import lombok.Builder; -import lombok.Getter; -import lombok.extern.log4j.Log4j2; - import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; +import lombok.Builder; +import lombok.Getter; +import lombok.extern.log4j.Log4j2; + @Getter @Log4j2 public class MLPredictRequestStats implements ToXContentFragment, Writeable { diff --git a/plugin/src/main/java/org/opensearch/ml/profile/MLProfileInput.java b/plugin/src/main/java/org/opensearch/ml/profile/MLProfileInput.java index eb340d1fd5..c16b2a2606 100644 --- a/plugin/src/main/java/org/opensearch/ml/profile/MLProfileInput.java +++ b/plugin/src/main/java/org/opensearch/ml/profile/MLProfileInput.java @@ -12,10 +12,6 @@ import java.util.HashSet; import java.util.Set; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; @@ -23,6 +19,10 @@ import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; + @Getter public class MLProfileInput implements ToXContentObject, Writeable { public static final String MODELS = "model_ids"; diff --git a/plugin/src/main/java/org/opensearch/ml/rest/RestMLPredictionAction.java b/plugin/src/main/java/org/opensearch/ml/rest/RestMLPredictionAction.java index 91a18c9b0b..eb64811e21 100644 --- a/plugin/src/main/java/org/opensearch/ml/rest/RestMLPredictionAction.java +++ b/plugin/src/main/java/org/opensearch/ml/rest/RestMLPredictionAction.java @@ -16,8 +16,6 @@ import java.util.Locale; import java.util.Optional; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.client.node.NodeClient; import org.opensearch.core.xcontent.XContentParser; @@ -39,6 +37,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class RestMLPredictionAction extends BaseRestHandler { private static final String ML_PREDICTION_ACTION = "ml_prediction_action"; diff --git a/plugin/src/main/java/org/opensearch/ml/rest/RestMLProfileAction.java b/plugin/src/main/java/org/opensearch/ml/rest/RestMLProfileAction.java index 5de27ce8dc..908ecf9968 100644 --- a/plugin/src/main/java/org/opensearch/ml/rest/RestMLProfileAction.java +++ b/plugin/src/main/java/org/opensearch/ml/rest/RestMLProfileAction.java @@ -21,8 +21,6 @@ import java.util.Optional; import java.util.stream.Collectors; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.service.ClusterService; @@ -45,6 +43,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class RestMLProfileAction extends BaseRestHandler { private static final String PROFILE_ML_ACTION = "profile_ml"; diff --git a/plugin/src/main/java/org/opensearch/ml/rest/RestMLStatsAction.java b/plugin/src/main/java/org/opensearch/ml/rest/RestMLStatsAction.java index c687b8faa0..3a6066c59e 100644 --- a/plugin/src/main/java/org/opensearch/ml/rest/RestMLStatsAction.java +++ b/plugin/src/main/java/org/opensearch/ml/rest/RestMLStatsAction.java @@ -22,8 +22,6 @@ import java.util.Optional; import java.util.stream.Collectors; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.node.DiscoveryNode; @@ -48,6 +46,8 @@ import com.google.common.collect.ImmutableList; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class RestMLStatsAction extends BaseRestHandler { private static final String STATS_ML_ACTION = "stats_ml"; diff --git a/plugin/src/main/java/org/opensearch/ml/stats/MLStat.java b/plugin/src/main/java/org/opensearch/ml/stats/MLStat.java index 5e783693ba..177209ca8a 100644 --- a/plugin/src/main/java/org/opensearch/ml/stats/MLStat.java +++ b/plugin/src/main/java/org/opensearch/ml/stats/MLStat.java @@ -7,11 +7,11 @@ import java.util.function.Supplier; -import lombok.Getter; - import org.opensearch.ml.stats.suppliers.CounterSupplier; import org.opensearch.ml.stats.suppliers.SettableSupplier; +import lombok.Getter; + /** * Class represents a stat the ML plugin keeps track of */ diff --git a/plugin/src/main/java/org/opensearch/ml/stats/MLStats.java b/plugin/src/main/java/org/opensearch/ml/stats/MLStats.java index b56a89cfff..b743c58434 100644 --- a/plugin/src/main/java/org/opensearch/ml/stats/MLStats.java +++ b/plugin/src/main/java/org/opensearch/ml/stats/MLStats.java @@ -10,11 +10,11 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.Supplier; -import lombok.Getter; - import org.opensearch.ml.common.FunctionName; import org.opensearch.ml.stats.suppliers.CounterSupplier; +import lombok.Getter; + /** * This class is the main entry-point for access to the stats that the ML plugin keeps track of. */ diff --git a/plugin/src/main/java/org/opensearch/ml/stats/MLStatsInput.java b/plugin/src/main/java/org/opensearch/ml/stats/MLStatsInput.java index c181a57ba5..801beda51c 100644 --- a/plugin/src/main/java/org/opensearch/ml/stats/MLStatsInput.java +++ b/plugin/src/main/java/org/opensearch/ml/stats/MLStatsInput.java @@ -15,9 +15,6 @@ import java.util.Locale; import java.util.Set; -import lombok.Builder; -import lombok.Getter; - import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; @@ -26,6 +23,9 @@ import org.opensearch.core.xcontent.XContentParser; import org.opensearch.ml.common.FunctionName; +import lombok.Builder; +import lombok.Getter; + @Getter public class MLStatsInput implements ToXContentObject, Writeable { public static final String TARGET_STAT_LEVEL = "target_stat_levels"; diff --git a/plugin/src/main/java/org/opensearch/ml/task/MLExecuteTaskRunner.java b/plugin/src/main/java/org/opensearch/ml/task/MLExecuteTaskRunner.java index e9b53138e9..b03c21f4aa 100644 --- a/plugin/src/main/java/org/opensearch/ml/task/MLExecuteTaskRunner.java +++ b/plugin/src/main/java/org/opensearch/ml/task/MLExecuteTaskRunner.java @@ -7,8 +7,6 @@ import static org.opensearch.ml.plugin.MachineLearningPlugin.EXECUTE_THREAD_POOL; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.client.Client; @@ -30,6 +28,8 @@ import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportResponseHandler; +import lombok.extern.log4j.Log4j2; + /** * MLExecuteTaskRunner is responsible for running execute tasks. */ diff --git a/plugin/src/main/java/org/opensearch/ml/task/MLPredictTaskRunner.java b/plugin/src/main/java/org/opensearch/ml/task/MLPredictTaskRunner.java index be9585fb8d..a2dcfde0f9 100644 --- a/plugin/src/main/java/org/opensearch/ml/task/MLPredictTaskRunner.java +++ b/plugin/src/main/java/org/opensearch/ml/task/MLPredictTaskRunner.java @@ -14,8 +14,6 @@ import java.time.Instant; import java.util.UUID; -import lombok.extern.log4j.Log4j2; - import org.opensearch.OpenSearchException; import org.opensearch.ResourceNotFoundException; import org.opensearch.action.ActionListener; @@ -61,6 +59,8 @@ import com.google.common.collect.ImmutableList; +import lombok.extern.log4j.Log4j2; + /** * MLPredictTaskRunner is responsible for running predict tasks. */ diff --git a/plugin/src/main/java/org/opensearch/ml/task/MLTaskCache.java b/plugin/src/main/java/org/opensearch/ml/task/MLTaskCache.java index 4f7ccaacc7..5e4eb01332 100644 --- a/plugin/src/main/java/org/opensearch/ml/task/MLTaskCache.java +++ b/plugin/src/main/java/org/opensearch/ml/task/MLTaskCache.java @@ -11,11 +11,11 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Semaphore; +import org.opensearch.ml.common.MLTask; + import lombok.Builder; import lombok.Getter; -import org.opensearch.ml.common.MLTask; - @Getter public class MLTaskCache { MLTask mlTask; diff --git a/plugin/src/main/java/org/opensearch/ml/task/MLTaskDispatcher.java b/plugin/src/main/java/org/opensearch/ml/task/MLTaskDispatcher.java index 121da93528..6d6f1735ab 100644 --- a/plugin/src/main/java/org/opensearch/ml/task/MLTaskDispatcher.java +++ b/plugin/src/main/java/org/opensearch/ml/task/MLTaskDispatcher.java @@ -15,8 +15,6 @@ import javax.naming.LimitExceededException; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.client.Client; import org.opensearch.cluster.node.DiscoveryNode; @@ -30,6 +28,8 @@ import com.google.common.collect.ImmutableSet; +import lombok.extern.log4j.Log4j2; + /** * MLTaskDispatcher is responsible for dispatching the ml tasks. * TODO: Add more test diff --git a/plugin/src/main/java/org/opensearch/ml/task/MLTaskManager.java b/plugin/src/main/java/org/opensearch/ml/task/MLTaskManager.java index f51af7fa19..86c313bb15 100644 --- a/plugin/src/main/java/org/opensearch/ml/task/MLTaskManager.java +++ b/plugin/src/main/java/org/opensearch/ml/task/MLTaskManager.java @@ -23,8 +23,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.index.IndexResponse; @@ -50,6 +48,8 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import lombok.extern.log4j.Log4j2; + /** * MLTaskManager is responsible for managing MLTask. */ @@ -342,15 +342,9 @@ public void updateMLTask( } public void updateMLTaskDirectly(String taskId, Map updatedFields) { - updateMLTaskDirectly( - taskId, - updatedFields, - ActionListener - .wrap( - r -> { log.debug("updated ML task directly: {}", taskId); }, - e -> { log.error("Failed to update ML task " + taskId, e); } - ) - ); + updateMLTaskDirectly(taskId, updatedFields, ActionListener.wrap(r -> { log.debug("updated ML task directly: {}", taskId); }, e -> { + log.error("Failed to update ML task " + taskId, e); + })); } public void updateMLTaskDirectly(String taskId, Map updatedFields, ActionListener listener) { diff --git a/plugin/src/main/java/org/opensearch/ml/task/MLTaskRunner.java b/plugin/src/main/java/org/opensearch/ml/task/MLTaskRunner.java index d867f6677a..939acdb276 100644 --- a/plugin/src/main/java/org/opensearch/ml/task/MLTaskRunner.java +++ b/plugin/src/main/java/org/opensearch/ml/task/MLTaskRunner.java @@ -10,8 +10,6 @@ import java.util.HashMap; import java.util.Map; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.cluster.service.ClusterService; import org.opensearch.ml.breaker.MLCircuitBreakerService; @@ -28,6 +26,8 @@ import com.google.common.collect.ImmutableMap; +import lombok.extern.log4j.Log4j2; + /** * MLTaskRunner has common code for dispatching and running predict/training tasks. * @param ML task request diff --git a/plugin/src/main/java/org/opensearch/ml/task/MLTrainAndPredictTaskRunner.java b/plugin/src/main/java/org/opensearch/ml/task/MLTrainAndPredictTaskRunner.java index 7df3724b39..30983171fa 100644 --- a/plugin/src/main/java/org/opensearch/ml/task/MLTrainAndPredictTaskRunner.java +++ b/plugin/src/main/java/org/opensearch/ml/task/MLTrainAndPredictTaskRunner.java @@ -10,8 +10,6 @@ import java.time.Instant; import java.util.UUID; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.support.ThreadedActionListener; @@ -41,6 +39,8 @@ import com.google.common.collect.ImmutableList; +import lombok.extern.log4j.Log4j2; + /** * MLPredictTaskRunner is responsible for running predict tasks. */ diff --git a/plugin/src/main/java/org/opensearch/ml/task/MLTrainingTaskRunner.java b/plugin/src/main/java/org/opensearch/ml/task/MLTrainingTaskRunner.java index 482d209339..f8937f9a0a 100644 --- a/plugin/src/main/java/org/opensearch/ml/task/MLTrainingTaskRunner.java +++ b/plugin/src/main/java/org/opensearch/ml/task/MLTrainingTaskRunner.java @@ -11,8 +11,6 @@ import java.time.Instant; import java.util.UUID; -import lombok.extern.log4j.Log4j2; - import org.opensearch.action.ActionListener; import org.opensearch.action.ActionListenerResponseHandler; import org.opensearch.action.index.IndexRequest; @@ -50,6 +48,8 @@ import com.google.common.collect.ImmutableList; +import lombok.extern.log4j.Log4j2; + /** * MLTrainingTaskRunner is responsible for running training tasks. */ @@ -155,11 +155,12 @@ private void startTrainingTask(MLTask mlTask, MLInput mlInput, ActionListener dataFrameActionListener = ActionListener - .wrap(dataSet -> { train(mlTask, mlInput.toBuilder().inputDataset(dataSet).build(), internalListener); }, e -> { - log.error("Failed to generate DataFrame from search query", e); - internalListener.onFailure(e); - }); + ActionListener dataFrameActionListener = ActionListener.wrap(dataSet -> { + train(mlTask, mlInput.toBuilder().inputDataset(dataSet).build(), internalListener); + }, e -> { + log.error("Failed to generate DataFrame from search query", e); + internalListener.onFailure(e); + }); mlInputDatasetHandler .parseSearchQueryInput( mlInput.getInputDataset(), diff --git a/plugin/src/main/java/org/opensearch/ml/utils/MLNodeUtils.java b/plugin/src/main/java/org/opensearch/ml/utils/MLNodeUtils.java index 2a3d099df7..588bcae0ea 100644 --- a/plugin/src/main/java/org/opensearch/ml/utils/MLNodeUtils.java +++ b/plugin/src/main/java/org/opensearch/ml/utils/MLNodeUtils.java @@ -12,8 +12,6 @@ import java.util.Set; import java.util.function.Function; -import lombok.experimental.UtilityClass; - import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.xcontent.LoggingDeprecationHandler; @@ -27,6 +25,8 @@ import org.opensearch.ml.stats.MLNodeLevelStat; import org.opensearch.ml.stats.MLStats; +import lombok.experimental.UtilityClass; + @UtilityClass public class MLNodeUtils { public boolean isMLNode(DiscoveryNode node) { diff --git a/plugin/src/main/java/org/opensearch/ml/utils/RestActionUtils.java b/plugin/src/main/java/org/opensearch/ml/utils/RestActionUtils.java index 0cd82b3719..5241874dcb 100644 --- a/plugin/src/main/java/org/opensearch/ml/utils/RestActionUtils.java +++ b/plugin/src/main/java/org/opensearch/ml/utils/RestActionUtils.java @@ -14,8 +14,6 @@ import java.util.Locale; import java.util.Optional; -import lombok.extern.log4j.Log4j2; - import org.apache.commons.lang3.ArrayUtils; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; @@ -30,6 +28,8 @@ import com.google.common.annotations.VisibleForTesting; +import lombok.extern.log4j.Log4j2; + @Log4j2 public class RestActionUtils { diff --git a/plugin/src/test/java/org/opensearch/ml/action/deploy/TransportDeployModelOnNodeActionTests.java b/plugin/src/test/java/org/opensearch/ml/action/deploy/TransportDeployModelOnNodeActionTests.java index 789fa3629b..c71be9553a 100644 --- a/plugin/src/test/java/org/opensearch/ml/action/deploy/TransportDeployModelOnNodeActionTests.java +++ b/plugin/src/test/java/org/opensearch/ml/action/deploy/TransportDeployModelOnNodeActionTests.java @@ -228,7 +228,7 @@ public void setup() throws IOException { null, nodes, null, - null, + new HashMap<>(), 0, false ); diff --git a/plugin/src/test/java/org/opensearch/ml/cluster/DiscoveryNodeHelperTests.java b/plugin/src/test/java/org/opensearch/ml/cluster/DiscoveryNodeHelperTests.java index 99d9e90a8c..e9b6c446c3 100644 --- a/plugin/src/test/java/org/opensearch/ml/cluster/DiscoveryNodeHelperTests.java +++ b/plugin/src/test/java/org/opensearch/ml/cluster/DiscoveryNodeHelperTests.java @@ -16,6 +16,7 @@ import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; @@ -128,7 +129,7 @@ public void setup() throws IOException { .add(mlNode1) .add(mlNode2) .build(); - clusterState = new ClusterState(new ClusterName(clusterName), 123l, "111111", null, null, nodes, null, null, 0, false); + clusterState = new ClusterState(new ClusterName(clusterName), 123l, "111111", null, null, nodes, null, new HashMap<>(), 0, false); when(clusterService.state()).thenReturn(clusterState); discoveryNodeHelper = new DiscoveryNodeHelper(clusterService, settings); @@ -157,7 +158,7 @@ public void testGetEligibleNodes_DataNode() { mockSettings(false, nonExistingNodeName); DiscoveryNodeHelper discoveryNodeHelper = new DiscoveryNodeHelper(clusterService, settings); DiscoveryNodes nodes = DiscoveryNodes.builder().add(clusterManagerNode).add(dataNode1).add(dataNode2).add(warmDataNode1).build(); - clusterState = new ClusterState(new ClusterName(clusterName), 123l, "111111", null, null, nodes, null, null, 0, false); + clusterState = new ClusterState(new ClusterName(clusterName), 123l, "111111", null, null, nodes, null, new HashMap<>(), 0, false); when(clusterService.state()).thenReturn(clusterState); DiscoveryNode[] eligibleNodes = discoveryNodeHelper.getEligibleNodes(); diff --git a/plugin/src/test/java/org/opensearch/ml/cluster/MLSyncUpCronTests.java b/plugin/src/test/java/org/opensearch/ml/cluster/MLSyncUpCronTests.java index da8002ca4b..b1dcce3732 100644 --- a/plugin/src/test/java/org/opensearch/ml/cluster/MLSyncUpCronTests.java +++ b/plugin/src/test/java/org/opensearch/ml/cluster/MLSyncUpCronTests.java @@ -51,7 +51,6 @@ import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.common.transport.TransportAddress; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.ml.common.MLModel; @@ -100,7 +99,8 @@ public void setup() throws IOException { } public void testRun_NoMLModelIndex() { - Metadata metadata = new Metadata.Builder().indices(ImmutableOpenMap.builder().build()).build(); + final Map indices = new HashMap<>(); + Metadata metadata = new Metadata.Builder().indices(indices).build(); DiscoveryNode node = new DiscoveryNode( "node", new TransportAddress(TransportAddress.META_ADDRESS, new AtomicInteger().incrementAndGet()), @@ -116,7 +116,7 @@ public void testRun_NoMLModelIndex() { null, DiscoveryNodes.builder().add(node).build(), null, - null, + new HashMap<>(), 0, false ); diff --git a/plugin/src/test/java/org/opensearch/ml/indices/MLIndicesHandlerTests.java b/plugin/src/test/java/org/opensearch/ml/indices/MLIndicesHandlerTests.java index a54a04fe6b..534a6f930c 100644 --- a/plugin/src/test/java/org/opensearch/ml/indices/MLIndicesHandlerTests.java +++ b/plugin/src/test/java/org/opensearch/ml/indices/MLIndicesHandlerTests.java @@ -104,32 +104,23 @@ private void testInitMLIndexIfAbsentWithExistingIndex(String indexName, String o throws ExecutionException, InterruptedException, IOException { - mlIndicesHandler - .shouldUpdateIndex( - indexName, - 1, - ActionListener.wrap(shouldUpdate -> { assertFalse(shouldUpdate); }, e -> { throw new RuntimeException(e); }) - ); + mlIndicesHandler.shouldUpdateIndex(indexName, 1, ActionListener.wrap(shouldUpdate -> { assertFalse(shouldUpdate); }, e -> { + throw new RuntimeException(e); + })); CreateIndexRequest request = new CreateIndexRequest(indexName).mapping(oldIndexMapping); client.admin().indices().create(request).get(); - mlIndicesHandler - .shouldUpdateIndex( - indexName, - 1, - ActionListener.wrap(shouldUpdate -> { assertTrue(shouldUpdate); }, e -> { throw new RuntimeException(e); }) - ); + mlIndicesHandler.shouldUpdateIndex(indexName, 1, ActionListener.wrap(shouldUpdate -> { assertTrue(shouldUpdate); }, e -> { + throw new RuntimeException(e); + })); assertNull(getIndexSchemaVersion(indexName)); ActionListener listener = ActionListener.wrap(r -> { assertTrue(r); Integer indexSchemaVersion = getIndexSchemaVersion(indexName); if (indexSchemaVersion != null) { assertEquals(schemaVersion, indexSchemaVersion.intValue()); - mlIndicesHandler - .shouldUpdateIndex( - indexName, - 1, - ActionListener.wrap(shouldUpdate -> { assertFalse(shouldUpdate); }, e -> { throw new RuntimeException(e); }) - ); + mlIndicesHandler.shouldUpdateIndex(indexName, 1, ActionListener.wrap(shouldUpdate -> { assertFalse(shouldUpdate); }, e -> { + throw new RuntimeException(e); + })); } }, e -> { throw new RuntimeException(e); }); mlIndicesHandler.initModelIndexIfAbsent(listener); @@ -151,8 +142,9 @@ public void testInitMLModelIndexIfAbsentWithNonExistingIndex_Exception() { actionListener.onFailure(new RuntimeException(errorMessage)); return null; }).when(adminClient).create(any(), any()); - ActionListener listener = ActionListener - .wrap(r -> { throw new RuntimeException("unexpected result"); }, e -> { assertEquals(errorMessage, e.getMessage()); }); + ActionListener listener = ActionListener.wrap(r -> { throw new RuntimeException("unexpected result"); }, e -> { + assertEquals(errorMessage, e.getMessage()); + }); mlIndicesHandler.initModelIndexIfAbsent(listener); when(mockClient.threadPool()).thenThrow(new RuntimeException(errorMessage)); diff --git a/plugin/src/test/java/org/opensearch/ml/rest/RestMLCustomModelActionIT.java b/plugin/src/test/java/org/opensearch/ml/rest/RestMLCustomModelActionIT.java index b180cdb9ad..35378f4f9b 100644 --- a/plugin/src/test/java/org/opensearch/ml/rest/RestMLCustomModelActionIT.java +++ b/plugin/src/test/java/org/opensearch/ml/rest/RestMLCustomModelActionIT.java @@ -13,6 +13,7 @@ import java.util.Map; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.rules.ExpectedException; import org.opensearch.ml.common.MLTaskState; @@ -30,6 +31,7 @@ public void setup() { registerModelInput = createRegisterModelInput(); } + @Ignore public void testCustomModelWorkflow() throws IOException, InterruptedException { // register model String taskId = registerModel(TestHelper.toJsonString(registerModelInput)); diff --git a/plugin/src/test/java/org/opensearch/ml/utils/TestHelper.java b/plugin/src/test/java/org/opensearch/ml/utils/TestHelper.java index 5dcfe1f0d4..6ad2da4d0a 100644 --- a/plugin/src/test/java/org/opensearch/ml/utils/TestHelper.java +++ b/plugin/src/test/java/org/opensearch/ml/utils/TestHelper.java @@ -49,7 +49,6 @@ import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; @@ -305,11 +304,7 @@ public static ClusterState state( .build(); final Settings.Builder existingSettings = Settings.builder().put(indexSettings).put(IndexMetadata.SETTING_INDEX_UUID, "test2UUID"); IndexMetadata indexMetaData = IndexMetadata.builder(indexName).settings(existingSettings).putMapping(mapping).build(); - - final ImmutableOpenMap indices = ImmutableOpenMap - .builder() - .fPut(indexName, indexMetaData) - .build(); + final Map indices = Collections.unmodifiableMap(Map.of(indexName, indexMetaData)); ClusterState clusterState = ClusterState.builder(name).metadata(Metadata.builder().indices(indices).build()).build(); return clusterState; @@ -352,26 +347,14 @@ public static ClusterState setupTestClusterState() { roleSet, Version.CURRENT ); - Metadata metadata = new Metadata.Builder() - .indices( - ImmutableOpenMap - .builder() - .fPut( - ML_MODEL_INDEX, - IndexMetadata - .builder("test") - .settings( - Settings - .builder() - .put("index.number_of_shards", 1) - .put("index.number_of_replicas", 1) - .put("index.version.created", Version.CURRENT.id) - ) - .build() - ) - .build() - ) - .build(); + final Settings.Builder indexSettings = Settings + .builder() + .put("index.number_of_shards", 1) + .put("index.number_of_replicas", 1) + .put("index.version.created", Version.CURRENT.id); + IndexMetadata indexMetaData = IndexMetadata.builder("test").settings(indexSettings).build(); + final Map indices = Map.of(ML_MODEL_INDEX, indexMetaData); + Metadata metadata = new Metadata.Builder().indices(indices).build(); return new ClusterState( new ClusterName("test cluster"), 123l, @@ -380,7 +363,7 @@ public static ClusterState setupTestClusterState() { null, DiscoveryNodes.builder().add(node).build(), null, - null, + new HashMap<>(), 0, false );