Skip to content

Commit

Permalink
Merge branch 'TH2-5015' into 'master'
Browse files Browse the repository at this point in the history
[TH2-5015] Migrated to the cradle version where auto-page feature doesn't...

See merge request vivarium/th2/th2-core-proprietary/th2-cradle-admin-tool!24
  • Loading branch information
Nikita-Smirnov-Exactpro committed Sep 21, 2023
2 parents c55b509 + c3a9953 commit c7d0502
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 23 deletions.
13 changes: 5 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions cradle-admin-tool-cli/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

dependencies {

implementation project(':')
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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));
Expand Down
17 changes: 16 additions & 1 deletion cradle-admin-tool-http/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -120,4 +121,4 @@ public void run() {
}
});
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version = 1.7.1
release_version = 1.7.2

0 comments on commit c7d0502

Please sign in to comment.