Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.iotdb.commons.service.ServiceType;
import org.apache.iotdb.commons.service.metric.JvmGcMonitorMetrics;
import org.apache.iotdb.commons.service.metric.MetricService;
import org.apache.iotdb.commons.service.metric.ProcessMetrics;
import org.apache.iotdb.commons.service.metric.cpu.CpuUsageMetrics;
import org.apache.iotdb.commons.utils.StatusUtils;
import org.apache.iotdb.commons.utils.TestOnly;
Expand All @@ -59,7 +60,6 @@
import org.apache.iotdb.confignode.rpc.thrift.TNodeVersionInfo;
import org.apache.iotdb.confignode.service.thrift.ConfigNodeRPCService;
import org.apache.iotdb.confignode.service.thrift.ConfigNodeRPCServiceProcessor;
import org.apache.iotdb.db.service.metrics.ProcessMetrics;
import org.apache.iotdb.metrics.config.MetricConfigDescriptor;
import org.apache.iotdb.metrics.metricsets.UpTimeMetrics;
import org.apache.iotdb.metrics.metricsets.disk.DiskMetrics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,6 @@ private DataNodeMiscMessages() {}
// ---------------------------------------------------------------------------
// service – metrics
// ---------------------------------------------------------------------------
public static final String FAILED_GET_PROCESS_RESIDENT_MEMORY =
"Failed to get process resident memory for pid {}";
public static final String DATANODE_PORT_CHECK_SUCCESSFUL = "DataNode port check successful.";

// ---------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,6 @@ private DataNodeMiscMessages() {}
// ---------------------------------------------------------------------------
// service – metrics
// ---------------------------------------------------------------------------
public static final String FAILED_GET_PROCESS_RESIDENT_MEMORY =
"获取进程 {} 的常驻内存失败";
public static final String DATANODE_PORT_CHECK_SUCCESSFUL = "DataNode 端口检查通过。";

// ---------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.iotdb.commons.service.metric.JvmGcMonitorMetrics;
import org.apache.iotdb.commons.service.metric.MetricService;
import org.apache.iotdb.commons.service.metric.PerformanceOverviewMetrics;
import org.apache.iotdb.commons.service.metric.ProcessMetrics;
import org.apache.iotdb.commons.service.metric.cpu.CpuUsageMetrics;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.pipe.metric.PipeDataNodeMetrics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,24 @@ public class MetricConfigDescriptor {
/** The metric config of metric service. */
private static final MetricConfig metricConfig = new MetricConfig();

private static final String CONFIG_NODE_PREFIX = "cn_";
private static final String DATA_NODE_PREFIX = "dn_";

private MetricConfigDescriptor() {
// empty constructor
}

/** Load properties into metric config. */
public void loadProps(Properties properties, boolean isConfigNode) {
MetricConfig loadConfig = generateFromProperties(properties, isConfigNode);
loadProps(properties, isConfigNode ? CONFIG_NODE_PREFIX : DATA_NODE_PREFIX);
}

/**
* Load properties into metric config with a node-specific prefix (e.g. {@code "cn_"}, {@code
* "dn_"}, {@code "sn_"}).
*/
public void loadProps(Properties properties, String prefix) {
MetricConfig loadConfig = generateFromProperties(properties, prefix);
metricConfig.copy(loadConfig);
}

Expand All @@ -49,7 +60,16 @@ public void loadProps(Properties properties, boolean isConfigNode) {
* @return reload level of metric service
*/
public ReloadLevel loadHotProps(Properties properties, boolean isConfigNode) {
MetricConfig newMetricConfig = generateFromProperties(properties, isConfigNode);
return loadHotProps(properties, isConfigNode ? CONFIG_NODE_PREFIX : DATA_NODE_PREFIX);
}

/**
* Load properties into metric config when reload service with a node-specific prefix.
*
* @return reload level of metric service
*/
public ReloadLevel loadHotProps(Properties properties, String prefix) {
MetricConfig newMetricConfig = generateFromProperties(properties, prefix);
ReloadLevel reloadLevel = ReloadLevel.NOTHING;
if (!metricConfig.equals(newMetricConfig)) {
if (!metricConfig.getMetricLevel().equals(newMetricConfig.getMetricLevel())
Expand All @@ -73,7 +93,7 @@ public ReloadLevel loadHotProps(Properties properties, boolean isConfigNode) {
}

/** Load properties into metric config. */
private MetricConfig generateFromProperties(Properties properties, boolean isConfigNode) {
private MetricConfig generateFromProperties(Properties properties, String prefix) {
MetricConfig loadConfig = new MetricConfig();

String reporterList =
Expand All @@ -85,32 +105,29 @@ private MetricConfig generateFromProperties(Properties properties, boolean isCon
.map(ReporterType::toString)
.collect(Collectors.toSet())),
properties,
isConfigNode);
prefix);
loadConfig.setMetricReporterList(reporterList);

loadConfig.setMetricLevel(
MetricLevel.valueOf(
getProperty(
"metric_level",
String.valueOf(loadConfig.getMetricLevel()),
properties,
isConfigNode)));
"metric_level", String.valueOf(loadConfig.getMetricLevel()), properties, prefix)));

loadConfig.setAsyncCollectPeriodInSecond(
Integer.parseInt(
getProperty(
"metric_async_collect_period",
String.valueOf(loadConfig.getAsyncCollectPeriodInSecond()),
properties,
isConfigNode)));
prefix)));

