inter12 commented on a change in pull request #1797:
URL: https://github.com/apache/incubator-inlong/pull/1797#discussion_r750057618



##########
File path: 
inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/config/holder/IdTopicConfigHolder.java
##########
@@ -0,0 +1,160 @@
+/**
+ * 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.dataproxy.config.holder;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.commons.lang.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.conf.Configurable;
+import org.apache.inlong.dataproxy.config.loader.ContextIdTopicConfigLoader;
+import org.apache.inlong.dataproxy.config.loader.IdTopicConfigLoader;
+import org.apache.inlong.dataproxy.config.pojo.IdTopicConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * IdTopicConfigHolder
+ */
+public class IdTopicConfigHolder implements Configurable {
+
+    public static final Logger LOG = 
LoggerFactory.getLogger(IdTopicConfigHolder.class);
+
+    protected Context context;
+    private long reloadInterval;
+    private Timer reloadTimer;
+    private IdTopicConfigLoader loader;
+
+    private List<IdTopicConfig> configList = new ArrayList<>();
+    private Map<String, IdTopicConfig> configMap = new ConcurrentHashMap<>();
+
+    /**
+     * configure
+     * 
+     * @param context
+     */
+    @Override
+    public void configure(Context context) {
+        this.context = context;
+        this.reloadInterval = context.getLong("reloadInterval", 60000L);
+        String loaderType = context.getString("idTopicConfig.type", 
ContextIdTopicConfigLoader.class.getName());
+        try {
+            Class<?> loaderClass = ClassUtils.getClass(loaderType);
+            Object loaderObject = 
loaderClass.getDeclaredConstructor().newInstance();
+            if (loaderObject instanceof IdTopicConfigLoader) {
+                this.loader = (IdTopicConfigLoader) loaderObject;
+            }
+        } catch (Throwable t) {
+            LOG.error("Fail to init loader,loaderType:{},error:{}", 
loaderType, t.getMessage());
+            LOG.error(t.getMessage(), t);
+        }
+        if (this.loader == null) {
+            this.loader = new ContextIdTopicConfigLoader();
+        }
+        this.loader.configure(context);
+    }
+
+    /**
+     * start
+     */
+    public void start() {
+        try {
+            this.reload();
+            this.setReloadTimer();
+        } catch (Exception e) {
+            e.printStackTrace();

Review comment:
       e.printstacktrace is not suitable




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