性能数据找不到应用id就退出

master
yineng.huang 2024-07-15 16:55:16 +08:00
parent 3e36ba544c
commit 43c7fc7eb0
5 changed files with 21 additions and 13 deletions

View File

@ -347,7 +347,6 @@ public class IosDebuggerServiceImpl extends AbstractDebuggerService {
iosDeviceInfoByPackageThread = new IOSDeviceInfoByPackageThread(info); iosDeviceInfoByPackageThread = new IOSDeviceInfoByPackageThread(info);
iosDeviceInfoByPackageThread.start(); iosDeviceInfoByPackageThread.start();
queryDeviceInfoByPackageMap.put(info.getCaseId(), iosDeviceInfoByPackageThread); queryDeviceInfoByPackageMap.put(info.getCaseId(), iosDeviceInfoByPackageThread);
logger.debug("记录设备【{}】的应用的性能在任务【{}】中已经开启完毕..................................", info.getDeviceId(),info.getCaseId());
IOSDeviceAllInfoThread deviceAllInfoThread = queryDeviceInfoMap.get(info.getCaseId()); IOSDeviceAllInfoThread deviceAllInfoThread = queryDeviceInfoMap.get(info.getCaseId());
if (null != deviceAllInfoThread) { if (null != deviceAllInfoThread) {
logger.debug("记录设备【{}】的性能数据,任务【{}】已经存在。。。。。。。。。。", info.getDeviceId(),info.getCaseId()); logger.debug("记录设备【{}】的性能数据,任务【{}】已经存在。。。。。。。。。。", info.getDeviceId(),info.getCaseId());
@ -358,7 +357,6 @@ public class IosDebuggerServiceImpl extends AbstractDebuggerService {
deviceAllInfoThread = new IOSDeviceAllInfoThread(info,iosDeviceInfoByPackageThread.getDeviceCpuNum()); deviceAllInfoThread = new IOSDeviceAllInfoThread(info,iosDeviceInfoByPackageThread.getDeviceCpuNum());
deviceAllInfoThread.start(); deviceAllInfoThread.start();
queryDeviceInfoMap.put(info.getCaseId(), deviceAllInfoThread); queryDeviceInfoMap.put(info.getCaseId(), deviceAllInfoThread);
logger.debug("记录设备【{}】的性能在任务【{}】中已经开启完毕..................................", info.getDeviceId(),info.getCaseId());
return true; return true;
} }
} }

View File

