Skip to content

Commit 2ddfe7b

Browse files
Nikita-Smirnov-ExactproOleg Smirnov
andauthored
[th2-5267] Shutdown processor thread in MessagePersistor.close method (#125)
* Publish artifact to sonatype for reusing in other projects * Split ErrorCollector to interface and implementation * Updated th2 gradle plugin 0.2.4 * Added testDrainTaskParameters --------- Co-authored-by: Oleg Smirnov <oleg.smirnov@exactprosystems.com>
1 parent 55ed975 commit 2ddfe7b

File tree

16 files changed

+315
-196
lines changed

16 files changed

+315
-196
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ updates:
99
- dependencies
1010
schedule:
1111
interval: daily
12-
allow:
13-
- dependency-name: '*'
14-
dependency-type: production
1512
- package-ecosystem: github-actions
1613
directory: /
1714
reviewers:

.github/workflows/build-dev-release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ jobs:
66
build:
77
uses: th2-net/.github/.github/workflows/compound-java.yml@main
88
with:
9-
build-target: 'Docker'
9+
build-target: 'Docker,Sonatype'
1010
devRelease: true
1111
createTag: true
1212
docker-username: ${{ github.actor }}
1313
secrets:
1414
docker-password: ${{ secrets.GITHUB_TOKEN }}
15+
sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
16+
sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
17+
sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }}
18+
sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
1519
nvd-api-key: ${{ secrets.NVD_APIKEY }}
1620
cisa-domain: ${{ secrets.CISA_DOMAIN }}
1721
cisa-user: ${{ secrets.CISA_USER }}

.github/workflows/build-release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ jobs:
66
build:
77
uses: th2-net/.github/.github/workflows/compound-java.yml@main
88
with:
9-
build-target: 'Docker'
9+
build-target: 'Docker,Sonatype'
1010
devRelease: false
1111
createTag: true
1212
docker-username: ${{ github.actor }}
1313
secrets:
1414
docker-password: ${{ secrets.GITHUB_TOKEN }}
15+
sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
16+
sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
17+
sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }}
18+
sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
1519
nvd-api-key: ${{ secrets.NVD_APIKEY }}
1620
cisa-domain: ${{ secrets.CISA_DOMAIN }}
1721
cisa-user: ${{ secrets.CISA_USER }}

