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/04/19 04:33:08 UTC

[GitHub] [incubator-inlong] luchunliang opened a new pull request, #3785: [INLONG-3773][Sort-Standalone] Sort-Standalone support configurable handler to transform data of Kafka Sort.

luchunliang opened a new pull request, #3785:
URL: https://github.com/apache/incubator-inlong/pull/3785

   ### Title Name: [INLONG-3773][Sort-Standalone] Sort-Standalone support a configurable handler to transform data of Kafka Sort.
   
   Fixes #3773 
   
   ### Motivation
   
   *Explain here the context, and why you're making that change. What is the problem you're trying to solve?*
   
   ### Modifications
   
   *Describe the modifications you've done.*
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [ ] 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] [incubator-inlong] luchunliang commented on pull request #3785: [INLONG-3773][Sort-Standalone] Support configurable handler to transform data of Kafka

Posted by GitBox <gi...@apache.org>.
luchunliang commented on PR #3785:
URL: https://github.com/apache/incubator-inlong/pull/3785#issuecomment-1107775340

   Rebase error, add new PR:https://github.com/apache/incubator-inlong/pull/3902;
   This PR will close.


-- 
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] [incubator-inlong] healchow commented on a diff in pull request #3785: [INLONG-3773][Sort-Standalone] Support configurable handler to transform data of Kafka

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #3785:
URL: https://github.com/apache/incubator-inlong/pull/3785#discussion_r852777907


