mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2025-02-25 13:20:37 +00:00
commit
a16bae6bc8
@ -264,7 +264,7 @@ public abstract class AbstractDataStore<T> extends SqlRunnable {
|
||||
} catch (SQLException | IllegalAccessException | InstantiationException | NoSuchFieldException exe) {
|
||||
LOGGER.error("select Exception: ", exe);
|
||||
} finally {
|
||||
close(rs, connection);
|
||||
close(stmt, rs, connection);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
@ -68,6 +68,8 @@ import static ohos.devtools.views.common.Constant.IS_SUPPORT_NEW_HDC;
|
||||
|
||||
/**
|
||||
* get trace data
|
||||
*
|
||||
* @since 2021/5/19 16:39
|
||||
*/
|
||||
public class SystemTraceHelper {
|
||||
private static final Logger LOGGER = LogManager.getLogger(SystemTraceHelper.class);
|
||||
|
@ -241,7 +241,7 @@ public class CpuDataConsumer extends AbsDataConsumer {
|
||||
threadValue =
|
||||
100.0 * (threadInfo.getThreadCpuTimeMs() - threadInfo.getPrevThreadCpuTimeMs()) / elapsedTime;
|
||||
}
|
||||
BigDecimal bigDecimal = new BigDecimal(threadValue);
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(threadValue);
|
||||
ChartDataModel threadInfoModel = new ChartDataModel();
|
||||
threadInfoModel.setIndex(threadInfo.getTid());
|
||||
threadInfoModel.setColor(JBColor.GREEN);
|
||||
|
@ -18,10 +18,8 @@ package ohos.devtools.datasources.utils.datahandler.datapoller;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import ohos.devtools.datasources.databases.datatable.MemoryTable;
|
||||
import ohos.devtools.datasources.databases.datatable.enties.ProcessMemInfo;
|
||||
import ohos.devtools.datasources.transport.grpc.service.AgentPluginNetworkData;
|
||||
import ohos.devtools.datasources.transport.grpc.service.CommonTypes;
|
||||
import ohos.devtools.datasources.transport.grpc.service.MemoryPluginResult;
|
||||
import ohos.devtools.datasources.utils.common.util.CommonUtil;
|
||||
import ohos.devtools.datasources.utils.common.util.DateTimeUtil;
|
||||
import ohos.devtools.datasources.utils.profilerlog.ProfilerLogManager;
|
||||
import ohos.devtools.datasources.utils.session.service.SessionManager;
|
||||
@ -51,7 +49,8 @@ import static ohos.devtools.views.layout.chartview.MonitorItemDetail.MEM_STACK;
|
||||
public class MemoryDataConsumer extends AbsDataConsumer {
|
||||
private static final Logger DATA = LogManager.getLogger("Data");
|
||||
private static final Logger LOGGER = LogManager.getLogger(MemoryDataConsumer.class);
|
||||
private static final long SAVE_FREQ = 1000;
|
||||
private static final long SAVE_FREQ = 1000L;
|
||||
|
||||
private List<ProcessMemInfo> processMemInfoList = new ArrayList<>();
|
||||
private Queue<CommonTypes.ProfilerPluginData> queue;
|
||||
private MemoryTable memoryTable;
|
||||
@ -66,6 +65,7 @@ public class MemoryDataConsumer extends AbsDataConsumer {
|
||||
* MemoryDataConsumer
|
||||
*/
|
||||
public MemoryDataConsumer() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,8 @@ public class MonitorConfigManager {
|
||||
/**
|
||||
* dataMap
|
||||
*/
|
||||
public static ConcurrentHashMap<Long, Map<String, LinkedList<String>>> dataMap = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentHashMap<Long, Map<String, LinkedList<String>>> DATA_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
private static volatile MonitorConfigManager singleton;
|
||||
|
||||
private MonitorConfigManager() {
|
||||
@ -106,7 +107,7 @@ public class MonitorConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
dataMap.put(localSessionId, monitors);
|
||||
DATA_MAP.put(localSessionId, monitors);
|
||||
// 解析后的数据先写表
|
||||
MonitorConfigDao.getInstance().insertMonitorInfos(monitorInfos);
|
||||
if (ProfilerLogManager.isInfoEnabled()) {
|
||||
|
@ -1305,6 +1305,9 @@ public class SessionManager {
|
||||
} finally {
|
||||
try {
|
||||
dataOut.flush();
|
||||
if (dataOut != null) {
|
||||
dataOut.close();
|
||||
}
|
||||
if (fileOut != null) {
|
||||
fileOut.close();
|
||||
}
|
||||
|
@ -226,6 +226,7 @@ public class CpuDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error(" SQLException {}", throwables.getMessage());
|
||||
}
|
||||
close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -275,6 +276,7 @@ public class CpuDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error(" SQLException {}", throwAbles.getMessage());
|
||||
}
|
||||
close();
|
||||
}
|
||||
// 取最后一个点的后一个点用于Chart绘制,填充空白,解决边界闪烁
|
||||
if (isNeedHeadTail) {
|
||||
@ -328,6 +330,7 @@ public class CpuDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error(" SQLException {}", throwAbles.getMessage());
|
||||
}
|
||||
close();
|
||||
}
|
||||
// 取最后一个点的后一个点用于Chart绘制,填充空白,解决边界闪烁
|
||||
if (isNeedHeadTail) {
|
||||
@ -380,6 +383,7 @@ public class CpuDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error(" SQLException {}", throwAbles.getMessage());
|
||||
}
|
||||
close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -428,6 +432,7 @@ public class CpuDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error(" SQLException {}", throwAbles.getMessage());
|
||||
}
|
||||
close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -531,4 +536,32 @@ public class CpuDao extends AbstractDataStore {
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
private void close() {
|
||||
if (conn != null) {
|
||||
try {
|
||||
cpuSelectMap.values().forEach(preparedStatement -> {
|
||||
try {
|
||||
preparedStatement.close();
|
||||
} catch (SQLException sqlException) {
|
||||
sqlException.printStackTrace();
|
||||
}
|
||||
});
|
||||
cpuSelectMap.clear();
|
||||
threadSelectMap.values().forEach(preparedStatement -> {
|
||||
try {
|
||||
preparedStatement.close();
|
||||
} catch (SQLException sqlException) {
|
||||
sqlException.printStackTrace();
|
||||
}
|
||||
});
|
||||
threadSelectMap.clear();
|
||||
conn.close();
|
||||
} catch (SQLException sqlException) {
|
||||
sqlException.printStackTrace();
|
||||
} finally {
|
||||
conn = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,18 +49,6 @@ public class ClassInfoDao extends AbstractDataStore {
|
||||
createClassInfo();
|
||||
}
|
||||
|
||||
private Connection getConnection(String tableName) {
|
||||
if (ProfilerLogManager.isInfoEnabled()) {
|
||||
LOGGER.info("getConnection");
|
||||
}
|
||||
Optional<Connection> optionalConnection = getConnectByTable(tableName);
|
||||
Connection conn = null;
|
||||
if (optionalConnection.isPresent()) {
|
||||
conn = optionalConnection.get();
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
/**
|
||||
* createClassInfo
|
||||
*
|
||||
@ -90,12 +78,15 @@ public class ClassInfoDao extends AbstractDataStore {
|
||||
Connection conn = null;
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
conn = getConnection("ClassInfo");
|
||||
String sql = "insert into ClassInfo (cId,className) values (?,?)";
|
||||
ps = conn.prepareStatement(sql);
|
||||
ps.setInt(1, classInfo.getcId());
|
||||
ps.setString(2, classInfo.getClassName());
|
||||
ps.executeUpdate();
|
||||
Optional<Connection> optionalConnection = getConnectByTable("ClassInfo");
|
||||
if (optionalConnection.isPresent()) {
|
||||
conn = optionalConnection.get();
|
||||
String sql = "insert into ClassInfo (cId,className) values (?,?)";
|
||||
ps = conn.prepareStatement(sql);
|
||||
ps.setInt(1, classInfo.getcId());
|
||||
ps.setString(2, classInfo.getClassName());
|
||||
ps.executeUpdate();
|
||||
}
|
||||
} catch (SQLException throwables) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("memoryHeapInfo Exception {}", throwables.getMessage());
|
||||
@ -121,18 +112,22 @@ public class ClassInfoDao extends AbstractDataStore {
|
||||
Connection conn = null;
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
conn = getConnection("ClassInfo");
|
||||
conn.setAutoCommit(false);
|
||||
String sql = "insert into ClassInfo (cId,className) values (?,?)";
|
||||
ps = conn.prepareStatement(sql);
|
||||
for (ClassInfo classInfo : classInfos) {
|
||||
ps.setInt(1, classInfo.getcId());
|
||||
ps.setString(2, classInfo.getClassName());
|
||||
ps.addBatch();
|
||||
Optional<Connection> optionalConnection = getConnectByTable("ClassInfo");
|
||||
if (optionalConnection.isPresent()) {
|
||||
conn = optionalConnection.get();
|
||||
conn.setAutoCommit(false);
|
||||
String sql = "insert into ClassInfo (cId,className) values (?,?)";
|
||||
ps = conn.prepareStatement(sql);
|
||||
for (ClassInfo classInfo : classInfos) {
|
||||
ps.setInt(1, classInfo.getcId());
|
||||
ps.setString(2, classInfo.getClassName());
|
||||
ps.addBatch();
|
||||
}
|
||||
int[] results = ps.executeBatch();
|
||||
conn.commit();
|
||||
return true;
|
||||
}
|
||||
int[] results = ps.executeBatch();
|
||||
conn.commit();
|
||||
return true;
|
||||
return false;
|
||||
} catch (SQLException throwables) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("memoryHeapInfo Exception {}", throwables.getMessage());
|
||||
@ -153,29 +148,32 @@ public class ClassInfoDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isInfoEnabled()) {
|
||||
LOGGER.info("getAllClassInfoData");
|
||||
}
|
||||
Connection conn = getConnection("ClassInfo");
|
||||
PreparedStatement ps = null;
|
||||
Optional<Connection> optionalConnection = getConnectByTable("ClassInfo");
|
||||
ArrayList<ClassInfo> classInfos = new ArrayList<>();
|
||||
try {
|
||||
String sql = "select cId,className from ClassInfo";
|
||||
ps = conn.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
ClassInfo classInfo = null;
|
||||
while (rs.next()) {
|
||||
classInfo = new ClassInfo();
|
||||
Integer cId = rs.getInt("cId");
|
||||
String className = rs.getString("className");
|
||||
classInfo.setcId(cId);
|
||||
classInfo.setClassName(className);
|
||||
classInfos.add(classInfo);
|
||||
if (optionalConnection.isPresent()) {
|
||||
Connection conn = optionalConnection.get();
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql = "select cId,className from ClassInfo";
|
||||
ps = conn.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
ClassInfo classInfo = null;
|
||||
while (rs.next()) {
|
||||
classInfo = new ClassInfo();
|
||||
Integer cId = rs.getInt("cId");
|
||||
String className = rs.getString("className");
|
||||
classInfo.setcId(cId);
|
||||
classInfo.setClassName(className);
|
||||
classInfos.add(classInfo);
|
||||
}
|
||||
return classInfos;
|
||||
} catch (SQLException throwables) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("memoryHeapInfo Exception {}", throwables.getMessage());
|
||||
}
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
return classInfos;
|
||||
} catch (SQLException throwables) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("memoryHeapInfo Exception {}", throwables.getMessage());
|
||||
}
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
return classInfos;
|
||||
}
|
||||
@ -190,23 +188,26 @@ public class ClassInfoDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isInfoEnabled()) {
|
||||
LOGGER.info("getClassIdByClassName");
|
||||
}
|
||||
Connection conn = getConnection("ClassInfo");
|
||||
PreparedStatement ps = null;
|
||||
Optional<Connection> optionalConnection = getConnectByTable("ClassInfo");
|
||||
int cId = 0;
|
||||
try {
|
||||
String sql = "select cId from ClassInfo where className = '" + className + "'";
|
||||
Statement statement = conn.createStatement();
|
||||
ResultSet rs = statement.executeQuery(sql);
|
||||
if (rs.next()) {
|
||||
cId = rs.getInt("cId");
|
||||
if (optionalConnection.isPresent()) {
|
||||
Connection conn = optionalConnection.get();
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql = "select cId from ClassInfo where className = '" + className + "'";
|
||||
Statement statement = conn.createStatement();
|
||||
ResultSet rs = statement.executeQuery(sql);
|
||||
if (rs.next()) {
|
||||
cId = rs.getInt("cId");
|
||||
}
|
||||
return cId;
|
||||
} catch (SQLException throwables) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("memoryHeapInfo Exception {}", throwables.getMessage());
|
||||
}
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
return cId;
|
||||
} catch (SQLException throwables) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("memoryHeapInfo Exception {}", throwables.getMessage());
|
||||
}
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
return cId;
|
||||
}
|
||||
|
@ -112,27 +112,31 @@ public class MemoryHeapDao extends AbstractDataStore {
|
||||
Connection conn = null;
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
conn = getConnection("MemoryHeapInfo");
|
||||
conn.setAutoCommit(false);
|
||||
String sql = "insert into "
|
||||
+ "MemoryHeapInfo("
|
||||
+ "cId, "
|
||||
+ "heapId, "
|
||||
+ "sessionId, "
|
||||
+ "allocations, "
|
||||
+ "deallocations, "
|
||||
+ "totalCount, "
|
||||
+ "shallowSize, "
|
||||
+ "createTime, "
|
||||
+ "instanceId) "
|
||||
+ "values(?,?,?,?,?,?,?,?,?)";
|
||||
ps = conn.prepareStatement(sql);
|
||||
setPreparedStatement(memoryHeapInfos, ps);
|
||||
ps.executeBatch();
|
||||
conn.commit();
|
||||
conn.setAutoCommit(true);
|
||||
ps.clearParameters();
|
||||
return true;
|
||||
Optional<Connection> optionalConnection = getConnectByTable("MemoryHeapInfo");
|
||||
if (optionalConnection.isPresent()) {
|
||||
conn = optionalConnection.get();
|
||||
conn.setAutoCommit(false);
|
||||
String sql = "insert into "
|
||||
+ "MemoryHeapInfo("
|
||||
+ "cId, "
|
||||
+ "heapId, "
|
||||
+ "sessionId, "
|
||||
+ "allocations, "
|
||||
+ "deallocations, "
|
||||
+ "totalCount, "
|
||||
+ "shallowSize, "
|
||||
+ "createTime, "
|
||||
+ "instanceId) "
|
||||
+ "values(?,?,?,?,?,?,?,?,?)";
|
||||
ps = conn.prepareStatement(sql);
|
||||
setPreparedStatement(memoryHeapInfos, ps);
|
||||
ps.executeBatch();
|
||||
conn.commit();
|
||||
conn.setAutoCommit(true);
|
||||
ps.clearParameters();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (SQLException sqlException) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("insert MemoryHeap {}", sqlException.getMessage());
|
||||
@ -172,39 +176,42 @@ public class MemoryHeapDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isInfoEnabled()) {
|
||||
LOGGER.info("getAllMemoryHeapInfos");
|
||||
}
|
||||
Connection conn = getConnection("MemoryHeapInfo");
|
||||
PreparedStatement ps = null;
|
||||
Optional<Connection> optionalConnection = getConnectByTable("MemoryHeapInfo");
|
||||
ArrayList<MemoryHeapInfo> memoryHeapInfos = new ArrayList<>();
|
||||
try {
|
||||
String sql =
|
||||
"select "
|
||||
+ "cId, "
|
||||
+ "heapId, "
|
||||
+ "sessionId, "
|
||||
+ "allocations, "
|
||||
+ "deallocations, "
|
||||
+ "totalCount, "
|
||||
+ "shallowSize, "
|
||||
+ "createTime, "
|
||||
+ "instanceId, "
|
||||
+ "updateTime "
|
||||
+ "from "
|
||||
+ "MemoryHeapInfo "
|
||||
+ "where "
|
||||
+ "sessionId = ?";
|
||||
ps = conn.prepareStatement(sql);
|
||||
ps.setLong(1, sessionId);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
MemoryHeapInfo memoryHeapInfo = null;
|
||||
getMemoryHeapData(sessionId, memoryHeapInfos, rs);
|
||||
ps.clearParameters();
|
||||
return memoryHeapInfos;
|
||||
} catch (SQLException sqlException) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("memoryHeapInfo Exception {}", sqlException.getMessage());
|
||||
if (optionalConnection.isPresent()) {
|
||||
Connection conn = optionalConnection.get();
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql =
|
||||
"select "
|
||||
+ "cId, "
|
||||
+ "heapId, "
|
||||
+ "sessionId, "
|
||||
+ "allocations, "
|
||||
+ "deallocations, "
|
||||
+ "totalCount, "
|
||||
+ "shallowSize, "
|
||||
+ "createTime, "
|
||||
+ "instanceId, "
|
||||
+ "updateTime "
|
||||
+ "from "
|
||||
+ "MemoryHeapInfo "
|
||||
+ "where "
|
||||
+ "sessionId = ?";
|
||||
ps = conn.prepareStatement(sql);
|
||||
ps.setLong(1, sessionId);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
MemoryHeapInfo memoryHeapInfo = null;
|
||||
getMemoryHeapData(sessionId, memoryHeapInfos, rs);
|
||||
ps.clearParameters();
|
||||
return memoryHeapInfos;
|
||||
} catch (SQLException sqlException) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("memoryHeapInfo Exception {}", sqlException.getMessage());
|
||||
}
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
return memoryHeapInfos;
|
||||
}
|
||||
@ -251,41 +258,44 @@ public class MemoryHeapDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isInfoEnabled()) {
|
||||
LOGGER.info("getMemoryHeapInfos");
|
||||
}
|
||||
Connection conn = getConnection("MemoryHeapInfo");
|
||||
PreparedStatement ps = null;
|
||||
Optional<Connection> optionalConnection = getConnectByTable("MemoryHeapInfo");
|
||||
List<AgentHeapBean> memoryHeapInfos = new ArrayList<>();
|
||||
try {
|
||||
String sql = getSql();
|
||||
ps = conn.prepareStatement(sql);
|
||||
setPreparedStatementData(sessionId, startTime, endTime, ps);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
AgentHeapBean memoryHeapInfo = null;
|
||||
while (rs.next()) {
|
||||
memoryHeapInfo = new AgentHeapBean();
|
||||
Integer cId = rs.getInt("cId");
|
||||
String className = rs.getString("className");
|
||||
Integer allocations = rs.getInt("allocations");
|
||||
Integer deallocations = rs.getInt("deallocations");
|
||||
Integer totalCount = rs.getInt("totalCount");
|
||||
Long shallowSize = rs.getLong("shallowSize");
|
||||
memoryHeapInfo.setAgentClazzId(cId);
|
||||
memoryHeapInfo.setAgentHeapId(0);
|
||||
memoryHeapInfo.setSessionId(sessionId);
|
||||
memoryHeapInfo.setAgentClazzName(className);
|
||||
memoryHeapInfo.setAgentAllocationsCount(allocations - deallocations);
|
||||
memoryHeapInfo.setAgentDeAllocationsCount(deallocations);
|
||||
memoryHeapInfo.setAgentTotalInstanceCount(totalCount);
|
||||
memoryHeapInfo.setAgentTotalshallowSize(shallowSize);
|
||||
memoryHeapInfos.add(memoryHeapInfo);
|
||||
if (optionalConnection.isPresent()) {
|
||||
Connection conn = optionalConnection.get();
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql = getSql();
|
||||
ps = conn.prepareStatement(sql);
|
||||
setPreparedStatementData(sessionId, startTime, endTime, ps);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
AgentHeapBean memoryHeapInfo = null;
|
||||
while (rs.next()) {
|
||||
memoryHeapInfo = new AgentHeapBean();
|
||||
Integer cId = rs.getInt("cId");
|
||||
String className = rs.getString("className");
|
||||
Integer allocations = rs.getInt("allocations");
|
||||
Integer deallocations = rs.getInt("deallocations");
|
||||
Integer totalCount = rs.getInt("totalCount");
|
||||
Long shallowSize = rs.getLong("shallowSize");
|
||||
memoryHeapInfo.setAgentClazzId(cId);
|
||||
memoryHeapInfo.setAgentHeapId(0);
|
||||
memoryHeapInfo.setSessionId(sessionId);
|
||||
memoryHeapInfo.setAgentClazzName(className);
|
||||
memoryHeapInfo.setAgentAllocationsCount(allocations - deallocations);
|
||||
memoryHeapInfo.setAgentDeAllocationsCount(deallocations);
|
||||
memoryHeapInfo.setAgentTotalInstanceCount(totalCount);
|
||||
memoryHeapInfo.setAgentTotalshallowSize(shallowSize);
|
||||
memoryHeapInfos.add(memoryHeapInfo);
|
||||
}
|
||||
ps.clearParameters();
|
||||
return memoryHeapInfos;
|
||||
} catch (SQLException sqlException) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("memoryHeapInfo Exception {}", sqlException.getMessage());
|
||||
}
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
ps.clearParameters();
|
||||
return memoryHeapInfos;
|
||||
} catch (SQLException sqlException) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("memoryHeapInfo Exception {}", sqlException.getMessage());
|
||||
}
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
return memoryHeapInfos;
|
||||
}
|
||||
|
@ -48,24 +48,6 @@ public class MemoryInstanceDetailsDao extends AbstractDataStore {
|
||||
createMemoryInstanceDetails();
|
||||
}
|
||||
|
||||
/**
|
||||
* get database connection
|
||||
*
|
||||
* @param tableName TableName
|
||||
* @return Connection
|
||||
*/
|
||||
private Connection getConnection(String tableName) {
|
||||
if (ProfilerLogManager.isInfoEnabled()) {
|
||||
LOGGER.info("getConnection");
|
||||
}
|
||||
Optional<Connection> optionalConnection = getConnectByTable(tableName);
|
||||
Connection conn = null;
|
||||
if (optionalConnection.isPresent()) {
|
||||
conn = optionalConnection.get();
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creation of a detailed table of object information for specific instances
|
||||
*
|
||||
@ -95,55 +77,54 @@ public class MemoryInstanceDetailsDao extends AbstractDataStore {
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean insertMemoryInstanceDetailsInfo(List<MemoryInstanceDetailsInfo> memoryInstanceDetailsInfos) {
|
||||
if (ProfilerLogManager.isInfoEnabled()) {
|
||||
LOGGER.info("insertMemoryInstanceDetailsInfo");
|
||||
}
|
||||
if (memoryInstanceDetailsInfos.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Connection conn = null;
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
conn = getConnection("MemoryInstanceDetailsInfo");
|
||||
conn.setAutoCommit(false);
|
||||
String sql = "insert into "
|
||||
+ "MemoryInstanceDetailsInfo("
|
||||
+ "instanceId, "
|
||||
+ "frameId, "
|
||||
+ "className, "
|
||||
+ "methodName, "
|
||||
+ "fieldName, "
|
||||
+ "lineNumber) "
|
||||
+ "values(?,?,?,?,?,?)";
|
||||
ps = conn.prepareStatement(sql);
|
||||
for (MemoryInstanceDetailsInfo memoryInstanceDetailsInfo : memoryInstanceDetailsInfos) {
|
||||
try {
|
||||
ps.setInt(1, memoryInstanceDetailsInfo.getInstanceId());
|
||||
ps.setInt(2, memoryInstanceDetailsInfo.getFrameId());
|
||||
ps.setString(3, memoryInstanceDetailsInfo.getClassName());
|
||||
ps.setString(4, memoryInstanceDetailsInfo.getMethodName());
|
||||
ps.setString(5, memoryInstanceDetailsInfo.getFieldName());
|
||||
ps.setInt(6, memoryInstanceDetailsInfo.getLineNumber());
|
||||
ps.addBatch();
|
||||
} catch (SQLException sqlException) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
Optional<Connection> optionalConnection = getConnectByTable("MemoryInstanceDetailsInfo");
|
||||
if (optionalConnection.isPresent()) {
|
||||
try {
|
||||
conn = optionalConnection.get();
|
||||
conn.setAutoCommit(false);
|
||||
String sql = "insert into "
|
||||
+ "MemoryInstanceDetailsInfo("
|
||||
+ "instanceId, "
|
||||
+ "frameId, "
|
||||
+ "className, "
|
||||
+ "methodName, "
|
||||
+ "fieldName, "
|
||||
+ "lineNumber) "
|
||||
+ "values(?,?,?,?,?,?)";
|
||||
ps = conn.prepareStatement(sql);
|
||||
for (MemoryInstanceDetailsInfo memoryInstanceDetailsInfo : memoryInstanceDetailsInfos) {
|
||||
try {
|
||||
ps.setInt(1, memoryInstanceDetailsInfo.getInstanceId());
|
||||
ps.setInt(2, memoryInstanceDetailsInfo.getFrameId());
|
||||
ps.setString(3, memoryInstanceDetailsInfo.getClassName());
|
||||
ps.setString(4, memoryInstanceDetailsInfo.getMethodName());
|
||||
ps.setString(5, memoryInstanceDetailsInfo.getFieldName());
|
||||
ps.setInt(6, memoryInstanceDetailsInfo.getLineNumber());
|
||||
ps.addBatch();
|
||||
} catch (SQLException sqlException) {
|
||||
LOGGER.error("insert AppInfo {}", sqlException.getMessage());
|
||||
}
|
||||
}
|
||||
ps.executeBatch();
|
||||
conn.commit();
|
||||
conn.setAutoCommit(true);
|
||||
ps.clearParameters();
|
||||
return true;
|
||||
} catch (SQLException throwables) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("insert Exception {}", throwables.getMessage());
|
||||
}
|
||||
return false;
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
ps.executeBatch();
|
||||
conn.commit();
|
||||
conn.setAutoCommit(true);
|
||||
ps.clearParameters();
|
||||
return true;
|
||||
} catch (SQLException throwables) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error("insert Exception {}", throwables.getMessage());
|
||||
}
|
||||
return false;
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,43 +137,46 @@ public class MemoryInstanceDetailsDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isInfoEnabled()) {
|
||||
LOGGER.info("getMemoryInstanceDetails");
|
||||
}
|
||||
Connection conn = getConnection("MemoryInstanceDetailsInfo");
|
||||
PreparedStatement ps = null;
|
||||
Optional<Connection> connection = getConnectByTable("MemoryInstanceDetailsInfo");
|
||||
ArrayList<MemoryInstanceDetailsInfo> memoryInstanceDetailsInfos = new ArrayList<>();
|
||||
try {
|
||||
String sql = "select "
|
||||
+ "* "
|
||||
+ "from "
|
||||
+ "MemoryInstanceDetailsInfo "
|
||||
+ "where "
|
||||
+ "instanceId = ?";
|
||||
ps = conn.prepareStatement(sql);
|
||||
ps.setInt(1, instanceId);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
MemoryInstanceDetailsInfo memoryInstanceDetailsInfo = null;
|
||||
while (rs.next()) {
|
||||
memoryInstanceDetailsInfo = new MemoryInstanceDetailsInfo();
|
||||
Integer frameId = rs.getInt("frameId");
|
||||
String className = rs.getString("className");
|
||||
String methodName = rs.getString("methodName");
|
||||
String fieldName = rs.getString("fieldName");
|
||||
Integer lineNumber = rs.getInt("lineNumber");
|
||||
memoryInstanceDetailsInfo.setInstanceId(instanceId);
|
||||
memoryInstanceDetailsInfo.setFrameId(frameId);
|
||||
memoryInstanceDetailsInfo.setClassName(className);
|
||||
memoryInstanceDetailsInfo.setMethodName(methodName);
|
||||
memoryInstanceDetailsInfo.setFieldName(fieldName);
|
||||
memoryInstanceDetailsInfo.setLineNumber(lineNumber);
|
||||
memoryInstanceDetailsInfos.add(memoryInstanceDetailsInfo);
|
||||
if (connection.isPresent()) {
|
||||
Connection conn = connection.get();
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql = "select "
|
||||
+ "* "
|
||||
+ "from "
|
||||
+ "MemoryInstanceDetailsInfo "
|
||||
+ "where "
|
||||
+ "instanceId = ?";
|
||||
ps = conn.prepareStatement(sql);
|
||||
ps.setInt(1, instanceId);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
MemoryInstanceDetailsInfo memoryInstanceDetailsInfo = null;
|
||||
while (rs.next()) {
|
||||
memoryInstanceDetailsInfo = new MemoryInstanceDetailsInfo();
|
||||
Integer frameId = rs.getInt("frameId");
|
||||
String className = rs.getString("className");
|
||||
String methodName = rs.getString("methodName");
|
||||
String fieldName = rs.getString("fieldName");
|
||||
Integer lineNumber = rs.getInt("lineNumber");
|
||||
memoryInstanceDetailsInfo.setInstanceId(instanceId);
|
||||
memoryInstanceDetailsInfo.setFrameId(frameId);
|
||||
memoryInstanceDetailsInfo.setClassName(className);
|
||||
memoryInstanceDetailsInfo.setMethodName(methodName);
|
||||
memoryInstanceDetailsInfo.setFieldName(fieldName);
|
||||
memoryInstanceDetailsInfo.setLineNumber(lineNumber);
|
||||
memoryInstanceDetailsInfos.add(memoryInstanceDetailsInfo);
|
||||
}
|
||||
ps.clearParameters();
|
||||
return memoryInstanceDetailsInfos;
|
||||
} catch (SQLException sqlException) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error(sqlException.getMessage());
|
||||
}
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
ps.clearParameters();
|
||||
return memoryInstanceDetailsInfos;
|
||||
} catch (SQLException sqlException) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error(sqlException.getMessage());
|
||||
}
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
return memoryInstanceDetailsInfos;
|
||||
}
|
||||
@ -206,46 +190,49 @@ public class MemoryInstanceDetailsDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isInfoEnabled()) {
|
||||
LOGGER.info("getAllMemoryInstanceDetails");
|
||||
}
|
||||
Connection conn = getConnection("MemoryInstanceDetailsInfo");
|
||||
PreparedStatement ps = null;
|
||||
Optional<Connection> optionalConnection = getConnectByTable("MemoryInstanceDetailsInfo");
|
||||
ArrayList<MemoryInstanceDetailsInfo> memoryInstanceDetailsInfos = new ArrayList<>();
|
||||
try {
|
||||
String sql = "select "
|
||||
+ "instanceId, "
|
||||
+ "frameId, "
|
||||
+ "className, "
|
||||
+ "methodName, "
|
||||
+ "fieldName, "
|
||||
+ "lineNumber "
|
||||
+ "from "
|
||||
+ "MemoryInstanceDetailsInfo";
|
||||
ps = conn.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
MemoryInstanceDetailsInfo memoryInstanceDetailsInfo = null;
|
||||
while (rs.next()) {
|
||||
memoryInstanceDetailsInfo = new MemoryInstanceDetailsInfo();
|
||||
Integer instanceId = rs.getInt("instanceId");
|
||||
Integer frameId = rs.getInt("frameId");
|
||||
String className = rs.getString("className");
|
||||
String methodName = rs.getString("methodName");
|
||||
String fieldName = rs.getString("fieldName");
|
||||
Integer lineNumber = rs.getInt("lineNumber");
|
||||
memoryInstanceDetailsInfo.setInstanceId(instanceId);
|
||||
memoryInstanceDetailsInfo.setFrameId(frameId);
|
||||
memoryInstanceDetailsInfo.setClassName(className);
|
||||
memoryInstanceDetailsInfo.setMethodName(methodName);
|
||||
memoryInstanceDetailsInfo.setFieldName(fieldName);
|
||||
memoryInstanceDetailsInfo.setLineNumber(lineNumber);
|
||||
memoryInstanceDetailsInfos.add(memoryInstanceDetailsInfo);
|
||||
if (optionalConnection.isPresent()) {
|
||||
Connection conn = optionalConnection.get();
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql = "select "
|
||||
+ "instanceId, "
|
||||
+ "frameId, "
|
||||
+ "className, "
|
||||
+ "methodName, "
|
||||
+ "fieldName, "
|
||||
+ "lineNumber "
|
||||
+ "from "
|
||||
+ "MemoryInstanceDetailsInfo";
|
||||
ps = conn.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
MemoryInstanceDetailsInfo memoryInstanceDetailsInfo = null;
|
||||
while (rs.next()) {
|
||||
memoryInstanceDetailsInfo = new MemoryInstanceDetailsInfo();
|
||||
Integer instanceId = rs.getInt("instanceId");
|
||||
Integer frameId = rs.getInt("frameId");
|
||||
String className = rs.getString("className");
|
||||
String methodName = rs.getString("methodName");
|
||||
String fieldName = rs.getString("fieldName");
|
||||
Integer lineNumber = rs.getInt("lineNumber");
|
||||
memoryInstanceDetailsInfo.setInstanceId(instanceId);
|
||||
memoryInstanceDetailsInfo.setFrameId(frameId);
|
||||
memoryInstanceDetailsInfo.setClassName(className);
|
||||
memoryInstanceDetailsInfo.setMethodName(methodName);
|
||||
memoryInstanceDetailsInfo.setFieldName(fieldName);
|
||||
memoryInstanceDetailsInfo.setLineNumber(lineNumber);
|
||||
memoryInstanceDetailsInfos.add(memoryInstanceDetailsInfo);
|
||||
}
|
||||
ps.clearParameters();
|
||||
return memoryInstanceDetailsInfos;
|
||||
} catch (SQLException throwables) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error(throwables.getMessage());
|
||||
}
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
ps.clearParameters();
|
||||
return memoryInstanceDetailsInfos;
|
||||
} catch (SQLException throwables) {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error(throwables.getMessage());
|
||||
}
|
||||
} finally {
|
||||
CloseResourceUtil.closeResource(LOGGER, conn, ps, null);
|
||||
}
|
||||
return memoryInstanceDetailsInfos;
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ import static ohos.devtools.services.memory.memorydao.MemoryDao.MemorySelectStat
|
||||
|
||||
/**
|
||||
* memory And Database Interaction Class
|
||||
*
|
||||
* @since 2021/5/19 16:39
|
||||
*/
|
||||
public class MemoryDao extends AbstractDataStore {
|
||||
private static final Logger LOGGER = LogManager.getLogger(MemoryDao.class);
|
||||
@ -207,6 +209,7 @@ public class MemoryDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error(" SQLException {}", throwables.getMessage());
|
||||
}
|
||||
close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -256,6 +259,7 @@ public class MemoryDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error(" SQLException {}", throwAbles.getMessage());
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
// 取最后一个点的后一个点用于Chart绘制,填充空白,解决边界闪烁
|
||||
@ -310,10 +314,31 @@ public class MemoryDao extends AbstractDataStore {
|
||||
if (ProfilerLogManager.isErrorEnabled()) {
|
||||
LOGGER.error(" SQLException {}", throwAbles.getMessage());
|
||||
}
|
||||
close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void close() {
|
||||
if (conn != null) {
|
||||
try {
|
||||
memorySelectMap.values().forEach(preparedStatement -> {
|
||||
try {
|
||||
preparedStatement.close();
|
||||
} catch (SQLException sqlException) {
|
||||
sqlException.printStackTrace();
|
||||
}
|
||||
});
|
||||
memorySelectMap.clear();
|
||||
conn.close();
|
||||
} catch (SQLException sqlException) {
|
||||
sqlException.printStackTrace();
|
||||
} finally {
|
||||
conn = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* deleteSessionData
|
||||
*
|
||||
|
@ -66,7 +66,7 @@ public class AllData {
|
||||
/**
|
||||
* list of process data
|
||||
*/
|
||||
public static List<Process> processes = new ArrayList<>();
|
||||
protected static List<Process> processes = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* get right TopDown tree by time range
|
||||
|
@ -52,8 +52,7 @@ public class EventTable extends JBPanel {
|
||||
/**
|
||||
* event data source
|
||||
*/
|
||||
public List<EventBean> dataSource = new ArrayList<>();
|
||||
|
||||
protected List<EventBean> dataSource = new ArrayList<>();
|
||||
private final int RowHeight = 25;
|
||||
private final int RowHeadHeight = 30;
|
||||
private List<Col<EventBean>> columnNames = new ArrayList<>();
|
||||
@ -246,12 +245,12 @@ public class EventTable extends JBPanel {
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
public String name;
|
||||
protected String name;
|
||||
|
||||
/**
|
||||
* callable
|
||||
*/
|
||||
public Function<T, Object> callable;
|
||||
protected Function<T, Object> callable;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -116,7 +116,7 @@ public final class ChartUtils {
|
||||
* @return BigDecimal结果
|
||||
*/
|
||||
public static BigDecimal divide(double num1, double num2) {
|
||||
return new BigDecimal(num1).divide(new BigDecimal(num2), DECIMAL_COUNTS, ROUND_HALF_UP);
|
||||
return BigDecimal.valueOf(num1).divide(BigDecimal.valueOf(num2), DECIMAL_COUNTS, ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +138,7 @@ public final class ChartUtils {
|
||||
* @return int结果
|
||||
*/
|
||||
public static int divideInt(double num1, double num2) {
|
||||
return new BigDecimal(num1).divide(new BigDecimal(num2), DECIMAL_COUNTS, ROUND_HALF_UP).intValue();
|
||||
return BigDecimal.valueOf(num1).divide(BigDecimal.valueOf(num2), DECIMAL_COUNTS, ROUND_HALF_UP).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,7 +149,7 @@ public final class ChartUtils {
|
||||
* @return int结果
|
||||
*/
|
||||
public static int divide(double num1, BigDecimal num2) {
|
||||
return new BigDecimal(num1).divide(num2, DECIMAL_COUNTS, ROUND_HALF_UP).intValue();
|
||||
return BigDecimal.valueOf(num1).divide(num2, DECIMAL_COUNTS, ROUND_HALF_UP).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,10 +121,10 @@ class MemoryItemPopupMenu {
|
||||
if (ProfilerLogManager.isInfoEnabled()) {
|
||||
LOGGER.info("initSelectedItems");
|
||||
}
|
||||
configMap = MonitorConfigManager.dataMap.get(sessionId);
|
||||
configMap = MonitorConfigManager.DATA_MAP.get(sessionId);
|
||||
if (configMap == null || configMap.get(MEMORY_NAME) == null) {
|
||||
configMap = initFullItems();
|
||||
MonitorConfigManager.dataMap.put(sessionId, configMap);
|
||||
MonitorConfigManager.DATA_MAP.put(sessionId, configMap);
|
||||
}
|
||||
|
||||
for (String str : configMap.get(MEMORY_NAME)) {
|
||||
@ -200,7 +200,7 @@ class MemoryItemPopupMenu {
|
||||
}
|
||||
configMap.remove(MEMORY_NAME);
|
||||
configMap.put(MEMORY_NAME, memoryFlushed);
|
||||
MonitorConfigManager.dataMap.put(sessionId, configMap);
|
||||
MonitorConfigManager.DATA_MAP.put(sessionId, configMap);
|
||||
// Refresh chart manually
|
||||
chartObserver.refreshManually();
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public class MemoryChartObserver implements IChartEventObserver {
|
||||
queryResult = MemoryDataCache.getInstance().getData(sessionId, start, end);
|
||||
}
|
||||
|
||||
Map<String, LinkedList<String>> configMap = MonitorConfigManager.dataMap.get(sessionId);
|
||||
Map<String, LinkedList<String>> configMap = MonitorConfigManager.DATA_MAP.get(sessionId);
|
||||
List<String> monitorItemList = new ArrayList<>();
|
||||
if (configMap != null) {
|
||||
monitorItemList = configMap.get("Memory");
|
||||
|
@ -52,7 +52,7 @@ public final class OperationUtils {
|
||||
* @return BigDecimal结果
|
||||
*/
|
||||
public static BigDecimal divide(double num1, double num2) {
|
||||
return new BigDecimal(num1).divide(new BigDecimal(num2), DECIMAL_COUNTS, ROUND_HALF_UP);
|
||||
return BigDecimal.valueOf(num1).divide(BigDecimal.valueOf(num2), DECIMAL_COUNTS, ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,7 +63,7 @@ public final class OperationUtils {
|
||||
* @return int结果
|
||||
*/
|
||||
public static int divideInt(double num1, double num2) {
|
||||
return new BigDecimal(num1).divide(new BigDecimal(num2), DECIMAL_COUNTS, ROUND_HALF_UP).intValue();
|
||||
return BigDecimal.valueOf(num1).divide(BigDecimal.valueOf(num2), DECIMAL_COUNTS, ROUND_HALF_UP).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,7 +74,7 @@ public final class OperationUtils {
|
||||
* @return int结果
|
||||
*/
|
||||
public static int divide(double num1, BigDecimal num2) {
|
||||
return new BigDecimal(num1).divide(num2, DECIMAL_COUNTS, ROUND_HALF_UP).intValue();
|
||||
return BigDecimal.valueOf(num1).divide(num2, DECIMAL_COUNTS, ROUND_HALF_UP).intValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -516,17 +516,23 @@ public class CpuItemViewLoadDialog implements ActionListener {
|
||||
File logFile = new File(logPath);
|
||||
if (logFile.exists() && numberOfParsingFile > 0) {
|
||||
RandomAccessFile randomFile = null;
|
||||
randomFile = new RandomAccessFile(logFile, "r");
|
||||
String tmp = null;
|
||||
while ((tmp = randomFile.readLine()) != null) {
|
||||
if (tmp.startsWith("last")) {
|
||||
continue;
|
||||
try {
|
||||
randomFile = new RandomAccessFile(logFile, "r");
|
||||
String tmp = null;
|
||||
while ((tmp = randomFile.readLine()) != null) {
|
||||
if (tmp.startsWith("last")) {
|
||||
continue;
|
||||
}
|
||||
if (Integer.valueOf(tmp.split(":")[1]) != 0) {
|
||||
numberOfParsingFile--;
|
||||
LOGGER.info("File parsing failed last time, try again. value is {}",
|
||||
Integer.valueOf(tmp.split(":")[1]));
|
||||
analysisTraceFileToDbFile();
|
||||
}
|
||||
}
|
||||
if (Integer.valueOf(tmp.split(":")[1]) != 0) {
|
||||
numberOfParsingFile--;
|
||||
LOGGER.info("File parsing failed last time, try again. value is {}",
|
||||
Integer.valueOf(tmp.split(":")[1]));
|
||||
analysisTraceFileToDbFile();
|
||||
} finally {
|
||||
if (randomFile != null) {
|
||||
randomFile.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -269,8 +269,7 @@ public final class CpuDb {
|
||||
if (pt == null) {
|
||||
return clazz;
|
||||
}
|
||||
Type argument = pt.getActualTypeArguments()[0];
|
||||
return argument;
|
||||
return pt.getActualTypeArguments()[0];
|
||||
}
|
||||
|
||||
private void release(ResultSet rs, Statement stat, Connection conn) {
|
||||
|
@ -59,12 +59,12 @@ public class BottomScrollPanel extends JBScrollPane {
|
||||
/**
|
||||
* line height
|
||||
*/
|
||||
public int lineHeight;
|
||||
protected int lineHeight;
|
||||
|
||||
/**
|
||||
* line width
|
||||
*/
|
||||
public int lineWidth;
|
||||
protected int lineWidth;
|
||||
|
||||
/**
|
||||
* construct with line width and line height
|
||||
|
@ -67,57 +67,57 @@ public final class ContentPanel extends JBPanel implements AbstractDataFragment.
|
||||
/**
|
||||
* start point object
|
||||
*/
|
||||
public Point startPoint;
|
||||
protected Point startPoint;
|
||||
|
||||
/**
|
||||
* end point object
|
||||
*/
|
||||
public Point endPoint;
|
||||
protected Point endPoint;
|
||||
|
||||
/**
|
||||
* Analysis component
|
||||
*/
|
||||
public AnalystPanel analystPanel;
|
||||
protected AnalystPanel analystPanel;
|
||||
|
||||
/**
|
||||
* draw range select flag
|
||||
*/
|
||||
public boolean drawRangeSelect;
|
||||
protected boolean drawRangeSelect;
|
||||
|
||||
/**
|
||||
* draw range select data flag
|
||||
*/
|
||||
public boolean drawRangeSelectData;
|
||||
protected boolean drawRangeSelectData;
|
||||
|
||||
/**
|
||||
* range select x1
|
||||
*/
|
||||
public int x1;
|
||||
protected int x1;
|
||||
|
||||
/**
|
||||
* range select y1
|
||||
*/
|
||||
public int y1;
|
||||
protected int y1;
|
||||
|
||||
/**
|
||||
* range select x2
|
||||
*/
|
||||
public int x2;
|
||||
protected int x2;
|
||||
|
||||
/**
|
||||
* range select y2
|
||||
*/
|
||||
public int y2;
|
||||
protected int y2;
|
||||
|
||||
/**
|
||||
* range start time
|
||||
*/
|
||||
public long rangeStartNS;
|
||||
protected long rangeStartNS;
|
||||
|
||||
/**
|
||||
* range end time
|
||||
*/
|
||||
public long rangeEndNS;
|
||||
protected long rangeEndNS;
|
||||
|
||||
private WakeupBean wakeupBean;
|
||||
private long startNS;
|
||||
|
@ -87,7 +87,7 @@ public class FTableModel<T extends Object> extends AbstractTableModel {
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
public String name;
|
||||
private String name;
|
||||
private Process callable;
|
||||
|
||||
/**
|
||||
|
@ -123,17 +123,17 @@ public class ScrollSlicePanel extends BottomScrollPanel {
|
||||
/**
|
||||
* parameter key
|
||||
*/
|
||||
public String key;
|
||||
protected String key;
|
||||
|
||||
/**
|
||||
* parameter value
|
||||
*/
|
||||
public String value;
|
||||
protected String value;
|
||||
|
||||
/**
|
||||
* parameter linkable
|
||||
*/
|
||||
public boolean linkable;
|
||||
protected boolean linkable;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -249,8 +249,7 @@ public class ScrollSlicePanel extends BottomScrollPanel {
|
||||
/**
|
||||
* linkable
|
||||
*/
|
||||
public boolean linkable;
|
||||
|
||||
private boolean linkable;
|
||||
private final int leftW = 200;
|
||||
private String key;
|
||||
private String value;
|
||||
|
@ -170,7 +170,7 @@ public class TabCounter extends JBPanel {
|
||||
long end = index == size - 1 ? rightNs : list.get(index + 1).getStartTime();
|
||||
weightAvg += list.get(index).getValue() * ((end - start) * 1.0 / timeRange);
|
||||
}
|
||||
BigDecimal decimal = new BigDecimal(weightAvg);
|
||||
BigDecimal decimal = BigDecimal.valueOf(weightAvg);
|
||||
weightAvg = decimal.setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
bean.setWeightAvgValue(weightAvg);
|
||||
}
|
||||
|
@ -41,32 +41,32 @@ public final class TimeViewPort extends JBViewport {
|
||||
/**
|
||||
* Initial height of the time axis
|
||||
*/
|
||||
public static int height = 140;
|
||||
|
||||
/**
|
||||
* Fragment above
|
||||
*/
|
||||
public TopFragment topFragment;
|
||||
|
||||
/**
|
||||
* Fragment on the left
|
||||
*/
|
||||
public LeftFragment leftFragment;
|
||||
|
||||
/**
|
||||
* Cpu fragment
|
||||
*/
|
||||
public CpuFragment cpuFragment;
|
||||
|
||||
/**
|
||||
* Rule fragment
|
||||
*/
|
||||
public RulerFragment rulerFragment;
|
||||
protected static int height = 140;
|
||||
|
||||
/**
|
||||
* Favorite fragment list
|
||||
*/
|
||||
public final List<AbstractDataFragment> favoriteFragments = new CopyOnWriteArrayList<>();
|
||||
protected final List<AbstractDataFragment> favoriteFragments = new CopyOnWriteArrayList<>();
|
||||
|
||||
/**
|
||||
* Fragment above
|
||||
*/
|
||||
protected TopFragment topFragment;
|
||||
|
||||
/**
|
||||
* Fragment on the left
|
||||
*/
|
||||
protected LeftFragment leftFragment;
|
||||
|
||||
/**
|
||||
* Cpu fragment
|
||||
*/
|
||||
protected CpuFragment cpuFragment;
|
||||
|
||||
/**
|
||||
* Rule fragment
|
||||
*/
|
||||
protected RulerFragment rulerFragment;
|
||||
|
||||
private final IRangeChangeListener rangeChangeListener;
|
||||
private final IHeightChangeListener heightChangeListener;
|
||||
|
@ -16,7 +16,6 @@
|
||||
package ohos.devtools.views.trace.fragment;
|
||||
|
||||
import ohos.devtools.views.trace.bean.AsyncEvent;
|
||||
import ohos.devtools.views.trace.bean.ThreadData;
|
||||
import ohos.devtools.views.trace.component.AnalystPanel;
|
||||
import ohos.devtools.views.trace.util.Final;
|
||||
import ohos.devtools.views.trace.util.Utils;
|
||||
@ -35,15 +34,10 @@ import java.util.stream.Collectors;
|
||||
* @since 2021/04/22 12:25
|
||||
*/
|
||||
public class AsyncEventDataFragment extends AbstractDataFragment<AsyncEvent> implements AsyncEvent.IEventListener {
|
||||
/**
|
||||
* graph event callback
|
||||
*/
|
||||
public static ThreadData currentSelectedThreadData;
|
||||
|
||||
/**
|
||||
* Process memory
|
||||
*/
|
||||
public AsyncEvent obj;
|
||||
private AsyncEvent obj;
|
||||
private boolean isLoading;
|
||||
private Rectangle2D bounds;
|
||||
private int max;
|
||||
|
@ -36,7 +36,7 @@ public class FunctionDataFragment extends AbstractDataFragment<FunctionBean> imp
|
||||
/**
|
||||
* graph event callback
|
||||
*/
|
||||
public static FunctionBean currentSelectedFunctionData;
|
||||
protected static FunctionBean currentSelectedFunctionData;
|
||||
|
||||
/**
|
||||
* Thread object
|
||||
|
@ -44,7 +44,7 @@ public class ThreadDataFragment extends AbstractDataFragment<ThreadData> impleme
|
||||
/**
|
||||
* graph event callback
|
||||
*/
|
||||
public static ThreadData currentSelectedThreadData;
|
||||
protected static ThreadData currentSelectedThreadData;
|
||||
|
||||
/**
|
||||
* Thread object
|
||||
|
@ -45,12 +45,18 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
/**
|
||||
* Metric Db
|
||||
*
|
||||
* @since 2021/5/19 16:39
|
||||
*/
|
||||
public final class MetricsDb {
|
||||
private static boolean isLocal;
|
||||
private static volatile MetricsDb db = new MetricsDb();
|
||||
private static String dbName;
|
||||
|
||||
private MetricsDb() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of dbName .
|
||||
*
|
||||
@ -70,9 +76,6 @@ public final class MetricsDb {
|
||||
MetricsDb.dbName = dbName;
|
||||
}
|
||||
|
||||
private MetricsDb() {
|
||||
}
|
||||
|
||||
private LinkedBlockingQueue<Connection> pool = new LinkedBlockingQueue<>();
|
||||
|
||||
/**
|
||||
@ -315,8 +318,7 @@ public final class MetricsDb {
|
||||
if (pt == null) {
|
||||
return clazz;
|
||||
}
|
||||
Type argument = pt.getActualTypeArguments()[0];
|
||||
return argument;
|
||||
return pt.getActualTypeArguments()[0];
|
||||
}
|
||||
|
||||
private void release(ResultSet rs, Statement stat, Connection conn) {
|
||||
|
@ -77,7 +77,7 @@ public class MonitorConfigManagerTest {
|
||||
processInfo.setProcessName("process");
|
||||
monitorConfigManager = MonitorConfigManager.getInstance();
|
||||
DataBaseApi.getInstance().initDataSourceManager();
|
||||
ConcurrentHashMap<Long, Map<String, LinkedList<String>>> dataMap = monitorConfigManager.dataMap;
|
||||
ConcurrentHashMap<Long, Map<String, LinkedList<String>>> dataMap = monitorConfigManager.DATA_MAP;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user