luchunliang commented on a change in pull request #2608:
URL: https://github.com/apache/incubator-inlong/pull/2608#discussion_r811041419
##########
File path:
inlong-common/src/main/java/org/apache/inlong/commons/metrics/MetricObserver.java
##########
@@ -43,35 +47,36 @@
/**
* init
- *
+ *
* @param commonProperties
*/
public static void init(Map<String, String> commonProperties) {
if (!isInited.compareAndSet(false, true)) {
return;
}
- // init
- Context context = new Context(commonProperties);
// get domain name list
- String metricDomains =
context.getString(MetricListener.KEY_METRIC_DOMAINS);
+ String metricDomains =
commonProperties.get(MetricListener.KEY_METRIC_DOMAINS);
if (StringUtils.isBlank(metricDomains)) {
return;
}
// split domain name
String[] domains = metricDomains.split("\\s+");
for (String domain : domains) {
// get domain parameters
- Context domainContext = new Context(
- context.getSubProperties(MetricListener.KEY_METRIC_DOMAINS
+ "." + domain + "."));
- List<MetricListener> listenerList = parseDomain(domain,
domainContext);
+ Map<String, String> domainMap = getSubProperties(commonProperties,
+ MetricListener.KEY_METRIC_DOMAINS + "." + domain + ".");
+ List<MetricListener> listenerList = parseDomain(domainMap);
// no listener
if (listenerList == null || listenerList.size() <= 0) {
continue;
}
// get snapshot interval
- long snapshotInterval =
domainContext.getLong(MetricListener.KEY_SNAPSHOT_INTERVAL, 60000L);
- LOG.info("begin to register
domain:{},MetricListeners:{},snapshotInterval:{}", domain, listenerList,
- snapshotInterval);
+ long snapshotInterval =
+
Long.parseLong(domainMap.getOrDefault(MetricListener.KEY_SNAPSHOT_INTERVAL,
Review comment:
If inlong-common do not want to import flume dependency, same function
can be implemented in this class.
##########
File path:
inlong-common/src/main/java/org/apache/inlong/commons/metrics/MetricObserver.java
##########
@@ -43,35 +47,36 @@
/**
* init
- *
+ *
* @param commonProperties
*/
public static void init(Map<String, String> commonProperties) {
if (!isInited.compareAndSet(false, true)) {
return;
}
- // init
- Context context = new Context(commonProperties);
// get domain name list
- String metricDomains =
context.getString(MetricListener.KEY_METRIC_DOMAINS);
+ String metricDomains =
commonProperties.get(MetricListener.KEY_METRIC_DOMAINS);
if (StringUtils.isBlank(metricDomains)) {
return;
}
// split domain name
String[] domains = metricDomains.split("\\s+");
for (String domain : domains) {
// get domain parameters
- Context domainContext = new Context(
- context.getSubProperties(MetricListener.KEY_METRIC_DOMAINS
+ "." + domain + "."));
- List<MetricListener> listenerList = parseDomain(domain,
domainContext);
+ Map<String, String> domainMap = getSubProperties(commonProperties,
+ MetricListener.KEY_METRIC_DOMAINS + "." + domain + ".");
+ List<MetricListener> listenerList = parseDomain(domainMap);
// no listener
if (listenerList == null || listenerList.size() <= 0) {
continue;
}
// get snapshot interval
- long snapshotInterval =
domainContext.getLong(MetricListener.KEY_SNAPSHOT_INTERVAL, 60000L);
- LOG.info("begin to register
domain:{},MetricListeners:{},snapshotInterval:{}", domain, listenerList,
- snapshotInterval);
+ long snapshotInterval =
+
Long.parseLong(domainMap.getOrDefault(MetricListener.KEY_SNAPSHOT_INTERVAL,
Review comment:
It is better that domainMap type is Context.
It can be removed that "60000" parse to long.
--
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]