This is an automated email from the ASF dual-hosted git repository. haonan pushed a commit to branch win_metrics_new in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 82a9e2a5b774ea037e6b9fea125e515a27d78b1d Author: unknown <[email protected]> AuthorDate: Thu Feb 5 17:20:51 2026 +0800 dev --- .../apache/iotdb/metrics/config/MetricConfig.java | 7 +- .../metricsets/disk/IDiskMetricsManager.java | 2 +- .../disk/NewWindowsDiskMetricsManager.java | 412 +++++++++++++++++++++ .../metricsets/disk/WindowsDiskMetricsManager.java | 155 -------- .../metricsets/net/WindowsNetMetricManager.java | 22 +- 5 files changed, 428 insertions(+), 170 deletions(-) diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java index 0d3f019ce61..08263a51002 100644 --- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java +++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/config/MetricConfig.java @@ -30,7 +30,6 @@ import org.slf4j.LoggerFactory; import java.lang.management.ManagementFactory; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.Base64; import java.util.Collections; import java.util.List; @@ -40,7 +39,8 @@ public class MetricConfig { private static final Logger LOGGER = LoggerFactory.getLogger(MetricConfig.class); /** The list of reporters provide metrics for external tool. */ - private List<ReporterType> metricReporterList = Collections.singletonList(ReporterType.PROMETHEUS); + private List<ReporterType> metricReporterList = + Collections.singletonList(ReporterType.PROMETHEUS); /** The level of metric service. */ private MetricLevel metricLevel = MetricLevel.ALL; @@ -98,8 +98,7 @@ public class MetricConfig { return metricReporterList; } - public void setMetricReporterList(String metricReporterList) { - } + public void setMetricReporterList(String metricReporterList) {} public InternalReporterType getInternalReportType() { return internalReporterType; diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/disk/IDiskMetricsManager.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/disk/IDiskMetricsManager.java index 83a9f311223..d56ac03cc6a 100644 --- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/disk/IDiskMetricsManager.java +++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/disk/IDiskMetricsManager.java @@ -125,7 +125,7 @@ public interface IDiskMetricsManager { String os = System.getProperty("os.name").toLowerCase(); if (os.startsWith("windows")) { - return new WindowsDiskMetricsManager(); + return new NewWindowsDiskMetricsManager(); } else if (os.startsWith("linux")) { return new LinuxDiskMetricsManager(); } else { diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/disk/NewWindowsDiskMetricsManager.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/disk/NewWindowsDiskMetricsManager.java new file mode 100644 index 00000000000..9630ce180b8 --- /dev/null +++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/disk/NewWindowsDiskMetricsManager.java @@ -0,0 +1,412 @@ +/* + * 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.iotdb.metrics.metricsets.disk; + +import org.apache.iotdb.metrics.config.MetricConfig; +import org.apache.iotdb.metrics.config.MetricConfigDescriptor; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +public class NewWindowsDiskMetricsManager extends AbstractDiskMetricsManager { + private static final Logger LOGGER = LoggerFactory.getLogger(NewWindowsDiskMetricsManager.class); + + private static final MetricConfig metricConfig = MetricConfigDescriptor.getInstance().getMetricConfig(); + + private static final int DEFAULT_SECTOR_SIZE = 512; + private final Map<String, Integer> diskSectorSizeMap = new HashMap<>(); + + private long lastReallyReadSizeForProcess = 0L; + private long lastReallyWriteSizeForProcess = 0L; + private long lastAttemptReadSizeForProcess = 0L; + private long lastAttemptWriteSizeForProcess = 0L; + private long lastReadOpsCountForProcess = 0L; + private long lastWriteOpsCountForProcess = 0L; + + public NewWindowsDiskMetricsManager() { + diskIdSet = new HashSet<>(); + init(); + collectDiskInfo(); + updateDiskInfo(); // 记录初始值 + updateProcessInfo(); + } + + @Override + public Map<String, Double> getReadDataSizeForDisk() { + checkUpdate(); + Map<String, Double> readDataMap = new HashMap<>(diskIdSet.size()); + for (Map.Entry<String, Long> entry : lastReadSectorCountForDisk.entrySet()) { + int sectorSize = diskSectorSizeMap.getOrDefault(entry.getKey(), DEFAULT_SECTOR_SIZE); + readDataMap.put(entry.getKey(), entry.getValue() * sectorSize / BYTES_PER_KB); + } + return readDataMap; + } + + @Override + public Map<String, Double> getWriteDataSizeForDisk() { + checkUpdate(); + Map<String, Double> writeDataMap = new HashMap<>(diskIdSet.size()); + for (Map.Entry<String, Long> entry : lastWriteSectorCountForDisk.entrySet()) { + int sectorSize = diskSectorSizeMap.getOrDefault(entry.getKey(), DEFAULT_SECTOR_SIZE); + writeDataMap.put(entry.getKey(), entry.getValue() * sectorSize / BYTES_PER_KB); + } + return writeDataMap; + } + + @Override + public Map<String, Long> getReadOperationCountForDisk() { + checkUpdate(); + return lastReadOperationCountForDisk; + } + + @Override + public Map<String, Long> getWriteOperationCountForDisk() { + checkUpdate(); + return lastWriteOperationCountForDisk; + } + + @Override + public Map<String, Long> getReadCostTimeForDisk() { + checkUpdate(); + return lastReadTimeCostForDisk; + } + + @Override + public Map<String, Long> getWriteCostTimeForDisk() { + checkUpdate(); + return lastWriteTimeCostForDisk; + } + + @Override + public Map<String, Double> getAvgReadCostTimeOfEachOpsForDisk() { + checkUpdate(); + Map<String, Double> avgReadTimeCostMap = new HashMap<>(diskIdSet.size()); + for (Map.Entry<String, Long> readCostEntry : incrementReadTimeCostForDisk.entrySet()) { + long readOpsCount = + Long.max( + incrementReadOperationCountForDisk.getOrDefault(readCostEntry.getKey(), 1L) + + incrementMergedReadOperationCountForDisk.getOrDefault( + readCostEntry.getKey(), 1L), + 1L); + avgReadTimeCostMap.put( + readCostEntry.getKey(), (double) readCostEntry.getValue() / readOpsCount); + } + return avgReadTimeCostMap; + } + + @Override + public Map<String, Double> getAvgWriteCostTimeOfEachOpsForDisk() { + checkUpdate(); + Map<String, Double> avgWriteTimeCostMap = new HashMap<>(diskIdSet.size()); + for (Map.Entry<String, Long> writeCostEntry : incrementWriteTimeCostForDisk.entrySet()) { + long writeOpsCount = + Long.max( + incrementWriteOperationCountForDisk.getOrDefault(writeCostEntry.getKey(), 1L) + + incrementMergedWriteOperationCountForDisk.getOrDefault( + writeCostEntry.getKey(), 1L), + 1L); + avgWriteTimeCostMap.put( + writeCostEntry.getKey(), (double) writeCostEntry.getValue() / writeOpsCount); + } + return avgWriteTimeCostMap; + } + + @Override + public Map<String, Double> getAvgSizeOfEachReadForDisk() { + checkUpdate(); + Map<String, Double> avgSizeOfReadMap = new HashMap<>(diskIdSet.size()); + for (Map.Entry<String, Long> readSectorSizeEntry : incrementReadSectorCountForDisk.entrySet()) { + long readOpsCount = + Long.max( + incrementReadOperationCountForDisk.getOrDefault(readSectorSizeEntry.getKey(), 1L) + + incrementMergedReadOperationCountForDisk.getOrDefault( + readSectorSizeEntry.getKey(), 1L), + 1L); + int sectorSize = + diskSectorSizeMap.getOrDefault(readSectorSizeEntry.getKey(), DEFAULT_SECTOR_SIZE); + avgSizeOfReadMap.put( + readSectorSizeEntry.getKey(), + ((double) readSectorSizeEntry.getValue()) / readOpsCount * sectorSize); + } + return avgSizeOfReadMap; + } + + @Override + public Map<String, Double> getAvgSizeOfEachWriteForDisk() { + checkUpdate(); + Map<String, Double> avgSizeOfWriteMap = new HashMap<>(diskIdSet.size()); + for (Map.Entry<String, Long> writeSectorSizeEntry : + incrementWriteSectorCountForDisk.entrySet()) { + long writeOpsCount = + Long.max( + incrementWriteOperationCountForDisk.getOrDefault(writeSectorSizeEntry.getKey(), 1L) + + incrementMergedWriteOperationCountForDisk.getOrDefault( + writeSectorSizeEntry.getKey(), 1L), + 1L); + int sectorSize = + diskSectorSizeMap.getOrDefault(writeSectorSizeEntry.getKey(), DEFAULT_SECTOR_SIZE); + avgSizeOfWriteMap.put( + writeSectorSizeEntry.getKey(), + ((double) writeSectorSizeEntry.getValue()) / writeOpsCount * sectorSize); + } + return avgSizeOfWriteMap; + } + + @Override + public Map<String, Long> getMergedWriteOperationForDisk() { + checkUpdate(); + return lastMergedWriteCountForDisk; + } + + @Override + public Map<String, Long> getMergedReadOperationForDisk() { + checkUpdate(); + return lastMergedReadCountForDisk; + } + + @Override + public Map<String, Double> getQueueSizeForDisk() { + checkUpdate(); + Map<String, Double> avgQueueSizeMap = new HashMap<>(diskIdSet.size()); + for (Map.Entry<String, Long> entry : incrementTimeInQueueForDisk.entrySet()) { + avgQueueSizeMap.put(entry.getKey(), (((double) entry.getValue()) / updateInterval)); + } + return avgQueueSizeMap; + } + + @Override + public double getActualReadDataSizeForProcess() { + checkUpdate(); + return lastReallyReadSizeForProcess / BYTES_PER_KB; + } + + @Override + public double getActualWriteDataSizeForProcess() { + checkUpdate(); + return lastReallyWriteSizeForProcess / BYTES_PER_KB; + } + + @Override + public long getReadOpsCountForProcess() { + checkUpdate(); + return lastReadOpsCountForProcess; + } + + @Override + public long getWriteOpsCountForProcess() { + checkUpdate(); + return lastWriteOpsCountForProcess; + } + + @Override + public double getAttemptReadSizeForProcess() { + checkUpdate(); + return lastAttemptReadSizeForProcess / BYTES_PER_KB; + } + + @Override + public double getAttemptWriteSizeForProcess() { + checkUpdate(); + return lastAttemptWriteSizeForProcess / BYTES_PER_KB; + } + + @Override + protected void collectDiskId() { + try { + Process process = + Runtime.getRuntime() + .exec( + "powershell.exe -Command \" Get-PhysicalDisk | Select DeviceId | Format-List \""); + BufferedReader reader = + new BufferedReader( + new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)); + String line; + while ((line = reader.readLine()) != null) { + line = line.trim(); + if (line.startsWith("DeviceId : ")) { + diskIdSet.add(line.substring("DeviceId : ".length()).trim()); + } + } + process.waitFor(); + } catch (IOException | InterruptedException e) { + LOGGER.error("Failed to collect disk IDs", e); + } + } + + private void collectDiskInfo() { + for (String diskId : diskIdSet) { + diskSectorSizeMap.put(diskId, DEFAULT_SECTOR_SIZE); + } + } + + @Override + protected void updateInfo() { + super.updateInfo(); + updateDiskInfo(); + updateProcessInfo(); + } + + private void updateDiskInfo() { + Map<String, Long> tempReadSectorCount = + queryCounterLong("Disk Read Bytes/sec"); // 需除以扇区大小估算sector + Map<String, Long> tempWriteSectorCount = queryCounterLong("Disk Write Bytes/sec"); + Map<String, Long> tempReadOperationCount = queryCounterLong("Disk Reads/sec"); + Map<String, Long> tempWriteOperationCount = queryCounterLong("Disk Writes/sec"); + Map<String, Long> tempReadTimeCost = queryCounterLong("Avg. Disk sec/Read"); // ms + Map<String, Long> tempWriteTimeCost = queryCounterLong("Avg. Disk sec/Write"); + Map<String, Long> tempIoBusyTime = queryCounterLong("% Disk Time"); // 忙碌时间百分比 + Map<String, Long> tempTimeInQueue = queryCounterLong("Avg. Disk Queue Length"); // 队列长度,乘时间估算 + for (String diskId : diskIdSet) { + updateSingleDiskInfo( + diskId, + adjustToSector(tempReadSectorCount).getOrDefault(diskId, 0L), + lastReadSectorCountForDisk, + incrementReadSectorCountForDisk); + updateSingleDiskInfo( + diskId, + adjustToSector(tempWriteSectorCount).getOrDefault(diskId, 0L), + lastWriteSectorCountForDisk, + incrementWriteSectorCountForDisk); + updateSingleDiskInfo( + diskId, + tempReadOperationCount.getOrDefault(diskId, 0L), + lastReadOperationCountForDisk, + incrementReadOperationCountForDisk); + updateSingleDiskInfo( + diskId, + tempWriteOperationCount.getOrDefault(diskId, 0L), + lastWriteOperationCountForDisk, + incrementWriteOperationCountForDisk); + updateSingleDiskInfo( + diskId, + 0L, + lastMergedReadCountForDisk, + incrementMergedReadOperationCountForDisk); + updateSingleDiskInfo( + diskId, + 0L, + lastMergedWriteCountForDisk, + incrementMergedWriteOperationCountForDisk); + updateSingleDiskInfo( + diskId, + tempReadTimeCost.getOrDefault(diskId, 0L), + lastReadTimeCostForDisk, + incrementReadTimeCostForDisk); + updateSingleDiskInfo( + diskId, + tempWriteTimeCost.getOrDefault(diskId, 0L), + lastWriteTimeCostForDisk, + incrementWriteTimeCostForDisk); + updateSingleDiskInfo( + diskId, + tempIoBusyTime.getOrDefault(diskId, 0L), + lastIoBusyTimeForDisk, + incrementIoBusyTimeForDisk); + updateSingleDiskInfo( + diskId, + tempTimeInQueue.getOrDefault(diskId, 0L), + lastTimeInQueueForDisk, + incrementTimeInQueueForDisk); + } + } + + private Map<String, Long> adjustToSector(Map<String, Long> byteMap) { + Map<String, Long> sectorMap = new HashMap<>(); + for (Map.Entry<String, Long> entry : byteMap.entrySet()) { + int sectorSize = diskSectorSizeMap.getOrDefault(entry.getKey(), DEFAULT_SECTOR_SIZE); + sectorMap.put(entry.getKey(), entry.getValue() / sectorSize); + } + return sectorMap; + } + + private Map<String, Long> queryCounterLong(String counterName) { + Map<String, Long> result = new HashMap<>(); + try { + String cmd = + "powershell.exe -Command \" Get-Counter -Counter '\\PhysicalDisk(*)\\" + + counterName + + "' | ForEach-Object { $_.CounterSamples } | Where-Object { $_.InstanceName -ne '_total' } | Select-Object InstanceName, CookedValue | Format-List\""; + Process process = Runtime.getRuntime().exec(cmd); + BufferedReader reader = + new BufferedReader( + new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)); + String line; + String instance = null; + while ((line = reader.readLine()) != null) { + line = line.trim(); + if (line.startsWith("InstanceName ")) { + instance = line.substring(line.indexOf(": ") + 2).trim(); + } else if (line.startsWith("CookedValue ") && instance != null) { + String valStr = line.substring(line.indexOf(": ") + 2).trim().replace(",", ""); + try { + result.put(instance.split(" ")[0], (long) Double.parseDouble(valStr)); + } catch (NumberFormatException ignored) { + } + instance = null; + } + } + process.waitFor(); + } catch (Exception e) { + LOGGER.error("Failed to query counter: {}", counterName, e); + } + return result; + } + + private void updateProcessInfo() { + try { + String cmd = + "powershell.exe -Command \" " + + "Get-WmiObject -Query 'SELECT IOReadOperationCount, IOWriteOperationCount, IOReadBytes, IOWriteBytes, IODataBytes, IOOtherBytes FROM Win32_PerfFormattedData_PerfProc_Process WHERE IDProcess=" + + metricConfig.getPid() + + "' | Select-Object IOReadOperationCount, IOWriteOperationCount, IOReadBytes, IOWriteBytes, IODataBytes, IOOtherBytes | Format-List \""; + Process process = Runtime.getRuntime().exec(cmd); + BufferedReader reader = + new BufferedReader( + new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)); + String line; + while ((line = reader.readLine()) != null) { + line = line.trim(); + if (line.startsWith("IOReadOperationCount :")) { + lastReadOpsCountForProcess = Long.parseLong(line.substring(23).trim()); + } else if (line.startsWith("IOWriteOperationCount :")) { + lastWriteOpsCountForProcess = Long.parseLong(line.substring(24).trim()); + } else if (line.startsWith("IOReadBytes :")) { + lastReallyReadSizeForProcess = Long.parseLong(line.substring(14).trim()); + } else if (line.startsWith("IOWriteBytes :")) { + lastReallyWriteSizeForProcess = Long.parseLong(line.substring(15).trim()); + } else if (line.startsWith("IODataBytes :")) { + lastAttemptReadSizeForProcess = Long.parseLong(line.substring(14).trim()); + lastAttemptWriteSizeForProcess = lastAttemptReadSizeForProcess; + } + } + process.waitFor(); + } catch (Exception e) { + LOGGER.error("Failed to update process info", e); + } + } +} diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/disk/WindowsDiskMetricsManager.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/disk/WindowsDiskMetricsManager.java deleted file mode 100644 index abc0194dd14..00000000000 --- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/disk/WindowsDiskMetricsManager.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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.iotdb.metrics.metricsets.disk; - -import org.apache.iotdb.metrics.config.MetricConfig; -import org.apache.iotdb.metrics.config.MetricConfigDescriptor; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -/** Disk Metrics Manager for Windows system. */ -public class WindowsDiskMetricsManager extends AbstractDiskMetricsManager { - private static final MetricConfig METRIC_CONFIG = - MetricConfigDescriptor.getInstance().getMetricConfig(); - - public WindowsDiskMetricsManager() { - init(); - } - - @Override - public Map<String, Double> getReadDataSizeForDisk() { - return getDiskCounter("Disk Read Bytes/sec"); - } - - @Override - public Map<String, Double> getWriteDataSizeForDisk() { - return getDiskCounter("Disk Write Bytes/sec"); - } - - @Override - public Map<String, Long> getReadOperationCountForDisk() { - return convertToLongMap(getDiskCounter("Disk Reads/sec")); - } - - @Override - public Map<String, Long> getWriteOperationCountForDisk() { - return convertToLongMap(getDiskCounter("Disk Writes/sec")); - } - - @Override - public Map<String, Double> getQueueSizeForDisk() { - return getDiskCounter("Current Disk Queue Length"); - } - - @Override - public double getActualReadDataSizeForProcess() { - return getProcessIoBytes("IOReadBytes") / BYTES_PER_KB; - } - - @Override - public double getActualWriteDataSizeForProcess() { - return getProcessIoBytes("IOWriteBytes") / BYTES_PER_KB; - } - - private Map<String, Double> getDiskCounter(String counterName) { - Map<String, Double> result = new HashMap<>(); - String cmd = - "Get-Counter \"\\PhysicalDisk(*)\\" - + counterName - + "\" | Select-Object -ExpandProperty CounterSamples"; - - String output = executePowerShell(cmd); - String[] lines = output.split("\n"); - - for (String line : lines) { - line = line.trim(); - if (line.contains("Path") && line.contains("CookedValue")) { - // format example: \\Computer\PhysicalDisk(0 C:)\Disk Read Bytes/sec : 123456 - try { - String path = - line.substring(line.indexOf("PhysicalDisk("), line.indexOf(")")) - .replace("PhysicalDisk(", ""); - long value = Long.parseLong(line.substring(line.lastIndexOf(":") + 1).trim()); - result.put(path, (double) value); - } catch (Exception ignored) { - } - } - } - return result; - } - - private Map<String, Long> convertToLongMap(Map<String, Double> map) { - Map<String, Long> result = new HashMap<>(); - map.forEach((k, v) -> result.put(k, v.longValue())); - return result; - } - - private long getProcessIoBytes(String field) { - String cmd = - "Get-Process -Id " - + METRIC_CONFIG.getPid() - + " | Select-Object " - + field - + " | Format-List"; - String output = executePowerShell(cmd); - - for (String line : output.split("\n")) { - if (line.contains(":")) { - try { - return Long.parseLong(line.split(":", 2)[1].trim()); - } catch (Exception ignored) { - } - } - } - return 0L; - } - - @Override - protected void collectDiskId() { - diskIdSet = new HashSet<>(getDiskCounter("Disk Read Bytes/sec").keySet()); - } - - private String executePowerShell(String command) { - try { - ProcessBuilder pb = new ProcessBuilder("powershell.exe", "-Command", command); - pb.redirectErrorStream(true); - Process process = pb.start(); - - StringBuilder output = new StringBuilder(); - try (BufferedReader reader = - new BufferedReader(new InputStreamReader(process.getInputStream()))) { - String line; - while ((line = reader.readLine()) != null) { - output.append(line).append("\n"); - } - } - process.waitFor(); - return output.toString(); - } catch (IOException | InterruptedException e) { - e.printStackTrace(); - return ""; - } - } -} diff --git a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/net/WindowsNetMetricManager.java b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/net/WindowsNetMetricManager.java index 23fdc039f7f..965d4387af6 100644 --- a/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/net/WindowsNetMetricManager.java +++ b/iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/metricsets/net/WindowsNetMetricManager.java @@ -41,7 +41,7 @@ public class WindowsNetMetricManager implements INetMetricManager { private static final Logger LOGGER = LoggerFactory.getLogger(WindowsNetMetricManager.class); private static final MetricConfig METRIC_CONFIG = - MetricConfigDescriptor.getInstance().getMetricConfig(); + MetricConfigDescriptor.getInstance().getMetricConfig(); private long lastUpdateTime = 0L; @@ -115,11 +115,12 @@ public class WindowsNetMetricManager implements INetMetricManager { private void updateInterfaces() { try { Process process = - Runtime.getRuntime() - .exec( - "cmd.exe /c chcp 65001 > nul & powershell.exe -Command \"Get-NetAdapter | Select Name | Format-List \""); + Runtime.getRuntime() + .exec( + "cmd.exe /c chcp 65001 > nul & powershell.exe -Command \"Get-NetAdapter | Select Name | Format-List \""); BufferedReader reader = - new BufferedReader(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)); + new BufferedReader( + new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)); String line; while ((line = reader.readLine()) != null) { line = line.trim(); @@ -140,11 +141,12 @@ public class WindowsNetMetricManager implements INetMetricManager { private void updateStatistics() { try { Process process = - Runtime.getRuntime() - .exec( - "cmd.exe /c chcp 65001 > nul & powershell.exe -Command \"Get-NetAdapterStatistics | Format-List Name,ReceivedBytes,SentBytes,ReceivedUnicastPackets,SentUnicastPackets \""); + Runtime.getRuntime() + .exec( + "cmd.exe /c chcp 65001 > nul & powershell.exe -Command \"Get-NetAdapterStatistics | Format-List Name,ReceivedBytes,SentBytes,ReceivedUnicastPackets,SentUnicastPackets \""); BufferedReader reader = - new BufferedReader(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)); + new BufferedReader( + new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)); String line; String currentName = null; while ((line = reader.readLine()) != null) { @@ -199,4 +201,4 @@ public class WindowsNetMetricManager implements INetMetricManager { LOGGER.error("Error updating connection num", e); } } -} \ No newline at end of file +}
