From: Hyunjong.park Date: Wed, 2 Jul 2014 08:51:00 +0000 (+0900) Subject: Network : refactoring X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F40%2F23740%2F1;p=sdk%2Ftools%2Fdynamic-analyzer.git Network : refactoring check NULL return, add open,stop precess Signed-off-by: Hyunjong.park Change-Id: I107d3e028a6d020b064c62f1d1bf7adbd610462a --- diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/OpenTraceHandler.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/OpenTraceHandler.java index 70a2d85..43d3f9d 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/OpenTraceHandler.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/OpenTraceHandler.java @@ -181,8 +181,6 @@ public class OpenTraceHandler extends AbstractHandler { OpenTraceProgressManager.getInstance().openTraceComplete(); // SqlManager.getInstance().closeConnection(); - NetworkDataManager.getInstance().openProcess(); - GLDataManager.getInstance().openProcess(); return null; } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkChartBoard.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkChartBoard.java index cbddd54..a08dd95 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkChartBoard.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkChartBoard.java @@ -396,7 +396,14 @@ public class NetworkChartBoard extends DAChartBoard { } public void updateSeries() { + if (null == chartItemList) { + return; + } List seriesList = filetirngSeriresList(); + if (null == seriesList) { + return; + } + for (NetworkChart chart : chartItemList) { chart.updateStatusSeries(seriesList); for (int i = 0; i < seriesList.size(); i++) { @@ -415,6 +422,9 @@ public class NetworkChartBoard extends DAChartBoard { private List filetirngSeriresList() { List filterTimeList = new ArrayList(); + if (null == NetworkDataManager.getInstance().getSeriesList()) { + return null; + } for (int i = 0; i < NetworkDataManager.getInstance().getSeriesList() .size(); i++) { double startTime = NetworkDataManager.getInstance().getSeriesList() diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkTable.java index 5e748db..2e703e0 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkTable.java @@ -99,7 +99,9 @@ public class NetworkTable extends DAApiListTableComposite { NetworkTableView view = (NetworkTableView) AnalyzerManager .getCurrentPage().getView(NetworkTableView.ID); - + if (null == view) { + return null; + } long rangeStartTime = view.getRangeStartTime(); long rangeEndTime = view.getRangeEndTime(); @@ -182,7 +184,7 @@ public class NetworkTable extends DAApiListTableComposite { contentText.add(removeTimeFormat); // elapsed time contentData.add(Long.toString(contentTemp.getTime() - startTime)); - removeTableIndex.add(startLogIndex.intValue()); + removeTableIndex.add(startLogIndex); } else { contentText.add(Formatter.toTimeFormat(contentTemp .getTime())); // start// @@ -302,7 +304,9 @@ public class NetworkTable extends DAApiListTableComposite { NetworkChartView chartview = (NetworkChartView) (AnalyzerManager .getCurrentPage().getView(NetworkPage.chartViewID)); - + if (null == chartview) { + return; + } chartview.setRangeMarker(startTime, endTime); } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkDataManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkDataManager.java index 7b27f21..83c3dba 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkDataManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkDataManager.java @@ -30,6 +30,7 @@ package org.tizen.dynamicanalyzer.ui.network.data; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; @@ -57,7 +58,7 @@ public class NetworkDataManager extends PageDataManager { public final static double MAX_NETWORK_HEAP_MEMORY_KB = 5000; // possible to make approximately 200 chart public final static double ONE_CHART_HEAP_MEMORY_KB = NETWORK_SERIES_TYPE_HEAP_MEMORY_KB; public final static double ONE_ACCESS_SERIES_HEAP_MEMORY_KB = NETWORK_SERIES_TYPE_HEAP_MEMORY_KB; - + private static NetworkDataManager instance = null; private NetworkDataMaker networkDataMaker = null; @@ -76,17 +77,6 @@ public class NetworkDataManager extends PageDataManager { private boolean isStopTrace = false; public NetworkDataManager() { - initDB(); - } - - public synchronized static NetworkDataManager getInstance() { - if (null == instance) { - instance = new NetworkDataManager(); - } - return instance; - } - - private void initDB() { networkDataMaker = new NetworkDataMaker( AnalyzerManager.getFailedChecker(), AnalyzerManager.getLeakDetector(), @@ -98,10 +88,14 @@ public class NetworkDataManager extends PageDataManager { addDBTable(seriesDBManager); } + public synchronized static NetworkDataManager getInstance() { + if (null == instance) { + instance = new NetworkDataManager(); + } + return instance; + } + public void clear() { - instance = null; - seriesDBManager = null; - apiDBManager = null; selectedTableAPIList = null; seriesList = new ArrayList(); checkStatusSeries = new LinkedHashMap(); @@ -145,6 +139,14 @@ public class NetworkDataManager extends PageDataManager { } } + public void saveData(Map dataMap) { + stopProcess(); + } + + public void openData(Map dataMap) { + openProcess(); + } + public void openProcess() { // set series list from DB if (seriesList.size() == 0) { @@ -152,9 +154,7 @@ public class NetworkDataManager extends PageDataManager { } } - @Override - protected void onThreadStop() { - // insert rest of the data to DB + public void stopProcess() { for (int i = 0; i < seriesList.size(); i++) { NetworkSeriesType seriesType = seriesList.get(i); if (seriesType.getEndTime() < 0) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/type/NetworkAPIType.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/type/NetworkAPIType.java index 19ab607..f77db57 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/type/NetworkAPIType.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/type/NetworkAPIType.java @@ -35,7 +35,7 @@ import org.tizen.dynamicanalyzer.swap.model.data.NetworkData; import org.tizen.dynamicanalyzer.ui.network.data.NetworkAPIDBManager; public class NetworkAPIType extends NetworkData { - private final int apiSeriesColumnSize = 6; + private final static int apiSeriesColumnSize = 6; private int seq = -1; private long time = -1; private String destinationAddress = CommonConstants.EMPTY; @@ -114,7 +114,7 @@ public class NetworkAPIType extends NetworkData { } public long getTime() { - return Math.round(time); + return time; } public void setTime(long apiTime) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/type/NetworkSeriesType.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/type/NetworkSeriesType.java index 68c44f9..7bdd971 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/type/NetworkSeriesType.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/type/NetworkSeriesType.java @@ -101,7 +101,7 @@ public class NetworkSeriesType { } public long getStartTime() { - return Math.round(startTime); + return startTime; } public void setStartTime(long startTime) { @@ -109,7 +109,7 @@ public class NetworkSeriesType { } public long getEndTime() { - return Math.round(endTime); + return endTime; } public void setEndTime(long endTime) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java index dc5b710..0c5a31a 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/ToolbarArea.java @@ -56,6 +56,7 @@ import org.tizen.dynamicanalyzer.resources.FontResources; import org.tizen.dynamicanalyzer.resources.ImageResources; import org.tizen.dynamicanalyzer.shortcut.ShortCutManager; import org.tizen.dynamicanalyzer.swap.channel.data.ProcessInfoPackage; +import org.tizen.dynamicanalyzer.ui.network.data.NetworkDataManager; import org.tizen.dynamicanalyzer.ui.opengl.data.GLDataManager; import org.tizen.dynamicanalyzer.ui.page.BaseView; import org.tizen.dynamicanalyzer.ui.timeline.TimelinePage; @@ -511,6 +512,7 @@ public class ToolbarArea { AnalyzerManager.setRunningState(false); AnalyzerManager.stopScreenshotTimer(); TraceStartStopThread.runStartStopThread(); + NetworkDataManager.getInstance().stopProcess(); GLDataManager.getInstance().stopProcess(); }