Skip to content

Commit

Permalink
[TH2-4918] th2 transport protocol support (#16)
Browse files Browse the repository at this point in the history
* [TH2-4987] Added gradle-git-properties plugin
* [TS-1512] Add parameter to disable type prefix
* [TH2-5051] Update common version with correct mapper settings
* [TH2-5082] Use dev release. Add support for event batching

---------

Co-authored-by: Oleg Smelov <[email protected]>
Co-authored-by: nikita.smirnov <[email protected]>
Co-authored-by: Oleg Smirnov <[email protected]>
  • Loading branch information
4 people authored Dec 6, 2023
1 parent 0e533c0 commit 316e824
Show file tree
Hide file tree
Showing 20 changed files with 905 additions and 334 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gradle:7.5.1-jdk11 AS build
FROM gradle:7.6-jdk11 AS build
ARG release_version
COPY ./ .
RUN gradle --no-daemon clean build dockerPrepare -Prelease_version=${release_version}
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AVRO codec (2.2.1)
# AVRO codec (2.3.0)
## Description
Designed for decode AVRO raw messages to parsed messages and encode back.
It is based on [th2-codec](https://github.com/th2-net/th2-codec).
Expand All @@ -15,7 +15,7 @@ The first byte of the AVRO header is always 0(MAGIC BYTE).
It is followed by four bytes which identify the AVRO schema to be used for decoding.
```text
[0],[][][][], [][][][]][][]...[]
schema id data
schema id data
```
### Schema resolution mode by session alias
Enabled when setting `sessionAliasToDictionaryAlias` is filled.
Expand Down Expand Up @@ -61,6 +61,7 @@ AVRO codec has the following parameters:

```yaml
enableIdPrefixEnumFields: false
enablePrefixEnumFieldsDecode: true
avroMessageIdToDictionaryAlias:
'1': "${dictionary_link:avro-schema-1-dictionary}"
'2': "${dictionary_link:avro-schema-2-dictionary}"
Expand All @@ -70,6 +71,10 @@ sessionAliasToDictionaryAlias:
'sessionGroup1Alias*': "${dictionary_link:avro-schema-2-dictionary}"
'???????Group2Alias*': "${dictionary_link:avro-schema-3-dictionary}"
```
**enablePrefixEnumFieldsDecode** - enables prefix before field name.
If disabled no type or ID prefix will be added before field name.
_NOTE: in this case the message decoded by codec cannot be encoded - encoding requires type or ID prefix_
**enableIdPrefixEnumFields** - prefix setting for UNION fields. If `false`, use prefix as `AVRO data type`(for example `Record-`, `Map-`), if `true` then use `schema id` prefix(for example `Id0-`, `Id3-`). The default value is `false`

**avroMessageIdToDictionaryAlias** - matching `schema id` pairs with its `alias` available for loading in the pipelineCodecContext.
Expand All @@ -80,6 +85,9 @@ Only one of settings `sessionAliasToDictionaryAlias` or `avroMessageIdToDictiona

## Release notes

### 2.3.0
+ TH2 transport protocol support

### 2.2.1
* Added detailed TRACE logging for parsing into class com.exactpro.th2.codec.MessageDatumReader

Expand Down
143 changes: 20 additions & 123 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,150 +1,47 @@
plugins {
id 'com.palantir.docker' version '0.25.0' apply false
id 'org.jetbrains.kotlin.jvm' version '1.6.21'
// for run ./gradlew jmh
id 'me.champeau.jmh' version '0.6.8'
id "org.owasp.dependencycheck" version "8.1.2"
}

apply plugin: 'application'
apply plugin: 'com.palantir.docker'
apply plugin: 'kotlin-kapt'

ext {
sailfishVersion = '3.3.54'
}
ext.excludeSailfish = { rcd ->
rcd.excludeModule("com.exactpro.sf", "sailfish-common")
rcd.excludeModule("com.exactpro.sf", "sailfish-rest-api-client")
}

group = 'com.exactpro.th2'
version = release_version

sourceCompatibility = 11
targetCompatibility = 11

repositories {
maven {
name 'Sonatype_snapshots'
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
metadataSources {
mavenPom()
artifact()
ignoreGradleMetadataRedirection()
buildscript {
repositories {
maven {
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
}
}
maven {
name 'Sonatype_releases'
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
content {
excludeSailfish(it)
}
}
maven {
name 'Sonatype_releases'
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
metadataSources {
mavenPom()
artifact()
ignoreGradleMetadataRedirection()
}
}
mavenCentral()

configurations.configureEach {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
dependencies {
classpath "com.exactpro.th2:th2-gradle-plugin:0.0.1-dev-5915772757-13a28ae-SNAPSHOT"
}
}

jar {
manifest {
attributes(
'Created-By': "${System.getProperty('java.version')} (${System.getProperty('java.vendor')})",
'Specification-Title': '',
'Specification-Vendor': 'Exactpro Systems LLC',
'Implementation-Title': project.archivesBaseName,
'Implementation-Vendor': 'Exactpro Systems LLC',
'Implementation-Vendor-Id': 'com.exactpro',
'Implementation-Version': project.version
)
}
plugins {
// for run ./gradlew jmh
id 'me.champeau.jmh' version '0.6.8'
}

configurations.implementation {
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
apply plugin: "com.exactpro.th2.common-conventions"
apply plugin: "com.exactpro.th2.docker-conventions"

apply plugin: 'kotlin-kapt'

dependencies {
api platform('com.exactpro.th2:bom:4.2.0')
api platform('com.exactpro.th2:bom:4.5.0')

implementation 'com.exactpro.th2:common:5.2.0-dev' //FIXME: migrate to release
implementation 'com.exactpro.th2:codec:5.2.0-dev'
implementation "com.exactpro.th2:common:5.4.2-dev"
implementation "com.exactpro.th2:common-utils:2.2.0-dev"
implementation "com.exactpro.th2:codec:5.4.0-dev"
implementation 'javax.xml.bind:jaxb-api:2.3.1'

implementation 'io.netty:netty-buffer'
implementation 'org.apache.avro:avro:1.11.1'
implementation 'commons-io:commons-io:2.12.0'

compileOnly 'com.google.auto.service:auto-service:1.0.1'

implementation 'org.slf4j:slf4j-api'

implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'io.github.microutils:kotlin-logging:3.0.0'

testImplementation "org.junit.jupiter:junit-jupiter:5.9.0"
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5:1.6.21'

kapt 'com.google.auto.service:auto-service:1.0.1'

jmh 'org.openjdk.jmh:jmh-core:1.36'
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.36'
jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.36'

implementation 'org.apache.avro:avro:1.11.1'
}

test {
useJUnitPlatform()
}

application {
mainClass.set('com.exactpro.th2.codec.MainKt')
}

applicationName = 'service'

distTar {
archiveFileName.set("${applicationName}.tar")
}

dockerPrepare {
dependsOn distTar
}

docker {
copySpec.from(tarTree("$buildDir/distributions/${applicationName}.tar"))
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "11"
}
}
jmh {
//profilers = ['stack'] // Use profilers to collect additional data. Supported profilers: [cl, comp, gc, stack, perf, perfnorm, perfasm, xperf, xperfasm, hs_cl, hs_comp, hs_gc, hs_rt, hs_thr, async]
}
dependencyLocking {
lockAllConfigurations()
}
dependencyCheck {
formats=['SARIF', 'JSON', 'HTML']
failBuildOnCVSS=5

analyzers {
assemblyEnabled = false
nugetconfEnabled = false
nodeEnabled = false
}
}
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
release_version=2.2.1
release_version=2.3.0
app_main_class=com.exactpro.th2.codec.MainKt
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 316e824

Please sign in to comment.