REVIEW: add some comments and TODOs for file analysis
authorj0kim <j0.kim@samsung.com>
Fri, 30 May 2014 06:43:39 +0000 (15:43 +0900)
committerj0kim <j0.kim@samsung.com>
Fri, 30 May 2014 06:43:39 +0000 (15:43 +0900)
Change-Id: Ic1ab6e58cf9bccae3ccab2c7dad39a0ec7db4fc2
Signed-off-by: j0kim <j0.kim@samsung.com>
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/manager/FileChartDataMaker.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/manager/FileChartManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileApiListTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileApiListView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileChartBoard.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileChartView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/view/FileDetailInfoView.java

index 63a7b92..5dec904 100644 (file)
@@ -83,6 +83,7 @@ public class FileChartDataMaker {
        private Map<Long, Integer> fileWritingCount = new HashMap<Long, Integer>();
        private Map<Long, Boolean> isFileLocking = new HashMap<Long, Boolean>(); 
        
+       // TODO: rename queue
        private Queue<List<FileEvent>> queue = new ConcurrentLinkedQueue<List<FileEvent>>();
        
        public FileChartDataMaker(FailedChecker failedChecker,
@@ -115,6 +116,7 @@ public class FileChartDataMaker {
                ArrayList<List<Object>> fileApiList = new ArrayList<List<Object>>();
                for (int i = 0; i < size; i++) {
                        FileData input = (FileData) inputs.get(i);
+                       // TODO: legacy code, need to check
                        if (ConfigurationDialogDataManager.getInstance()
                                        .getfeatureValue(
                                                        ConfigureLabels.INCLUDE_INSIDE_CALL_FILE) == 0) {
@@ -149,6 +151,7 @@ public class FileChartDataMaker {
                                FailedData failedData = new FailedData(input);
                                this.failedChecker.getFailedList().add(failedData);
                        } else if (apiName.equals("fdopen")) { //$NON-NLS-1$
+                               // TODO: legacy code, need to check
                                DA_LOG.debug("fdopen");
                                continue;
                        }
@@ -158,6 +161,7 @@ public class FileChartDataMaker {
                        key = createKey(pid, tid);
                        
                        // check fileAccessList, fileStatusList, fileAccessorMap size
+                       // TODO: need to return when failed.
                        checkHeapMemory();
                        
                        switch(apiType){
@@ -171,6 +175,7 @@ public class FileChartDataMaker {
                                break;
                        case LogCenterConstants.FD_API_TYPE_CLOSE:
                                if (errNo == 0) {
+                                       // TODO: legacy code, need to check
                                        timeLineFileChartFDCount--;
                                        if (timeLineFileChartFDCount >= 0) {
                                                timeLineFileChart.setFDCount(-1, eventTime);
@@ -211,6 +216,7 @@ public class FileChartDataMaker {
                                addEndAccessData(dentry, pid, tid, filePath, eventTime, fileSize,
                                                LogCenterConstants.FD_API_TYPE_WRITE_START);
                                break;
+                               // TODO: default
                        }
                        fileEventQueue.add(event);
                        
@@ -249,6 +255,11 @@ public class FileChartDataMaker {
                                break;
                        }
                }
+               /* TODO: what to do, when search failed?
+                               make the fake start log: start time = 0
+                               chart: if (start time == 0) do as if start time = trace start time
+                               api list: if (start time == 0) "-"
+               */
        }
        
        private String createKey(int pid, int tid) {
@@ -256,7 +267,9 @@ public class FileChartDataMaker {
                key.append(pid);
                key.append(":");
                key.append(tid);
-               
+               // TODO: change the key type to long 
+               // ex) long key = pid << 32; key += tid;
+
                return key.toString();
        }
        
@@ -266,6 +279,7 @@ public class FileChartDataMaker {
                }
        }
        
+       // TODO: deprecate
        private void addReadingCount(long key, FileAccess readAccess) {
                if(fileReadingCount.get(key) != null ) {
                        if(fileReadingCount.get(key) > 0) {
@@ -278,6 +292,7 @@ public class FileChartDataMaker {
                }
        }
        
+       // TODO: deprecate
        private void deleteReadingCount(long key) {
                int count = fileReadingCount.get(key);
                if(count > 0) {
@@ -285,6 +300,7 @@ public class FileChartDataMaker {
                }
        }
        
+       // TODO: deprecate
        private void addWritingCount(long key, FileAccess writeAccess) {
                if(fileWritingCount.get(key) != null ) {
                        if(fileWritingCount.get(key) > 0) {
@@ -296,6 +312,7 @@ public class FileChartDataMaker {
                }
        }
        
+       // TODO: deprecate
        private void deleteWritingCount(long key) {
                int count = fileWritingCount.get(key);
                if(count > 0) {
@@ -316,12 +333,15 @@ public class FileChartDataMaker {
        }
        
        private void checkHeapMemory() {
+               // TODO: define the AnalyzerLimit.java
+               // TODO: test: reduce the size less than 10
                if ( (fileAccessList.size() > 10000 
                                || fileStatusList.size() > 100000) 
                                || fileAccessorMap.size() > 100000) {
                        ToolbarArea.getInstance().stopTrace();
                        Display.getDefault().asyncExec(new Runnable() {
                                @Override
+                               // TODO: legacy code, need to check
                                public void run() {
                                        final Shell shell = WorkbenchUtil.getWorkbenchWindow()
                                                        .getShell();
@@ -335,7 +355,7 @@ public class FileChartDataMaker {
                        });
                }
        }
-       
+       // TODO: legacy code, need to check 
        private boolean isPrintLog(FileData input) {
                String apiName = input.getApiName();
                if (apiName.contains("print")) {//$NON-NLS-1$
@@ -344,6 +364,7 @@ public class FileChartDataMaker {
                return false;
        }
        
+       // TODO: legacy code, need to check 
        private boolean isOpenMainLog(FileData input) {
                String filePath = input.getFilePath();
                if (filePath.contains(CommonConstants.SLASH)) {
index bf3d51f..e763270 100644 (file)
@@ -50,6 +50,7 @@ public class FileChartManager extends PageDataManager {
        private FileApiDB apiDB = null;
        private FileStatusDB statusDB = null;
        
+       // TODO: comment or rename eventList
        private List<FileEvent> eventList = new ArrayList<FileEvent>();
        private List<FileEvent> selectedTableAPIList = new ArrayList<FileEvent>();
        
@@ -128,6 +129,7 @@ public class FileChartManager extends PageDataManager {
                this.selectedTableAPIList = selectedTableAPIList;
        }
 
+       // TODO: change the comment
        /*** make network data thread ***/
        @Override
        protected void makeData(LogPackage pack) {
index fd02458..90c81b2 100644 (file)
@@ -50,6 +50,8 @@ import org.tizen.dynamicanalyzer.ui.file.FilePage;
 import org.tizen.dynamicanalyzer.ui.file.manager.FileChartManager;
 import org.tizen.dynamicanalyzer.ui.file.model.FileEvent;
 
+
+// TODO: contains a lot legacy code, need to refatoring this class 
 public class FileApiListTable extends DAApiListTableComposite {
        public FileApiListTable(Composite parent, int compStyle, int tableStyle) {
                super(parent, compStyle, tableStyle);
index 4e05582..337aecc 100644 (file)
@@ -52,7 +52,10 @@ import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
 import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
 import org.tizen.dynamicanalyzer.ui.file.manager.FileChartManager;
 
+//TODO: contains a lot legacy code, need to refatoring this class 
 public class FileApiListView extends DAViewComposite {
+       // TODO: comment below variables
+       // TODO: remove unused variables
        private long analysisStartTime = 0;
        private long analysisEndTime = 0;
        private int preSelectionPId = 1;
@@ -116,6 +119,7 @@ public class FileApiListView extends DAViewComposite {
                long newAnalysisStartTime = 0;
                long newAnalysisEndTime = 0;
 
+               // TODO: comment
                if (RangeDataManager.getInstance().isBeingAnalyzed()) {
                        newAnalysisStartTime = RangeDataManager.getInstance()
                                        .getAnalysisStartTime();
index 3ef9a8e..cf687a2 100644 (file)
@@ -78,6 +78,7 @@ public class FileChartBoard extends DAChartBoard{
 
        private List<FileChart> chartList = new ArrayList<FileChart>();
        private FileChartManager fileChartManager = FileChartManager.getInstance();
+       //TODO: use the fileAccessorMap in the DataMaker
        private Map<String, Long> fileAccessorMap = new HashMap<String, Long>();
        private FileChartDataMaker dataMaker;
        private FileApiDB apiDB;
@@ -109,7 +110,12 @@ public class FileChartBoard extends DAChartBoard{
                super.callBackSizeChanged();
        }
        
+       // starting point of processing file information for file chart
+       // 1. FileChartView->updateView : periodic, message received
+       // 2. callBackScaleChanged
+       // 3. callBackScrollChanged
        public void updateChart() {
+               // TODO: find out the way of updating without clearing the chart.
                clearSeries();
                createChartList();
                updateStatusSeries();
@@ -136,13 +142,22 @@ public class FileChartBoard extends DAChartBoard{
        private void createChartList() {
                FileChart parent = null;
                FileChart child = null;
+               // TODO:change the dentry init value to 0
                long dentry = -1;
                String key = null;
 
                List<FileEvent> eventList =  dataMaker.getFileEventList();
                if(eventList == null){
+                       // No file event at all.
                        return;
                }
+               /*
+                *  TODO:
+                *  1. parent and child tag ??
+                *  2. key includes dentry??
+                *  3. detry value error check ??
+                *  4. check else case ??  
+                */
                for(FileEvent event : eventList) {
                        key = createKey(event.getPid(), event.getTid());
                        if(event.getApiType() == LogCenterConstants.FD_API_TYPE_OPEN){
@@ -176,6 +191,12 @@ public class FileChartBoard extends DAChartBoard{
                }
        }
        
+       /* 
+        * Drawing the chart title
+        * 1. parent: file name: max 2line, last: ... 
+        * 2. child: "pid(PID) \n tid(TID)" 
+        * need to refactoring
+        */
        private void createChartItem(FileChart parent, FileChart fileChart) {
                DAChartBoardItem item;
                DAChart chart;
@@ -188,6 +209,9 @@ public class FileChartBoard extends DAChartBoard{
                                        + Long.toHexString(fileChart.getTid()) + "(TID)"
                                        );
                        chart = item.getChart();
+                       if (chart == null) {
+                               // TODO: very strange case, ask to ryu what is this case
+                       }
                        item.setData(new FileSelectedData(fileChart.getDentry(), fileChart
                                        .getPid(), fileChart.getTid(), false));
                        initFileChart(chart, false);
@@ -204,6 +228,9 @@ public class FileChartBoard extends DAChartBoard{
                                        .getPid(), fileChart.getTid(), true, fileChart
                                        .getFilePath(), fileChart.getFileSize()));
                        chart = item.getChart();
+                       if (chart == null) {
+                               // TODO: very strange case, ask to ryu what is this case
+                       }
                        initFileChart(chart, true);
                }
 
@@ -240,6 +267,7 @@ public class FileChartBoard extends DAChartBoard{
                        List<FileEvent> apiList = apiDB.selectAPISeries(getVisibleStartTime(),
                                        getVisibleEndTime());
                        if (null == apiList) {
+                               // no file event within  the selected time range.
                                return;
                        }
                        for (FileChart chart : chartList) {
@@ -249,6 +277,9 @@ public class FileChartBoard extends DAChartBoard{
                                chart.updateApiSeries(apiList);
                        }
                }
+               else { // chartList.size() <= 0
+                       // No data at all                       
+               }
        }
        
        private FileChart getParentChart(long dentry) {
@@ -268,6 +299,7 @@ public class FileChartBoard extends DAChartBoard{
                return key.toString();
        }
        
+       // TODO: rename getVisibleSatausList => getVisibleStatusList
        private List<FileStatus> getVisibleSatausList() {
                return dataMaker.getFileStatusList();
        }
@@ -275,6 +307,7 @@ public class FileChartBoard extends DAChartBoard{
        private List<FileAccess> getVisibleAccessList() {
                List<FileAccess> data = new ArrayList<FileAccess>();
                for(FileAccess access : dataMaker.getFileAccessList()){
+                       // TODO: use the utility API
                        double startTime = access.getStartTime() / TimelineConstants.MEGA_DOUBLE;
                        double endTime = access.getEndTime() / TimelineConstants.MEGA_DOUBLE;
                        if ( startTime >= getVisibleStartTime()
@@ -283,7 +316,7 @@ public class FileChartBoard extends DAChartBoard{
                        } else if (endTime >= getVisibleStartTime()
                                        && endTime <= getVisibleEndTime()) {
                                data.add(access);
-                       } else if (endTime <= 0) { // ing
+                       } else if (endTime <= 0) { // not finished
                                data.add(access);
                        }
                }
@@ -314,6 +347,7 @@ public class FileChartBoard extends DAChartBoard{
                }
                DAChartPlot plot = chart.getPlot();
                if (null == plot) {
+                               // TODO: very strange case, ask to ryu what is this case
                        return;
                }
                if (isParent) {
@@ -334,7 +368,7 @@ public class FileChartBoard extends DAChartBoard{
                        chart.addSeries(accessSeries);
                        plot.setBackgroundImage(ImageResources.BG_CHILD_GRADIENT);
                }
-               
+               // TODO: legacy code, need to understand them
                plot.setAutoHeightRange(AutoRangeType.MANUAL);
                plot.setAxisFont(FontResources.CHART_AXIS_FONT);
                plot.setAxisRangeY(0, 101);
@@ -384,6 +418,7 @@ public class FileChartBoard extends DAChartBoard{
                plot.setMarkers(getMarkers());
        }
        
+       // TODO: legacy code, need to understand them
        private void initIntervalMarkers() {
                // selection marker
                DAChartPlotIntervalMarker selectionMarker = new DAChartPlotIntervalMarker(
index 34ed11b..6883f7d 100644 (file)
@@ -61,6 +61,7 @@ import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
 import org.tizen.dynamicanalyzer.widgets.timeline.DATimeline;
 
 public class FileChartView extends DAViewComposite {
+       // TODO: the height can be changed
        public final static int FILE_CHART_HEIGHT = 40;
 
        private final Composite contents;
@@ -95,10 +96,12 @@ public class FileChartView extends DAViewComposite {
                                                                                (long) (((DAChartPlotIntervalMarker) fileChartBoard
                                                                                                .getMarkers()
                                                                                                .get(UICommonConstants.SELECTION_MARKER_INDEX))
+                                                                                               // TODO: use utility API
                                                                                                .getStartVal() * TimelineConstants.MEGA_DOUBLE),
                                                                                (long) (((DAChartPlotIntervalMarker) fileChartBoard
                                                                                                .getMarkers()
                                                                                                .get(UICommonConstants.SELECTION_MARKER_INDEX))
+                                                                                               // TODO: use utility API
                                                                                                .getEndVal() * TimelineConstants.MEGA_DOUBLE),
                                                                                item.getData(), null));
                        }
@@ -107,6 +110,7 @@ public class FileChartView extends DAViewComposite {
                initIntervalMarkers(fileChartBoard);
 
                stackLayout.topControl = fileChartBoard;
+               // comment : textBoxLabel
                Composite textBoxLabel = new Composite(fileChartBoard.getTitleComp(),
                                SWT.NONE);
                textBoxLabel.addPaintListener(new PaintListener() {
@@ -171,6 +175,7 @@ public class FileChartView extends DAViewComposite {
        }
 
        @Override
+       // TODO: need to refactoring
        public void updateView(DAViewData data) {
                fileChartBoard.updateChart();
                if (data instanceof DASelectionData) {
index 2dc5266..b38d931 100644 (file)
@@ -50,6 +50,9 @@ import org.tizen.dynamicanalyzer.utils.Formatter;
 import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
 import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
 
+//TODO: contains a lot legacy code, need to refatoring this class 
+// TODO: comment the contents of the detail view
+// TODO: add: process name (PID), thread function name (TID) 
 public class FileDetailInfoView extends DAViewComposite {
        private Canvas canvas = null;
        private String fileName = AnalyzerLabels.EMPTY_STRING;
@@ -59,7 +62,7 @@ public class FileDetailInfoView extends DAViewComposite {
        private long writeSize = 0;
        private long totalUseTime = 0;
        private int apiCount = 0;
-       private int failedApiCount = 0;
+       private int failedApiCount = 0; 
        
        private FileChartManager fileChartManager = FileChartManager.getInstance();