From c3a9953c4c97dd845c48b23399471ab5df0f7eb5 Mon Sep 17 00:00:00 2001 From: "nikita.smirnov" Date: Thu, 21 Sep 2023 08:58:09 +0000 Subject: [PATCH] [TH2-5015] Migrated to the cradle version where auto-page feature doesn't... --- build.gradle | 13 +++++-------- cradle-admin-tool-cli/build.gradle | 4 ++-- .../th2/cradle/adm/cli/Application.java | 10 ++++------ cradle-admin-tool-http/README.md | 17 ++++++++++++++++- .../th2/cradle/adm/http/PageManager.java | 11 ++++++----- gradle.properties | 2 +- 6 files changed, 34 insertions(+), 23 deletions(-) diff --git a/build.gradle b/build.gradle index d12f2f6..33e0ca1 100644 --- a/build.gradle +++ b/build.gradle @@ -12,8 +12,8 @@ apply plugin: 'application' ext { - commonVersion = '5.2.1-dev' - cradleVersion = '5.0.3-dev' + commonVersion = '5.4.2-dev' + cradleVersion = '5.1.4-dev' } allprojects { @@ -43,20 +43,17 @@ allprojects { } } - configurations { - implementation.exclude group: 'com.google.guava', module: 'guava' - } - dependencies { + implementation(platform("com.exactpro.th2:bom:4.5.0")) implementation("com.exactpro.th2:common:$commonVersion") { exclude group: 'com.squareup.okhttp3', module: 'okhttp' } - implementation(platform("com.exactpro.th2:bom:4.4.0")) implementation "com.exactpro.th2:cradle-core:$cradleVersion" implementation "com.exactpro.th2:cradle-cassandra:$cradleVersion" implementation 'org.apache.commons:commons-lang3:3.12.0' - implementation 'org.apache.logging.log4j:log4j-1.2-api:2.14.1' + + implementation "org.slf4j:slf4j-api" testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.2' diff --git a/cradle-admin-tool-cli/build.gradle b/cradle-admin-tool-cli/build.gradle index 52d9c1d..680343d 100644 --- a/cradle-admin-tool-cli/build.gradle +++ b/cradle-admin-tool-cli/build.gradle @@ -1,4 +1,3 @@ - dependencies { implementation project(':') @@ -30,7 +29,8 @@ jar { mainClassName = 'com.exactpro.th2.cradle.adm.cli.Application' -task release(type: Zip, dependsOn: jar) { +tasks.register('release', Zip) { + dependsOn jar archiveFileName = "th2-cradle-admin-cli-${project.version}.zip" from(configurations.runtimeClasspath) { into "lib" diff --git a/cradle-admin-tool-cli/src/main/java/com/exactpro/th2/cradle/adm/cli/Application.java b/cradle-admin-tool-cli/src/main/java/com/exactpro/th2/cradle/adm/cli/Application.java index 6851db6..5cc62c2 100644 --- a/cradle-admin-tool-cli/src/main/java/com/exactpro/th2/cradle/adm/cli/Application.java +++ b/cradle-admin-tool-cli/src/main/java/com/exactpro/th2/cradle/adm/cli/Application.java @@ -1,5 +1,5 @@ -/******************************************************************************* - * Copyright 2021-2021 Exactpro (Exactpro Systems Limited) +/* + * Copyright 2021-2023 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.cradle.adm.cli; @@ -29,7 +29,6 @@ import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; -import org.apache.log4j.PropertyConfigurator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -80,7 +79,7 @@ public static void main(String[] args) throws Exception { } } catch (Exception e) { - logger.error("Exception {}", e); + logger.error("Cannot start application, cause {}", e.getMessage(), e); printHelp(options); } } @@ -106,7 +105,6 @@ private static void printHelp(Options options) { private static void initApplication(String[] args) { - PropertyConfigurator.configureAndWatch("log.properties"); initMetadata(); System.out.printf("%s, version %s, build-date %s%n", IMPLEMENTATION_TITLE, VERSION, BUILD_DATE); System.out.println("Started with arguments: " + Arrays.toString(args)); diff --git a/cradle-admin-tool-http/README.md b/cradle-admin-tool-http/README.md index ee5b8e5..7cd2a60 100644 --- a/cradle-admin-tool-http/README.md +++ b/cradle-admin-tool-http/README.md @@ -1,4 +1,4 @@ -# cradle-admin-tool-http (1.7.0) +# cradle-admin-tool-http (1.7.2) Service which allows user to manage books/pages via RestAPI requests. - The first page in a book can be created only if start time is more than current time. - After the first page all new pages must have start time more than current time + `bookRefreshIntervalMillis` * 2 @@ -44,6 +44,21 @@ spec: ## Release notes +### 1.7.2 + ++ Bug fix: + + Migrated to the cradle version where auto-page feature doesn't produce cassandra tombstone. + ++ Updated: + + Cradle API to `5.1.4-dev` + + bom to `4.5.0` + + common to `5.4.2-dev` + +### 1.7.1 + ++ Vulnerability fix: + + Excluded the `com.squareup.okhttp3:okhttp` dependency + ### 1.7.0 + Feature: diff --git a/cradle-admin-tool-http/src/main/java/com/exactpro/th2/cradle/adm/http/PageManager.java b/cradle-admin-tool-http/src/main/java/com/exactpro/th2/cradle/adm/http/PageManager.java index e0a0f6a..900f387 100644 --- a/cradle-admin-tool-http/src/main/java/com/exactpro/th2/cradle/adm/http/PageManager.java +++ b/cradle-admin-tool-http/src/main/java/com/exactpro/th2/cradle/adm/http/PageManager.java @@ -35,6 +35,7 @@ public class PageManager implements AutoCloseable, Runnable{ private static final Logger logger = LoggerFactory.getLogger(Application.class); + private static final String AUTO_PAGE_COMMENT = "auto-page"; private final CradleStorage storage; private final long pageActionRejectionThreshold; @@ -79,20 +80,20 @@ private BookInfo checkBook(BookInfo book, AutoPageConfiguration autoPageConfigur PageInfo pageInfo = book.getLastPage(); if (pageInfo == null) { - return storage.addPage(book.getId(), "auto-page-" + nowMillis, nowPlusThreshold, null); + return storage.addPage(book.getId(), "auto-page-" + nowMillis, nowPlusThreshold, AUTO_PAGE_COMMENT); } Instant lastPageStart = pageInfo.getStarted(); if (lastPageStart.isBefore(nowPlusThreshold)) { int comparison = nowPlusThreshold.compareTo(pageStartBase); if (comparison < 0) { - return storage.addPage(book.getId(), "auto-page-" + nowMillis, pageStartBase, null); + return storage.addPage(book.getId(), "auto-page-" + nowMillis, pageStartBase, AUTO_PAGE_COMMENT); } else if (comparison > 0) { Duration diff = Duration.between(pageStartBase, nowPlusThreshold); Instant nextMark = pageStartBase.plus(pageDuration.multipliedBy(diff.dividedBy(pageDuration) + 1)); - return storage.addPage(book.getId(), "auto-page-" + nowMillis, nextMark, null); + return storage.addPage(book.getId(), "auto-page-" + nowMillis, nextMark, AUTO_PAGE_COMMENT); } else { - return storage.addPage(book.getId(), "auto-page-" + nowMillis, pageStartBase.plus(pageDuration), null); + return storage.addPage(book.getId(), "auto-page-" + nowMillis, pageStartBase.plus(pageDuration), AUTO_PAGE_COMMENT); } } @@ -120,4 +121,4 @@ public void run() { } }); } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 1742301..6e46a89 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -release_version = 1.7.1 +release_version = 1.7.2