inter12 commented on a change in pull request #1797: URL: https://github.com/apache/incubator-inlong/pull/1797#discussion_r750059647
########## File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/config/loader/ContextCacheClusterConfigLoader.java ########## @@ -0,0 +1,76 @@ +/** + * 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.loader; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.flume.Context; +import org.apache.inlong.dataproxy.config.pojo.CacheClusterConfig; +import org.apache.pulsar.shade.org.apache.commons.lang3.StringUtils; + +/** + * + * ContextCacheClusterConfigLoader + */ +public class ContextCacheClusterConfigLoader implements CacheClusterConfigLoader { + + private Context context; + + /** + * load + * + * @return + */ + @Override + public List<CacheClusterConfig> load() { + String clusterNames = context.getString("cacheClusterConfig"); Review comment: extract to constant ########## File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/config/loader/ContextIdTopicConfigLoader.java ########## @@ -0,0 +1,64 @@ +/** + * 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.loader; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.flume.Context; +import org.apache.inlong.dataproxy.config.pojo.IdTopicConfig; + +/** + * + * ContextIdTopicConfigLoader + */ +public class ContextIdTopicConfigLoader implements IdTopicConfigLoader { + + private Context context; + + /** + * load + * + * @return + */ + @Override + public List<IdTopicConfig> load() { + Map<String, String> idTopicMap = context.getSubProperties("idTopicConfig."); + List<IdTopicConfig> configList = new ArrayList<>(idTopicMap.size()); Review comment: NPE check? ########## File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/config/loader/ClassResourceCommonPropertiesLoader.java ########## @@ -0,0 +1,85 @@ +/** + * 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.loader; + +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * FileCommonPropertiesLoader + */ +public class ClassResourceCommonPropertiesLoader implements CommonPropertiesLoader { + + public static final Logger LOG = LoggerFactory.getLogger(ClassResourceCommonPropertiesLoader.class); + + /** + * load + * + * @return + */ + @Override + public Map<String, String> load() { + return this.loadProperties("common.properties"); + } + + /** + * loadProperties + * + * @param fileName + * @return + */ + protected Map<String, String> loadProperties(String fileName) { + Map<String, String> result = new ConcurrentHashMap<>(); + InputStream inStream = null; Review comment: recommend to use try-resource ########## File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/metrics/MetricObserver.java ########## @@ -0,0 +1,114 @@ +/** + * 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.metrics; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.apache.commons.lang.ClassUtils; +import org.apache.flume.Context; +import org.apache.pulsar.shade.org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * MetricObserver + */ +public class MetricObserver { + + public static final Logger LOG = LoggerFactory.getLogger(MetricObserver.class); + private static final AtomicBoolean isInited = new AtomicBoolean(false); + private static ScheduledExecutorService statExecutor = Executors.newScheduledThreadPool(5); Review comment: should init with thead name for online trouble shooting -- 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]
