From 4ee72c6bcf1d63d8587d2bd9387580f41b483464 Mon Sep 17 00:00:00 2001 From: jaeyong lee Date: Fri, 25 Mar 2016 09:32:49 +0900 Subject: [PATCH] [SRADA-238] Replace TimelineChartaManager to MemoryDataManager Change-Id: I7c3afb1b37d468aa66e49694f63f0943a7af2d87 --- .../dynamicanalyzer/ui/memory/MemoryChartView.java | 2 -- .../ui/memory/chart/MemoryChartBoard.java | 12 +++----- .../ui/memory/chart/ProcessMemoryChart.java | 10 +++---- .../ui/memory/chart/SystemMemoryChart.java | 12 ++++---- .../ui/memory/data/MemoryDataManager.java | 32 ++++++++++++++++++++-- 5 files changed, 45 insertions(+), 23 deletions(-) diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/MemoryChartView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/MemoryChartView.java index 43b0389..0f67ae3 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/MemoryChartView.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/MemoryChartView.java @@ -55,7 +55,6 @@ public class MemoryChartView extends DAViewComposite { private final Composite contents; private MemoryChartBoard memoryChartBoard; private final StackLayout stackLayout; - private DAChartBoardItem lastSelectedItemForSummary = null; private Boolean isLatestTraceMode = true; private final RangeDataManager rangeDataManager = RangeDataManager.getInstance(); @@ -76,7 +75,6 @@ public class MemoryChartView extends DAViewComposite { memoryChartBoard.addSelectionListener(new DAChartBoardSelectionListener() { @Override public void handleSelectionEvent(DAChartBoardItem item) { - lastSelectedItemForSummary = item; DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) memoryChartBoard .getMarkers().get(UICommonConstants.SELECTION_MARKER_INDEX); long selectiedStartTime = (long) (intervalMarker.getStartVal() * TimelineConstants.MEGA_DOUBLE); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/MemoryChartBoard.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/MemoryChartBoard.java index 29bd4b5..ee6caa6 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/MemoryChartBoard.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/MemoryChartBoard.java @@ -35,8 +35,8 @@ import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener; import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter; import org.tizen.dynamicanalyzer.ui.common.UICommonConstants; import org.tizen.dynamicanalyzer.ui.memory.MemoryPage; +import org.tizen.dynamicanalyzer.ui.memory.data.MemoryDataManager; import org.tizen.dynamicanalyzer.ui.range.RangeDataManager; -import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineChartManager; import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; @@ -108,10 +108,6 @@ public class MemoryChartBoard extends DAChartBoard { } public void updateChart() { - TimelineChartManager.getInstance().makeChartSeries( - AnalyzerUtil.translateSecToMicroSec(getVisibleStartTime()), - AnalyzerUtil.translateSecToMicroSec(getVisibleEndTime())); - double timelineMarkerStartTime = RangeDataManager.getInstance().getMarkerStartTime() / TimelineConstants.MEGA_DOUBLE; double timelineMarkerEndTime = RangeDataManager.getInstance().getMarkerEndTime() @@ -141,14 +137,14 @@ public class MemoryChartBoard extends DAChartBoard { long startTime = AnalyzerUtil.translateSecToMicroSec(getVisibleStartTime()); long endTime = AnalyzerUtil.translateSecToMicroSec(getVisibleEndTime()); - List> systemDBData = TimelineChartManager.getInstance(). + List> systemDBData = MemoryDataManager.getInstance(). getSystemDataFromDB(startTime, endTime); int selectedPID = 0; if (Toolbar.INSTANCE != null) { selectedPID = Toolbar.INSTANCE.getSelectedPid(); } - Map>> targetProcessDBData = TimelineChartManager.getInstance() - .getTargetProcessDataFromDB(startTime, endTime, selectedPID); + Map>> targetProcessDBData = MemoryDataManager.getInstance() + .getTargetProcessDataMapFromDB(startTime, endTime, selectedPID); /* diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/ProcessMemoryChart.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/ProcessMemoryChart.java index 123e279..0c0b4bf 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/ProcessMemoryChart.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/ProcessMemoryChart.java @@ -37,7 +37,7 @@ import org.tizen.dynamicanalyzer.resources.ColorResources; import org.tizen.dynamicanalyzer.resources.ImageResources; import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener; import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter; -import org.tizen.dynamicanalyzer.ui.timeline.TargetProcessDBTable; +import org.tizen.dynamicanalyzer.ui.memory.data.ProcessMemoryDBTable; import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; @@ -164,13 +164,13 @@ public class ProcessMemoryChart extends MemoryChart { List> data = processDataMap.get(pid); for (int i = 0; i < data.size(); i++) { List row = data.get(i); - double time = (Long) row.get(TargetProcessDBTable.COLUMN.SAMPLING_TIME.ordinal()) + double time = (Long) row.get(ProcessMemoryDBTable.COLUMN.SAMPLING_TIME.ordinal()) / TimelineConstants.MEGA_DOUBLE; long vssMemory = (Long) row - .get(TargetProcessDBTable.COLUMN.MEMORY_VIRTUAL.ordinal()); + .get(ProcessMemoryDBTable.COLUMN.MEMORY_VIRTUAL.ordinal()); long rssMemory = (Long) row - .get(TargetProcessDBTable.COLUMN.MEMORY_RESIDENT.ordinal()); - long pssMemory = (Long) row.get(TargetProcessDBTable.COLUMN.MEMORY_PSS + .get(ProcessMemoryDBTable.COLUMN.MEMORY_RESIDENT.ordinal()); + long pssMemory = (Long) row.get(ProcessMemoryDBTable.COLUMN.MEMORY_PSS .ordinal()); seriesList.get(VSS).addSeriesItem( new DAChartSeriesItem(time, vssMemory, Formatter diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/SystemMemoryChart.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/SystemMemoryChart.java index 665755c..4e0117b 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/SystemMemoryChart.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/SystemMemoryChart.java @@ -36,8 +36,8 @@ import org.tizen.dynamicanalyzer.nl.MemoryPageLabels; import org.tizen.dynamicanalyzer.nl.TimelineChartLabels; import org.tizen.dynamicanalyzer.resources.ColorResources; import org.tizen.dynamicanalyzer.resources.ImageResources; -import org.tizen.dynamicanalyzer.ui.timeline.SystemDataDBTable; -import org.tizen.dynamicanalyzer.ui.timeline.TargetProcessDBTable; +import org.tizen.dynamicanalyzer.ui.memory.data.ProcessMemoryDBTable; +import org.tizen.dynamicanalyzer.ui.memory.data.SystemMemoryDBTable; import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; import org.tizen.dynamicanalyzer.util.Logger; import org.tizen.dynamicanalyzer.utils.Formatter; @@ -99,12 +99,12 @@ public class SystemMemoryChart extends MemoryChart { double maxTime = 0.0; for (int i = 0; i < systemData.size(); i++) { List row = systemData.get(i); - double time = (Long) row.get(SystemDataDBTable.COLUMN.SAMPLING_TIME + double time = (Long) row.get(SystemMemoryDBTable.COLUMN.SAMPLING_TIME .ordinal()) / TimelineConstants.MEGA_DOUBLE; try { long systemMemoryUsage = (Long) row - .get(SystemDataDBTable.COLUMN.MEMORY_USAGE_SYSTEM + .get(SystemMemoryDBTable.COLUMN.MEMORY_USAGE_SYSTEM .ordinal()); totalSeries.addSeriesItem(new DAChartSeriesItem(time, systemMemorySize, Formatter @@ -128,10 +128,10 @@ public class SystemMemoryChart extends MemoryChart { List> data = targetProcessDataMap.get(pid); for (int i = 0; i < data.size(); i++) { List oneTime = data.get(i); - Long time = (Long) oneTime.get(TargetProcessDBTable.COLUMN.SAMPLING_TIME + Long time = (Long) oneTime.get(ProcessMemoryDBTable.COLUMN.SAMPLING_TIME .ordinal()); Long processMemorySize = (Long) oneTime - .get(TargetProcessDBTable.COLUMN.MEMORY_RESIDENT + .get(ProcessMemoryDBTable.COLUMN.MEMORY_RESIDENT .ordinal()); Long processMemorySizeSum = processLoadSumMap.get(time); if (processMemorySizeSum == null) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/MemoryDataManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/MemoryDataManager.java index a767b8a..96dc840 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/MemoryDataManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/MemoryDataManager.java @@ -38,7 +38,6 @@ import org.tizen.dynamicanalyzer.database.DBInserter; import org.tizen.dynamicanalyzer.database.SqlConnectionManager; import org.tizen.dynamicanalyzer.project.BinaryInfo; import org.tizen.dynamicanalyzer.project.LibraryObject; -import org.tizen.dynamicanalyzer.project.ProcessInformation; import org.tizen.dynamicanalyzer.project.ProcessMemoryMap; import org.tizen.dynamicanalyzer.project.Project; import org.tizen.dynamicanalyzer.protocol.ProtocolConstants; @@ -47,9 +46,9 @@ import org.tizen.dynamicanalyzer.swap.logparser.Logs; import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager; import org.tizen.dynamicanalyzer.swap.model.data.LogData; import org.tizen.dynamicanalyzer.swap.model.data.MemoryData; -import org.tizen.dynamicanalyzer.swap.model.data.MemoryMapData; import org.tizen.dynamicanalyzer.swap.model.data.ProcessProfileData; import org.tizen.dynamicanalyzer.swap.model.data.SystemData; +import org.tizen.dynamicanalyzer.ui.timeline.TargetProcessDBTable; import org.tizen.dynamicanalyzer.util.Logger; public class MemoryDataManager extends PageDataManager { @@ -361,6 +360,35 @@ public class MemoryDataManager extends PageDataManager { return processedResult; } + + public Map>> getTargetProcessDataMapFromDB(long start, long end, + int targetPID) { + Map>> processedResult = new HashMap>>(); + String where = "WHERE SAMPLING_TIME BETWEEN " + start + " AND " + end; + if (targetPID > 0) { + where += " AND PID = " + targetPID; + } else { + // Do nothing. Get information from all processes. + } + where += " ORDER BY SAMPLING_TIME"; + + List> queryResult = processMemoryDBTable.selectAllColumnData(where); + if (queryResult == null) { + return processedResult; + } + + for (int i = 0; i < queryResult.size(); i++) { + List row = queryResult.get(i); + Integer pid = (Integer) row.get(TargetProcessDBTable.COLUMN.PID.ordinal()); + List> processData = processedResult.get(pid); + if (processData == null) { + processData = new ArrayList>(); + processedResult.put(pid, processData); + } + processData.add(row); + } + return processedResult; + } public long getProcessMemoriesFromDB(long time) { long processMemories = 0; -- 2.7.4