loadConfig.setPrometheusReporterPort(
Integer.parseInt(
getProperty(
"metric_prometheus_reporter_port",
String.valueOf(loadConfig.getPrometheusReporterPort()),
properties,
isConfigNode)));
prefix)));

loadConfig.setPrometheusReporterUsername(
getPropertyWithoutPrefix(
Expand Down Expand Up @@ -139,54 +156,45 @@ private MetricConfig generateFromProperties(Properties properties, boolean isCon

IoTDBReporterConfig reporterConfig = loadConfig.getIoTDBReporterConfig();
reporterConfig.setHost(
getProperty(
"metric_iotdb_reporter_host", reporterConfig.getHost(), properties, isConfigNode));
getProperty("metric_iotdb_reporter_host", reporterConfig.getHost(), properties, prefix));

reporterConfig.setPort(
Integer.valueOf(
getProperty(
"metric_iotdb_reporter_port",
String.valueOf(reporterConfig.getPort()),
properties,
isConfigNode)));
prefix)));

reporterConfig.setUsername(
getProperty(
"metric_iotdb_reporter_username",
reporterConfig.getUsername(),
properties,
isConfigNode));
"metric_iotdb_reporter_username", reporterConfig.getUsername(), properties, prefix));

reporterConfig.setPassword(
getProperty(
"metric_iotdb_reporter_password",
reporterConfig.getPassword(),
properties,
isConfigNode));
"metric_iotdb_reporter_password", reporterConfig.getPassword(), properties, prefix));

reporterConfig.setMaxConnectionNumber(
Integer.valueOf(
getProperty(
"metric_iotdb_reporter_max_connection_number",
String.valueOf(reporterConfig.getMaxConnectionNumber()),
properties,
isConfigNode)));
prefix)));

reporterConfig.setLocation(
getProperty(
"metric_iotdb_reporter_location",
reporterConfig.getLocation(),
properties,
isConfigNode));
"metric_iotdb_reporter_location", reporterConfig.getLocation(), properties, prefix));

reporterConfig.setPushPeriodInSecond(
Integer.valueOf(
getProperty(
"metric_iotdb_reporter_push_period",
String.valueOf(reporterConfig.getPushPeriodInSecond()),
properties,
isConfigNode)));
if (!isConfigNode) {
prefix)));

if (DATA_NODE_PREFIX.equals(prefix)) {
loadConfig.setInternalReportType(
InternalReporterType.valueOf(
properties.getProperty(
Expand All @@ -197,11 +205,12 @@ private MetricConfig generateFromProperties(Properties properties, boolean isCon
return loadConfig;
}

/** Get property from confignode or datanode. */
/**
* Get property with a node-specific prefix (e.g. {@code "cn_"}, {@code "dn_"}, {@code "sn_"}).
*/
private String getProperty(
String target, String defaultValue, Properties properties, boolean isConfigNode) {
return Optional.ofNullable(
properties.getProperty((isConfigNode ? "cn_" : "dn_") + target, defaultValue))
String target, String defaultValue, Properties properties, String prefix) {
return Optional.ofNullable(properties.getProperty(prefix + target, defaultValue))
.map(String::trim)
.orElse(defaultValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

public enum NodeType {
CONFIGNODE,
DATANODE;
DATANODE,
STREAMNODE;

@Override
public String toString() {
Expand Down
8 changes: 8 additions & 0 deletions iotdb-core/node-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@
<groupId>com.github.luben</groupId>
<artifactId>zstd-jni</artifactId>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ public final class ServiceMessages {
// ---- CpuUsageMetrics ----
public static final String CPU_USAGE_UPDATE_TIME = "Time for update cpu usage is {} ns";

// ---- ProcessMetrics ----
public static final String FAILED_GET_PROCESS_RESIDENT_MEMORY =
"Failed to get process resident memory for pid {}";

private ServiceMessages() {}

public static final String UNKNOWN_SERVICE_TYPE = "Unknown ServiceType: ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ public final class ServiceMessages {
// ---- CpuUsageMetrics ----
public static final String CPU_USAGE_UPDATE_TIME = "CPU 使用率更新耗时 {} 纳秒";

// ---- ProcessMetrics ----
public static final String FAILED_GET_PROCESS_RESIDENT_MEMORY =
"获取进程 {} 的常驻内存失败";

private ServiceMessages() {}

public static final String UNKNOWN_SERVICE_TYPE = "未知服务类型:";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* "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
* 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
Expand All @@ -17,10 +17,10 @@
* under the License.
*/

package org.apache.iotdb.db.service.metrics;
package org.apache.iotdb.commons.service.metric;

import org.apache.iotdb.commons.i18n.ServiceMessages;
import org.apache.iotdb.commons.service.metric.enums.Tag;
import org.apache.iotdb.db.i18n.DataNodeMiscMessages;
import org.apache.iotdb.metrics.AbstractMetricService;
import org.apache.iotdb.metrics.MetricConstant;
import org.apache.iotdb.metrics.config.MetricConfig;
Expand Down Expand Up @@ -253,7 +253,7 @@ private long getResidentMemory() {
return 0L;
}
} catch (Exception e) {
LOGGER.debug(DataNodeMiscMessages.FAILED_GET_PROCESS_RESIDENT_MEMORY, CONFIG.getPid(), e);
LOGGER.debug(ServiceMessages.FAILED_GET_PROCESS_RESIDENT_MEMORY, CONFIG.getPid(), e);
return 0L;
}
}
Expand Down
Loading