From 43c7fc7eb028c9c5b513431cc426df4a7e0663c6 Mon Sep 17 00:00:00 2001 From: "yineng.huang" Date: Mon, 15 Jul 2024 16:55:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=A7=E8=83=BD=E6=95=B0=E6=8D=AE=E6=89=BE?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E5=BA=94=E7=94=A8id=E5=B0=B1=E9=80=80?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IosDebuggerServiceImpl.java | 2 -- .../thread/AndroidDeviceAllInfoThread.java | 7 ++++--- .../thread/AndroidDeviceInfoByPackageThread.java | 15 +++++++++++---- .../service/thread/IOSDeviceAllInfoThread.java | 5 +++-- .../thread/IOSDeviceInfoByPackageThread.java | 5 +++-- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/IosDebuggerServiceImpl.java b/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/IosDebuggerServiceImpl.java index 5b7ab8b..e8fdec6 100644 --- a/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/IosDebuggerServiceImpl.java +++ b/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/IosDebuggerServiceImpl.java @@ -347,7 +347,6 @@ public class IosDebuggerServiceImpl extends AbstractDebuggerService { iosDeviceInfoByPackageThread = new IOSDeviceInfoByPackageThread(info); iosDeviceInfoByPackageThread.start(); queryDeviceInfoByPackageMap.put(info.getCaseId(), iosDeviceInfoByPackageThread); - logger.debug("记录设备【{}】的应用的性能在任务【{}】中已经开启完毕..................................", info.getDeviceId(),info.getCaseId()); IOSDeviceAllInfoThread deviceAllInfoThread = queryDeviceInfoMap.get(info.getCaseId()); if (null != deviceAllInfoThread) { logger.debug("记录设备【{}】的性能数据,任务【{}】已经存在。。。。。。。。。。", info.getDeviceId(),info.getCaseId()); @@ -358,7 +357,6 @@ public class IosDebuggerServiceImpl extends AbstractDebuggerService { deviceAllInfoThread = new IOSDeviceAllInfoThread(info,iosDeviceInfoByPackageThread.getDeviceCpuNum()); deviceAllInfoThread.start(); queryDeviceInfoMap.put(info.getCaseId(), deviceAllInfoThread); - logger.debug("记录设备【{}】的性能在任务【{}】中已经开启完毕..................................", info.getDeviceId(),info.getCaseId()); return true; } } diff --git a/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/AndroidDeviceAllInfoThread.java b/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/AndroidDeviceAllInfoThread.java index d54f4bf..ebedfbd 100644 --- a/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/AndroidDeviceAllInfoThread.java +++ b/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/AndroidDeviceAllInfoThread.java @@ -1,6 +1,7 @@ package net.northking.cctp.upperComputer.service.thread; import com.alibaba.fastjson.JSON; +import net.northking.cctp.upperComputer.deviceManager.UpperComputerManager; import net.northking.cctp.upperComputer.driver.adb.Adb; import net.northking.cctp.upperComputer.driver.adb.AdbDevice; import net.northking.cctp.upperComputer.driver.adb.AdbTransport; @@ -79,7 +80,7 @@ public class AndroidDeviceAllInfoThread extends Thread { logger.error("无法创建设备连接", e); throw new ParamMistakeException("当前设备未连接,监控设备性能失败"); } - String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); + String stfPath = UpperComputerManager.getInstance().getApplicationPath(); File dir = new File(stfPath + "/perInfoTmp/"); if (!dir.exists()) { dir.mkdirs(); @@ -202,7 +203,7 @@ public class AndroidDeviceAllInfoThread extends Thread { public String stopThread() { logger.info("收到设备【{}】的性能数据停止请求,任务id:{}。。。。。。", info.getDeviceId(), info.getCaseId()); - agentSession.send(CloseSessionCommand.getInstance()); + agentSession.closeSilence(); exit = true; try { cpuOutPutStream.close(); @@ -212,7 +213,7 @@ public class AndroidDeviceAllInfoThread extends Thread { } catch (IOException e) { logger.error("文件流关闭异常", e); } - String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); + String stfPath = UpperComputerManager.getInstance().getApplicationPath(); File dir = new File(stfPath + "/perInfoTmp/"); if (!dir.exists()) { dir.mkdirs(); diff --git a/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/AndroidDeviceInfoByPackageThread.java b/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/AndroidDeviceInfoByPackageThread.java index a367cd5..07cba41 100644 --- a/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/AndroidDeviceInfoByPackageThread.java +++ b/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/AndroidDeviceInfoByPackageThread.java @@ -1,6 +1,7 @@ package net.northking.cctp.upperComputer.service.thread; import com.alibaba.fastjson.JSON; +import net.northking.cctp.upperComputer.deviceManager.UpperComputerManager; import net.northking.cctp.upperComputer.driver.adb.Adb; import net.northking.cctp.upperComputer.driver.adb.AdbDevice; import net.northking.cctp.upperComputer.driver.adb.AdbTransport; @@ -141,7 +142,6 @@ public class AndroidDeviceInfoByPackageThread extends Thread { Thread.sleep(1000 - time); } } catch (InterruptedException exit) { - Thread.currentThread().interrupt(); break; } catch (Exception e) { logger.error("获取安卓性能数据异常", e); @@ -162,7 +162,7 @@ public class AndroidDeviceInfoByPackageThread extends Thread { logger.error("文件流关闭异常", e); } logger.debug("文件流关闭"); - String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); + String stfPath = UpperComputerManager.getInstance().getApplicationPath(); File dir = new File(stfPath + "/perInfoTmp/"); if (!dir.exists()) { dir.mkdirs(); @@ -262,8 +262,9 @@ public class AndroidDeviceInfoByPackageThread extends Thread { private List getPid() { List pids = null; + AndroidAgentSession agentSession = null; try { - AndroidAgentSession agentSession = new AndroidAgentSession(adbDevice, false); + agentSession = new AndroidAgentSession(adbDevice, false); agentSession.start(); List runningAppProcessInfos = agentSession.send(RunningAppProcessInfoCommand.getInstance()); if (!CollectionUtils.isEmpty(runningAppProcessInfos)) { @@ -282,6 +283,10 @@ public class AndroidDeviceInfoByPackageThread extends Thread { } } catch (Exception e) { logger.error("获取Pid失败", e); + }finally { + if (null != agentSession) { + agentSession.closeSilence(); + } } return pids; } @@ -363,7 +368,9 @@ public class AndroidDeviceInfoByPackageThread extends Thread { private float getFlow() { float downFlow = 0f; if (CollectionUtils.isEmpty(appProcessId)) { - appProcessId = getPid(); + logger.warn("设备【{}】在任务【{}】中采集包【】性能数据未获取到应用启动的pid,可能应用已经退出了,退出采集..............",info.getDeviceId(),info.getCaseId(),info.getAppPackage()); +// stopThread(); +// appProcessId = getPid(); } if (CollectionUtils.isEmpty(appProcessId)) { return 0f; diff --git a/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/IOSDeviceAllInfoThread.java b/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/IOSDeviceAllInfoThread.java index 807d976..8adbfbd 100644 --- a/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/IOSDeviceAllInfoThread.java +++ b/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/IOSDeviceAllInfoThread.java @@ -2,6 +2,7 @@ package net.northking.cctp.upperComputer.service.thread; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import net.northking.cctp.upperComputer.deviceManager.UpperComputerManager; import net.northking.cctp.upperComputer.enums.FileBusinessTypeEnum; import net.northking.cctp.upperComputer.entity.Attachment; import net.northking.cctp.upperComputer.entity.DebuggerDeviceInfo; @@ -63,7 +64,7 @@ public class IOSDeviceAllInfoThread extends Thread { logger.error("开启性能获取失败", e); } logger.info("设备性能开始完毕。。。。。。。cpuNum:{},任务id:{}",cpuNum,info.getCaseId()); - String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); + String stfPath = UpperComputerManager.getInstance().getApplicationPath(); File dir = new File(stfPath + "/perInfoTmp/"); if (!dir.exists()) { dir.mkdirs(); @@ -176,7 +177,7 @@ public class IOSDeviceAllInfoThread extends Thread { } catch (IOException e) { logger.error("文件流关闭异常", e); } - String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); + String stfPath = UpperComputerManager.getInstance().getApplicationPath(); File dir = new File(stfPath + "/perInfoTmp/"); if (!dir.exists()) { dir.mkdirs(); diff --git a/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/IOSDeviceInfoByPackageThread.java b/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/IOSDeviceInfoByPackageThread.java index 13a2182..ec83662 100644 --- a/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/IOSDeviceInfoByPackageThread.java +++ b/cctp-atu/atu-upper-computer/src/main/java/net/northking/cctp/upperComputer/service/thread/IOSDeviceInfoByPackageThread.java @@ -2,6 +2,7 @@ package net.northking.cctp.upperComputer.service.thread; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import net.northking.cctp.upperComputer.deviceManager.UpperComputerManager; import net.northking.cctp.upperComputer.enums.FileBusinessTypeEnum; import net.northking.cctp.upperComputer.entity.Attachment; import net.northking.cctp.upperComputer.entity.DebuggerDeviceInfo; @@ -65,7 +66,7 @@ public class IOSDeviceInfoByPackageThread extends Thread { } catch (IOException e) { logger.error("开启性能获取失败", e); } - String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); + String stfPath = UpperComputerManager.getInstance().getApplicationPath(); File dir = new File(stfPath + "/perInfoTmp/"); if (!dir.exists()) { dir.mkdirs(); @@ -176,7 +177,7 @@ public class IOSDeviceInfoByPackageThread extends Thread { } catch (IOException e) { logger.error("文件流关闭异常", e); } - String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); + String stfPath = UpperComputerManager.getInstance().getApplicationPath(); File dir = new File(stfPath + "/perInfoTmp/"); if (!dir.exists()) { dir.mkdirs();