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

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 5bb869e29 [benchmark] benchmark module code optimization  (#2308)
5bb869e29 is described below

commit 5bb869e29c6809377f575317b47c91ac29effefd
Author: ChengJie1053 <[email protected]>
AuthorDate: Fri Nov 17 14:13:14 2023 +0800

    [benchmark] benchmark module code optimization  (#2308)
---
 .../benchmark/metric/cpu/CpuMetricReceiver.java    |  3 +-
 .../paimon/benchmark/metric/cpu/SysInfoLinux.java  | 73 +++++++---------------
 2 files changed, 23 insertions(+), 53 deletions(-)

diff --git 
a/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/metric/cpu/CpuMetricReceiver.java
 
b/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/metric/cpu/CpuMetricReceiver.java
index 84db0bf30..022e1c726 100644
--- 
a/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/metric/cpu/CpuMetricReceiver.java
+++ 
b/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/metric/cpu/CpuMetricReceiver.java
@@ -35,7 +35,6 @@ import java.net.Socket;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
@@ -153,7 +152,7 @@ public class CpuMetricReceiver implements Closeable {
         }
     }
 
-    public static void main(String[] args) throws ExecutionException, 
InterruptedException {
+    public static void main(String[] args) throws InterruptedException {
         // start metric servers
         Configuration conf = BenchmarkGlobalConfiguration.loadConfiguration();
         String reporterAddress = 
conf.get(BenchmarkOptions.METRIC_REPORTER_HOST);
diff --git 
a/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/metric/cpu/SysInfoLinux.java
 
b/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/metric/cpu/SysInfoLinux.java
index 776377589..e4a5cfa57 100644
--- 
a/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/metric/cpu/SysInfoLinux.java
+++ 
b/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/metric/cpu/SysInfoLinux.java
@@ -18,11 +18,7 @@
 
 package org.apache.paimon.benchmark.metric.cpu;
 
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
+import java.io.*;
 import java.math.BigInteger;
 import java.nio.charset.Charset;
 import java.util.HashMap;
@@ -253,15 +249,8 @@ public class SysInfoLinux {
             }
         } catch (IOException io) {
         } finally {
-            // Close the streams
-            try {
-                fReader.close();
-                try {
-                    in.close();
-                } catch (IOException i) {
-                }
-            } catch (IOException i) {
-            }
+            closeReader(fReader);
+            closeReader(in);
         }
 
         readMemInfoFile = true;
@@ -317,15 +306,8 @@ public class SysInfoLinux {
             numCpuSocket = physicalIds.size();
         } catch (IOException io) {
         } finally {
-            // Close the streams
-            try {
-                fReader.close();
-                try {
-                    in.close();
-                } catch (IOException i) {
-                }
-            } catch (IOException i) {
-            }
+            closeReader(fReader);
+            closeReader(in);
         }
         readCpuInfoFile = true;
     }
@@ -362,15 +344,8 @@ public class SysInfoLinux {
             }
         } catch (IOException io) {
         } finally {
-            // Close the streams
-            try {
-                fReader.close();
-                try {
-                    in.close();
-                } catch (IOException i) {
-                }
-            } catch (IOException i) {
-            }
+            closeReader(fReader);
+            closeReader(in);
         }
     }
 
@@ -415,15 +390,8 @@ public class SysInfoLinux {
             }
         } catch (IOException io) {
         } finally {
-            // Close the streams
-            try {
-                fReader.close();
-                try {
-                    in.close();
-                } catch (IOException i) {
-                }
-            } catch (IOException i) {
-            }
+            closeReader(fReader);
+            closeReader(in);
         }
     }
 
@@ -485,11 +453,7 @@ public class SysInfoLinux {
             }
         } catch (IOException e) {
         } finally {
-            // Close the streams
-            try {
-                in.close();
-            } catch (IOException e) {
-            }
+            closeReader(in);
         }
     }
 
@@ -533,11 +497,7 @@ public class SysInfoLinux {
         } catch (IOException | NumberFormatException e) {
             return defSector;
         } finally {
-            // Close the streams
-            try {
-                in.close();
-            } catch (IOException e) {
-            }
+            closeReader(in);
         }
     }
 
@@ -623,6 +583,17 @@ public class SysInfoLinux {
         return numDisksBytesWritten;
     }
 
+    public void closeReader(Reader reader) {
+        // Close the streams
+        if (reader != null) {
+            try {
+                reader.close();
+            } catch (IOException e) {
+
+            }
+        }
+    }
+
     /**
      * Test the {@link SysInfoLinux}.
      *

Reply via email to