You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/11/30 10:08:29 UTC

[GitHub] [inlong] yunqingmoswu opened a new pull request, #6688: [INLONG-6671][Sort] Supports dirty data side-output for kafka connector

yunqingmoswu opened a new pull request, #6688:
URL: https://github.com/apache/inlong/pull/6688

   ### Prepare a Pull Request
   *(Change the title refer to the following example)*
   
   - Title: [INLONG-6671][Sort] Supports dirty data side-output for kafka connector
   
   *(The following *XYZ* should be replaced by the actual [GitHub Issue](https://github.com/apache/inlong/issues) number)*
   
   - Fixes #6671
   
   ### Motivation
   
   Supports dirty data side-output for kafka connector.
   In this part:
   1. Load 'DirtySinkFactory' and create 'DirtySink' by the config
   2. It is needs to determine whether it is dirty data in the connector.
   3. Side output dirty data by the 'DirtySink' dependents on the configured, the built-in side-out of dirty data has 'LogDirtySink'(https://github.com/apache/inlong/pull/6618) and 'S3DirtySink'(https://github.com/apache/inlong/pull/6655).
   
   ### Modifications
   
   1. Create dirty sink and inject it for kafka source and kafka sink
   2. Add dirty handle for 'DynamicKafkaDeserializationSchema' and 'DynamicKafkaSerializationSchema'
   3. Add a unit test for this
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [x] This change is already covered by existing tests, such as:
     *(please describe tests)*
   
   - [ ] This change added tests and can be verified as follows:
   
     *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a follow-up issue for adding the documentation
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] EMsnap commented on a diff in pull request #6688: [INLONG-6671][Sort] Supports dirty data side-output for kafka connector

Posted by GitBox <gi...@apache.org>.
EMsnap commented on code in PR #6688:
URL: https://github.com/apache/inlong/pull/6688#discussion_r1036740045


##########
inlong-sort/sort-connectors/kafka/src/main/java/org/apache/inlong/sort/kafka/table/DynamicKafkaDeserializationSchema.java:
##########
@@ -149,6 +171,35 @@ public void deserialize(ConsumerRecord<byte[], byte[]> record, Collector<RowData
         keyCollector.buffer.clear();
     }
 
+    private void deserializeWithDirtyHandle(byte[] value, DirtyType dirtyType,
+            DeserializationSchema<RowData> deserialization, Collector<RowData> collector) throws IOException {
+        if (!dirtyOptions.ignoreDirty()) {
+            deserialization.deserialize(value, collector);
+        } else {
+            try {
+                deserialization.deserialize(value, collector);
+            } catch (IOException e) {
+                LOG.error(String.format("deserialize error, raw data: %s", new String(value)), e);
+                if (dirtySink != null) {
+                    DirtyData.Builder<String> builder = DirtyData.builder();
+                    try {
+                        builder.setData(new String(value))
+                                .setDirtyType(dirtyType)
+                                .setLabels(dirtyOptions.getLabels())
+                                .setLogTag(dirtyOptions.getLogTag())
+                                .setIdentifier(dirtyOptions.getIdentifier());
+                        dirtySink.invoke(builder.build());
+                    } catch (Exception ex) {
+                        if (!dirtyOptions.ignoreSideOutputErrors()) {
+                            throw new IOException(ex);
+                        }
+                        LOG.warn("Dirty sink failed", ex);

Review Comment:
   no change ? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] yunqingmoswu merged pull request #6688: [INLONG-6671][Sort] Supports dirty data side-output for kafka connector

Posted by GitBox <gi...@apache.org>.
yunqingmoswu merged PR #6688:
URL: https://github.com/apache/inlong/pull/6688


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] EMsnap commented on a diff in pull request #6688: [INLONG-6671][Sort] Supports dirty data side-output for kafka connector

Posted by GitBox <gi...@apache.org>.
EMsnap commented on code in PR #6688:
URL: https://github.com/apache/inlong/pull/6688#discussion_r1035862494


##########
inlong-sort/sort-connectors/kafka/src/main/java/org/apache/inlong/sort/kafka/table/DynamicKafkaDeserializationSchema.java:
##########
@@ -149,6 +171,35 @@ public void deserialize(ConsumerRecord<byte[], byte[]> record, Collector<RowData
         keyCollector.buffer.clear();
     }
 
+    private void deserializeWithDirtyHandle(byte[] value, DirtyType dirtyType,
+            DeserializationSchema<RowData> deserialization, Collector<RowData> collector) throws IOException {
+        if (!dirtyOptions.ignoreDirty()) {
+            deserialization.deserialize(value, collector);
+        } else {
+            try {
+                deserialization.deserialize(value, collector);
+            } catch (IOException e) {
+                LOG.warn("deserialize error", e);
+                if (dirtySink != null) {
+                    DirtyData.Builder<String> builder = DirtyData.builder();
+                    try {
+                        builder.setData(new String(value))
+                                .setDirtyType(dirtyType)
+                                .setLabels(dirtyOptions.getLabels())
+                                .setLogTag(dirtyOptions.getLogTag())
+                                .setIdentifier(dirtyOptions.getIdentifier());
+                        dirtySink.invoke(builder.build());
+                    } catch (Exception ex) {
+                        if (!dirtyOptions.ignoreSideOutputErrors()) {
+                            throw new IOException(ex);
+                        }
+                        LOG.warn("Dirty sink failed", ex);

Review Comment:
   suggested to error log and print the dirty data 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] yunqingmoswu commented on a diff in pull request #6688: [INLONG-6671][Sort] Supports dirty data side-output for kafka connector

Posted by GitBox <gi...@apache.org>.
yunqingmoswu commented on code in PR #6688:
URL: https://github.com/apache/inlong/pull/6688#discussion_r1036009305


##########
inlong-sort/sort-connectors/kafka/src/main/java/org/apache/inlong/sort/kafka/table/DynamicKafkaDeserializationSchema.java:
##########
@@ -149,6 +171,35 @@ public void deserialize(ConsumerRecord<byte[], byte[]> record, Collector<RowData
         keyCollector.buffer.clear();
     }
 
+    private void deserializeWithDirtyHandle(byte[] value, DirtyType dirtyType,
+            DeserializationSchema<RowData> deserialization, Collector<RowData> collector) throws IOException {
+        if (!dirtyOptions.ignoreDirty()) {
+            deserialization.deserialize(value, collector);
+        } else {
+            try {
+                deserialization.deserialize(value, collector);
+            } catch (IOException e) {
+                LOG.warn("deserialize error", e);
+                if (dirtySink != null) {
+                    DirtyData.Builder<String> builder = DirtyData.builder();
+                    try {
+                        builder.setData(new String(value))
+                                .setDirtyType(dirtyType)
+                                .setLabels(dirtyOptions.getLabels())
+                                .setLogTag(dirtyOptions.getLogTag())
+                                .setIdentifier(dirtyOptions.getIdentifier());
+                        dirtySink.invoke(builder.build());
+                    } catch (Exception ex) {
+                        if (!dirtyOptions.ignoreSideOutputErrors()) {
+                            throw new IOException(ex);
+                        }
+                        LOG.warn("Dirty sink failed", ex);

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org