##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/kafka/DefaultEvent2KafkaRecordHandler.java:
##########
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.inlong.sort.standalone.sink.kafka;
+
+import org.apache.inlong.sdk.commons.protocol.EventConstants;
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.slf4j.Logger;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * 
+ * DefaultEvent2KafkaRecordHandler
+ */
+public class DefaultEvent2KafkaRecordHandler implements IEvent2KafkaRecordHandler {
+
+    public static final Logger LOG = InlongLoggerFactory.getLogger(DefaultEvent2KafkaRecordHandler.class);
+
+    public static final String KEY_EXTINFO = "extinfo";
+    protected final ByteArrayOutputStream outMsg = new ByteArrayOutputStream();
+    protected final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

Review Comment:
   The `SimpleDateFormat` is not thread-safe, will there be a problem here?



##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsSinkContext.java:
##########
@@ -565,21 +550,25 @@ public void setUseIndexId(boolean isUseIndexId) {
     }
 
     /**
-     * get indexRequestHandler
+     * create indexRequestHandler
      * 
      * @return the indexRequestHandler
      */
-    public IEvent2IndexRequestHandler getIndexRequestHandler() {
-        return indexRequestHandler;
-    }
-
-    /**
-     * set indexRequestHandler
-     * 
-     * @param indexRequestHandler the indexRequestHandler to set
-     */
-    public void setIndexRequestHandler(IEvent2IndexRequestHandler indexRequestHandler) {
-        this.indexRequestHandler = indexRequestHandler;
+    public IEvent2IndexRequestHandler createIndexRequestHandler() {
+        // IEvent2IndexRequestHandler
+        String indexRequestHandlerClass = CommonPropertiesHolder.getString(KEY_EVENT_INDEXREQUEST_HANDLER,
+                DefaultEvent2IndexRequestHandler.class.getName());
+        try {
+            Class<?> handlerClass = ClassUtils.getClass(indexRequestHandlerClass);
+            Object handlerObject = handlerClass.getDeclaredConstructor().newInstance();
+            if (handlerObject instanceof IEvent2IndexRequestHandler) {
+                IEvent2IndexRequestHandler handler = (IEvent2IndexRequestHandler) handlerObject;
+                return handler;
+            }
+        } catch (Throwable t) {
+            LOG.error("Fail to init IEvent2IndexRequestHandler,handlerClass:{},error:{}",

Review Comment:
   In the error log, it is suggested to print all exception stacks.



-- 
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] [incubator-inlong] healchow commented on a diff in pull request #3785: [INLONG-3773][Sort-Standalone] Support configurable handler to transform data of Kafka

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #3785:
URL: https://github.com/apache/incubator-inlong/pull/3785#discussion_r852589848


##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsSinkContext.java:
##########
@@ -17,13 +17,7 @@
 
 package org.apache.inlong.sort.standalone.sink.elasticsearch;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.atomic.AtomicLong;
+import com.alibaba.fastjson.JSON;

Review Comment:
   There are too many security risks in this package, could you replace it with the Gson?



##########
inlong-manager/manager-dao/pom.xml:
##########
@@ -57,8 +57,31 @@
                     <artifactId>spring-boot-autoconfigure</artifactId>
                     <groupId>org.springframework.boot</groupId>
                 </exclusion>
+                <exclusion>
+                    <artifactId>com.sun</artifactId>
+                    <groupId>tools</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>com.sun</artifactId>
+                    <groupId>jconsoles</groupId>
+                </exclusion>
             </exclusions>
         </dependency>
+        
+        <dependency>
+            <groupId>com.sun</groupId>
+            <artifactId>tools</artifactId>
+                <version>1.8.0</version>
+                <scope>system</scope>
+                <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>

Review Comment:
   Can this configuration work in Windows OS?



-- 
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] [incubator-inlong] luchunliang commented on a diff in pull request #3785: [INLONG-3773][Sort-Standalone] Support configurable handler to transform data of Kafka

Posted by GitBox <gi...@apache.org>.
luchunliang commented on code in PR #3785:
URL: https://github.com/apache/incubator-inlong/pull/3785#discussion_r855744616


##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsSinkContext.java:
##########
@@ -565,21 +550,25 @@ public void setUseIndexId(boolean isUseIndexId) {
     }
 
     /**
-     * get indexRequestHandler
+     * create indexRequestHandler
      * 
      * @return the indexRequestHandler
      */
-    public IEvent2IndexRequestHandler getIndexRequestHandler() {
-        return indexRequestHandler;
-    }
-
-    /**
-     * set indexRequestHandler
-     * 
-     * @param indexRequestHandler the indexRequestHandler to set
-     */
-    public void setIndexRequestHandler(IEvent2IndexRequestHandler indexRequestHandler) {
-        this.indexRequestHandler = indexRequestHandler;
+    public IEvent2IndexRequestHandler createIndexRequestHandler() {
+        // IEvent2IndexRequestHandler
+        String indexRequestHandlerClass = CommonPropertiesHolder.getString(KEY_EVENT_INDEXREQUEST_HANDLER,
+                DefaultEvent2IndexRequestHandler.class.getName());
+        try {
+            Class<?> handlerClass = ClassUtils.getClass(indexRequestHandlerClass);
+            Object handlerObject = handlerClass.getDeclaredConstructor().newInstance();
+            if (handlerObject instanceof IEvent2IndexRequestHandler) {
+                IEvent2IndexRequestHandler handler = (IEvent2IndexRequestHandler) handlerObject;
+                return handler;
+            }
+        } catch (Throwable t) {
+            LOG.error("Fail to init IEvent2IndexRequestHandler,handlerClass:{},error:{}",

Review Comment:
   ok, print all exception stacks.



-- 
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] [incubator-inlong] luchunliang commented on a diff in pull request #3785: [INLONG-3773][Sort-Standalone] Support configurable handler to transform data of Kafka

Posted by GitBox <gi...@apache.org>.
luchunliang commented on code in PR #3785:
URL: https://github.com/apache/incubator-inlong/pull/3785#discussion_r855743966


##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsSinkContext.java:
##########
@@ -17,13 +17,7 @@
 
 package org.apache.inlong.sort.standalone.sink.elasticsearch;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.atomic.AtomicLong;
+import com.alibaba.fastjson.JSON;

Review Comment:
   change to com.fasterxml.jackson.databind.ObjectMapper



-- 
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] [incubator-inlong] luchunliang commented on a diff in pull request #3785: [INLONG-3773][Sort-Standalone] Support configurable handler to transform data of Kafka

Posted by GitBox <gi...@apache.org>.
luchunliang commented on code in PR #3785:
URL: https://github.com/apache/incubator-inlong/pull/3785#discussion_r852645036


##########
inlong-manager/manager-dao/pom.xml:
##########
@@ -57,8 +57,31 @@
                     <artifactId>spring-boot-autoconfigure</artifactId>
                     <groupId>org.springframework.boot</groupId>
                 </exclusion>
+                <exclusion>
+                    <artifactId>com.sun</artifactId>
+                    <groupId>tools</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>com.sun</artifactId>
+                    <groupId>jconsoles</groupId>
+                </exclusion>
             </exclusions>
         </dependency>
+        
+        <dependency>
+            <groupId>com.sun</groupId>
+            <artifactId>tools</artifactId>
+                <version>1.8.0</version>
+                <scope>system</scope>
+                <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>

Review Comment:
   It can work in Window OS. If removing this, we will get this error:
   [ERROR] Failed to execute goal on project manager-dao: Could not resolve dependencies for project org.apache.inlong:manager-dao:jar:1.2.0-incubating-SNAPSHOT: The following artifacts could not be resolved: com.sun:tools:jar:1.8, com.sun:jconsole:jar:1.8: Could not find artifact com.sun:tools:jar:1.8 at specified path C:\Users\rudylu\.m2\repository\com\alibaba\druid\1.2.6/lib/openjdk-1.8-tools.jar -> [Help 1]
   
   remove them



##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsSinkContext.java:
##########
@@ -17,13 +17,7 @@
 
 package org.apache.inlong.sort.standalone.sink.elasticsearch;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.atomic.AtomicLong;
+import com.alibaba.fastjson.JSON;

Review Comment:
   Gson generate JSON string, the string is not certain, Fastjson will sort the child by the property name.
   The newest version of Fastjson is OK.



##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/elasticsearch/EsSinkContext.java:
##########
@@ -565,21 +550,25 @@ public void setUseIndexId(boolean isUseIndexId) {
     }
 
     /**
-     * get indexRequestHandler
+     * create indexRequestHandler
      * 
      * @return the indexRequestHandler
      */
-    public IEvent2IndexRequestHandler getIndexRequestHandler() {
-        return indexRequestHandler;
-    }
-
-    /**
-     * set indexRequestHandler
-     * 
-     * @param indexRequestHandler the indexRequestHandler to set
-     */
-    public void setIndexRequestHandler(IEvent2IndexRequestHandler indexRequestHandler) {
-        this.indexRequestHandler = indexRequestHandler;
+    public IEvent2IndexRequestHandler createIndexRequestHandler() {
+        // IEvent2IndexRequestHandler
+        String indexRequestHandlerClass = CommonPropertiesHolder.getString(KEY_EVENT_INDEXREQUEST_HANDLER,
+                DefaultEvent2IndexRequestHandler.class.getName());
+        try {
+            Class<?> handlerClass = ClassUtils.getClass(indexRequestHandlerClass);
+            Object handlerObject = handlerClass.getDeclaredConstructor().newInstance();
+            if (handlerObject instanceof IEvent2IndexRequestHandler) {
+                IEvent2IndexRequestHandler handler = (IEvent2IndexRequestHandler) handlerObject;
+                return handler;
+            }
+        } catch (Throwable t) {
+            LOG.error("Fail to init IEvent2IndexRequestHandler,handlerClass:{},error:{}",

Review Comment:
   It is easy to cause the disk full, if print all exception stack.



##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/kafka/DefaultEvent2KafkaRecordHandler.java:
##########
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.inlong.sort.standalone.sink.kafka;
+
+import org.apache.inlong.sdk.commons.protocol.EventConstants;
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.slf4j.Logger;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * 
+ * DefaultEvent2KafkaRecordHandler
+ */
+public class DefaultEvent2KafkaRecordHandler implements IEvent2KafkaRecordHandler {
+
+    public static final Logger LOG = InlongLoggerFactory.getLogger(DefaultEvent2KafkaRecordHandler.class);
+
+    public static final String KEY_EXTINFO = "extinfo";
+    protected final ByteArrayOutputStream outMsg = new ByteArrayOutputStream();
+    protected final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

Review Comment:
   Every EsChannelWorker have a IEvent2KafkaRecordHandler.



-- 
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] [incubator-inlong] luchunliang closed pull request #3785: [INLONG-3773][Sort-Standalone] Support configurable handler to transform data of Kafka

Posted by GitBox <gi...@apache.org>.
luchunliang closed pull request #3785: [INLONG-3773][Sort-Standalone] Support configurable handler to transform data of Kafka
URL: https://github.com/apache/incubator-inlong/pull/3785


-- 
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