@ -1,6 +1,7 @@
package net.northking.cctp.upperComputer.service.thread; package net.northking.cctp.upperComputer.service.thread;
import com.alibaba.fastjson.JSON; 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.Adb;
import net.northking.cctp.upperComputer.driver.adb.AdbDevice; import net.northking.cctp.upperComputer.driver.adb.AdbDevice;
import net.northking.cctp.upperComputer.driver.adb.AdbTransport; import net.northking.cctp.upperComputer.driver.adb.AdbTransport;
@ -79,7 +80,7 @@ public class AndroidDeviceAllInfoThread extends Thread {
logger.error("无法创建设备连接", e); logger.error("无法创建设备连接", e);
throw new ParamMistakeException("当前设备未连接,监控设备性能失败"); throw new ParamMistakeException("当前设备未连接,监控设备性能失败");
} }
String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); String stfPath = UpperComputerManager.getInstance().getApplicationPath();
File dir = new File(stfPath + "/perInfoTmp/"); File dir = new File(stfPath + "/perInfoTmp/");
if (!dir.exists()) { if (!dir.exists()) {
dir.mkdirs(); dir.mkdirs();
@ -202,7 +203,7 @@ public class AndroidDeviceAllInfoThread extends Thread {
public String stopThread() { public String stopThread() {
logger.info("收到设备【{}】的性能数据停止请求,任务id:{}。。。。。。", info.getDeviceId(), info.getCaseId()); logger.info("收到设备【{}】的性能数据停止请求,任务id:{}。。。。。。", info.getDeviceId(), info.getCaseId());
agentSession.send(CloseSessionCommand.getInstance()); agentSession.closeSilence();
exit = true; exit = true;
try { try {
cpuOutPutStream.close(); cpuOutPutStream.close();
@ -212,7 +213,7 @@ public class AndroidDeviceAllInfoThread extends Thread {
} catch (IOException e) { } catch (IOException e) {
logger.error("文件流关闭异常", e); logger.error("文件流关闭异常", e);
} }
String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); String stfPath = UpperComputerManager.getInstance().getApplicationPath();
File dir = new File(stfPath + "/perInfoTmp/"); File dir = new File(stfPath + "/perInfoTmp/");
if (!dir.exists()) { if (!dir.exists()) {
dir.mkdirs(); dir.mkdirs();

View File

@ -1,6 +1,7 @@
package net.northking.cctp.upperComputer.service.thread; package net.northking.cctp.upperComputer.service.thread;
import com.alibaba.fastjson.JSON; 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.Adb;
import net.northking.cctp.upperComputer.driver.adb.AdbDevice; import net.northking.cctp.upperComputer.driver.adb.AdbDevice;
import net.northking.cctp.upperComputer.driver.adb.AdbTransport; import net.northking.cctp.upperComputer.driver.adb.AdbTransport;
@ -141,7 +142,6 @@ public class AndroidDeviceInfoByPackageThread extends Thread {
Thread.sleep(1000 - time); Thread.sleep(1000 - time);
} }
} catch (InterruptedException exit) { } catch (InterruptedException exit) {
Thread.currentThread().interrupt();
break; break;
} catch (Exception e) { } catch (Exception e) {
logger.error("获取安卓性能数据异常", e); logger.error("获取安卓性能数据异常", e);
@ -162,7 +162,7 @@ public class AndroidDeviceInfoByPackageThread extends Thread {
logger.error("文件流关闭异常", e); logger.error("文件流关闭异常", e);
} }
logger.debug("文件流关闭"); logger.debug("文件流关闭");
String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); String stfPath = UpperComputerManager.getInstance().getApplicationPath();
File dir = new File(stfPath + "/perInfoTmp/"); File dir = new File(stfPath + "/perInfoTmp/");
if (!dir.exists()) { if (!dir.exists()) {
dir.mkdirs(); dir.mkdirs();
@ -262,8 +262,9 @@ public class AndroidDeviceInfoByPackageThread extends Thread {
private List<String> getPid() { private List<String> getPid() {
List<String> pids = null; List<String> pids = null;
AndroidAgentSession agentSession = null;
try { try {
AndroidAgentSession agentSession = new AndroidAgentSession(adbDevice, false); agentSession = new AndroidAgentSession(adbDevice, false);
agentSession.start(); agentSession.start();
List<RunningAppProcessInfo> runningAppProcessInfos = agentSession.send(RunningAppProcessInfoCommand.getInstance()); List<RunningAppProcessInfo> runningAppProcessInfos = agentSession.send(RunningAppProcessInfoCommand.getInstance());
if (!CollectionUtils.isEmpty(runningAppProcessInfos)) { if (!CollectionUtils.isEmpty(runningAppProcessInfos)) {
@ -282,6 +283,10 @@ public class AndroidDeviceInfoByPackageThread extends Thread {
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("获取Pid失败", e); logger.error("获取Pid失败", e);
}finally {
if (null != agentSession) {
agentSession.closeSilence();
}
} }
return pids; return pids;
} }
@ -363,7 +368,9 @@ public class AndroidDeviceInfoByPackageThread extends Thread {
private float getFlow() { private float getFlow() {
float downFlow = 0f; float downFlow = 0f;
if (CollectionUtils.isEmpty(appProcessId)) { if (CollectionUtils.isEmpty(appProcessId)) {
appProcessId = getPid(); logger.warn("设备【{}】在任务【{}】中采集包【】性能数据未获取到应用启动的pid可能应用已经退出了退出采集..............",info.getDeviceId(),info.getCaseId(),info.getAppPackage());
// stopThread();
// appProcessId = getPid();
} }
if (CollectionUtils.isEmpty(appProcessId)) { if (CollectionUtils.isEmpty(appProcessId)) {
return 0f; return 0f;

View File

@ -2,6 +2,7 @@ package net.northking.cctp.upperComputer.service.thread;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import net.northking.cctp.upperComputer.deviceManager.UpperComputerManager;
import net.northking.cctp.upperComputer.enums.FileBusinessTypeEnum; import net.northking.cctp.upperComputer.enums.FileBusinessTypeEnum;
import net.northking.cctp.upperComputer.entity.Attachment; import net.northking.cctp.upperComputer.entity.Attachment;
import net.northking.cctp.upperComputer.entity.DebuggerDeviceInfo; import net.northking.cctp.upperComputer.entity.DebuggerDeviceInfo;
@ -63,7 +64,7 @@ public class IOSDeviceAllInfoThread extends Thread {
logger.error("开启性能获取失败", e); logger.error("开启性能获取失败", e);
} }
logger.info("设备性能开始完毕。。。。。。。cpuNum:{},任务id:{}",cpuNum,info.getCaseId()); 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/"); File dir = new File(stfPath + "/perInfoTmp/");
if (!dir.exists()) { if (!dir.exists()) {
dir.mkdirs(); dir.mkdirs();
@ -176,7 +177,7 @@ public class IOSDeviceAllInfoThread extends Thread {
} catch (IOException e) { } catch (IOException e) {
logger.error("文件流关闭异常", e); logger.error("文件流关闭异常", e);
} }
String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); String stfPath = UpperComputerManager.getInstance().getApplicationPath();
File dir = new File(stfPath + "/perInfoTmp/"); File dir = new File(stfPath + "/perInfoTmp/");
if (!dir.exists()) { if (!dir.exists()) {
dir.mkdirs(); dir.mkdirs();

View File

@ -2,6 +2,7 @@ package net.northking.cctp.upperComputer.service.thread;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import net.northking.cctp.upperComputer.deviceManager.UpperComputerManager;
import net.northking.cctp.upperComputer.enums.FileBusinessTypeEnum; import net.northking.cctp.upperComputer.enums.FileBusinessTypeEnum;
import net.northking.cctp.upperComputer.entity.Attachment; import net.northking.cctp.upperComputer.entity.Attachment;
import net.northking.cctp.upperComputer.entity.DebuggerDeviceInfo; import net.northking.cctp.upperComputer.entity.DebuggerDeviceInfo;
@ -65,7 +66,7 @@ public class IOSDeviceInfoByPackageThread extends Thread {
} catch (IOException e) { } catch (IOException e) {
logger.error("开启性能获取失败", e); logger.error("开启性能获取失败", e);
} }
String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); String stfPath = UpperComputerManager.getInstance().getApplicationPath();
File dir = new File(stfPath + "/perInfoTmp/"); File dir = new File(stfPath + "/perInfoTmp/");
if (!dir.exists()) { if (!dir.exists()) {
dir.mkdirs(); dir.mkdirs();
@ -176,7 +177,7 @@ public class IOSDeviceInfoByPackageThread extends Thread {
} catch (IOException e) { } catch (IOException e) {
logger.error("文件流关闭异常", e); logger.error("文件流关闭异常", e);
} }
String stfPath = SpringUtils.getProperties("nk.mobile-computer.stfPath"); String stfPath = UpperComputerManager.getInstance().getApplicationPath();
File dir = new File(stfPath + "/perInfoTmp/"); File dir = new File(stfPath + "/perInfoTmp/");
if (!dir.exists()) { if (!dir.exists()) {
dir.mkdirs(); dir.mkdirs();