解决ios一台设备同时存在两个线程获取性能数据

master
yineng.huang 2024-07-12 11:51:49 +08:00
parent c2b8a98a2c
commit 3e36ba544c
2 changed files with 18 additions and 12 deletions

View File

@ -129,6 +129,7 @@ public class AndroidDebuggerServiceImpl extends AbstractDebuggerService {
androidDeviceInfoByPackageThread = new AndroidDeviceInfoByPackageThread(info);
androidDeviceInfoByPackageThread.start();
queryDeviceInfoByPackageMap.put(info.getDeviceId(), androidDeviceInfoByPackageThread);
logger.debug("记录设备【{}】的应用的性能在任务【{}】中已经开启完毕..................................", info.getDeviceId(),info.getCaseId());
AndroidDeviceAllInfoThread androidDeviceAllInfoThread = queryDeviceInfoMap.get(info.getCaseId());
if (androidDeviceAllInfoThread != null ) {
logger.debug("记录设备【{}】的性能数据,任务【{}】已经存在。。。。。。。。。。", info.getDeviceId(),info.getCaseId());
@ -139,6 +140,7 @@ public class AndroidDebuggerServiceImpl extends AbstractDebuggerService {
androidDeviceAllInfoThread = new AndroidDeviceAllInfoThread(info);
androidDeviceAllInfoThread.start();
queryDeviceInfoMap.put(info.getCaseId(), androidDeviceAllInfoThread);
logger.debug("记录设备【{}】的性能在任务【{}】中已经开启完毕..................................", info.getDeviceId(),info.getCaseId());
return true;
}

View File

@ -338,23 +338,27 @@ public class IosDebuggerServiceImpl extends AbstractDebuggerService {
@Override
public boolean recordDevicePer(DebuggerDeviceInfo info) {
IOSDeviceInfoByPackageThread iosDeviceInfoByPackageThread = queryDeviceInfoByPackageMap.get(info.getCaseId());
if (null == iosDeviceInfoByPackageThread || !iosDeviceInfoByPackageThread.isAlive() || iosDeviceInfoByPackageThread.isInterrupted()) {
logger.debug("开始记录任务id【{}】的应用的参数。。。。。。。。。。", info.getCaseId());
iosDeviceInfoByPackageThread = new IOSDeviceInfoByPackageThread(info);
iosDeviceInfoByPackageThread.start();
queryDeviceInfoByPackageMap.put(info.getCaseId(), iosDeviceInfoByPackageThread);
if (null != iosDeviceInfoByPackageThread) {
logger.debug("记录设备【{}】的应用的性能在任务【{}】中已经存在,干掉上一个。。。。。。。。。。", info.getDeviceId(),info.getCaseId());
iosDeviceInfoByPackageThread.stopThread();
} else {
logger.debug("任务id【{}】的应用的参数线程存在,无需创建。。。。。。。。。。", info.getCaseId());
logger.debug("记录设备【{}】的应用的性能线程不存在。。。。。。。。。。", info.getDeviceId());
}
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 || !deviceAllInfoThread.isAlive() || deviceAllInfoThread.isInterrupted()) {
logger.debug("开始记录任务id【{}】的设备的参数。。。。。。。。。。", info.getCaseId());
deviceAllInfoThread = new IOSDeviceAllInfoThread(info,iosDeviceInfoByPackageThread.getDeviceCpuNum());
deviceAllInfoThread.start();
queryDeviceInfoMap.put(info.getCaseId(), deviceAllInfoThread);
if (null != deviceAllInfoThread) {
logger.debug("记录设备【{}】的性能数据,任务【{}】已经存在。。。。。。。。。。", info.getDeviceId(),info.getCaseId());
deviceAllInfoThread.stopThread();
} else {
logger.debug("任务id【{}】的设备的参数线程存在,无需创建。。。。。。。。。。", info.getCaseId());
logger.debug("记录设备【{}】性能线程不存在。。。。。。。。。。", info.getDeviceId());
}
deviceAllInfoThread = new IOSDeviceAllInfoThread(info,iosDeviceInfoByPackageThread.getDeviceCpuNum());
deviceAllInfoThread.start();
queryDeviceInfoMap.put(info.getCaseId(), deviceAllInfoThread);
logger.debug("记录设备【{}】的性能在任务【{}】中已经开启完毕..................................", info.getDeviceId(),info.getCaseId());
return true;
}
}