[SRADA-238] Replace TimelineChartManager to MemoryDataManager
authorjaeyong lee <jae-yong.lee@samsung.com>
Fri, 25 Mar 2016 00:32:49 +0000 (09:32 +0900)
committerjaeyong lee <jae-yong.lee@samsung.com>
Mon, 28 Mar 2016 01:33:38 +0000 (10:33 +0900)
Change-Id: I7c3afb1b37d468aa66e49694f63f0943a7af2d87

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/MemoryChartView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/MemoryChartBoard.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/ProcessMemoryChart.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/chart/SystemMemoryChart.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/MemoryDataManager.java

index 43b0389..0f67ae3 100755 (executable)
@@ -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);
index 29bd4b5..ee6caa6 100755 (executable)
@@ -35,8 +35,8 @@ import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;
 import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;\r
 import org.tizen.dynamicanalyzer.ui.common.UICommonConstants;\r
 import org.tizen.dynamicanalyzer.ui.memory.MemoryPage;\r
+import org.tizen.dynamicanalyzer.ui.memory.data.MemoryDataManager;\r
 import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;\r
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineChartManager;\r
 import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;\r
 import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;\r
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;\r
@@ -108,10 +108,6 @@ public class MemoryChartBoard extends DAChartBoard {
        }\r
        \r
        public void updateChart() {\r
-               TimelineChartManager.getInstance().makeChartSeries(\r
-                               AnalyzerUtil.translateSecToMicroSec(getVisibleStartTime()),\r
-                               AnalyzerUtil.translateSecToMicroSec(getVisibleEndTime()));\r
-\r
                double timelineMarkerStartTime = RangeDataManager.getInstance().getMarkerStartTime()\r
                                / TimelineConstants.MEGA_DOUBLE;\r
                double timelineMarkerEndTime = RangeDataManager.getInstance().getMarkerEndTime()\r
@@ -141,14 +137,14 @@ public class MemoryChartBoard extends DAChartBoard {
                long startTime = AnalyzerUtil.translateSecToMicroSec(getVisibleStartTime());\r
                long endTime = AnalyzerUtil.translateSecToMicroSec(getVisibleEndTime());\r
                \r
-               List<List<Object>> systemDBData = TimelineChartManager.getInstance().\r
+               List<List<Object>> systemDBData = MemoryDataManager.getInstance().\r
                                getSystemDataFromDB(startTime, endTime);\r
                int selectedPID = 0;\r
                if (Toolbar.INSTANCE != null) {\r
                        selectedPID = Toolbar.INSTANCE.getSelectedPid();\r
                }\r
-               Map<Integer, List<List<Object>>> targetProcessDBData = TimelineChartManager.getInstance()\r
-                               .getTargetProcessDataFromDB(startTime, endTime, selectedPID);\r
+               Map<Integer, List<List<Object>>> targetProcessDBData = MemoryDataManager.getInstance()\r
+                               .getTargetProcessDataMapFromDB(startTime, endTime, selectedPID);\r
                \r
                \r
                /*\r
index 123e279..0c0b4bf 100755 (executable)
@@ -37,7 +37,7 @@ import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.resources.ImageResources;\r
 import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener;\r
 import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter;\r
-import org.tizen.dynamicanalyzer.ui.timeline.TargetProcessDBTable;\r
+import org.tizen.dynamicanalyzer.ui.memory.data.ProcessMemoryDBTable;\r
 import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;\r
 import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;\r
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;\r
@@ -164,13 +164,13 @@ public class ProcessMemoryChart extends MemoryChart {
                        List<List<Object>> data = processDataMap.get(pid);\r
                        for (int i = 0; i < data.size(); i++) {\r
                                List<Object> row = data.get(i);\r
-                               double time = (Long) row.get(TargetProcessDBTable.COLUMN.SAMPLING_TIME.ordinal())\r
+                               double time = (Long) row.get(ProcessMemoryDBTable.COLUMN.SAMPLING_TIME.ordinal())\r
                                                / TimelineConstants.MEGA_DOUBLE;\r
                                long vssMemory = (Long) row\r
-                                               .get(TargetProcessDBTable.COLUMN.MEMORY_VIRTUAL.ordinal());\r
+                                               .get(ProcessMemoryDBTable.COLUMN.MEMORY_VIRTUAL.ordinal());\r
                                long rssMemory = (Long) row\r
-                                               .get(TargetProcessDBTable.COLUMN.MEMORY_RESIDENT.ordinal());\r
-                               long pssMemory = (Long) row.get(TargetProcessDBTable.COLUMN.MEMORY_PSS\r
+                                               .get(ProcessMemoryDBTable.COLUMN.MEMORY_RESIDENT.ordinal());\r
+                               long pssMemory = (Long) row.get(ProcessMemoryDBTable.COLUMN.MEMORY_PSS\r
                                                .ordinal());\r
                                seriesList.get(VSS).addSeriesItem(\r
                                                new DAChartSeriesItem(time, vssMemory, Formatter\r
index 665755c..4e0117b 100755 (executable)
@@ -36,8 +36,8 @@ import org.tizen.dynamicanalyzer.nl.MemoryPageLabels;
 import org.tizen.dynamicanalyzer.nl.TimelineChartLabels;\r
 import org.tizen.dynamicanalyzer.resources.ColorResources;\r
 import org.tizen.dynamicanalyzer.resources.ImageResources;\r
-import org.tizen.dynamicanalyzer.ui.timeline.SystemDataDBTable;\r
-import org.tizen.dynamicanalyzer.ui.timeline.TargetProcessDBTable;\r
+import org.tizen.dynamicanalyzer.ui.memory.data.ProcessMemoryDBTable;\r
+import org.tizen.dynamicanalyzer.ui.memory.data.SystemMemoryDBTable;\r
 import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;\r
 import org.tizen.dynamicanalyzer.util.Logger;\r
 import org.tizen.dynamicanalyzer.utils.Formatter;\r
@@ -99,12 +99,12 @@ public class SystemMemoryChart extends MemoryChart {
                double maxTime = 0.0;\r
                for (int i = 0; i < systemData.size(); i++) {\r
                        List<Object> row = systemData.get(i);\r
-                       double time = (Long) row.get(SystemDataDBTable.COLUMN.SAMPLING_TIME\r
+                       double time = (Long) row.get(SystemMemoryDBTable.COLUMN.SAMPLING_TIME\r
                                        .ordinal()) / TimelineConstants.MEGA_DOUBLE;\r
 \r
                        try {\r
                                long systemMemoryUsage = (Long) row\r
-                                               .get(SystemDataDBTable.COLUMN.MEMORY_USAGE_SYSTEM\r
+                                               .get(SystemMemoryDBTable.COLUMN.MEMORY_USAGE_SYSTEM\r
                                                                .ordinal());\r
                                totalSeries.addSeriesItem(new DAChartSeriesItem(time,\r
                                                systemMemorySize, Formatter\r
@@ -128,10 +128,10 @@ public class SystemMemoryChart extends MemoryChart {
                        List<List<Object>> data = targetProcessDataMap.get(pid);\r
                        for (int i = 0; i < data.size(); i++) {\r
                                List<Object> oneTime = data.get(i);\r
-                               Long time = (Long) oneTime.get(TargetProcessDBTable.COLUMN.SAMPLING_TIME\r
+                               Long time = (Long) oneTime.get(ProcessMemoryDBTable.COLUMN.SAMPLING_TIME\r
                                                .ordinal());\r
                                Long processMemorySize = (Long) oneTime\r
-                                               .get(TargetProcessDBTable.COLUMN.MEMORY_RESIDENT\r
+                                               .get(ProcessMemoryDBTable.COLUMN.MEMORY_RESIDENT\r
                                                                .ordinal());\r
                                Long processMemorySizeSum = processLoadSumMap.get(time);\r
                                if (processMemorySizeSum == null) {\r
index a767b8a..96dc840 100755 (executable)
@@ -38,7 +38,6 @@ import org.tizen.dynamicanalyzer.database.DBInserter;
 import org.tizen.dynamicanalyzer.database.SqlConnectionManager;\r
 import org.tizen.dynamicanalyzer.project.BinaryInfo;\r
 import org.tizen.dynamicanalyzer.project.LibraryObject;\r
-import org.tizen.dynamicanalyzer.project.ProcessInformation;\r
 import org.tizen.dynamicanalyzer.project.ProcessMemoryMap;\r
 import org.tizen.dynamicanalyzer.project.Project;\r
 import org.tizen.dynamicanalyzer.protocol.ProtocolConstants;\r
@@ -47,9 +46,9 @@ import org.tizen.dynamicanalyzer.swap.logparser.Logs;
 import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;\r
 import org.tizen.dynamicanalyzer.swap.model.data.LogData;\r
 import org.tizen.dynamicanalyzer.swap.model.data.MemoryData;\r
-import org.tizen.dynamicanalyzer.swap.model.data.MemoryMapData;\r
 import org.tizen.dynamicanalyzer.swap.model.data.ProcessProfileData;\r
 import org.tizen.dynamicanalyzer.swap.model.data.SystemData;\r
+import org.tizen.dynamicanalyzer.ui.timeline.TargetProcessDBTable;\r
 import org.tizen.dynamicanalyzer.util.Logger;\r
 \r
 public class MemoryDataManager extends PageDataManager {\r
@@ -361,6 +360,35 @@ public class MemoryDataManager extends PageDataManager {
                \r
                return processedResult;\r
        }\r
+       \r
+       public Map<Integer, List<List<Object>>> getTargetProcessDataMapFromDB(long start, long end,\r
+                       int targetPID) {\r
+               Map<Integer, List<List<Object>>> processedResult = new HashMap<Integer, List<List<Object>>>();\r
+               String where = "WHERE SAMPLING_TIME BETWEEN " + start + " AND " + end;\r
+               if (targetPID > 0) {\r
+                       where += " AND PID = " + targetPID;\r
+               } else {\r
+                       // Do nothing. Get information from all processes.\r
+               }\r
+               where += " ORDER BY SAMPLING_TIME";\r
+\r
+               List<List<Object>> queryResult = processMemoryDBTable.selectAllColumnData(where);\r
+               if (queryResult == null) {\r
+                       return processedResult;\r
+               }\r
+\r
+               for (int i = 0; i < queryResult.size(); i++) {\r
+                       List<Object> row = queryResult.get(i);\r
+                       Integer pid = (Integer) row.get(TargetProcessDBTable.COLUMN.PID.ordinal());\r
+                       List<List<Object>> processData = processedResult.get(pid);\r
+                       if (processData == null) {\r
+                               processData = new ArrayList<List<Object>>();\r
+                               processedResult.put(pid, processData);\r
+                       }\r
+                       processData.add(row);\r
+               }\r
+               return processedResult;\r
+       }\r
 \r
        public long getProcessMemoriesFromDB(long time) {\r
                long processMemories = 0;\r