From 6b74174c028cd64f03ce5f1040d0a7431528ac71 Mon Sep 17 00:00:00 2001 From: "nikita.smirnov" Date: Tue, 27 Aug 2024 17:00:45 +0400 Subject: [PATCH 1/5] [TH2-5234] Updated dependencies --- README.md | 12 +- build.gradle | 24 +- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 22 +- gradlew | 269 +++++++++++------- gradlew.bat | 38 +-- .../th2/rptdataprovider/Extensions.kt | 8 +- .../com/exactpro/th2/rptdataprovider/Main.kt | 4 +- .../th2/rptdataprovider/cache/EventCache.kt | 8 +- .../entities/configuration/Configuration.kt | 4 +- .../entities/configuration/Variable.kt | 8 +- .../entities/filters/FilterPredicate.kt | 9 +- .../filters/messages/AttachedEventFilters.kt | 4 +- .../messages/MessageBodyBinaryFilter.kt | 4 +- .../entities/internal/ProtoProtocolInfo.kt | 4 +- .../entities/mappers/ProtoMessageMapper.kt | 4 +- .../mappers/TransportMessageMapper.kt | 4 +- .../entities/responses/EventTreeNode.kt | 8 +- .../entities/responses/StreamInfo.kt | 9 +- .../entities/sse/StreamWriter.kt | 4 +- .../grpc/RptDataProviderGrpcHandler.kt | 7 +- .../handlers/PipelineComponent.kt | 4 +- .../handlers/SearchEventsHandler.kt | 4 +- .../handlers/SearchMessagesHandler.kt | 18 +- .../messages/MessageBatchConverter.kt | 4 +- .../handlers/messages/MessageBatchDecoder.kt | 4 +- .../handlers/messages/MessageBatchUnpacker.kt | 4 +- .../handlers/messages/MessageExtractor.kt | 4 +- .../handlers/messages/StreamMerger.kt | 4 +- .../producers/EventProducer.kt | 8 +- .../producers/MessageProducer.kt | 4 +- .../th2/rptdataprovider/server/GrpcServer.kt | 4 +- .../th2/rptdataprovider/server/HttpServer.kt | 13 +- .../services/cradle/CradleService.kt | 4 +- .../cradle/MessageGroupCradleService.kt | 4 +- .../services/rabbitmq/CodecRequest.kt | 4 +- .../services/rabbitmq/RabbitMqService.kt | 4 +- 37 files changed, 299 insertions(+), 248 deletions(-) diff --git a/README.md b/README.md index b0e330ee..4217ebb7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Report data provider (5.11.0) +# Report data provider (5.13.0) # Overview This component serves as a backend for rpt-viewer. It will connect to the cassandra database via cradle api and expose the data stored in there as REST resources. @@ -295,6 +295,16 @@ spec: # Release notes +## 5.13.0 +* Updated: + * th2 gradle plugin: `0.1.1` + * common: `5.14.0-dev` + * gradle api: `5.4.2-dev` + * common-utils: `2.3.0-dev` + * ktor-bom: `2.3.12` + * ehcache: `3.10.8` + * kotlin-logging: `5.1.4` + ## 5.12.0 * Migrate to th2 gradle plugin `0.0.8` * Updated common: `5.12.0-dev` diff --git a/build.gradle b/build.gradle index f2f0a33f..16e49638 100644 --- a/build.gradle +++ b/build.gradle @@ -2,13 +2,13 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id 'org.jetbrains.kotlin.jvm' version '1.8.22' - id "com.exactpro.th2.gradle.component" version "0.0.8" + id "com.exactpro.th2.gradle.component" version "0.1.1" id 'application' } ext { dockerImageVersion = release_version - cradleVersion = '5.3.0-dev' + cradleVersion = '5.4.2-dev' } group 'com.exactpro.th2' @@ -42,15 +42,13 @@ dependencies { implementation 'com.fasterxml.jackson.module:jackson-module-kotlin' implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' - implementation group: 'net.jpountz.lz4', name: 'lz4', version: '1.3.0' - implementation 'org.apache.commons:commons-lang3' - implementation('com.exactpro.th2:common:5.12.0-dev') { + implementation('com.exactpro.th2:common:5.14.0-dev') { exclude group: 'com.exactpro.th2', module: 'cradle-core' exclude group: 'com.exactpro.th2', module: 'cradle-cassandra' } - implementation 'com.exactpro.th2:common-utils:2.2.3-dev' + implementation 'com.exactpro.th2:common-utils:2.3.0-dev' implementation "com.exactpro.th2:cradle-core:${cradleVersion}" @@ -58,29 +56,29 @@ dependencies { implementation 'com.exactpro.th2:grpc-data-provider:0.2.0-dev' - implementation 'io.github.microutils:kotlin-logging:3.0.5' + implementation 'io.github.oshai:kotlin-logging:5.1.4' implementation 'io.prometheus:simpleclient' - implementation(platform('io.ktor:ktor-bom:2.3.3')) + implementation(platform('io.ktor:ktor-bom:2.3.12')) implementation 'io.ktor:ktor-server-netty' implementation 'io.ktor:ktor-server' - implementation 'org.ehcache:ehcache:3.8.1' + implementation 'org.ehcache:ehcache:3.10.8' implementation('org.glassfish.jaxb:jaxb-runtime:2.3.9') { because("'2.3.9' version has 'EDL 1.0' license instead of 'CDDL GPL 1.1' in the '2.3.1'") } - testImplementation('io.mockk:mockk:1.12.4') { // The last version bases on kotlin 1.6.0 + testImplementation('io.mockk:mockk:1.13.12') { // The last version bases on kotlin 1.6.0 exclude group: 'org.jetbrains.kotlin', module: 'kotlin-reflect' // because we need kotlin reflect with different version } testImplementation('org.jetbrains.kotlin:kotlin-reflect') { because('mockk needs it') } - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2' - testImplementation "org.junit.jupiter:junit-jupiter-params:5.10.2" + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.0' + testImplementation "org.junit.jupiter:junit-jupiter-params:5.11.0" - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.0' } tasks.withType(KotlinCompile).configureEach { diff --git a/gradle.properties b/gradle.properties index 83f77591..264d9816 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,5 +15,5 @@ ################################################################################ kotlin.code.style=official -release_version=5.12.0 +release_version=5.13.0 docker_image_name= \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 518af947..20db9ad5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,22 +1,6 @@ -################################################################################ -# Copyright 2009-2020 Exactpro (Exactpro Systems Limited) -# -# 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 -# -# http://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. -################################################################################ - -#Tue Apr 14 11:21:33 MSK 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 2fe81a7d..65dcd68d 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# 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. @@ -17,78 +17,113 @@ # ############################################################################## -## -## 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 -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # 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"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; 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 # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -105,79 +140,105 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - 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 fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + 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 - i=`expr $i + 1` + # 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 - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# 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 +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + 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. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 24467a14..6689b85b 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 init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +55,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,38 +65,26 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line 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 %CMD_LINE_ARGS% +"%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/src/main/kotlin/com/exactpro/th2/rptdataprovider/Extensions.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/Extensions.kt index f27f860f..43cf8ce1 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/Extensions.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/Extensions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,19 +21,21 @@ import com.exactpro.cradle.filters.ComparisonOperation import com.exactpro.cradle.messages.GroupedMessageFilter import com.exactpro.cradle.messages.MessageFilter import com.exactpro.cradle.messages.StoredMessageId -import com.exactpro.cradle.testevents.* +import com.exactpro.cradle.testevents.BatchedStoredTestEvent +import com.exactpro.cradle.testevents.StoredTestEventBatch +import com.exactpro.cradle.testevents.StoredTestEventId import com.exactpro.th2.common.grpc.ConnectionID import com.exactpro.th2.common.grpc.MessageID import com.exactpro.th2.common.message.toTimestamp import com.exactpro.th2.common.schema.message.impl.rabbitmq.transport.MessageId import com.fasterxml.jackson.databind.ObjectMapper +import io.github.oshai.kotlinlogging.KotlinLogging import io.prometheus.client.Gauge import io.prometheus.client.Histogram import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope.coroutineContext import kotlinx.coroutines.withContext -import mu.KotlinLogging import java.io.IOException import java.time.Instant import kotlin.system.measureTimeMillis diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/Main.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/Main.kt index 7ae90c6c..2c1fe0a1 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/Main.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/Main.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.IO_PARALLELISM_PROPERTY_NAME import kotlinx.coroutines.InternalCoroutinesApi -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.* import java.util.concurrent.ConcurrentLinkedDeque import java.util.concurrent.locks.Condition diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/cache/EventCache.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/cache/EventCache.kt index 43646827..65b34608 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/cache/EventCache.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/cache/EventCache.kt @@ -1,5 +1,5 @@ -/******************************************************************************* - * Copyright 2020-2021 Exactpro (Exactpro Systems Limited) +/* + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ * 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. - ******************************************************************************/ + */ package com.exactpro.th2.rptdataprovider.cache import com.exactpro.th2.rptdataprovider.entities.internal.ProviderEventId import com.exactpro.th2.rptdataprovider.entities.responses.BaseEventEntity import com.exactpro.th2.rptdataprovider.producers.EventProducer -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.ehcache.Cache import org.ehcache.config.builders.CacheConfigurationBuilder import org.ehcache.config.builders.CacheManagerBuilder diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Configuration.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Configuration.kt index ab660a25..5a6cfbcf 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Configuration.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Configuration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package com.exactpro.th2.rptdataprovider.entities.configuration import com.exactpro.th2.rptdataprovider.server.ServerType -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging class CustomConfigurationClass { val hostname: String = "localhost" diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Variable.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Variable.kt index 37b13d1a..b7b62f7a 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Variable.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Variable.kt @@ -1,5 +1,5 @@ -/******************************************************************************* - * Copyright 2020-2020 Exactpro (Exactpro Systems Limited) +/* + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,11 +12,11 @@ * 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. - ******************************************************************************/ + */ package com.exactpro.th2.rptdataprovider.entities.configuration -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging class Variable( diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/filters/FilterPredicate.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/filters/FilterPredicate.kt index 15637470..4714ba74 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/filters/FilterPredicate.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/filters/FilterPredicate.kt @@ -1,5 +1,5 @@ -/******************************************************************************* - * Copyright 2020-2021 Exactpro (Exactpro Systems Limited) +/* + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,13 +12,12 @@ * 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. - ******************************************************************************/ + */ package com.exactpro.th2.rptdataprovider.entities.filters import com.exactpro.th2.rptdataprovider.entities.filters.info.FilterSpecialType -import com.exactpro.th2.rptdataprovider.logTime -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import kotlin.system.measureTimeMillis class FilterPredicate(private val filters: List>, private val specialTypes: List) { diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/filters/messages/AttachedEventFilters.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/filters/messages/AttachedEventFilters.kt index b55a1991..f6285171 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/filters/messages/AttachedEventFilters.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/filters/messages/AttachedEventFilters.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import com.exactpro.th2.rptdataprovider.entities.filters.info.Parameter import com.exactpro.th2.rptdataprovider.entities.internal.MessageWithMetadata import com.exactpro.th2.rptdataprovider.entities.internal.ProviderEventId import com.exactpro.th2.rptdataprovider.services.cradle.CradleService -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging class AttachedEventFilters private constructor( private var messagesFromAttachedId: Set, diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/filters/messages/MessageBodyBinaryFilter.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/filters/messages/MessageBodyBinaryFilter.kt index b49d246e..9abe85e7 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/filters/messages/MessageBodyBinaryFilter.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/filters/messages/MessageBodyBinaryFilter.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import com.exactpro.th2.rptdataprovider.entities.filters.info.FilterSpecialType import com.exactpro.th2.rptdataprovider.entities.filters.info.Parameter import com.exactpro.th2.rptdataprovider.entities.internal.MessageWithMetadata import com.exactpro.th2.rptdataprovider.services.cradle.CradleService -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.* class MessageBodyBinaryFilter private constructor( diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/internal/ProtoProtocolInfo.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/internal/ProtoProtocolInfo.kt index bdb57c43..69b06f8a 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/internal/ProtoProtocolInfo.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/internal/ProtoProtocolInfo.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2022-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ package com.exactpro.th2.rptdataprovider.entities.internal -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging object ProtoProtocolInfo { val logger = KotlinLogging.logger{} diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/mappers/ProtoMessageMapper.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/mappers/ProtoMessageMapper.kt index 8506f438..7eb5ffbb 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/mappers/ProtoMessageMapper.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/mappers/ProtoMessageMapper.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2022-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import com.exactpro.th2.rptdataprovider.convertToProto import com.exactpro.th2.rptdataprovider.entities.internal.MessageWithMetadata import com.exactpro.th2.rptdataprovider.entities.responses.HttpMessage import com.google.protobuf.ByteString -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.* object ProtoMessageMapper { diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/mappers/TransportMessageMapper.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/mappers/TransportMessageMapper.kt index 5238bde9..5dff27a4 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/mappers/TransportMessageMapper.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/mappers/TransportMessageMapper.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2022-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import com.exactpro.th2.rptdataprovider.convertToProto import com.exactpro.th2.rptdataprovider.convertToTransport import com.exactpro.th2.rptdataprovider.entities.internal.MessageWithMetadata import com.exactpro.th2.rptdataprovider.entities.responses.HttpMessage -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.* object TransportMessageMapper { diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/responses/EventTreeNode.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/responses/EventTreeNode.kt index 195a900e..8beb08ea 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/responses/EventTreeNode.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/responses/EventTreeNode.kt @@ -1,5 +1,5 @@ -/******************************************************************************* - * Copyright 2020-2021 Exactpro (Exactpro Systems Limited) +/* + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ * 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. - ******************************************************************************/ + */ package com.exactpro.th2.rptdataprovider.entities.responses @@ -26,7 +26,7 @@ import com.exactpro.th2.dataprovider.grpc.EventMetadata import com.exactpro.th2.rptdataprovider.entities.exceptions.ParseEventTreeNodeException import com.exactpro.th2.rptdataprovider.entities.internal.ProviderEventId import com.fasterxml.jackson.annotation.JsonIgnore -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Instant data class EventTreeNode( diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/responses/StreamInfo.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/responses/StreamInfo.kt index 7b6134fe..4fc948e9 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/responses/StreamInfo.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/responses/StreamInfo.kt @@ -1,5 +1,5 @@ -/******************************************************************************* - * Copyright 2020-2021 Exactpro (Exactpro Systems Limited) +/* + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ * 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. - ******************************************************************************/ + */ package com.exactpro.th2.rptdataprovider.entities.responses @@ -21,9 +21,8 @@ import com.exactpro.th2.dataprovider.grpc.Stream import com.exactpro.th2.rptdataprovider.convertToProto import com.exactpro.th2.rptdataprovider.cradleDirectionToGrpc import com.exactpro.th2.rptdataprovider.entities.internal.StreamName -import com.exactpro.th2.rptdataprovider.entities.internal.StreamPointer import com.fasterxml.jackson.annotation.JsonIgnore -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Instant data class StreamInfo(val streamPointer: StreamName, @JsonIgnore val messageId: StoredMessageId? = null) { diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/sse/StreamWriter.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/sse/StreamWriter.kt index 94f70a10..2f5bb7f7 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/sse/StreamWriter.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/sse/StreamWriter.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Deferred import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.launch -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.io.Writer import java.util.concurrent.atomic.AtomicLong import kotlin.math.roundToInt diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/grpc/RptDataProviderGrpcHandler.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/grpc/RptDataProviderGrpcHandler.kt index 3f672ef9..a1d74693 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/grpc/RptDataProviderGrpcHandler.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/grpc/RptDataProviderGrpcHandler.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,10 +48,10 @@ import com.exactpro.th2.rptdataprovider.logMetrics import com.exactpro.th2.rptdataprovider.services.cradle.CradleObjectNotFoundException import com.google.protobuf.MessageOrBuilder import com.google.protobuf.TextFormat +import io.github.oshai.kotlinlogging.KotlinLogging import io.grpc.Status import io.grpc.stub.StreamObserver -import io.ktor.server.engine.* -import io.ktor.util.* +import io.ktor.util.InternalAPI import io.prometheus.client.Counter import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineExceptionHandler @@ -65,7 +65,6 @@ import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import mu.KotlinLogging import org.apache.commons.lang3.exception.ExceptionUtils import java.time.Instant import java.util.concurrent.Executors diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/PipelineComponent.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/PipelineComponent.kt index 70480cad..ad4b28df 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/PipelineComponent.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/PipelineComponent.kt @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2021-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import com.exactpro.th2.rptdataprovider.entities.internal.StreamName import com.exactpro.th2.rptdataprovider.entities.requests.SseMessageSearchRequest import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.Channel -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging abstract class PipelineComponent( diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchEventsHandler.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchEventsHandler.kt index 398956d1..2a4b0e44 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchEventsHandler.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchEventsHandler.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ import kotlinx.coroutines.flow.take import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Instant import java.time.LocalTime import java.time.ZoneOffset diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchMessagesHandler.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchMessagesHandler.kt index fa3a7ec0..222e959d 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchMessagesHandler.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchMessagesHandler.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,12 @@ import com.exactpro.th2.rptdataprovider.ProtoMessageGroup import com.exactpro.th2.rptdataprovider.ProtoRawMessage import com.exactpro.th2.rptdataprovider.TransportMessageGroup import com.exactpro.th2.rptdataprovider.TransportRawMessage -import com.exactpro.th2.rptdataprovider.entities.internal.* +import com.exactpro.th2.rptdataprovider.entities.internal.EmptyPipelineObject +import com.exactpro.th2.rptdataprovider.entities.internal.PipelineFilteredMessage +import com.exactpro.th2.rptdataprovider.entities.internal.PipelineKeepAlive +import com.exactpro.th2.rptdataprovider.entities.internal.PipelineRawBatch +import com.exactpro.th2.rptdataprovider.entities.internal.StreamEndObject +import com.exactpro.th2.rptdataprovider.entities.internal.StreamName import com.exactpro.th2.rptdataprovider.entities.mappers.TimeRelationMapper import com.exactpro.th2.rptdataprovider.entities.requests.SseMessageSearchRequest import com.exactpro.th2.rptdataprovider.entities.responses.StreamInfo @@ -39,13 +44,16 @@ import com.exactpro.th2.rptdataprovider.handlers.messages.MessageExtractor import com.exactpro.th2.rptdataprovider.handlers.messages.ProtoChainBuilder import com.exactpro.th2.rptdataprovider.handlers.messages.StreamMerger import com.exactpro.th2.rptdataprovider.handlers.messages.TransportChainBuilder +import io.github.oshai.kotlinlogging.KotlinLogging import io.prometheus.client.Counter -import kotlinx.coroutines.* -import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.cancel +import kotlinx.coroutines.ensureActive import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.onCompletion import kotlinx.coroutines.flow.takeWhile -import mu.KotlinLogging +import kotlinx.coroutines.withContext import java.util.concurrent.atomic.AtomicLong import kotlin.coroutines.coroutineContext import kotlin.math.roundToInt diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageBatchConverter.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageBatchConverter.kt index 408d3219..9c638690 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageBatchConverter.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageBatchConverter.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2022-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ import com.exactpro.th2.rptdataprovider.services.rabbitmq.TransportCodecBatchReq import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging abstract class MessageBatchConverter( context: Context, diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageBatchDecoder.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageBatchDecoder.kt index 8f7d09f0..d7813a58 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageBatchDecoder.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageBatchDecoder.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2022-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging class MessageBatchDecoder( context: Context, diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageBatchUnpacker.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageBatchUnpacker.kt index 8ec9b60d..f32bddc0 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageBatchUnpacker.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageBatchUnpacker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2021-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ import com.exactpro.th2.rptdataprovider.handlers.PipelineStatus import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import kotlin.time.DurationUnit import kotlin.time.ExperimentalTime import kotlin.time.measureTimedValue diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt index ebc78105..979d0025 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2021-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ import com.exactpro.th2.rptdataprovider.handlers.PipelineStatus import com.exactpro.th2.rptdataprovider.isAfterOrEqual import com.exactpro.th2.rptdataprovider.isBeforeOrEqual import kotlinx.coroutines.* -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Instant diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/StreamMerger.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/StreamMerger.kt index 206f13ab..4c97328d 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/StreamMerger.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/StreamMerger.kt @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2021-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import com.exactpro.th2.rptdataprovider.handlers.messages.helpers.MultipleStream import com.exactpro.th2.rptdataprovider.isAfterOrEqual import com.exactpro.th2.rptdataprovider.isBeforeOrEqual import kotlinx.coroutines.* -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Instant import kotlin.coroutines.coroutineContext import kotlin.time.DurationUnit diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/producers/EventProducer.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/producers/EventProducer.kt index 6477689a..b01c6f71 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/producers/EventProducer.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/producers/EventProducer.kt @@ -1,5 +1,5 @@ -/******************************************************************************* - * Copyright 2020-2021 Exactpro (Exactpro Systems Limited) +/* + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ * 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. - ******************************************************************************/ + */ package com.exactpro.th2.rptdataprovider.producers @@ -27,7 +27,7 @@ import com.exactpro.th2.rptdataprovider.entities.responses.BaseEventEntity import com.exactpro.th2.rptdataprovider.services.cradle.CradleEventNotFoundException import com.exactpro.th2.rptdataprovider.services.cradle.CradleService import com.fasterxml.jackson.databind.ObjectMapper -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Instant class EventProducer(private val cradle: CradleService, private val mapper: ObjectMapper) { diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/producers/MessageProducer.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/producers/MessageProducer.kt index 7645e78f..7ea412e6 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/producers/MessageProducer.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/producers/MessageProducer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ import com.exactpro.th2.rptdataprovider.services.rabbitmq.ProtoCodecBatchRequest import com.exactpro.th2.rptdataprovider.services.rabbitmq.ProtoCodecBatchRequest.Companion.protocol import com.exactpro.th2.rptdataprovider.services.rabbitmq.TransportCodecBatchRequest import com.exactpro.th2.rptdataprovider.services.rabbitmq.TransportCodecBatchRequest.Companion.protocol -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import kotlin.system.measureTimeMillis import kotlin.time.ExperimentalTime import kotlin.time.measureTimedValue diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/GrpcServer.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/GrpcServer.kt index 7d15c5a6..1fb7e54d 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/GrpcServer.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/GrpcServer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import com.exactpro.th2.rptdataprovider.entities.internal.MessageWithMetadata import com.exactpro.th2.rptdataprovider.grpc.RptDataProviderGrpcHandler import io.ktor.util.InternalAPI import kotlinx.coroutines.ExperimentalCoroutinesApi -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.TimeUnit diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/HttpServer.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/HttpServer.kt index 092df6a1..a635e1e2 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/HttpServer.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/HttpServer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,21 +35,20 @@ import com.exactpro.th2.rptdataprovider.entities.sse.StreamWriter import com.exactpro.th2.rptdataprovider.logMetrics import com.exactpro.th2.rptdataprovider.server.handler.AbortableRequestHandler import com.exactpro.th2.rptdataprovider.services.cradle.CradleObjectNotFoundException -import io.ktor.server.application.* - +import io.github.oshai.kotlinlogging.KotlinLogging import io.ktor.http.* -import io.ktor.server.request.* -import io.ktor.server.response.* -import io.ktor.server.routing.* +import io.ktor.server.application.* import io.ktor.server.engine.* import io.ktor.server.netty.* import io.ktor.server.plugins.compression.Compression +import io.ktor.server.request.* +import io.ktor.server.response.* +import io.ktor.server.routing.* import io.ktor.server.util.getOrFail import io.ktor.util.* import io.ktor.util.pipeline.* import io.prometheus.client.Counter import kotlinx.coroutines.* -import mu.KotlinLogging import java.nio.channels.ClosedChannelException import java.util.concurrent.atomic.AtomicBoolean import kotlin.coroutines.coroutineContext diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/cradle/CradleService.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/cradle/CradleService.kt index e3d810e2..671bb51a 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/cradle/CradleService.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/cradle/CradleService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.future.await import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.Executors open class CradleService(configuration: Configuration, cradleManager: CradleManager) { diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/cradle/MessageGroupCradleService.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/cradle/MessageGroupCradleService.kt index 122e635b..0c79ba5c 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/cradle/MessageGroupCradleService.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/cradle/MessageGroupCradleService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 Exactpro (Exactpro Systems Limited) + * Copyright 2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ import com.exactpro.th2.rptdataprovider.logMetrics import com.exactpro.th2.rptdataprovider.logTime import com.exactpro.th2.rptdataprovider.toGroupedMessageFilter import kotlinx.coroutines.future.await -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.ehcache.Cache import org.ehcache.config.builders.CacheConfigurationBuilder import org.ehcache.config.builders.CacheManagerBuilder diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/rabbitmq/CodecRequest.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/rabbitmq/CodecRequest.kt index 59d19817..13af5c14 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/rabbitmq/CodecRequest.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/rabbitmq/CodecRequest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import com.exactpro.th2.rptdataprovider.ProtoMessageGroup import com.exactpro.th2.rptdataprovider.TransportMessageGroup import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.Job -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging data class CodecRequestId(private val ids: Set) { diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/rabbitmq/RabbitMqService.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/rabbitmq/RabbitMqService.kt index b58176e8..a7c8d543 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/rabbitmq/RabbitMqService.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/services/rabbitmq/RabbitMqService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.Executors import kotlin.system.measureTimeMillis From ab47acad67283bafd65757b3dd0edf1ae68f16b2 Mon Sep 17 00:00:00 2001 From: "nikita.smirnov" Date: Tue, 27 Aug 2024 17:17:11 +0400 Subject: [PATCH 2/5] [TH2-5234] Updated dependencies --- Dockerfile | 2 +- README.md | 1 + .../requests/SseMessageSearchRequest.kt | 9 +++++ .../handlers/messages/MessageExtractor.kt | 40 +++++++++++++++---- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index ecefb87f..028fdbfb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM gradle:7.6-jdk11 AS build +FROM gradle:8.7-jdk11 AS build ARG Prelease_version=0.0.0 COPY ./ . RUN gradle clean build dockerPrepare -Prelease_version=${Prelease_version} diff --git a/README.md b/README.md index 4217ebb7..804536a5 100644 --- a/README.md +++ b/README.md @@ -296,6 +296,7 @@ spec: # Release notes ## 5.13.0 +* Provided ability to limit `messageIds` request by `lookupLimitDays` argument * Updated: * th2 gradle plugin: `0.1.1` * common: `5.14.0-dev` diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/requests/SseMessageSearchRequest.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/requests/SseMessageSearchRequest.kt index 49ea5443..6cd37081 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/requests/SseMessageSearchRequest.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/requests/SseMessageSearchRequest.kt @@ -164,6 +164,14 @@ data class SseMessageSearchRequest( } } + private fun checkLookupLimitDays() { + if (lookupLimitDays != null && endTimestamp != null) { + throw InvalidRequestException( + "endTimestamp: $endTimestamp must be null if lookupLimitDays: $lookupLimitDays isn't null" + ) + } + } + private fun checkStartPoint() { if (startTimestamp == null && resumeFromIdsList.isEmpty()) throw InvalidRequestException("One of the 'startTimestamp' or 'messageId' must not be null") @@ -206,6 +214,7 @@ data class SseMessageSearchRequest( checkEndTimestamp() checkStreamList() checkTimestampAndId() + checkLookupLimitDays() checkResumeIds() } diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt index 979d0025..4c51f3fd 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt @@ -34,9 +34,15 @@ import com.exactpro.th2.rptdataprovider.handlers.PipelineComponent import com.exactpro.th2.rptdataprovider.handlers.PipelineStatus import com.exactpro.th2.rptdataprovider.isAfterOrEqual import com.exactpro.th2.rptdataprovider.isBeforeOrEqual -import kotlinx.coroutines.* import io.github.oshai.kotlinlogging.KotlinLogging +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch import java.time.Instant +import java.time.temporal.ChronoUnit class MessageExtractor( @@ -173,12 +179,32 @@ class MessageExtractor( } } // always need to make sure that we send messages within the specified timestamp (in case the resume ID points to the past) - if (order == Order.DIRECT) { - request.startTimestamp?.let { builder.timestampFrom().isGreaterThanOrEqualTo(it) } - request.endTimestamp?.let { builder.timestampTo().isLessThan(it) } - } else { - request.startTimestamp?.let { builder.timestampTo().isLessThanOrEqualTo(it) } - request.endTimestamp?.let { builder.timestampFrom().isGreaterThan(it) } + with(request) { + if (order == Order.DIRECT) { + startTimestamp?.let { builder.timestampFrom().isGreaterThanOrEqualTo(it) } + endTimestamp?.let { builder.timestampTo().isLessThan(it) } + + if (startTimestamp != null && + endTimestamp == null && + lookupLimitDays != null + ) { + builder.timestampTo().isLessThan( + startTimestamp.plus(lookupLimitDays.toLong(), ChronoUnit.DAYS) + ) + } + } else { + startTimestamp?.let { builder.timestampTo().isLessThanOrEqualTo(it) } + endTimestamp?.let { builder.timestampFrom().isGreaterThan(it) } + + if (startTimestamp != null && + endTimestamp == null && + lookupLimitDays != null + ) { + builder.timestampFrom().isGreaterThan( + startTimestamp.minus(lookupLimitDays.toLong(), ChronoUnit.DAYS) + ) + } + } } }.build() ) From aee986987983b8cfc6f4ecf4d33fbaca5ed126c8 Mon Sep 17 00:00:00 2001 From: "nikita.smirnov" Date: Tue, 27 Aug 2024 19:05:08 +0400 Subject: [PATCH 3/5] [TH2-5234] Added messageIdsLookupLimit option --- README.md | 2 +- .../entities/configuration/Configuration.kt | 7 +++++++ .../requests/SseMessageSearchRequest.kt | 18 ++++++++++++------ .../handlers/SearchMessagesHandler.kt | 15 +++++++++++---- .../handlers/messages/MessageExtractor.kt | 19 ++++--------------- .../th2/rptdataprovider/server/HttpServer.kt | 2 +- 6 files changed, 36 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 804536a5..bdde59b7 100644 --- a/README.md +++ b/README.md @@ -296,7 +296,7 @@ spec: # Release notes ## 5.13.0 -* Provided ability to limit `messageIds` request by `lookupLimitDays` argument +* Provided ability to limit `messageIds` request by `lookupLimitDays` argument or `messageIdsLookupLimit` option * Updated: * th2 gradle plugin: `0.1.1` * common: `5.14.0-dev` diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Configuration.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Configuration.kt index 5a6cfbcf..d4d88831 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Configuration.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Configuration.kt @@ -48,6 +48,7 @@ class CustomConfigurationClass { val messageUnpackerOutputMessageBuffer: Int = 100 val messageFilterOutputMessageBuffer: Int = 100 val messageMergerOutputMessageBuffer: Int = 10 + val messageIdsLookupLimit: Int = 60 * 30 * 1_000 val codecResponseTimeout: Int = 6_000 val codecPendingBatchLimit: Int = 16 @@ -177,6 +178,12 @@ class Configuration(customConfiguration: CustomConfigurationClass) { "10" ) + val messageIdsLookupLimit: Variable = Variable( + "messageIdsLookupLimit", + customConfiguration.messageIdsLookupLimit.toString(), + "1800000" + ) + val codecResponseTimeout: Variable = Variable( "codecResponseTimeout", customConfiguration.codecResponseTimeout.toString(), "6000" diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/requests/SseMessageSearchRequest.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/requests/SseMessageSearchRequest.kt index 6cd37081..4f200ad1 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/requests/SseMessageSearchRequest.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/requests/SseMessageSearchRequest.kt @@ -39,7 +39,7 @@ data class SseMessageSearchRequest( val endTimestamp: Instant?, val resultCountLimit: Int?, val attachedEvents: Boolean, - val lookupLimitDays: Int?, + val lookupLimit: Long?, val resumeFromIdsList: List, val includeProtocols: List?, val excludeProtocols: List?, @@ -70,7 +70,7 @@ data class SseMessageSearchRequest( resultCountLimit = parameters["resultCountLimit"]?.firstOrNull()?.toInt(), attachedEvents = parameters["attachedEvents"]?.firstOrNull()?.toBoolean() ?: false, - lookupLimitDays = parameters["lookupLimitDays"]?.firstOrNull()?.toInt(), + lookupLimit = parameters["lookupLimitDays"]?.firstOrNull()?.toLong()?.run { this * 24 * 60 * 60 * 1_000 }, includeProtocols = parameters["includeProtocols"], excludeProtocols = parameters["excludeProtocols"], @@ -127,7 +127,7 @@ data class SseMessageSearchRequest( attachedEvents = false, - lookupLimitDays = null, + lookupLimit = null, includeProtocols = null, @@ -165,13 +165,19 @@ data class SseMessageSearchRequest( } private fun checkLookupLimitDays() { - if (lookupLimitDays != null && endTimestamp != null) { + if (lookupLimit != null && endTimestamp != null) { throw InvalidRequestException( - "endTimestamp: $endTimestamp must be null if lookupLimitDays: $lookupLimitDays isn't null" + "endTimestamp: $endTimestamp must be null if lookupLimit: $lookupLimit isn't null" ) } } + private fun checkNoEndTimestamp() { + if (endTimestamp != null) { + throw InvalidRequestException("endTimestamp: $endTimestamp must be null") + } + } + private fun checkStartPoint() { if (startTimestamp == null && resumeFromIdsList.isEmpty()) throw InvalidRequestException("One of the 'startTimestamp' or 'messageId' must not be null") @@ -211,7 +217,7 @@ data class SseMessageSearchRequest( fun checkIdsRequest() { checkStartPoint() - checkEndTimestamp() + checkNoEndTimestamp() checkStreamList() checkTimestampAndId() checkLookupLimitDays() diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchMessagesHandler.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchMessagesHandler.kt index 222e959d..799452ba 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchMessagesHandler.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchMessagesHandler.kt @@ -127,7 +127,10 @@ abstract class SearchMessagesHandler( } } - suspend fun getIds(request: SseMessageSearchRequest): Map> { + suspend fun getIds(request: SseMessageSearchRequest, lookupLimit: Long): Map> { + require(request.startTimestamp != null && request.endTimestamp == null) { + "startTimestamp must be not null and endTimestamp be null in request: $request" + } searchMessageRequests.inc() val resumeId = request.resumeFromIdsList.firstOrNull() val messageId = resumeId?.let { @@ -143,8 +146,8 @@ abstract class SearchMessagesHandler( request.copy(startTimestamp = resumeId.timestamp) } ?: request - val before = getIds(resultRequest, messageId, TimeRelation.BEFORE) - val after = getIds(resultRequest, messageId, TimeRelation.AFTER) + val before = getIds(resultRequest, messageId, lookupLimit, TimeRelation.BEFORE) + val after = getIds(resultRequest, messageId, lookupLimit, TimeRelation.AFTER) return mapOf( TimeRelationMapper.toHttp(TimeRelation.BEFORE) to before, @@ -161,9 +164,13 @@ abstract class SearchMessagesHandler( private suspend fun getIds( request: SseMessageSearchRequest, messageId: StoredMessageId?, + lookupLimit: Long, searchDirection: TimeRelation ): MutableList { - val resultRequest = request.copy(searchDirection = searchDirection) + val resultRequest = request.copy( + searchDirection = searchDirection, + lookupLimit = request.lookupLimit ?: lookupLimit + ) val pipelineStatus = PipelineStatus() diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt index 4c51f3fd..bd06fb43 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt @@ -42,7 +42,6 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import java.time.Instant -import java.time.temporal.ChronoUnit class MessageExtractor( @@ -184,25 +183,15 @@ class MessageExtractor( startTimestamp?.let { builder.timestampFrom().isGreaterThanOrEqualTo(it) } endTimestamp?.let { builder.timestampTo().isLessThan(it) } - if (startTimestamp != null && - endTimestamp == null && - lookupLimitDays != null - ) { - builder.timestampTo().isLessThan( - startTimestamp.plus(lookupLimitDays.toLong(), ChronoUnit.DAYS) - ) + if (startTimestamp != null && endTimestamp == null && lookupLimit != null) { + builder.timestampTo().isLessThan(startTimestamp.plusMillis(lookupLimit)) } } else { startTimestamp?.let { builder.timestampTo().isLessThanOrEqualTo(it) } endTimestamp?.let { builder.timestampFrom().isGreaterThan(it) } - if (startTimestamp != null && - endTimestamp == null && - lookupLimitDays != null - ) { - builder.timestampFrom().isGreaterThan( - startTimestamp.minus(lookupLimitDays.toLong(), ChronoUnit.DAYS) - ) + if (startTimestamp != null && endTimestamp == null && lookupLimit != null) { + builder.timestampFrom().isGreaterThan(startTimestamp.minusMillis(lookupLimit)) } } } diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/HttpServer.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/HttpServer.kt index a635e1e2..7891dcfa 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/HttpServer.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/HttpServer.kt @@ -445,7 +445,7 @@ class HttpServer( queryParametersMap, messageFiltersPredicateFactory.getEmptyPredicate(), ).also(SseMessageSearchRequest<*, *>::checkIdsRequest) - searchMessagesHandler.getIds(request) + searchMessagesHandler.getIds(request, configuration.messageIdsLookupLimit.value.toLong()) } } From 3be9d9986b18ce163ecca732e30a2ee9ddde739f Mon Sep 17 00:00:00 2001 From: "nikita.smirnov" Date: Thu, 29 Aug 2024 11:20:41 +0400 Subject: [PATCH 4/5] [TH2-5234] Corrected after review --- README.md | 4 ++- .../entities/configuration/Configuration.kt | 10 +++---- .../requests/SseMessageSearchRequest.kt | 23 +++------------ .../handlers/SearchMessagesHandler.kt | 29 ++++++++++++------- .../handlers/messages/MessageExtractor.kt | 22 ++++---------- .../th2/rptdataprovider/server/HttpServer.kt | 6 ++-- 6 files changed, 40 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index bdde59b7..aef00ad8 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,8 @@ spec: messageUnpackerOutputMessageBuffer: 100 messageFilterOutputMessageBuffer: 100 messageMergerOutputMessageBuffer: 10 + + messageIdsLookupLimitDays: 7 // lookup limit value for seacing next and previous message ids. codecPendingBatchLimit: 16 // the total number of messages sent to the codec batches in parallel for all pipelines codecCallbackThreadPool: 4 // thread pool for parsing messages received from codecs @@ -296,7 +298,7 @@ spec: # Release notes ## 5.13.0 -* Provided ability to limit `messageIds` request by `lookupLimitDays` argument or `messageIdsLookupLimit` option +* Provided ability to limit `messageIds` request by `lookupLimitDays` argument or `messageIdsLookupLimitDays` option * Updated: * th2 gradle plugin: `0.1.1` * common: `5.14.0-dev` diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Configuration.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Configuration.kt index d4d88831..5be9bd2a 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Configuration.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/configuration/Configuration.kt @@ -48,7 +48,7 @@ class CustomConfigurationClass { val messageUnpackerOutputMessageBuffer: Int = 100 val messageFilterOutputMessageBuffer: Int = 100 val messageMergerOutputMessageBuffer: Int = 10 - val messageIdsLookupLimit: Int = 60 * 30 * 1_000 + val messageIdsLookupLimitDays: Int = 7 val codecResponseTimeout: Int = 6_000 val codecPendingBatchLimit: Int = 16 @@ -178,10 +178,10 @@ class Configuration(customConfiguration: CustomConfigurationClass) { "10" ) - val messageIdsLookupLimit: Variable = Variable( - "messageIdsLookupLimit", - customConfiguration.messageIdsLookupLimit.toString(), - "1800000" + val messageIdsLookupLimitDays: Variable = Variable( + "messageIdsLookupLimitDays", + customConfiguration.messageIdsLookupLimitDays.toString(), + "7" ) val codecResponseTimeout: Variable = Variable( diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/requests/SseMessageSearchRequest.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/requests/SseMessageSearchRequest.kt index 4f200ad1..5ae2fb82 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/requests/SseMessageSearchRequest.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/entities/requests/SseMessageSearchRequest.kt @@ -39,7 +39,7 @@ data class SseMessageSearchRequest( val endTimestamp: Instant?, val resultCountLimit: Int?, val attachedEvents: Boolean, - val lookupLimit: Long?, + val lookupLimitDays: Long?, val resumeFromIdsList: List, val includeProtocols: List?, val excludeProtocols: List?, @@ -70,7 +70,7 @@ data class SseMessageSearchRequest( resultCountLimit = parameters["resultCountLimit"]?.firstOrNull()?.toInt(), attachedEvents = parameters["attachedEvents"]?.firstOrNull()?.toBoolean() ?: false, - lookupLimit = parameters["lookupLimitDays"]?.firstOrNull()?.toLong()?.run { this * 24 * 60 * 60 * 1_000 }, + lookupLimitDays = parameters["lookupLimitDays"]?.firstOrNull()?.toLong(), includeProtocols = parameters["includeProtocols"], excludeProtocols = parameters["excludeProtocols"], @@ -127,7 +127,7 @@ data class SseMessageSearchRequest( attachedEvents = false, - lookupLimit = null, + lookupLimitDays = null, includeProtocols = null, @@ -164,20 +164,6 @@ data class SseMessageSearchRequest( } } - private fun checkLookupLimitDays() { - if (lookupLimit != null && endTimestamp != null) { - throw InvalidRequestException( - "endTimestamp: $endTimestamp must be null if lookupLimit: $lookupLimit isn't null" - ) - } - } - - private fun checkNoEndTimestamp() { - if (endTimestamp != null) { - throw InvalidRequestException("endTimestamp: $endTimestamp must be null") - } - } - private fun checkStartPoint() { if (startTimestamp == null && resumeFromIdsList.isEmpty()) throw InvalidRequestException("One of the 'startTimestamp' or 'messageId' must not be null") @@ -217,10 +203,9 @@ data class SseMessageSearchRequest( fun checkIdsRequest() { checkStartPoint() - checkNoEndTimestamp() + checkEndTimestamp() checkStreamList() checkTimestampAndId() - checkLookupLimitDays() checkResumeIds() } diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchMessagesHandler.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchMessagesHandler.kt index 799452ba..9a15bff1 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchMessagesHandler.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/SearchMessagesHandler.kt @@ -18,6 +18,8 @@ package com.exactpro.th2.rptdataprovider.handlers import com.exactpro.cradle.Direction import com.exactpro.cradle.TimeRelation +import com.exactpro.cradle.TimeRelation.AFTER +import com.exactpro.cradle.TimeRelation.BEFORE import com.exactpro.cradle.messages.StoredMessageId import com.exactpro.th2.common.grpc.Message import com.exactpro.th2.common.grpc.MessageGroupBatch @@ -54,6 +56,7 @@ import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.onCompletion import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.withContext +import java.time.temporal.ChronoUnit.DAYS import java.util.concurrent.atomic.AtomicLong import kotlin.coroutines.coroutineContext import kotlin.math.roundToInt @@ -127,7 +130,7 @@ abstract class SearchMessagesHandler( } } - suspend fun getIds(request: SseMessageSearchRequest, lookupLimit: Long): Map> { + suspend fun getIds(request: SseMessageSearchRequest, lookupLimitDays: Long): Map> { require(request.startTimestamp != null && request.endTimestamp == null) { "startTimestamp must be not null and endTimestamp be null in request: $request" } @@ -146,12 +149,12 @@ abstract class SearchMessagesHandler( request.copy(startTimestamp = resumeId.timestamp) } ?: request - val before = getIds(resultRequest, messageId, lookupLimit, TimeRelation.BEFORE) - val after = getIds(resultRequest, messageId, lookupLimit, TimeRelation.AFTER) + val before = getIds(resultRequest, messageId, lookupLimitDays, BEFORE) + val after = getIds(resultRequest, messageId, lookupLimitDays, AFTER) return mapOf( - TimeRelationMapper.toHttp(TimeRelation.BEFORE) to before, - TimeRelationMapper.toHttp(TimeRelation.AFTER) to after, + TimeRelationMapper.toHttp(BEFORE) to before, + TimeRelationMapper.toHttp(AFTER) to after, ) } @@ -164,13 +167,19 @@ abstract class SearchMessagesHandler( private suspend fun getIds( request: SseMessageSearchRequest, messageId: StoredMessageId?, - lookupLimit: Long, + lookupLimitDays: Long, searchDirection: TimeRelation ): MutableList { - val resultRequest = request.copy( - searchDirection = searchDirection, - lookupLimit = request.lookupLimit ?: lookupLimit - ) + val lookupLimit = request.lookupLimitDays ?: lookupLimitDays + val resultRequest = request.run { + copy( + searchDirection = searchDirection, + endTimestamp = when (searchDirection) { + BEFORE -> startTimestamp?.minus(lookupLimit, DAYS) + AFTER -> startTimestamp?.plus(lookupLimit, DAYS) + } + ).also(SseMessageSearchRequest<*, *>::checkIdsRequest) + } val pipelineStatus = PipelineStatus() diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt index bd06fb43..bc067cf8 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/handlers/messages/MessageExtractor.kt @@ -178,22 +178,12 @@ class MessageExtractor( } } // always need to make sure that we send messages within the specified timestamp (in case the resume ID points to the past) - with(request) { - if (order == Order.DIRECT) { - startTimestamp?.let { builder.timestampFrom().isGreaterThanOrEqualTo(it) } - endTimestamp?.let { builder.timestampTo().isLessThan(it) } - - if (startTimestamp != null && endTimestamp == null && lookupLimit != null) { - builder.timestampTo().isLessThan(startTimestamp.plusMillis(lookupLimit)) - } - } else { - startTimestamp?.let { builder.timestampTo().isLessThanOrEqualTo(it) } - endTimestamp?.let { builder.timestampFrom().isGreaterThan(it) } - - if (startTimestamp != null && endTimestamp == null && lookupLimit != null) { - builder.timestampFrom().isGreaterThan(startTimestamp.minusMillis(lookupLimit)) - } - } + if (order == Order.DIRECT) { + request.startTimestamp?.let { builder.timestampFrom().isGreaterThanOrEqualTo(it) } + request.endTimestamp?.let { builder.timestampTo().isLessThan(it) } + } else { + request.startTimestamp?.let { builder.timestampTo().isLessThanOrEqualTo(it) } + request.endTimestamp?.let { builder.timestampFrom().isGreaterThan(it) } } }.build() ) diff --git a/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/HttpServer.kt b/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/HttpServer.kt index 7891dcfa..a7199188 100644 --- a/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/HttpServer.kt +++ b/src/main/kotlin/com/exactpro/th2/rptdataprovider/server/HttpServer.kt @@ -445,19 +445,19 @@ class HttpServer( queryParametersMap, messageFiltersPredicateFactory.getEmptyPredicate(), ).also(SseMessageSearchRequest<*, *>::checkIdsRequest) - searchMessagesHandler.getIds(request, configuration.messageIdsLookupLimit.value.toLong()) + searchMessagesHandler.getIds(request, configuration.messageIdsLookupLimitDays.value.toLong()) } } get("/bookIds") { - handleRequest(call, context, "book ids", null, false, false) { + handleRequest(call, context, "book ids", null, probe = false, useSse = false) { cradleService.getBookIds() } } get("/scopeIds") { val book = call.parameters["bookId"]!! - handleRequest(call, context, "event scopes", null, false, false) { + handleRequest(call, context, "event scopes", null, probe = false, useSse = false) { cradleService.getEventScopes(BookId(book)) } } From f6a102f6e5b30d086d7e8a95723506480fbe849c Mon Sep 17 00:00:00 2001 From: "nikita.smirnov" Date: Thu, 29 Aug 2024 12:21:20 +0400 Subject: [PATCH 5/5] [TH2-5234] Removed environment variables --- Dockerfile | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 028fdbfb..bc49c84e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,15 +4,6 @@ COPY ./ . RUN gradle clean build dockerPrepare -Prelease_version=${Prelease_version} FROM adoptopenjdk/openjdk11:alpine -ENV CRADLE_INSTANCE_NAME=instance1 \ - CASSANDRA_DATA_CENTER=kos \ - CASSANDRA_HOST=cassandra \ - CASSANDRA_PORT=9042 \ - CASSANDRA_KEYSPACE=demo \ - CASSANDRA_USERNAME=guest \ - CASSANDRA_PASSWORD=guest \ - HTTP_PORT=8080 \ - HTTP_HOST=localhost WORKDIR /home COPY --from=build /home/gradle/build/docker . ENTRYPOINT ["/home/service/bin/service", "run", "com.exactpro.th2.rptdataprovider.MainKt"]