-
Couldn't load subscription status.
- Fork 15
Create UnArchive transformer #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
9464f9c
6205de2
a32f80b
1302e3d
6f8701e
d27c12c
0815a10
7f846fc
dc522f1
b7499eb
c679fa0
97929ba
705e7b0
4b7a5f0
27514a7
a091e6d
51d40e1
ff36b72
e61f5bc
2e0ace0
5ad147a
864b06e
7922c22
c4f46e9
0704396
9fcc778
10aa03e
239b8aa
dd0c492
a9278b1
1914893
3fe65e3
f31c3fe
9007776
b9923bd
1b18fe7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,3 +22,4 @@ | |
| hs_err_pid* | ||
| target | ||
| .okhttpcache | ||
| /.idea/ | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||||||||||||
| FROM maven:3-openjdk-8-slim AS BUILD_CONNECT_TRANSFORM_ARCHIVE_PLUGIN | ||||||||||||||||||
| WORKDIR /tmp | ||||||||||||||||||
| RUN apt-get update && apt-get install -y git | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DL3009: Delete the apt-get lists after installing something ℹ️ Learn about @sonatype-lift commandsYou can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
Note: When talking to LiftBot, you need to refresh the page to see its response. Was this a good recommendation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DL3015: Avoid additional packages by specifying ℹ️ Learn about @sonatype-lift commandsYou can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
Note: When talking to LiftBot, you need to refresh the page to see its response. Was this a good recommendation? |
||||||||||||||||||
| COPY . /tmp/kafka-connect-transform-archive | ||||||||||||||||||
| RUN cd kafka-connect-transform-archive && mvn package | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DL3003: Use WORKDIR to switch to a directory ℹ️ Learn about @sonatype-lift commandsYou can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
Note: When talking to LiftBot, you need to refresh the page to see its response. Was this a good recommendation? |
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,67 @@ | ||||||||||
| /** | ||||||||||
| * Copyright © 2022 Iosif Nicolae ([email protected]) | ||||||||||
| * | ||||||||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
| * you may not use this file except in compliance with the License. | ||||||||||
| * You may obtain a copy of the License at | ||||||||||
| * | ||||||||||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
| * | ||||||||||
| * Unless required by applicable law or agreed to in writing, software | ||||||||||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| * 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.github.jcustenborder.kafka.connect.archive; | ||||||||||
|
|
||||||||||
| import com.github.jcustenborder.kafka.connect.utils.config.Description; | ||||||||||
| import com.github.jcustenborder.kafka.connect.utils.config.DocumentationNote; | ||||||||||
| import org.apache.kafka.common.config.ConfigDef; | ||||||||||
| import org.apache.kafka.connect.connector.ConnectRecord; | ||||||||||
| import org.apache.kafka.connect.transforms.Transformation; | ||||||||||
|
|
||||||||||
| import java.util.Map; | ||||||||||
|
|
||||||||||
| import static org.apache.commons.lang3.SerializationUtils.deserialize; | ||||||||||
|
|
||||||||||
|
|
||||||||||
| @Description("The UnArchive transformation is used to unarchive data from S3 into the original format.") | ||||||||||
| @DocumentationNote("This transform works by copying the key, value, topic, and timestamp to new record where this is all " + | ||||||||||
| "contained in the value of the message. This will allow connectors like Confluent's S3 connector to properly unarchive " + | ||||||||||
| "the record.") | ||||||||||
| public class UnArchive<R extends ConnectRecord<R>> implements Transformation<R> { | ||||||||||
| @Override | ||||||||||
| public R apply(R r) { | ||||||||||
| return applySchemaless(r); | ||||||||||
| } | ||||||||||
| @SuppressWarnings("unchecked") | ||||||||||
| private R applySchemaless(R r) { | ||||||||||
| final Map<String, Object> value = (Map<String, Object>) r.value(); | ||||||||||
| return r.newRecord( | ||||||||||
| r.topic(), | ||||||||||
| value.get("partition") != null ? Integer.parseInt(value.get("partition").toString()) : null, | ||||||||||
| null, | ||||||||||
| deserialize((byte[]) value.get("key")), | ||||||||||
| null, | ||||||||||
| value.get("value"), | ||||||||||
| Long.parseLong(value.get("timestamp").toString()) | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NULL_DEREFERENCE: object returned by ℹ️ Learn about @sonatype-lift commandsYou can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
Note: When talking to LiftBot, you need to refresh the page to see its response. Was this a good recommendation? |
||||||||||
| ); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| @Override | ||||||||||
| public ConfigDef config() { | ||||||||||
| return new ConfigDef(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| @Override | ||||||||||
| public void close() { | ||||||||||
|
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| @Override | ||||||||||
| public void configure(Map<String, ?> map) { | ||||||||||
|
|
||||||||||
| } | ||||||||||
| } | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DL3008: Pin versions in apt get install. Instead of
apt-get install <package>useapt-get install <package>=<version>ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
@sonatype-lift ignore@sonatype-lift ignoreall@sonatype-lift exclude <file|issue|path|tool>file|issue|path|toolfrom Lift findings by updating your config.toml fileNote: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]