.github/workflows/build-sanpshot.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ jobs:
1212
build-job:
1313
uses: th2-net/.github/.github/workflows/compound-java-dev.yml@main
1414
with:
15-
build-target: 'Docker'
15+
build-target: 'Docker,Sonatype'
1616
docker-username: ${{ github.actor }}
1717
secrets:
1818
docker-password: ${{ secrets.GITHUB_TOKEN }}
19+
sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
20+
sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
21+
sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }}
22+
sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
1923
nvd-api-key: ${{ secrets.NVD_APIKEY }}
2024
cisa-domain: ${{ secrets.CISA_DOMAIN }}
2125
cisa-user: ${{ secrets.CISA_USER }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM gradle:8.11.1-jdk11 AS build
1+
FROM gradle:8.11.1-jdk21 AS build
22
ARG release_version
33
COPY ./ .
44
RUN gradle --no-daemon clean build dockerPrepare -Prelease_version=${release_version}

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Overview (5.9.0)
1+
# Overview (5.10.0)
22

33
Message store (mstore) is an important th2 component responsible for storing raw messages into Cradle. Please refer to [Cradle repository] (https://github.com/th2-net/cradleapi/blob/master/README.md) for more details. This component has a pin for listening messages via MQ.
44

@@ -45,7 +45,7 @@ book, session alias, direction and sequence number are a **compound unique ident
4545
"drain-interval" : 100,
4646
"prefetchRatioToDrain" : 0.8,
4747
"maxBatchSize" : 200000,
48-
48+
"persisotr-termination-timeout" : 1000,
4949
"termination-timeout" : 1000
5050
}
5151
```
@@ -59,6 +59,7 @@ book, session alias, direction and sequence number are a **compound unique ident
5959
+ _prefetchRatioToDrain_ - Threshold ratio of fetched messages to RabbitMQ prefetch size to force aggregated batch draining.
6060
+ _maxBatchSize_ - Maximum aggregated batch size in case of re-batching
6161
+ _termination-timeout_ - Timeout in milliseconds to await for the inner drain scheduler to finish all the tasks. The default value is 5000.
62+
+ _persisotr-termination-timeout_ - The timeout in milliseconds to await for the persisotr thread complete. The default value is 5000.
6263

6364
If some of these parameters are not provided, mstore will use default(undocumented) value.
6465
If _maxTaskCount_ or _maxTaskDataSize_ limits are reached during processing, mstore will pause processing new messages
@@ -89,6 +90,7 @@ spec:
8990
prefetchRatioToDrain: 0.8
9091
maxBatchSize: 200000
9192
termination-timeout: 5000
93+
persisotr-termination-timeout: 5000
9294
pins:
9395
mq:
9496
subscribers:
@@ -117,9 +119,13 @@ Please see more details about this feature via [link](https://github.com/th2-net
117119
118120
# Release notes
119121
120-
## next release
121-
* Updated:
122-
* th2 gradle plugin `0.2.3` based on bom: `4.11.0`
122+
## 5.10.0
123+
* Publish mstore as moven artifact.
124+
* Prepared MessagePersistor class for using in other project.
125+
* Added `persisotr-termination-timeout` option
126+
* Updated
127+
* th2 gradle plugin `0.2.4` based on bom: `4.11.0`
128+
* task-utils: `0.1.3`
123129

124130
## 5.9.0
125131
* Updated

build.gradle

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
plugins {
22
id "application"
3-
id "com.exactpro.th2.gradle.component" version "0.2.4"
4-
}
5-
6-
ext {
7-
cradleVersion = '5.4.4-dev'
3+
id "maven-publish"
4+
alias(libs.plugins.th2.publish)
5+
alias(libs.plugins.th2.component)
86
}
97

108
group = 'com.exactpro.th2'
119
version = release_version
1210

13-
th2JavaRelease {
14-
targetJavaVersion.set(JavaVersion.VERSION_11)
15-
}
16-
1711
repositories {
1812
mavenCentral()
1913

@@ -38,11 +32,11 @@ javadoc {
3832
}
3933

4034
dependencies {
41-
implementation 'com.exactpro.th2:common:5.14.0-dev'
42-
implementation('com.exactpro.th2:common-utils:2.3.0-dev') {
35+
implementation(libs.th2.common)
36+
implementation(libs.th2.common.utils) {
4337
because("executor service utils is used")
4438
}
45-
implementation 'com.exactpro.th2:task-utils:0.1.3'
39+
implementation(libs.th2.task.utils)
4640

4741
implementation 'com.google.protobuf:protobuf-java-util'
4842

@@ -53,14 +47,14 @@ dependencies {
5347

5448
implementation 'io.netty:netty-buffer'
5549

56-
implementation "com.exactpro.th2:cradle-core:$cradleVersion"
57-
implementation "com.exactpro.th2:cradle-cassandra:$cradleVersion"
50+
implementation(libs.cradle.core)
51+
implementation(libs.cradle.cassandra)
5852

5953
implementation 'org.apache.commons:commons-lang3'
6054

6155
implementation "org.slf4j:slf4j-api"
62-
testImplementation 'org.junit.jupiter:junit-jupiter:5.12.0'
63-
testImplementation 'org.mockito:mockito-junit-jupiter:5.16.0'
56+
testImplementation(libs.junit.jupiter)
57+
testImplementation(libs.mockito.junit.jupiter)
6458
testRuntimeOnly('org.junit.platform:junit-platform-launcher') {
6559
because 'This artifact will not be added automatically since gradle 9.0. You can read more information here:' +
6660
'https://docs.gradle.org/8.3/userguide/upgrading_version_8.html#test_framework_implementation_dependencies'

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
release_version=5.9.0
1+
release_version=5.10.0
22
description='th2 mstore component'
33
vcs_url=https://github.com/th2-net/th2-mstore

gradle/libs.versions.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[versions]
2+
th2-plugin = "0.2.4"
3+
cradle = "5.4.4-dev"
4+
5+
[libraries]
6+
th2-common-utils = { group = "com.exactpro.th2", name = "common-utils", version = "2.3.0-dev" }
7+
th2-common = { group = "com.exactpro.th2", name = "common", version = "5.14.0-dev" }
8+
th2-task-utils = { group = "com.exactpro.th2", name = "task-utils", version = "0.1.3" }
9+
10+
cradle-core = { group = "com.exactpro.th2", name = "cradle-core", version.ref = "cradle" }
11+
cradle-cassandra = { group = "com.exactpro.th2", name = "cradle-cassandra", version.ref = "cradle" }
12+
13+
junit-jupiter = { group = "org.junit.jupiter", name = "junit-jupiter", version = "5.12.0" }
14+
mockito-junit-jupiter = { group = "org.mockito", name = "mockito-junit-jupiter", version = "5.16.0" }
15+
16+
[plugins]
17+
th2-publish = { id = "com.exactpro.th2.gradle.publish", version.ref = "th2-plugin" }
18+
th2-component = { id = "com.exactpro.th2.gradle.component", version.ref = "th2-plugin" }

src/main/java/com/exactpro/th2/mstore/Configuration.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2022 Exactpro (Exactpro Systems Limited)
2+
* Copyright 2020-2025 Exactpro (Exactpro Systems Limited)
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
55
* You may obtain a copy of the License at
@@ -24,6 +24,7 @@
2424
public class Configuration {
2525
private long drainInterval;
2626
private long terminationTimeout;
27+
private long persisotrTerminationTimeout;
2728
private int maxTaskCount;
2829
private long maxTaskDataSize;
2930
private int maxRetryCount;
@@ -49,6 +50,11 @@ public long getTerminationTimeout() {
4950
return terminationTimeout;
5051
}
5152

53+
@JsonProperty("persisotr-termination-timeout")
54+
public long getPersisotrTerminationTimeout() {
55+
return persisotrTerminationTimeout;
56+
}
57+
5258
public Long getMaxTaskDataSize() {
5359
return maxTaskDataSize;
5460
}
@@ -101,6 +107,10 @@ public static final class Builder {
101107
@JsonPropertyDescription("The timeout in milliseconds to await for the inner drain scheduler to finish all the tasks")
102108
private long terminationTimeout;
103109

110+
@JsonProperty("persisotr-termination-timeout")
111+
@JsonPropertyDescription("The timeout in milliseconds to await for the persisotr thread complete")
112+
private long persisotrTerminationTimeout;
113+
104114
@JsonProperty("maxTaskCount")
105115
private Integer maxTaskCount;
106116

@@ -126,6 +136,7 @@ public static final class Builder {
126136
private Builder() {
127137
drainInterval = DEFAULT_DRAIN_INTERVAL;
128138
terminationTimeout = DEFAULT_WAIT_TIMEOUT;
139+
persisotrTerminationTimeout = DEFAULT_WAIT_TIMEOUT;
129140
maxTaskDataSize = Runtime.getRuntime().totalMemory() / 2;
130141
maxTaskCount = DEFAULT_MAX_TASK_COUNT;
131142
maxRetryCount = DEFAULT_MAX_TASK_RETRIES;
@@ -146,6 +157,11 @@ public Builder withTerminationTimeout(long terminationTimeout) {
146157
return this;
147158
}
148159

160+
public Builder withPersisotrTerminationTimeout(long terminationTimeout) {
161+
this.persisotrTerminationTimeout = terminationTimeout;
162+
return this;
163+
}
164+
149165
public Builder withMaxTaskCount(Integer maxTaskCount) {
150166
this.maxTaskCount = maxTaskCount;
151167
return this;
@@ -186,6 +202,7 @@ public Configuration build() {
186202
Configuration configuration = new Configuration();
187203
configuration.drainInterval = drainInterval;
188204
configuration.terminationTimeout = terminationTimeout;
205+
configuration.persisotrTerminationTimeout = persisotrTerminationTimeout;
189206
configuration.maxRetryCount = this.maxRetryCount;
190207
configuration.maxTaskDataSize = this.maxTaskDataSize;
191208
configuration.retryDelayBase = this.retryDelayBase;

0 commit comments

Comments
 (0)