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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to