This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new 161d599c32b [fix](fe-ui) support read hardware info from aarch64 MacOS 
(#23708) (#33079)
161d599c32b is described below

commit 161d599c32b91c57cf983c5c3ff15ad96215102a
Author: htyoung <hty551...@hotmail.com>
AuthorDate: Mon Apr 8 23:47:42 2024 +0800

    [fix](fe-ui) support read hardware info from aarch64 MacOS (#23708) (#33079)
    
    update the version of oshi and jna to support read hardware info from 
aarch64 MacOS
    
    (cherry picked from commit da5c780)
---
 fe/fe-core/pom.xml                                 |  4 ++--
 .../httpv2/controller/HardwareInfoController.java  | 22 ++++++++++++----------
 fe/pom.xml                                         |  2 +-
 3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/fe/fe-core/pom.xml b/fe/fe-core/pom.xml
index c4bb07c9442..7a2985cdb28 100644
--- a/fe/fe-core/pom.xml
+++ b/fe/fe-core/pom.xml
@@ -571,12 +571,12 @@ under the License.
         <dependency>
             <groupId>net.java.dev.jna</groupId>
             <artifactId>jna</artifactId>
-            <version>5.5.0</version>
+            <version>5.13.0</version>
         </dependency>
         <dependency>
             <groupId>net.java.dev.jna</groupId>
             <artifactId>jna-platform</artifactId>
-            <version>5.5.0</version>
+            <version>5.13.0</version>
         </dependency>
         <dependency>
             <groupId>software.amazon.awssdk</groupId>
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/controller/HardwareInfoController.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/controller/HardwareInfoController.java
index 8b3802adfa7..08751165481 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/controller/HardwareInfoController.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/controller/HardwareInfoController.java
@@ -36,6 +36,7 @@ import oshi.software.os.NetworkParams;
 import oshi.software.os.OSFileStore;
 import oshi.software.os.OSProcess;
 import oshi.software.os.OperatingSystem;
+import oshi.software.os.OperatingSystem.ProcessSorting;
 import oshi.util.FormatUtil;
 import oshi.util.Util;
 
@@ -101,8 +102,8 @@ public class HardwareInfoController {
         processorInfo.add(" " + processor.getPhysicalProcessorCount() + " 
physical CPU core(s)");
         processorInfo.add(" " + processor.getLogicalProcessorCount() + " 
logical CPU(s)");
 
-        processorInfo.add("Identifier:&nbsp;&nbsp; " + 
processor.getIdentifier());
-        processorInfo.add("ProcessorID:&nbsp;&nbsp; " + 
processor.getProcessorID());
+        processorInfo.add("Identifier:&nbsp;&nbsp; " + 
processor.getProcessorIdentifier().getIdentifier());
+        processorInfo.add("ProcessorID:&nbsp;&nbsp; " + 
processor.getProcessorIdentifier().getProcessorID());
         processorInfo.add("Context Switches/Interrupts:&nbsp;&nbsp; " + 
processor.getContextSwitches()
                 + " / " + processor.getInterrupts() + "<br>");
 
@@ -150,7 +151,7 @@ public class HardwareInfoController {
             procCpu.append(String.format(" %.1f%%", avg * 100));
         }
         processorInfo.add(procCpu.toString());
-        long freq = processor.getVendorFreq();
+        long freq = processor.getProcessorIdentifier().getVendorFreq();
         if (freq > 0) {
             processorInfo.add("Vendor Frequency:&nbsp;&nbsp; " + 
FormatUtil.formatHertz(freq));
         }
@@ -187,7 +188,8 @@ public class HardwareInfoController {
         processInfo.add("Processes:&nbsp;&nbsp; " + os.getProcessCount()
                 + ", Threads:&nbsp;&nbsp; " + os.getThreadCount());
         // Sort by highest CPU
-        List<OSProcess> procs = Arrays.asList(os.getProcesses(5, 
OperatingSystem.ProcessSort.CPU));
+
+        List<OSProcess> procs = os.getProcesses((osProcess) -> true, 
ProcessSorting.CPU_DESC, 5);
 
         processInfo.add("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PID  
%CPU %MEM       VSZ       RSS Name");
         for (int i = 0; i < procs.size() && i < 5; i++) {
@@ -201,7 +203,7 @@ public class HardwareInfoController {
         return processInfo;
     }
 
-    private List<String> getDisks(HWDiskStore[] diskStores) {
+    private List<String> getDisks(List<HWDiskStore> diskStores) {
         List<String> diskInfo = new ArrayList<>();
         diskInfo.add("Disks:&nbsp;&nbsp;");
         for (HWDiskStore disk : diskStores) {
@@ -213,7 +215,7 @@ public class HardwareInfoController {
                     readwrite ? disk.getReads() : "?", readwrite ? 
FormatUtil.formatBytes(disk.getReadBytes()) : "?",
                     readwrite ? disk.getWrites() : "?", readwrite ? 
FormatUtil.formatBytes(disk.getWriteBytes()) : "?",
                     readwrite ? disk.getTransferTime() : "?"));
-            HWPartition[] partitions = disk.getPartitions();
+            List<HWPartition> partitions = disk.getPartitions();
             for (HWPartition part : partitions) {
                 
diskInfo.add(String.format("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
                                 + " |-- %s: %s (%s) Maj:Min=%d:%d, size: 
%s%s", part.getIdentification(),
@@ -232,13 +234,13 @@ public class HardwareInfoController {
         fsInfo.add(String.format("&nbsp;&nbsp;&nbsp;&nbsp;File Descriptors: 
%d/%d", fileSystem.getOpenFileDescriptors(),
                 fileSystem.getMaxFileDescriptors()));
 
-        OSFileStore[] fsArray = fileSystem.getFileStores();
-        for (OSFileStore fs : fsArray) {
+        List<OSFileStore> fsList = fileSystem.getFileStores();
+        for (OSFileStore fs : fsList) {
             long usable = fs.getUsableSpace();
             long total = fs.getTotalSpace();
             
fsInfo.add(String.format("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
                             + "%s (%s) [%s] %s of %s free (%.1f%%), %s of %s 
files free (%.1f%%) is %s "
-                            + (fs.getLogicalVolume() != null && 
fs.getLogicalVolume().length() > 0 ? "[%s]" : "%s")
+                            + (fs.getLogicalVolume() != null && 
!fs.getLogicalVolume().isEmpty() ? "[%s]" : "%s")
                             + " and is mounted at %s",
                     fs.getName(), fs.getDescription().isEmpty() ? "file 
system" : fs.getDescription(), fs.getType(),
                     FormatUtil.formatBytes(usable), 
FormatUtil.formatBytes(fs.getTotalSpace()), 100d * usable / total,
@@ -249,7 +251,7 @@ public class HardwareInfoController {
         return fsInfo;
     }
 
-    private List<String> getNetworkInterfaces(NetworkIF[] networkIFs) {
+    private List<String> getNetworkInterfaces(List<NetworkIF> networkIFs) {
         List<String> getNetwork = new ArrayList<>();
         getNetwork.add("Network interfaces:&nbsp;&nbsp;");
         for (NetworkIF net : networkIFs) {
diff --git a/fe/pom.xml b/fe/pom.xml
index 657446436e9..6215cd0ffb4 100644
--- a/fe/pom.xml
+++ b/fe/pom.xml
@@ -239,7 +239,7 @@ under the License.
         <validation-api.version>1.1.0.Final</validation-api.version>
         <zjsonpatch.version>0.2.3</zjsonpatch.version>
         <kafka-clients.version>3.4.0</kafka-clients.version>
-        <oshi-core.version>4.0.0</oshi-core.version>
+        <oshi-core.version>6.4.5</oshi-core.version>
         <xnio-nio.version>3.8.8.Final</xnio-nio.version>
         <javax.annotation-api.version>1.3.2</javax.annotation-api.version>
         <javax.activation.version>1.2.0</javax.activation.version>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to