Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 39 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
# Csv codec (5.0.0)
# Csv codec (5.1.0)

## Description
Designed for decode csv raw messages from csv reader to the parsed messages.
It is based on [th2-codec](https://github.com/th2-net/th2-codec).
You can find additional information [here](https://github.com/th2-net/th2-codec/blob/master/README.md)

Designed for decode csv raw messages from csv reader to the parsed messages. It is based
on [th2-codec](https://github.com/th2-net/th2-codec). You can find additional
information [here](https://github.com/th2-net/th2-codec/blob/master/README.md)

## Decoding

The codec decodes each raw message in the received batch.
Each raw message might contain several line in CSV format.
If the default header parameter is not set the codec trites the first line from the raw message as a header.
Otherwise, the default header will be used for decoding the rest of data.
Output message type is taken from `th2.csv.override_message_type` property in input message.
If the property missing, the default value (`Csv_Message`) for output message type is used.
The codec decodes each raw message in the received batch. Each raw message might contain several line in CSV format. If
the default header parameter is not set the codec trites the first line from the raw message as a header. Otherwise, the
default header will be used for decoding the rest of data. Output message type is taken
from `th2.csv.override_message_type` property in input message. If the property missing, the default
value (`Csv_Message`) for output message type is used.

If no data was decoded from raw message, the message will be skipped, and an error event will be reported.

**NOTE: the encoding is not supported**.

## Decode Example

Simple example:
Simple example:

```text
A, B, V, G
Expand Down Expand Up @@ -52,31 +53,37 @@ into
{
"A": 1,
"B": 2,
"V": [3, 4, 5],
"V": [
3,
4,
5
],
"G": 6,
"D": 7
}
```

## Settings

Csv codec has the following parameters:

```yaml
default-header: [A, B, C]
default-header: [ A, B, C ]
delimiter: ','
encoding: UTF-8
display-name: CodecCsv
validate-length: true
publish-header: false
```

**default-header** - the default header for this codec. It will be used if no header found in the received batch.

**delimiter** - the delimiter to split values in received data. The default value is `,`.

**encoding** - the encoding for the received data. The default value is `UTF-8`.

**display-name** - the name to set in the root event sent to the event store. All errors during decoding will be attached to that root event.
The default value for the name is `CodecCsv`.
**display-name** - the name to set in the root event sent to the event store. All errors during decoding will be
attached to that root event. The default value for the name is `CodecCsv`.

**validate-length** - check if csv have different count of values against header's count.

Expand All @@ -94,7 +101,7 @@ spec:
image-version: 4.0.0
custom-config:
codecSettings:
default-header: [A, B, C]
default-header: [ A, B, C ]
delimiter: ','
encoding: UTF-8
pins:
Expand All @@ -108,29 +115,37 @@ spec:
# decoder
- name: in_codec_decode
connection-type: mq
attributes: ['decoder_in', 'raw', 'subscribe']
attributes: [ 'decoder_in', 'raw', 'subscribe' ]
- name: out_codec_decode
connection-type: mq
attributes: ['decoder_out', 'parsed', 'publish']
attributes: [ 'decoder_out', 'parsed', 'publish' ]
# encoder general (technical)
- name: in_codec_general_encode
connection-type: mq
attributes: ['general_encoder_in', 'parsed', 'subscribe']
attributes: [ 'general_encoder_in', 'parsed', 'subscribe' ]
- name: out_codec_general_encode
connection-type: mq
attributes: ['general_encoder_out', 'raw', 'publish']
attributes: [ 'general_encoder_out', 'raw', 'publish' ]
# decoder general (technical)
- name: in_codec_general_decode
connection-type: mq
attributes: ['general_decoder_in', 'raw', 'subscribe']
attributes: [ 'general_decoder_in', 'raw', 'subscribe' ]
- name: out_codec_general_decode
connection-type: mq
attributes: ['general_decoder_out', 'parsed', 'publish']
attributes: [ 'general_decoder_out', 'parsed', 'publish' ]
```

## Release notes

### 5.1.0

+ Supports th2 transport protocol
+ Updated bom:4.4.0
+ Updated common:5.3.0
+ Updated codec:5.3.0

### 5.0.0

+ Migrated to books&pages concept

### 4.1.0
Expand Down Expand Up @@ -168,7 +183,8 @@ spec:

+ reads dictionaries from the /var/th2/config/dictionary folder.
+ uses mq_router, grpc_router, cradle_manager optional JSON configs from the /var/th2/config folder
+ tries to load log4j.properties files from sources in order: '/var/th2/config', '/home/etc', configured path via cmd, default configuration
+ tries to load log4j.properties files from sources in order: '/var/th2/config', '/home/etc', configured path via cmd,
default configuration
+ update Cradle version. Introduce async API for storing events
+ removed gRPC event loop handling
+ fixed dictionary reading
121 changes: 25 additions & 96 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,109 +1,38 @@
plugins {
id 'java-library'
id 'application'
id 'com.palantir.docker' version '0.25.0'
id "org.owasp.dependencycheck" version "8.1.2"
}

dependencyCheck {
format='HTML'
}

ext {
sharedDir = file("${project.rootDir}/shared")
}

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

sourceCompatibility = 11
targetCompatibility = 11

repositories {
maven {
name 'MavenLocal'
url sharedDir
}
mavenCentral()

maven {
name 'Sonatype_snapshots'
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
}

maven {
name 'Sonatype_releases'
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}

mavenLocal()

configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
buildscript {
repositories {
gradlePluginPortal()
maven {
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
}
}
}

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
)
dependencies {
classpath "com.exactpro.th2:th2-gradle-plugin:0.0.1-dev-5915772757-13a28ae-SNAPSHOT"
}
}

dependencies {
api platform('com.exactpro.th2:bom:4.2.0')
implementation 'com.exactpro.th2:common:5.2.0-dev'
implementation 'com.exactpro.th2:codec:5.2.0-dev'

implementation "org.slf4j:slf4j-api"
apply plugin: "com.exactpro.th2.common-conventions"
apply plugin: "com.exactpro.th2.docker-conventions"

implementation 'net.sourceforge.javacsv:javacsv:2.0'
implementation 'org.jetbrains:annotations:23.0.0'
apply plugin: 'kotlin-kapt'

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

testImplementation 'org.mockito:mockito-core:3.5.15'
testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2'
}

test {
useJUnitPlatform()
}

application {
mainClassName 'com.exactpro.th2.codec.MainKt'
}
dependencies {
api platform("com.exactpro.th2:bom:4.5.0")
implementation "com.exactpro.th2:common:5.4.0-dev"
implementation "com.exactpro.th2:codec:5.3.0-new-proto-+"
implementation "com.exactpro.th2:common-utils:2.2.0-dev"

applicationName = 'service'
implementation "org.apache.commons:commons-lang3"
implementation "com.fasterxml.jackson.core:jackson-databind"

distTar {
archiveFileName.set("${applicationName}.tar")
}
implementation "net.sourceforge.javacsv:javacsv:2.0"

dockerPrepare {
dependsOn distTar
compileOnly "com.google.auto.service:auto-service-annotations:1.1.1"
annotationProcessor "com.google.auto.service:auto-service:1.1.1"
kapt "com.google.auto.service:auto-service:1.1.1"
}

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

dependencyCheck {
formats=['SARIF', 'JSON', 'HTML']
failBuildOnCVSS=5

analyzers {
assemblyEnabled = false
nugetconfEnabled = false
nodeEnabled = false
configurations {
compileClasspath {
resolutionStrategy.activateDependencyLocking()
}
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
release_version = 5.0.0

docker_image_name=
release_version=5.1.0
app_main_class=com.exactpro.th2.codec.MainKt
docker_image_name=
2 changes: 1 addition & 1 deletion src/main/java/com/exactpro/th2/codec/csv/CodecFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ public void init(@NotNull InputStream inputStream) {
@Override
public void close() {
}
}
}
Loading