public static Color FILE_ACCESS_WRITE = getColor("file_access_write"); //$NON-NLS-1$\r
public static Color FILE_ACCESS_CONCURRENT_READ = getColor("file_access_concurrent_read"); //$NON-NLS-1$\r
public static Color FILE_ACCESS_CONCURRENT_WRITE = getColor("file_access_concurrent_write"); //$NON-NLS-1$\r
- public static Color FILE_LOCK_ACQUIRED = getColor("file_lock_acquired"); //$NON-NLS-1$\r
+ public static Color FILE_LOCK = getColor("file_lock"); //$NON-NLS-1$\r
+ public static Color FILE_UNLOCK = getColor("file_unlock"); //$NON-NLS-1$file_unlock\r
public static Color FILE_LOCK_WAITING = getColor("file_lock_waiting"); //$NON-NLS-1$\r
public static Color FILE_OTHER_OPERATION = getColor("file_other_operation"); //$NON-NLS-1$\r
public static Color FILE_OPENED = getColor("file_opened"); //$NON-NLS-1$\r
setColor("file_access_write",new RGB(131, 207, 232)); //$NON-NLS-1$
setColor("file_access_concurrent_read", new RGB(40, 160, 198)); //$NON-NLS-1$
setColor("file_access_concurrent_write", new RGB(40, 160, 198)); //$NON-NLS-1$
- setColor("file_lock_acquired", new RGB(229, 123, 206)); //$NON-NLS-1$
+ setColor("file_lock", new RGB(229, 123, 206)); //$NON-NLS-1$
+ setColor("file_unlock", new RGB(125, 61, 204)); //$NON-NLS-1$
setColor("file_lock_waiting", new RGB(194, 79, 167)); //$NON-NLS-1$
setColor("file_other_operation", new RGB(173, 173, 173)); //$NON-NLS-1$
setColor("file_other_operation", new RGB(173, 173, 173)); //$NON-NLS-1$
/* special character */
public static final String EMPTY = ""; //$NON-NLS-1$
public static final String SPACE = " "; //$NON-NLS-1$
+ public static final String DOUBLE_SPACE = " "; //$NON-NLS-1$
public static final String TAB = " "; //$NON-NLS-1$
public static final String SLASH = "/"; //$NON-NLS-1$
public static final String BSLASH = "\\"; //$NON-NLS-1$
public static final String CMD_SPLIT_DOT = "\\."; //$NON-NLS-1$
public static final String NEW_LINE_CHAR = "\\n"; //$NON-NLS-1$
public static final String NEW_LINE = "\n"; //$NON-NLS-1$
+ public static final String DOUBLE_NEW_LINE = "\n\n"; //$NON-NLS-1$
public static final String DOT = "."; //$NON-NLS-1$
public static final String COMMA = ","; //$NON-NLS-1$
public static final String COLON = ":"; //$NON-NLS-1$
}
}
});
- processName = cmdResultMultiLines.get(1);
+ if(cmdResultMultiLines.size() == 1) {
+ processName = "unknow proccess";//$NON-NLS-1$
+ }else{
+ processName = cmdResultMultiLines.get(1);
+ }
+
return processName;
}
*/
// length of string type column
+ public static final int SHORT_TEXT_LEN = 64;
public static final int TEXT_LEN = 256;
public static final int BIG_TEXT_LEN = 1024;
+ public static final int LONG_TEXT_LEN = 4096;
public static final int BIGBIG_TEXT_LEN = 16384;
+ public static final String SHORT_TEXT = "VARCHAR(" + SHORT_TEXT_LEN + ")";//$NON-NLS-1$
public static final String TEXT = "VARCHAR(" + TEXT_LEN + ")";//$NON-NLS-1$
public static final String BIG_TEXT = "VARCHAR(" + BIG_TEXT_LEN + ")";//$NON-NLS-1$
public static final String BIGBIG_TEXT = "VARCHAR(" + BIGBIG_TEXT_LEN + ")";//$NON-NLS-1$
+ public static final String LONG_TEXT = "VARCHAR(" + LONG_TEXT_LEN + ")";//$NON-NLS-1$
public static final String TEXT_LIB_NAME = "VARCHAR(1024)";//$NON-NLS-1$
// types type constant
public static final int FD_API_TYPE_LOCK_START = 14;
public static final int FD_API_TYPE_LOCK_END = 15;
public static final int FD_API_TYPE_UNLOCK = 16;
- public static final int FD_API_TYPE_LOCK_WAIT_START = 17;
- public static final int FD_API_TYPE_LOCK_WAIT_END = 18;
+ public static final int FD_API_TYPE_LOCK_AUTORELEASE = 17;
+ public static final int FD_API_TYPE_FAIL = 18;
/* network api type */
public static final int SOCKET_API_FD_OPEN = 0;
public static String FILE_CHART_TOOLTIP_READ;
public static String FILE_CHART_TOOLTIP_CONCURRENT_READ;
public static String FILE_CHART_TOOLTIP_LOCK;
+ public static String FILE_CHART_TOOLTIP_UNLOCK;
+ public static String FILE_CHART_TOOLTIP_LOCK_AUTORELEASE;
public static String FILE_CHART_TOOLTIP_LOCK_WAIT;
+ public static String FILE_CHART_TOOLTIP_FAIL;
+
public static String FILE_API_DB;
public static String FILE_STATUS_DB;
public static String FILE_ACCESS_DB;
+ public static String FILE_ACCESSOR_DB;
public static String FILE_CHART_LOCK;
FILE_CHART_TOOLTIP_CONCURRENT_WRITE=CONCURRENT WRITE
FILE_CHART_TOOLTIP_READ=READ
FILE_CHART_TOOLTIP_CONCURRENT_READ=CONCURRENT READ
-FILE_CHART_TOOLTIP_LOCK=LOCKED
+FILE_CHART_TOOLTIP_LOCK=LOCK
+FILE_CHART_TOOLTIP_UNLOCK=UNLOCK
FILE_CHART_TOOLTIP_LOCK_WAIT=LOCK WAITING
+FILE_CHART_TOOLTIP_LOCK_AUTORELEASE=AUTO RELEASE
+FILE_CHART_TOOLTIP_FAIL=FAIL
FILE_API_DB=FILE_API_DB
FILE_STATUS_DB=FILE_STATUS_DB
FILE_ACCESS_DB=FILE_ACCESS_DB
+FILE_ACCESSOR_DB=FILE_ACCESSOR_DB
TIME_MS = ms
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.common.DASelectionData;
import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.error.ErrorCodeManager;
import org.tizen.dynamicanalyzer.logparser.LogCenterConstants;
import org.tizen.dynamicanalyzer.model.TableInput;
-import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.swap.model.data.FileData;
-import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.ui.file.data.FileApiDB;
-import org.tizen.dynamicanalyzer.ui.file.data.FileApiDB.COLUMN;
import org.tizen.dynamicanalyzer.ui.file.manager.FileDataManager;
+import org.tizen.dynamicanalyzer.ui.file.model.FileAccessor;
import org.tizen.dynamicanalyzer.ui.file.model.FileEvent;
import org.tizen.dynamicanalyzer.ui.file.model.FileSelectedData;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.ui.widgets.table.DAApiListTableComposite;
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
import org.tizen.dynamicanalyzer.utils.Formatter;
-import org.tizen.dynamicanalyzer.widgets.chart.DAChartSeriesItem;
public class FileApiListTable extends DAApiListTableComposite {
FileSelectedData selectedData = fileDataManager.getSelectedData();
ResultSet rs = fileDataManager.getApiDB().selectAPI(
selectedData.getFileId(),
- selectedData.getPid(),
- selectedData.getTid(),
+ selectedData.getAccessorId(),
selectedData.isParentChart());
+ FileAccessor accessor = selectedData.getFileAccessor();
+ boolean isParentChart = selectedData.isParentChart();
+ String filePath = null;
+ int pid = -1;
+ int tid = -1;
if (rs != null) {
try {
int i = -1;
List<String> contentData = new ArrayList<String>();
Integer startLogIndex = 0;
- int seq = rs.getInt(FileApiDB.COLUMN.SEQ.index );
- String filePath = rs.getString(FileApiDB.COLUMN.FILE_PATH.index );
- int pid = rs.getInt(FileApiDB.COLUMN.PID.index);
- int tid = rs.getInt(FileApiDB.COLUMN.TID.index);
- long fd = rs.getLong(FileApiDB.COLUMN.FD.index);
- int fdApiType = rs.getInt(FileApiDB.COLUMN.API_TYPE.index);
- long time = rs.getLong(FileApiDB.COLUMN.EVENT_TIME.index);
- int apiId = rs.getInt(FileApiDB.COLUMN.API_ID.index);
- long errno = rs.getLong(FileApiDB.COLUMN.ERRNO.index);
- String returns = rs.getString(COLUMN.RETURN_VALUE.index);
- String args = rs.getString(FileApiDB.COLUMN.ARGS.index);
- boolean isTarget =rs.getBoolean(COLUMN.TARGET.index);
- long fileSize = rs.getLong(COLUMN.FILE_SIZE.index);
- long size = rs.getLong(COLUMN.SIZE.index);
+ int seq = rs.getInt(1);
+ long fd = rs.getLong(2);
+ int fdApiType = rs.getInt(3);
+ long time = rs.getLong(4);
+ int apiId = rs.getInt(5);
+ long errno = rs.getLong(6);
+ long fileSize = rs.getLong(7);
+ long ioSize = rs.getLong(8);
+ String returns = rs.getString(9);
+ String args = rs.getString(10);
- FileEvent fileEvent = new FileEvent(seq, filePath, pid,
- tid, fd, fdApiType, apiId, time, fileSize, size,
- args, returns, errno, isTarget);
+ if(isParentChart){
+ filePath = rs.getString(11);
+ pid = rs.getInt(12);
+ tid = rs.getInt(13);
+ }else{
+ filePath = accessor.getFilePath();
+ pid = accessor.getPid();
+ tid = accessor.getTid();
+ }
+
+ FileEvent fileEvent = new FileEvent(seq, filePath, pid,
+ tid, fd, fdApiType, apiId, time, fileSize, ioSize,
+ args, returns, errno);
String apiName = Global.getFunctionName(apiId);
long startTime = 0;
package org.tizen.dynamicanalyzer.ui.file;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
import org.tizen.dynamicanalyzer.nl.FilePageLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.ui.file.manager.FileDataManager;
-import org.tizen.dynamicanalyzer.ui.file.model.FileEvent;
import org.tizen.dynamicanalyzer.ui.file.model.FileSelectedData;
import org.tizen.dynamicanalyzer.ui.range.RangeDataManager;
import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
}
// if new event is put from swap, update table
- ResultSet rs = manager.getApiDB().selectAPI(
- selectedData.getFileId(),
- selectedData.getPid(),
- selectedData.getTid(),
- selectedData.isParentChart());
-
- if(rs != null) {
- try {
- if(rs.next() && tableComp.getTable().getItemCount() > 0) {
- manager.setSelectedData(selectedData);
- isUpdate = true;
- }
- } catch (SQLException e) {
- e.printStackTrace();
- } finally {
- SqlConnectionManager.releaseResultSet(rs);
- }
+ /*int newTotal = manager.getApiDB().getTotal();
+ if(tableComp.getTable().getItemCount() > 0 && newTotal > currentTotal) {
+ manager.setSelectedData(selectedData);
isUpdate = true;
- }
-
+ }*/
+
return isUpdate;
}
package org.tizen.dynamicanalyzer.ui.file;
-import java.sql.ResultSet;
-import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.swt.graphics.Color;
-import org.tizen.dynamicanalyzer.common.Global;
-import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
import org.tizen.dynamicanalyzer.logparser.LogCenterConstants;
import org.tizen.dynamicanalyzer.nl.FilePageLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.ui.file.manager.FileDataManager;
import org.tizen.dynamicanalyzer.ui.file.model.FileAccess;
-import org.tizen.dynamicanalyzer.ui.file.model.FileEvent;
+import org.tizen.dynamicanalyzer.ui.file.model.FileAccessor;
import org.tizen.dynamicanalyzer.ui.file.model.FileStatus;
import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
import org.tizen.dynamicanalyzer.utils.Formatter;
private String filePath = null;
private int fileId = -1;
- private int pid = -1;
- private int tid = -1;
- private long fd = -1;
- private long fileSize = 0;
+
+ private FileAccessor fileAccessor = null;
private int chartIndex = -1;
private boolean isTarget = false;
- private FileDataManager fileChartManager = FileDataManager.getInstance();
-
public FileChart(String filePath, int fileId) {
this.filePath = filePath;
this.fileId = fileId;
}
- public FileChart(String filePath, int pid, int tid, long fd) {
- this.filePath = filePath;
- this.pid = pid;
- this.tid = tid;
- this.fd = fd;
- }
-
- public FileChart(int pid, int tid, long fd, String filePath, long fileSize,
- boolean isTarget, int chartIndex, int fileId) {
- this.filePath = filePath;
- this.pid = pid;
- this.tid = tid;
- this.fd = fd;
- this.fileSize = fileSize;
- this.isTarget = isTarget;
+ public FileChart(FileAccessor fileAccessor, int chartIndex, boolean isTarget) {
+ this.fileAccessor = fileAccessor;
this.chartIndex = chartIndex;
- this.fileId = fileId;
+ this.isTarget = isTarget;
}
public void setItem(DAChartBoardItem item) {
}
/**
- * Update API series chart
- * @param apiList
- */
- public void updateApiSeries(double startTime, double endTime){
- ResultSet rs = fileChartManager.getApiDB().selectFailedAPI(
- startTime, endTime, this.fileId, this.pid, this.tid);
- if (rs != null) {
- try {
- while (rs.next()) {
- double time = rs.getLong(1) / TimelineConstants.MEGA_DOUBLE;
- String apiName = Global.getFunctionName(rs.getInt(2));
- Color color = ColorResources.FILE_API_FAILED;
-
- DAChartSeriesItem seriesItem = new DAChartSeriesItem(time,
- DAChartSeriesItem.SERIES_AREA_BAR, color, color, apiName);
- accessSeries.addSeriesItem(seriesItem);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- } finally {
- SqlConnectionManager.releaseResultSet(rs);
- }
- }
- chart.redraw();
- }
-
- /**
* Update access series chart - read/write/lock event
* @param accessList
*/
public void updateAccessSeries(List<FileAccess> accessList) {
for(int i=0; i < accessList.size(); i++) {
FileAccess data = accessList.get(i);
- if(!data.getFilePath().equals(this.filePath) ||
- data.getPid() != this.pid ||
- data.getTid() != this.tid ||
- data.getErroNo() != 0) {
+ if(data.getAccessorId() != this.fileAccessor.getAccessorId()) {
continue;
}
-
double startTime = data.getStartTime() / TimelineConstants.MEGA_DOUBLE;
double endTime = data.getEndTime() / TimelineConstants.MEGA_DOUBLE;
startTime, DAChartSeriesItem.SERIES_AREA_START,
ColorResources.FILE_ACCESS_CONCURRENT_READ,
ColorResources.FILE_ACCESS_CONCURRENT_READ, false,
- FilePageLabels.FILE_CHART_TOOLTIP_CONCURRENT_READ));
+ data.getTooltip()));
if(endTime > 0) {
accessSeries.addSeriesItem(new DAChartSeriesItem(
endTime, DAChartSeriesItem.SERIES_AREA_END,
ColorResources.FILE_ACCESS_CONCURRENT_READ,
ColorResources.FILE_ACCESS_CONCURRENT_READ, false,
- FilePageLabels.FILE_CHART_TOOLTIP_CONCURRENT_READ));
+ data.getTooltip()));
} // else, if endTime <=0, still accessing
}else{
// the file has been read by only one process or thread
startTime, DAChartSeriesItem.SERIES_AREA_START,
ColorResources.FILE_ACCESS_READ,
ColorResources.FILE_ACCESS_READ, false,
- FilePageLabels.FILE_CHART_TOOLTIP_READ));
+ data.getTooltip()));
if(endTime > 0) {
accessSeries.addSeriesItem(new DAChartSeriesItem(
endTime, DAChartSeriesItem.SERIES_AREA_END,
ColorResources.FILE_ACCESS_READ,
ColorResources.FILE_ACCESS_READ, false,
- FilePageLabels.FILE_CHART_TOOLTIP_READ));
+ data.getTooltip()));
} // else, if endTime <=0, still accessing
}
break;
startTime, DAChartSeriesItem.SERIES_AREA_START,
ColorResources.FILE_ACCESS_CONCURRENT_WRITE,
ColorResources.FILE_ACCESS_CONCURRENT_WRITE, false,
- FilePageLabels.FILE_CHART_TOOLTIP_CONCURRENT_WRITE));
+ data.getTooltip()));
if(endTime > 0) {
accessSeries.addSeriesItem(new DAChartSeriesItem(
endTime, DAChartSeriesItem.SERIES_AREA_END,
ColorResources.FILE_ACCESS_CONCURRENT_WRITE,
ColorResources.FILE_ACCESS_CONCURRENT_WRITE, false,
- FilePageLabels.FILE_CHART_TOOLTIP_CONCURRENT_WRITE));
+ data.getTooltip()));
} // else, if endTime <=0, still accessing
}else{
// the file has been written by only one process or thread
startTime, DAChartSeriesItem.SERIES_AREA_START,
ColorResources.FILE_ACCESS_WRITE,
ColorResources.FILE_ACCESS_WRITE, false,
- FilePageLabels.FILE_CHART_TOOLTIP_WRITE));
+ data.getTooltip()));
if(endTime > 0) {
accessSeries.addSeriesItem(new DAChartSeriesItem(
endTime, DAChartSeriesItem.SERIES_AREA_END,
ColorResources.FILE_ACCESS_WRITE,
ColorResources.FILE_ACCESS_WRITE, false,
- FilePageLabels.FILE_CHART_TOOLTIP_WRITE));
+ data.getTooltip()));
}// else, if endTime <=0, still accessing
}
break;
case LogCenterConstants.FD_API_TYPE_LOCK_START:
lockSeries.addSeriesItem(new DAChartSeriesItem(
startTime, DAChartSeriesItem.SERIES_AREA_START,
- ColorResources.FILE_LOCK_ACQUIRED,
- ColorResources.FILE_LOCK_ACQUIRED, false,
- FilePageLabels.FILE_CHART_TOOLTIP_LOCK));
+ ColorResources.FILE_LOCK,
+ ColorResources.FILE_LOCK, false,
+ data.getTooltip()));
if(endTime > 0){
lockSeries.addSeriesItem(new DAChartSeriesItem(
endTime, DAChartSeriesItem.SERIES_AREA_END,
- ColorResources.FILE_LOCK_ACQUIRED,
- ColorResources.FILE_LOCK_ACQUIRED, false,
- FilePageLabels.FILE_CHART_TOOLTIP_LOCK));
+ ColorResources.FILE_LOCK,
+ ColorResources.FILE_LOCK, false,
+ data.getTooltip()));
}// else, if endTime <=0, still accessing
break;
- case LogCenterConstants.FD_API_TYPE_LOCK_WAIT_START:
- lockSeries.addSeriesItem(new DAChartSeriesItem(startTime,
- DAChartSeriesItem.SERIES_AREA_START,
- ColorResources.FILE_LOCK_WAITING,
- ColorResources.FILE_LOCK_WAITING, false,
- FilePageLabels.FILE_CHART_TOOLTIP_LOCK_WAIT));
- if (endTime > 0) {
- lockSeries.addSeriesItem(new DAChartSeriesItem(endTime,
- DAChartSeriesItem.SERIES_AREA_END,
- ColorResources.FILE_LOCK_WAITING,
- ColorResources.FILE_LOCK_WAITING, false,
- FilePageLabels.FILE_CHART_TOOLTIP_LOCK_WAIT));
- }// else, if endTime <=0, still accessing
+ case LogCenterConstants.FD_API_TYPE_UNLOCK:
+ lockSeries.addSeriesItem(new DAChartSeriesItem(
+ startTime, DAChartSeriesItem.SERIES_AREA_BAR,
+ ColorResources.FILE_UNLOCK, ColorResources.FILE_UNLOCK,
+ data.getTooltip()));
+ break;
+ case LogCenterConstants.FD_API_TYPE_LOCK_AUTORELEASE:
+ lockSeries.addSeriesItem(new DAChartSeriesItem(
+ startTime, DAChartSeriesItem.SERIES_AREA_BAR,
+ ColorResources.FILE_UNLOCK, ColorResources.FILE_UNLOCK,
+ data.getTooltip()));
+ break;
+ case LogCenterConstants.FD_API_TYPE_FAIL:
+ accessSeries.addSeriesItem(new DAChartSeriesItem(
+ startTime, DAChartSeriesItem.SERIES_AREA_BAR,
+ ColorResources.FILE_API_FAILED, ColorResources.FILE_API_FAILED,
+ data.getTooltip()));
break;
}
}
for(int i =0; i < statusList.size(); i++) {
FileStatus data = statusList.get(i);
- if(!data.getFilePath().equals(this.filePath)
- || data.getErrNo() != 0) {
+ if(data.getFileId() != this.fileId) {
continue;
}
double time = Formatter.toLongTimeForDoubleTime(data.getEventTime());
}
}
- public FileChart getChildChart(FileEvent event) {
+ public FileChart getChildChart(FileAccessor accessor) {
int size = child.size();
FileChart row;
for (int i = 0; i < size; i++) {
row = child.get(i);
- if (row.getPid() == event.getPid()
- && row.getTid() == event.getTid()){
+ if (row.getFileAccessor().equals(accessor)){
return row;
}
}
return null;
}
+
public DAChartBoardItem getItem() {
return item;
}
this.filePath = filePath;
}
- public int getPid() {
- return pid;
- }
-
- public void setPid(int pid) {
- this.pid = pid;
- }
-
- public int getTid() {
- return tid;
- }
-
- public void setTid(int tid) {
- this.tid = tid;
- }
-
- public long getFileSize() {
- return fileSize;
- }
-
- public void getFileSize(long fileSize) {
- this.fileSize = fileSize;
- }
-
- public long getFd() {
- return fd;
- }
-
- public void setFd(long fd) {
- this.fd = fd;
- }
-
public void setTarget(boolean isTarget) {
this.isTarget = isTarget;
}
public void setFileId(int fileId) {
this.fileId = fileId;
}
+
+ public void setFileAccessor(FileAccessor fileAccessor) {
+ this.fileAccessor = fileAccessor;
+ }
+
+ public FileAccessor getFileAccessor() {
+ return fileAccessor;
+ }
}
\ No newline at end of file
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.tizen.dynamicanalyzer.ui.file.manager.FileDataMaker;
import org.tizen.dynamicanalyzer.ui.file.manager.FileDataManager;
import org.tizen.dynamicanalyzer.ui.file.model.FileAccess;
-import org.tizen.dynamicanalyzer.ui.file.model.FileEvent;
+import org.tizen.dynamicanalyzer.ui.file.model.FileAccessor;
import org.tizen.dynamicanalyzer.ui.file.model.FileSelectedData;
import org.tizen.dynamicanalyzer.ui.file.model.FileStatus;
+import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
import org.tizen.dynamicanalyzer.util.Logger;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
import org.tizen.dynamicanalyzer.utils.Formatter;
private FileDataManager fileChartManager = FileDataManager.getInstance();
private FileDataMaker dataMaker;
private int parentChartIndex = -1;
- private Map<HashSet<Object>, int[]> chartIndexMap = new HashMap<HashSet<Object>, int[]>();
+ private int preSelectionPId = -1;
+ private Map<Integer, int[]> chartIndexMap = new HashMap<Integer, int[]>();
public FileChartBoard(Composite parent, String title) {
super(parent, title);
addNewFileChartRows();
updateStatusSeries();
updateAccessSeries();
- updateApiSeries();
+ chartFilteringByPId();
}
public void clear() {
}
}
- /**
- * create chart rows
- */
+ private void chartFilteringByPId() {
+ if (null == getItemList()) {
+ return;
+ }
+ int selectedPid = ToolbarArea.getInstance().getSelectedPid();
+ if (preSelectionPId != -1 && preSelectionPId != selectedPid) {
+ return;
+ }
+
+ int parentIndex = 0;
+ for (FileChart chart : chartList) {
+ if (!chart.isParentChart()) {
+ continue;
+ }
+ if (selectedPid == 0) {
+ showItem(parentIndex);
+ } else if (selectedPid == chart.getFileAccessor().getPid()) {
+ showItem(parentIndex);
+ } else {
+ hideItem(parentIndex);
+ }
+ parentIndex++;
+ }
+ preSelectionPId = selectedPid;
+ }
+
private void addNewFileChartRows() {
FileChart parent = null;
FileChart child = null;
String filePath = null;
+ boolean isTarget = false;
int fileId = 0;
- List<FileEvent> eventList = dataMaker.getFileEventList();
- if (eventList == null) {
- // no file event at all.
- if(dataMaker.getFileApiList() != null) {
- eventList = dataMaker.getFileApiList();
+ // 1. get accessorlist from data maker
+ List<FileAccessor> accessorList = dataMaker.getFileAccessor();
+ if (accessorList == null) {
+ if(dataMaker.getFileAccessorList() != null) {
+ accessorList = dataMaker.getFileAccessorList();
}else {
return;
}
}
- for (FileEvent event : eventList) {
- //TODO change fileId
- filePath = event.getFilePath();
- parent = getParentChart(filePath);
- fileId = event.getFileId();
+ for (FileAccessor accessor : accessorList) {
+ filePath = accessor.getFilePath();
+ fileId = accessor.getFileId();
+ isTarget = accessor.isTarget();
+ parent = getParentChart(fileId);
if (parent == null) {
parentChartIndex++;
parent = new FileChart(filePath, fileId);
- child = new FileChart(event.getPid(), event.getTid(),
- event.getFdValue(), event.getFilePath(),
- event.getFileSize(), event.isTarget(), parentChartIndex, fileId);
+ child = new FileChart(accessor, parentChartIndex, isTarget);
parent.addChild(child);
parent.setChartIndex(parentChartIndex);
createChartItem(null, parent);
chartList.add(child);
putChartIndextoMap(child, parent);
} else {
- child = parent.getChildChart(event);
+ child = parent.getChildChart(accessor);
if (child == null) {
- child = new FileChart(event.getPid(), event.getTid(),
- event.getFdValue(), event.getFilePath(),
- event.getFileSize(), event.isTarget(), parent.getChartIndex(), fileId);
+ child = new FileChart(accessor, parent.getChartIndex(), isTarget);
parent.addChild(child);
createChartItem(parent, child);
chartList.add(child);
}
}
+
/**
* Drawing the chart title 1. parent: file name: max 2line, last: ... 2.
* child: "pid(PID) \n tid(TID)"
if (parent != null) { // child chart row
DAChartBoardItem parentItem = parent.getItem();
StringBuffer title = new StringBuffer();
- int pid = fileChart.getPid();
+ int pid = fileChart.getFileAccessor().getPid();
String processName = null;
- if(fileChart.isTarget()) {
- processName = AnalyzerUtil.getProcessName(fileChart.getPid());
+ if(fileChart.getFileAccessor().isTarget()) {
+ processName = AnalyzerUtil.getProcessName(fileChart.getFileAccessor().getPid());
} else {
processName = DACommunicator.getProcessNameFromTarget(pid);
}
if(processName!=null){
+ processName = splitTitle(processName, DALimit.MAX_STRING_LENGTH);
title.append(processName + CommonConstants.NEW_LINE);
}else{
- title.append("unKnown process" + CommonConstants.NEW_LINE);
+ title.append("unKnown process" + CommonConstants.NEW_LINE);//$NON-NLS-1$
}
- title.append(fileChart.getPid() + "(PID)"
- + CommonConstants.NEW_LINE + fileChart.getTid() + "(TID)");
+ title.append(fileChart.getFileAccessor().getPid() + "(PID)"
+ + CommonConstants.NEW_LINE + fileChart.getFileAccessor().getTid() + "(TID)");
item = new DAChartBoardItem(parentItem, title.toString());
chart = item.getChart();
- item.setData(new FileSelectedData(fileChart.getFilePath(), fileChart.getPid(),
- fileChart.getTid(), fileChart.getFd(), false, fileChart.getFileId()));
+
+ // add a selected data
+ item.setData(new FileSelectedData(fileChart.getFileAccessor(), false));
+
// disable non-target rows
if(!fileChart.isTarget()) {
item.setSelectable(false);
+ fileName.substring(maxLen, maxLen*2 - 1) + "...";
}
item = new DAChartBoardItem(this, title);
- item.setData(new FileSelectedData(fileChart.getFilePath(),
- fileChart.getPid(), fileChart.getTid(), fileChart.getFd(),
- true, fileChart.getFileId()));
+
+ // add a selected data
+ item.setData(new FileSelectedData(fileChart.getFileId(), true));
+
chart = item.getChart();
initFileChart(chart, true);
}
if (chartList.size() > 0) {
List<FileAccess> accessList = getVisibleAccessList();
for (FileChart chart : chartList) {
- chart.updateAccessSeries(accessList);
- }
- }
- }
-
- /**
- * update file api
- */
- private void updateApiSeries() {
- if (chartList.size() > 0) {
- for (FileChart chart : chartList) {
- if (chart.isParentChart()) {
- continue;
+ if(!chart.isParentChart()) {
+ chart.updateAccessSeries(accessList);
}
- chart.updateApiSeries(getVisibleStartTime(), getVisibleEndTime());
}
}
}
- private FileChart getParentChart(String filePath) {
+ private FileChart getParentChart(int id) {
for (FileChart chart : chartList) {
- if (chart.getFilePath().equals(filePath) && chart.isParentChart()) {
+ if (chart.getFileId()==id && chart.isParentChart()) {
return chart;
}
}
}
private void putChartIndextoMap(FileChart childChart, FileChart parentChart ) {
- HashSet<Object> set = new HashSet<Object>();
- set.add(childChart.getFilePath());
- set.add(childChart.getPid());
- set.add(childChart.getTid());
- chartIndexMap.put(set, new int[] { parentChart.getChartIndex(),
- parentChart.getLastChildChartIndex() });
+ chartIndexMap.put(childChart.getFileAccessor().getAccessorId(),
+ new int[] { parentChart.getChartIndex(), parentChart.getLastChildChartIndex() });
}
- public int[] getChartIndex(String filePath, int pid, int tid) {
- HashSet<Object> set = new HashSet<Object>();
- set.add(filePath);
- set.add(pid);
- set.add(tid);
- if(chartIndexMap.containsKey(set)) {
- return chartIndexMap.get(set);
+ public int[] getChartIndex(int accessorId) {
+ if(chartIndexMap.containsKey(accessorId)) {
+ return chartIndexMap.get(accessorId);
}
- Logger.error("couldn't find index:" + filePath + ","
- + pid + "," + tid);
+ Logger.error("couldn't find index:" + accessorId );
return new int[]{0, 0};
}
+ private String splitTitle(String name, int maxLen) {
+ String title = name;
+ if (name.length() > maxLen ) {
+ title = name.substring(0, maxLen) + "...";
+ }
+ return title;
+ }
+
private void initFileChart(DAChart chart, boolean isParent) {
if (null == chart) {
return;
LogData ldata = (LogData) obData;
dataTime = ldata.getTime();
int seq = ldata.getSeq();
+
ResultSet rs = chartManager.getApiDB().selectFileEventBySeq(seq);
if (rs != null) {
try {
if (rs.next()) {
- int selectedIndex[] = fileChartBoard.getChartIndex(rs.getString(1),
- rs.getInt(2), rs.getInt(3));
+ int selectedIndex[] = fileChartBoard.getChartIndex(rs.getInt(1));
fileChartBoard.selectItem(selectedIndex[0], selectedIndex[1]);
if (null != lastSelectedItemForSummary) {
AnalyzerManager.getCurrentPage().updateView(
import java.sql.SQLException;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
import org.tizen.dynamicanalyzer.common.DASelectionData;
+import org.tizen.dynamicanalyzer.constant.CommonConstants;
import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
import org.tizen.dynamicanalyzer.logparser.LogCenterConstants;
import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
import org.tizen.dynamicanalyzer.nl.FilePageLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.resources.FontResources;
-import org.tizen.dynamicanalyzer.ui.file.data.FileApiDB;
import org.tizen.dynamicanalyzer.ui.file.manager.FileDataManager;
+import org.tizen.dynamicanalyzer.ui.file.model.FileAccessor;
import org.tizen.dynamicanalyzer.ui.file.model.FileSelectedData;
import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
private int failedApiCount = 0;
private FileDataManager fileChartManager = FileDataManager.getInstance();
+
+ private Text detailText = null;
+ private Label labelMessage = null;
private void init() {
fileName = AnalyzerLabels.EMPTY_STRING;
this.setLayout(new FillLayout());
setTitle(FilePageLabels.FILE_DETAILS_TITLE);
-
- Composite contents = getContentArea();
+
+ Composite detailCom = getContentArea();
+ detailCom.setBackground(ColorResources.VIEW_BG_COLOR);
+ detailCom.setLayout(new FormLayout());
+ FormData labelData = new FormData();
+ labelData.top = new FormAttachment(0, 0);
+ labelData.left = new FormAttachment(0, 0);
+ labelData.right = new FormAttachment(100, 0);
+ labelData.bottom = new FormAttachment(100, 0);
+ detailCom.setLayoutData(labelData);
+
+ Composite contents = detailCom;
contents.setBackground(ColorResources.VIEW_BG_COLOR);
- contents.setLayout(new FillLayout());
- canvas = new Canvas(contents, SWT.TRANSPARENT);
- canvas.addPaintListener(new PaintListener() {
-
- @Override
- public void paintControl(PaintEvent e) {
- int x = 0;
- int y = 0;
- Rectangle rect = canvas.getBounds();
- e.gc.setBackground(ColorResources.VIEW_BG_COLOR);
- e.gc.fillRectangle(rect.x, rect.y, rect.width, rect.height);
- e.gc.setForeground(ColorResources.TABLE_CONTENTS_FONT_COLOR);
- e.gc.setFont(FontResources.DETAIL_INFO_FONT);
-
- String pathLabel = FilePageLabels.FILE_DETAILS_FILE_PATH;
- Point pathSize = e.gc.textExtent(pathLabel, SWT.DRAW_MNEMONIC);
- int fontHeight = pathSize.y + 5;
- e.gc.drawString(FilePageLabels.FILE_DETAILS_FILE_PATH
- + filePath, x + 10, y += fontHeight);
-
- e.gc.drawString( FilePageLabels.FILE_DETAILS_FILE_NAME
- + fileName, x += 10, y += fontHeight);
-
- e.gc.drawString(
- FilePageLabels.FILE_DETAILS_TOTAL_SIZE
- + Long.toString(fileSize), x, y += fontHeight);
- e.gc.drawString(
- FilePageLabels.FILE_DETAILS_READ_SIZE
- + Long.toString(readSize), x, y += fontHeight);
- e.gc.drawString(
- FilePageLabels.FILE_DETAILS_WRITE_SIZE
- + Long.toString(writeSize), x, y += fontHeight);
- e.gc.drawString(
- FilePageLabels.FILE_DETAILS_API_COUNT
- + Integer.toString(apiCount), x,
- y += fontHeight);
- e.gc.drawString(FilePageLabels.FILE_DETAILS_FAILED_API_COUNT
- + Integer.toString(failedApiCount), x, y += fontHeight);
- }
- });
+ contents.setLayout(new FormLayout());
+
+ detailText = new Text(contents, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ detailText.setBackground(ColorResources.VIEW_BG_COLOR);
+ detailText.setForeground(ColorResources.TABLE_CONTENTS_FONT_COLOR);
+ detailText.setFont(FontResources.DETAIL_INFO_FONT);
+
+ FormData buttonData = new FormData();
+ buttonData.top = new FormAttachment(labelMessage, 0);
+ buttonData.left = new FormAttachment(0, 0);
+ buttonData.right = new FormAttachment(100, 0);
+ buttonData.bottom = new FormAttachment(100, 0);
+ detailText.setLayoutData(buttonData);
+ detailText.getVerticalBar().setVisible(true);
+ detailText.getHorizontalBar().setVisible(true);
+
+ showDetailInfoContents();
+
}
@Override
failedApiCount = 0;
ResultSet rs = fileChartManager.getApiDB().selectAPI(
selectData.getFileId(),
- selectData.getPid(),
- selectData.getTid(),
+ selectData.getAccessorId(),
selectData.isParentChart());
-
+ boolean isParentChart = selectData.isParentChart();
+ FileAccessor accessor = selectData.getFileAccessor();
if (rs != null) {
try {
long readSize = 0;
while (rs.next()) {
apiCount++;
-
if(rs.isFirst()) {
- filePath = rs.getString(FileApiDB.COLUMN.FILE_PATH.index);
+ if(isParentChart){
+ filePath = rs.getString(11);
+ }else{
+ filePath = accessor.getFilePath();
+ }
String[] splitPath = filePath.split("\\/"); //$NON-NLS-1$
fileName = new String(splitPath[splitPath.length - 1]);
}else if(rs.isLast()) {
- fileSize = rs.getLong(FileApiDB.COLUMN.FILE_SIZE.index);
+ fileSize = rs.getLong(7);
}
- int apiType = rs.getInt(FileApiDB.COLUMN.API_TYPE.index);
- long errno = rs.getInt(FileApiDB.COLUMN.ERRNO.index);
- long size = rs.getLong(FileApiDB.COLUMN.SIZE.index);
+ int apiType = rs.getInt(3);
+ long errno = rs.getInt(6);
+ long ioSize = rs.getLong(8);
switch(apiType) {
case LogCenterConstants.FD_API_TYPE_OPEN:
if(errno != 0) {
failedApiCount++;
}
- readSize += size;
+ readSize += ioSize;
// except *_end event among the API count
apiCount--;
break;
if(errno != 0) {
failedApiCount++;
}
- writeSize += size;
+ writeSize += ioSize;
// except *_end event among the API count
apiCount--;
break;
} finally {
SqlConnectionManager.releaseResultSet(rs);
}
- canvas.redraw();
+
+ showDetailInfoContents();
}
}
+ private void showDetailInfoContents() {
+ StringBuffer strDetailView = new StringBuffer(CommonConstants.DOUBLE_NEW_LINE);
+ strDetailView.append(CommonConstants.DOUBLE_SPACE + FilePageLabels.FILE_DETAILS_FILE_PATH );
+ strDetailView.append(filePath);
+ strDetailView.append(CommonConstants.DOUBLE_NEW_LINE);
+ strDetailView.append(CommonConstants.DOUBLE_SPACE + FilePageLabels.FILE_DETAILS_FILE_NAME);
+ strDetailView.append(fileName);
+ strDetailView.append(CommonConstants.DOUBLE_NEW_LINE);
+ strDetailView.append(CommonConstants.DOUBLE_SPACE + FilePageLabels.FILE_DETAILS_TOTAL_SIZE);
+ strDetailView.append(fileSize);
+ strDetailView.append(CommonConstants.DOUBLE_NEW_LINE);
+ strDetailView.append(CommonConstants.DOUBLE_SPACE + FilePageLabels.FILE_DETAILS_READ_SIZE);
+ strDetailView.append(readSize);
+ strDetailView.append(CommonConstants.DOUBLE_NEW_LINE);
+ strDetailView.append(CommonConstants.DOUBLE_SPACE + FilePageLabels.FILE_DETAILS_WRITE_SIZE);
+ strDetailView.append(writeSize);
+ strDetailView.append(CommonConstants.DOUBLE_NEW_LINE);
+ strDetailView.append(CommonConstants.DOUBLE_SPACE + FilePageLabels.FILE_DETAILS_API_COUNT);
+ strDetailView.append(apiCount);
+ strDetailView.append(CommonConstants.DOUBLE_NEW_LINE);
+ strDetailView.append(CommonConstants.DOUBLE_SPACE + FilePageLabels.FILE_DETAILS_FAILED_API_COUNT);
+ strDetailView.append(failedApiCount);
+ strDetailView.append(CommonConstants.DOUBLE_NEW_LINE);
+ detailText.setText(strDetailView.toString());
+ }
+
@Override
public Control getControl() {
return canvas;
@Override
public void clear() {
init();
- canvas.redraw();
+ showDetailInfoContents();
}
}
import org.tizen.dynamicanalyzer.nl.FilePageLabels;
import org.tizen.dynamicanalyzer.ui.file.model.FileAccess;
-// read, write, lock
public class FileAccessDB extends DBTable {
- private static final String TABLE_NAME = FilePageLabels.FILE_ACCESS_DB;
-
+ private static final String ACCESS_TABLE = FilePageLabels.FILE_ACCESS_DB;
+ private static final String DBTYPE_TOOLTIP = "VARCHAR(256)";//$NON-NLS-1$
+
public static enum COLUMN {
- PID(1, "PID"),
- TID(2, "TID"),
- FILE_PATH(3, "FILE_PATH"),
- FD(4, "FD"),
- API_TYPE(5, "API_TYPE"),
- START_TIME(6, "START_TIME"),
- END_TIME(7, "END_TIME"),
- ERRNO(8, "ERRNO"),
- FILE_SIZE(9, "FILE_SIZE");
+ ACCESSOR_ID(1, "ACCESSOR_ID"),
+ API_TYPE(2, "API_TYPE"),
+ START_TIME(3, "START_TIME"),
+ END_TIME(4, "END_TIME"),
+ TOOLTIP(5, "TOOLTIP");
private final int index;
private final String name;
return name;
}
}
-
+
public FileAccessDB() {
- addColumn(new DBColumn(COLUMN.PID.name, DBConstants.NOT_NULL, DBConstants.INTEGER));
- addColumn(new DBColumn(COLUMN.TID.name, DBConstants.NOT_NULL, DBConstants.INTEGER));
- addColumn(new DBColumn(COLUMN.FILE_PATH.name, DBConstants.EMPTY, DBConstants.BIG_TEXT));
- addColumn(new DBColumn(COLUMN.FD.name, DBConstants.EMPTY, DBConstants.LONG));
- addColumn(new DBColumn(COLUMN.API_TYPE.name, DBConstants.NOT_NULL, DBConstants.INTEGER));
- addColumn(new DBColumn(COLUMN.START_TIME.name, DBConstants.NOT_NULL, DBConstants.LONG));
- addColumn(new DBColumn(COLUMN.END_TIME.name, DBConstants.NOT_NULL, DBConstants.LONG));
- addColumn(new DBColumn(COLUMN.ERRNO.name, DBConstants.EMPTY, DBConstants.LONG));
- addColumn(new DBColumn(COLUMN.FILE_SIZE.name, DBConstants.EMPTY, DBConstants.LONG));
+ addColumn(new DBColumn(COLUMN.ACCESSOR_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.API_TYPE.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.START_TIME.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
+ addColumn(new DBColumn(COLUMN.END_TIME.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
+ addColumn(new DBColumn(COLUMN.TOOLTIP.name, DBConstants.EMPTY, DBTYPE_TOOLTIP));
}
-
@Override
public String getTableName() {
- return TABLE_NAME;
+ return ACCESS_TABLE;
}
private static final String selectAll = selectAll();
private static final String SELECT_QUERY = "select "
+ selectAll
- + " from " + TABLE_NAME; //$NON-NLS-1$
+ + " from " + ACCESS_TABLE;
public List<FileAccess> executeQueryRS(String query) {
List<FileAccess> resultData = new ArrayList<FileAccess>();
FileAccess access = null;
try {
access = new FileAccess(
- rs.getInt(COLUMN.PID.index),
- rs.getInt(COLUMN.TID.index),
- rs.getString(COLUMN.FILE_PATH.index),
- rs.getLong(COLUMN.FD.index),
+ rs.getInt(COLUMN.ACCESSOR_ID.index),
rs.getInt(COLUMN.API_TYPE.index),
rs.getLong(COLUMN.START_TIME.index),
rs.getLong(COLUMN.END_TIME.index),
- rs.getLong(COLUMN.ERRNO.index),
- rs.getLong(COLUMN.FILE_SIZE.index)
+ rs.getString(COLUMN.TOOLTIP.index)
);
} catch (SQLException e) {
e.printStackTrace();
insertDataList.add(insertData.getDBData());
insertData(insertDataList);
}
-
+
public List<FileAccess> select() {
String query = String.format(SELECT_QUERY);
accessList = executeQueryRS(query);
return accessList;
}
-
+
public static String selectAll() {
StringBuffer selectAllColumn = new StringBuffer();
- selectAllColumn.append(COLUMN.PID.name);
- selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.TID.name);
- selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.FILE_PATH.name);
- selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.FD.name);
+ selectAllColumn.append(COLUMN.ACCESSOR_ID.name);
selectAllColumn.append(",");
selectAllColumn.append(COLUMN.API_TYPE.name);
selectAllColumn.append(",");
selectAllColumn.append(",");
selectAllColumn.append(COLUMN.END_TIME.name);
selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.ERRNO.name);
- selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.FILE_SIZE.name);
+ selectAllColumn.append(COLUMN.TOOLTIP.name);
return selectAllColumn.toString();
}
try {
prep.setInt(1, (Integer)(rowData.get(0)));
prep.setInt(2, (Integer)(rowData.get(1)));
- prep.setString(3, (String)(rowData.get(2)));
+ prep.setLong(3, (Long)(rowData.get(2)));
prep.setLong(4, (Long)(rowData.get(3)));
- prep.setInt(5, (Integer)(rowData.get(4)));
- prep.setLong(6, (Long)(rowData.get(5)));
- prep.setLong(7, (Long)(rowData.get(6)));
- prep.setLong(8, (Long)(rowData.get(7)));
- prep.setLong(9, (Long)(rowData.get(8)));
+ prep.setString(5, (String)(rowData.get(4)));
} catch (SQLException e) {
e.printStackTrace();
isPrepared = false;
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hyeran Kim <Hyeran74.kim@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.dynamicanalyzer.ui.file.data;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.tizen.dynamicanalyzer.database.DBColumn;
+import org.tizen.dynamicanalyzer.database.DBConstants;
+import org.tizen.dynamicanalyzer.database.DBTable;
+import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
+import org.tizen.dynamicanalyzer.nl.FilePageLabels;
+import org.tizen.dynamicanalyzer.ui.file.model.FileAccessor;
+
+public class FileAccessorDB extends DBTable {
+ private static final String ACCESSOR_TABLE = FilePageLabels.FILE_ACCESSOR_DB;
+ private static final String DBTYPE_FILEPATH = "VARCHAR(4096)";//$NON-NLS-1$
+
+ public static enum COLUMN {
+ ACCESSOR_ID(1, "ACCESSOR_ID"),
+ FILE_ID(2, "FILE_ID"),
+ FILE_PATH(3, "FILE_PATH"),
+ PID(4, "PID"),
+ TID(5, "TID"),
+ IS_TARGET(6, "IS_TARGET");
+
+
+ private final int index;
+ private final String name;
+ private COLUMN(int index, String name) {
+ this.index = index;
+ this.name = name;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public String getName() {
+ return name;
+ }
+ }
+
+ public FileAccessorDB() {
+ addColumn(new DBColumn(COLUMN.ACCESSOR_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.FILE_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.FILE_PATH.name, DBConstants.NOT_NULL, DBTYPE_FILEPATH));
+ addColumn(new DBColumn(COLUMN.PID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.TID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.IS_TARGET.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_BOOLEAN));
+ }
+
+
+ @Override
+ public String getTableName() {
+ return ACCESSOR_TABLE;
+ }
+
+ private static final String selectAll = selectAll();
+ private static final String SELECT_QUERY = "select "
+ + selectAll
+ + " from " + ACCESSOR_TABLE; //$NON-NLS-1$
+
+ public List<FileAccessor> executeQueryRS(String query) {
+ List<FileAccessor> resultData = new ArrayList<FileAccessor>();
+ ResultSet rs = SqlConnectionManager.executeQueryRS(query);
+ if (rs != null) {
+ try {
+ while (rs.next()) {
+ FileAccessor accessor = getDataFromResultSet(rs);
+ if (accessor != null) {
+ resultData.add(accessor);
+ }
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ SqlConnectionManager.releaseResultSet(rs);
+ }
+ }
+ return resultData;
+ }
+
+ public FileAccessor getDataFromResultSet(ResultSet rs) {
+ FileAccessor accessor = null;
+ try {
+ accessor = new FileAccessor(
+ rs.getInt(COLUMN.ACCESSOR_ID.index),
+ rs.getInt(COLUMN.FILE_ID.index),
+ rs.getString(COLUMN.FILE_PATH.index),
+ rs.getInt(COLUMN.PID.index),
+ rs.getInt(COLUMN.TID.index),
+ rs.getBoolean(COLUMN.IS_TARGET.index)
+ );
+ } catch (SQLException e) {
+ e.printStackTrace();
+ return null;
+ }
+ return accessor;
+ }
+
+ public void insert(FileAccessor insertData) {
+ List<List<Object>> insertDataList = new ArrayList<List<Object>>();
+ insertDataList.add(insertData.getDBData());
+ insertData(insertDataList);
+ }
+
+ public List<FileAccessor> select() {
+ String query = String.format(SELECT_QUERY);
+
+ List<FileAccessor> accessorList = new ArrayList<FileAccessor>();
+ accessorList = executeQueryRS(query);
+ return accessorList;
+ }
+
+ public static String selectAll() {
+ StringBuffer selectAllColumn = new StringBuffer();
+ selectAllColumn.append(COLUMN.ACCESSOR_ID.name);
+ selectAllColumn.append(",");
+ selectAllColumn.append(COLUMN.FILE_ID.name);
+ selectAllColumn.append(",");
+ selectAllColumn.append(COLUMN.FILE_PATH.name);
+ selectAllColumn.append(",");
+ selectAllColumn.append(COLUMN.PID.name);
+ selectAllColumn.append(",");
+ selectAllColumn.append(COLUMN.TID.name);
+ selectAllColumn.append(",");
+ selectAllColumn.append(COLUMN.IS_TARGET.name);
+ return selectAllColumn.toString();
+ }
+
+ @Override
+ public boolean prepare(PreparedStatement prep, List<Object> rowData) {
+ boolean isPrepared = true;
+
+ int columnsize = getColumnSize();
+ if (columnsize != rowData.size()) {
+ isPrepared = false;
+ } else {
+ try {
+ prep.setInt(1, (Integer)(rowData.get(0)));
+ prep.setInt(2, (Integer)(rowData.get(1)));
+ prep.setString(3, (String)(rowData.get(2)));
+ prep.setLong(4, (Integer)(rowData.get(3)));
+ prep.setInt(5, (Integer)(rowData.get(4)));
+ prep.setBoolean(6, (Boolean)(rowData.get(5)));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ isPrepared = false;
+ }
+ }
+ return isPrepared;
+ }
+}
import org.tizen.dynamicanalyzer.database.SqlConnectionManager;
import org.tizen.dynamicanalyzer.nl.FilePageLabels;
import org.tizen.dynamicanalyzer.ui.file.model.FileEvent;
-import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants;
public class FileApiDB extends DBTable {
- private static final String TABLE_NAME = FilePageLabels.FILE_API_DB;
+ private static final String API_TABLE = FilePageLabels.FILE_API_DB;
+ private static final String ACCESSOR_TABLE = FilePageLabels.FILE_ACCESSOR_DB;
+ private static final String DBTYPE_RETUREN_VALUE = "VARCHAR(1024)";//$NON-NLS-1$
+ private static final String DBTYPE_ARGUMENTS_VALUE = "VARCHAR(1024)";//$NON-NLS-1$
public static enum COLUMN {
- SEQ(1, "SEQ"),
- FILE_PATH(2, "FILE_PATH"),
- PID(3, "PID"),
- TID(4, "TID"),
- FD(5, "FD"),
- API_TYPE(6, "API_TYPE"),
- EVENT_TIME(7, "EVENT_TIME"),
- API_ID(8, "API_ID"),
- ERRNO(9, "ERRNO"),
- IO_SIZE(10, "IO_SIZE"),
- FILE_SIZE(11, "FILE_SIZE"),
- SIZE(12, "SIZE"),
- RETURN_VALUE(13, "RETURN_VALUE"),
- ARGS(14, "ARGS"),
- TARGET(15, "TARGET"),
- FILE_ID(16, "FILE_ID");
+ SEQUENCE_NUMBER(1, "SEQUENCE_NUMBER"),
+ FILE_ID(2, "FILE_ID"),
+ ACCESSOR_ID(3, "ACCESSOR_ID"),
+ FD(4, "FD"),
+ API_TYPE(5, "API_TYPE"),
+ EVENT_TIME(6, "EVENT_TIME"),
+ API_ID(7, "API_ID"),
+ ERRNO(8, "ERRNO"),
+ IO_SIZE(9, "IO_SIZE"),
+ FILE_SIZE(10, "FILE_SIZE"),
+ RETURN_VALUE(11, "RETURN_VALUE"),
+ ARGUMENTS_VALUE(12, "ARGUMENTS_VALUE");
public final int index;
public final String name;
@Override
public String getTableName() {
- return TABLE_NAME;
+ return API_TABLE;
}
-
+
public FileApiDB() {
- addColumn(new DBColumn(COLUMN.SEQ.name, DBConstants.NOT_NULL, DBConstants.INTEGER));
- addColumn(new DBColumn(COLUMN.FILE_PATH.name, DBConstants.EMPTY, DBConstants.BIG_TEXT));
- addColumn(new DBColumn(COLUMN.PID.name, DBConstants.NOT_NULL, DBConstants.INTEGER));
- addColumn(new DBColumn(COLUMN.TID.name, DBConstants.NOT_NULL, DBConstants.INTEGER));
- addColumn(new DBColumn(COLUMN.FD.name, DBConstants.EMPTY, DBConstants.LONG));
- addColumn(new DBColumn(COLUMN.API_TYPE.name, DBConstants.NOT_NULL, DBConstants.INTEGER));
- addColumn(new DBColumn(COLUMN.EVENT_TIME.name, DBConstants.NOT_NULL, DBConstants.LONG));
- addColumn(new DBColumn(COLUMN.API_ID.name, DBConstants.EMPTY, DBConstants.INTEGER));
- addColumn(new DBColumn(COLUMN.ERRNO.name, DBConstants.EMPTY, DBConstants.LONG));
- addColumn(new DBColumn(COLUMN.IO_SIZE.name, DBConstants.EMPTY, DBConstants.LONG));
- addColumn(new DBColumn(COLUMN.FILE_SIZE.name, DBConstants.EMPTY, DBConstants.LONG));
- addColumn(new DBColumn(COLUMN.SIZE.name, DBConstants.EMPTY, DBConstants.LONG));
- addColumn(new DBColumn(COLUMN.RETURN_VALUE.name, DBConstants.EMPTY, DBConstants.BIG_TEXT));
- addColumn(new DBColumn(COLUMN.ARGS.name, DBConstants.EMPTY, DBConstants.BIG_TEXT));
- addColumn(new DBColumn(COLUMN.TARGET.name, DBConstants.NOT_NULL, DBConstants.BOOLEAN));
- addColumn(new DBColumn(COLUMN.FILE_ID.name, DBConstants.NOT_NULL, DBConstants.INTEGER));
+ addColumn(new DBColumn(COLUMN.SEQUENCE_NUMBER.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.FILE_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.ACCESSOR_ID.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.FD.name, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
+ addColumn(new DBColumn(COLUMN.API_TYPE.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.EVENT_TIME.name, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
+ addColumn(new DBColumn(COLUMN.API_ID.name, DBConstants.EMPTY, DBConstants.DBTYPE_INT4));
+ addColumn(new DBColumn(COLUMN.ERRNO.name, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
+ addColumn(new DBColumn(COLUMN.IO_SIZE.name, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
+ addColumn(new DBColumn(COLUMN.FILE_SIZE.name, DBConstants.EMPTY, DBConstants.DBTYPE_LONG));
+ addColumn(new DBColumn(COLUMN.RETURN_VALUE.name, DBConstants.EMPTY, DBTYPE_RETUREN_VALUE));
+ addColumn(new DBColumn(COLUMN.ARGUMENTS_VALUE.name, DBConstants.EMPTY, DBTYPE_ARGUMENTS_VALUE));
+
}
private static final String selectAllColumn = selectAllColumn();
- private static final String SELECT_FAILED_API_SERIES = "select "
- + COLUMN.EVENT_TIME + " , "
- + COLUMN.API_ID
- +" from "
- + TABLE_NAME + " where %s <= "
- + COLUMN.EVENT_TIME.name + " and "
- + COLUMN.EVENT_TIME.name
- + " <= %s" + " and "
- //+ COLUMN.FILE_PATH.name + " = '%s'" + " and "
- + COLUMN.FILE_ID.name + " = '%d'" + " and "
- + COLUMN.PID.name + " = '%d'" + " and "
- + COLUMN.TID.name + " = '%d'" + " and "
- + COLUMN.ERRNO.name + " != '0'" + " and "
- + COLUMN.TARGET.name + " = 'true'";
-
- private static final String SELECT_APIS_FOR_CHILD = "select "
- + selectAllColumn
- +" from "
- + TABLE_NAME + " where "
- + COLUMN.FILE_ID.name + " = '%d'" + " and "
- + COLUMN.PID.name + " = '%d'" + " and "
- + COLUMN.TID.name + " = '%d'" + " and "
- + COLUMN.TARGET.name + " = 'true'";
+ private static final String SELECT_APIS_FOR_CHILD =
+ "select "
+ + "SEQUENCE_NUMBER, FD, API_TYPE, EVENT_TIME, API_ID, ERRNO, "
+ + "IO_SIZE, FILE_SIZE, RETURN_VALUE, ARGUMENTS_VALUE "
+ + "from " + API_TABLE
+ + " where "
+ + "ACCESSOR_ID" + " = '%d'";
+
- private static final String SELECT_APIS_FOR_PARENT= "select "
- + selectAllColumn
- + " from "
- + TABLE_NAME + " where "
- + COLUMN.FILE_ID.name + " = '%d'" + " and "
- + COLUMN.TARGET.name + " = 'true'";
+ private static final String SELECT_APIS_FOR_PARENT=
+ "select "
+ + "api.SEQUENCE_NUMBER, api.FD, api.API_TYPE, api.EVENT_TIME, api.API_ID, api.ERRNO, "
+ + "api.IO_SIZE, api.FILE_SIZE, api.RETURN_VALUE, api.ARGUMENTS_VALUE, "
+ + "accessor.FILE_PATH, accessor.PID, accessor.TID "
+ + "from " + API_TABLE + " api, " + ACCESSOR_TABLE + " accessor "
+ + "where "
+ + "api.FILE_ID" + " = '%d'"+ " and " + "api.ACCESSOR_ID = accessor.ACCESSOR_ID";
private static final String SELECT_FILE_EVENT_BY_SEQ = "select "
- + COLUMN.FILE_PATH.name + " , "
- + COLUMN.PID.name + " , "
- + COLUMN.TID.name
- + " from "
- + TABLE_NAME + " where "
- + COLUMN.SEQ.name + " = '%d'"+ " and "
- + COLUMN.TARGET.name + " = 'true'";
+ + COLUMN.ACCESSOR_ID.name
+ + " from " + API_TABLE
+ + " where "
+ + COLUMN.SEQUENCE_NUMBER.name + " = '%d'";
+
+ private static final String SELECT_APIS_COUNT =
+ "select COUNT(*) from " + API_TABLE;
private static final String SELECT_ALL = "select "
+ selectAllColumn
+ " from "
- + TABLE_NAME + " where "
- + COLUMN.TARGET.name + " = 'true'";
+ + API_TABLE;
public ResultSet executeQuery(String query) {
ResultSet rs = SqlConnectionManager.executeQueryRS(query);
FileEvent event = null;
try {
event = new FileEvent(
- rs.getInt(COLUMN.SEQ.index),
- rs.getString(COLUMN.FILE_PATH.index),
- rs.getInt(COLUMN.PID.index),
- rs.getInt(COLUMN.TID.index),
+ rs.getInt(COLUMN.SEQUENCE_NUMBER.index),
+ rs.getInt(COLUMN.FILE_ID.index),
+ rs.getInt(COLUMN.ACCESSOR_ID.index),
rs.getLong(COLUMN.FD.index),
rs.getInt(COLUMN.API_TYPE.index),
rs.getInt(COLUMN.API_ID.index),
rs.getLong(COLUMN.EVENT_TIME.index),
rs.getLong(COLUMN.FILE_SIZE.index),
- rs.getLong(COLUMN.SIZE.index),
- rs.getString(COLUMN.ARGS.index),
+ rs.getLong(COLUMN.IO_SIZE.index),
+ rs.getString(COLUMN.ARGUMENTS_VALUE.index),
rs.getString(COLUMN.RETURN_VALUE.index),
- rs.getLong(COLUMN.ERRNO.index),
- rs.getBoolean(COLUMN.TARGET.index),
- rs.getInt(COLUMN.FILE_ID.index)
+ rs.getLong(COLUMN.ERRNO.index)
);
} catch (SQLException e) {
e.printStackTrace();
insertData(insertData);
}
- // for updating api series chart
- public ResultSet selectFailedAPI(double visibleStartTime,
- double visibleEndTime, int fileId, int pid, int tid) {
- double selectStartTime = visibleStartTime
- * TimelineConstants.MEGA_DOUBLE;
- double selectEndTime = visibleEndTime * TimelineConstants.MEGA_DOUBLE;
- String query = String.format(SELECT_FAILED_API_SERIES, selectStartTime,
- selectEndTime, fileId, pid, tid);
-
- return SqlConnectionManager.executeQueryRS(query);
- }
-
-
// for updating api table view and detail view
- public ResultSet selectAPI(int fileId, int pid, int tid,
+ public ResultSet selectAPI(int fileId, int accessorId,
boolean isParentChart) {
- String query = String.format(SELECT_APIS_FOR_CHILD, fileId, pid, tid);
+ String query = null;
if (isParentChart) {
query = String.format(SELECT_APIS_FOR_PARENT, fileId);
+ }else{
+ query = String.format(SELECT_APIS_FOR_CHILD, accessorId);
}
return SqlConnectionManager.executeQueryRS(query);
}
-
+
// to get chart row index
public ResultSet selectFileEventBySeq(long seq) {
String query = String.format(SELECT_FILE_EVENT_BY_SEQ, seq);
return SqlConnectionManager.executeQueryRS(query);
}
+ public int getTotal() {
+ String query = SELECT_APIS_COUNT;
+ ResultSet rs = SqlConnectionManager.executeQueryRS(query);
+ int totalCount = 0;
+ if (rs != null) {
+ try {
+ if (rs.next()) {
+ totalCount = rs.getInt(1);
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ SqlConnectionManager.releaseResultSet(rs);
+ }
+ }
+ return totalCount;
+ }
+
public List<FileEvent> select() {
String query = String.format(SELECT_ALL);
List<FileEvent> apiList = executeQueryRS(query);
public static String selectAllColumn() {
StringBuffer selectAllColumn = new StringBuffer();
- selectAllColumn.append(COLUMN.SEQ.name);
+ selectAllColumn.append(COLUMN.SEQUENCE_NUMBER.name);
selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.FILE_PATH.name);
- selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.PID.name);
+ selectAllColumn.append(COLUMN.FILE_ID.name);
selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.TID.name);
+ selectAllColumn.append(COLUMN.ACCESSOR_ID.name);
selectAllColumn.append(",");
selectAllColumn.append(COLUMN.FD.name);
selectAllColumn.append(",");
selectAllColumn.append(",");
selectAllColumn.append(COLUMN.FILE_SIZE.name);
selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.SIZE.name);
- selectAllColumn.append(",");
selectAllColumn.append(COLUMN.RETURN_VALUE.name);
selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.ARGS.name);
- selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.TARGET.name);
- selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.FILE_ID.name);
+ selectAllColumn.append(COLUMN.ARGUMENTS_VALUE.name);
return selectAllColumn.toString();
}
} else {
try {
prep.setInt(1, (Integer)(rowData.get(0)));
- prep.setString(2, (String)(rowData.get(1)));
+ prep.setInt(2, (Integer)(rowData.get(1)));
prep.setInt(3, (Integer)(rowData.get(2)));
- prep.setInt(4, (Integer)(rowData.get(3)));
- prep.setLong(5, (Long)(rowData.get(4)));
- prep.setInt(6, (Integer)(rowData.get(5)));
- prep.setLong(7, (Long)(rowData.get(6)));
- prep.setInt(8, (Integer)(rowData.get(7)));
+ prep.setLong(4, (Long)(rowData.get(3)));
+ prep.setInt(5, (Integer)(rowData.get(4)));
+ prep.setLong(6, (Long)(rowData.get(5)));
+ prep.setInt(7, (Integer)(rowData.get(6)));
+ prep.setLong(8, (Long)(rowData.get(7)));
prep.setLong(9, (Long)(rowData.get(8)));
prep.setLong(10, (Long)(rowData.get(9)));
- prep.setLong(11, (Long)(rowData.get(10)));
- prep.setLong(12, (Long)(rowData.get(11)));
- prep.setString(13, (String)(rowData.get(12)));
- prep.setString(14, (String)(rowData.get(13)));
- prep.setBoolean(15, (Boolean)(rowData.get(14)));
- prep.setInt(16, (Integer)(rowData.get(15)));
+ prep.setString(11, (String)(rowData.get(10)));
+ prep.setString(12, (String)(rowData.get(11)));
} catch (SQLException e) {
e.printStackTrace();
isPrepared = false;
}
return isPrepared;
}
-}
+}
\ No newline at end of file
// open, close
public class FileStatusDB extends DBTable {
- private static final String TABLE_NAME = FilePageLabels.FILE_STATUS_DB;
+ private static final String STATUS_TABLE = FilePageLabels.FILE_STATUS_DB;
public static enum COLUMN {
- FILE_PATH(1, "FILE_PATH"),
+ FILE_ID(1, "FILE_ID"),
API_TYPE(2, "API_TYPE"),
- EVENT_TIME(3, "EVENT_TIME"),
- ERRNO(4, "ERRNO");
+ EVENT_TIME(3, "EVENT_TIME");
private final int index;
private final String name;
}
public FileStatusDB() {
- addColumn(new DBColumn(COLUMN.FILE_PATH.name, DBConstants.NOT_NULL, DBConstants.BIG_TEXT));
+ addColumn(new DBColumn(COLUMN.FILE_ID.name, DBConstants.NOT_NULL, DBConstants.INTEGER));
addColumn(new DBColumn(COLUMN.API_TYPE.name, DBConstants.NOT_NULL, DBConstants.INTEGER));
addColumn(new DBColumn(COLUMN.EVENT_TIME.name, DBConstants.NOT_NULL, DBConstants.LONG));
- addColumn(new DBColumn(COLUMN.ERRNO.name, DBConstants.NOT_NULL, DBConstants.LONG));
}
@Override
public String getTableName() {
- return TABLE_NAME;
+ return STATUS_TABLE;
}
private static final String selectAll = selectAll();
private static final String SELECT_QUERY = "select "
+ selectAll
- + " from " + TABLE_NAME; //$NON-NLS-1$
+ + " from " + STATUS_TABLE; //$NON-NLS-1$
public List<FileStatus> executeQueryRS(String query) {
List<FileStatus> resultData = new ArrayList<FileStatus>();
FileStatus status = null;
try {
status = new FileStatus(
- rs.getString(COLUMN.FILE_PATH.index),
+ rs.getInt(COLUMN.FILE_ID.index),
rs.getInt(COLUMN.API_TYPE.index),
- rs.getLong(COLUMN.EVENT_TIME.index),
- rs.getLong(COLUMN.ERRNO.index)
+ rs.getLong(COLUMN.EVENT_TIME.index)
);
} catch (SQLException e) {
e.printStackTrace();
public static String selectAll() {
StringBuffer selectAllColumn = new StringBuffer();
- selectAllColumn.append(COLUMN.FILE_PATH.name);
+ selectAllColumn.append(COLUMN.FILE_ID.name);
selectAllColumn.append(",");
selectAllColumn.append(COLUMN.API_TYPE.name);
selectAllColumn.append(",");
selectAllColumn.append(COLUMN.EVENT_TIME.name);
- selectAllColumn.append(",");
- selectAllColumn.append(COLUMN.ERRNO.name);
return selectAllColumn.toString();
}
isPrepared = false;
} else {
try {
- prep.setString(1, (String)(rowData.get(0)));
+ prep.setInt(1, (Integer)(rowData.get(0)));
prep.setInt(2, (Integer)(rowData.get(1)));
prep.setLong(3, (Long)(rowData.get(2)));
- prep.setLong(4, (Long)(rowData.get(3)));
} catch (SQLException e) {
e.printStackTrace();
isPrepared = false;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
+import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
import org.tizen.dynamicanalyzer.common.DALimit;
import org.tizen.dynamicanalyzer.common.Global;
import org.tizen.dynamicanalyzer.swap.model.data.LogData;
import org.tizen.dynamicanalyzer.swap.model.data.ProfileData;
import org.tizen.dynamicanalyzer.ui.file.model.FileAccess;
+import org.tizen.dynamicanalyzer.ui.file.model.FileAccessor;
import org.tizen.dynamicanalyzer.ui.file.model.FileEvent;
import org.tizen.dynamicanalyzer.ui.file.model.FileStatus;
import org.tizen.dynamicanalyzer.ui.summary.SummaryDataManager;
private List<FileStatus> fileStatusList = new ArrayList<FileStatus>();
private List<FileAccess> fileAccessList = new ArrayList<FileAccess>();
private List<FileEvent> fileApiList = new ArrayList<FileEvent>();
-
-
- // to find file path, (key(PID, TID, FD), value (file_path))
- private Map<String, String> fileAccessorMap = new HashMap<String, String>();
-
- // temporary, file log list for 1second
- private Queue<List<FileEvent>> fileLogsQueue = new ConcurrentLinkedQueue<List<FileEvent>>();
-
- // (key(file path), value (read_count or write_count))
- private Map<String, Integer> concurrentAccessNumMap = new HashMap<String, Integer>();
- private Map<String, Integer> lockNumMap = new HashMap<String, Integer>();
+ private List<FileAccessor> fileAccessorList = new ArrayList<FileAccessor>();
- // for filtering out non-target file from syscall messages
- List<String> accessedFilePathList = new ArrayList<String>();
+ private Map<Integer, FileEvent> entryMap = new HashMap<Integer, FileEvent>(); // to match entry and exit message
+ private Map<String, List<Object>> fileAccessorMap= new HashMap<String, List<Object>>();
+ private Map<String, List<Object>> filePathMap= new HashMap<String, List<Object>>(); // to find file path
+ private Queue<List<FileAccessor>> fileAccessorQueue = new ConcurrentLinkedQueue<List<FileAccessor>>();
+ private Map<List<Integer>, List<Integer>> accessorHasLockMap = new HashMap<List<Integer>, List<Integer>>(); //to auto release
+ private Map<String, Integer> concurrentAccessNumMap = new HashMap<String, Integer>(); // to check concurrent access
- // temporary, to check if open event has been sent before the event has been sent
- private Map<String, FileEvent> sysCallMap = new HashMap<String, FileEvent>();
- // for searching entry message from exit message
- Map<Integer, FileEvent> entryMap = new HashMap<Integer, FileEvent>();
-
- private Map<String, Integer> fileMap = new HashMap<String, Integer>();
+ AtomicInteger idGenerator = new AtomicInteger();
public FileDataMaker() {}
public void clear(){
fileStatusList.clear();
fileAccessList.clear();
+ fileApiList.clear();
+ fileAccessorList.clear();
fileAccessorMap.clear();
- fileLogsQueue.clear();
+ fileAccessorQueue.clear();
+ filePathMap.clear();
+ accessorHasLockMap.clear();
concurrentAccessNumMap.clear();
- lockNumMap.clear();
- sysCallMap.clear();
- accessedFilePathList.clear();
entryMap.clear();
}
*/
List<FileEvent> fileEventList = new ArrayList<FileEvent>();
+ List<FileAccessor> fileAccessorList = new ArrayList<FileAccessor>();
// 1. In case of target process that the user is interested to analyze
ArrayList<List<Object>> fileApiList = new ArrayList<List<Object>>();
}
// filtering out print log and main func log
- // TODO: DISCUSSION: checkInvalidApiName: make the SWAP not send
- // TODO: DISCUSSION: isOpenMainLog: why osp main?
if (checkInvalidApiName(input) || isOpenMainLog(input)) {
continue;
}
input.getArgs(), input.getReturn(), input.getErrno(),
true);
- switch(input.getFdApiType()) {
- case LogCenterConstants.FD_API_TYPE_OPEN:
- accessedFilePathList.add(input.getFilePath());
- break;
- case LogCenterConstants.FD_API_TYPE_LOCK_START:
- case LogCenterConstants.FD_API_TYPE_LOCK_END:
- String args = input.getArgs();
- String[] splitPath = args.split(",\\s+");
- event.setLockType(Integer.parseInt(splitPath[1]));
- break;
- }
addFileEvent(fileEventList, event, input);
}
}
if (syscallLogs != null) {
ProfileData profileData = null;
FileEvent event = null;
+ FileEvent fakeOpenEvent = null;
String filePath = null;
long fd = 0;
String[] splitPath = args.split(",\\s+");
filePath = splitPath[0];
fd = Long.parseLong(splitPath[1]);
- FileEvent openEvent = null;
+
+ event = new FileEvent(seq, pid, tid, fd, filePath, eventType, time, 0, false);
+ fakeOpenEvent = new FileEvent(0, pid, tid, fd, filePath,
+ LogCenterConstants.FD_API_TYPE_OPEN, time, 0, false);
- // filtering out non-target files that user in not interested
- if(accessedFilePathList.contains(filePath)) {
- // target file
+ //fileAccessorMap: to filter out non-target files that user in not interested
+ //filePathMap: to check if the open event is exist
+ if(fileAccessorMap.containsKey(filePath)) {
Logger.debug(">> syscall:seq:" + seq + ", pid:" + pid
+ ", tid:" + tid + ", type:" + eventType + ", args:" + args);
if(fd == -1) {
event.setErrNo(-1);
}
+
+ String key = createKey(pid, tid, fd);
switch(eventType) {
case LogCenterConstants.FD_API_TYPE_OPEN:
- sysCallMap.put(filePath, event);
+ addFilePathInfo(key, filePath, -1, -1);
addFileEvent(fileEventList, event, null);
break;
case LogCenterConstants.FD_API_TYPE_CLOSE:
- openEvent = sysCallMap.get(filePath);
- if(openEvent != null) {
+ if(filePathMap.containsKey(key)) {
addFileEvent(fileEventList, event, null);
+ removeFilePathInfo(key);
}
break;
case LogCenterConstants.FD_API_TYPE_LOCK_START:
- openEvent = sysCallMap.get(filePath);
- if(openEvent == null) {
- // make fake open event
- FileEvent fakeOpenEvent = new FileEvent(0, pid,
- tid, fd, filePath,
- LogCenterConstants.FD_API_TYPE_OPEN,
- time, 0, false);
+ if(!filePathMap.containsKey(key)){
addFileEvent(fileEventList, fakeOpenEvent, null);
+ addFilePathInfo(key, filePath, -1, -1);
}
entryMap.put(seq, event);
- event.setLockType(Integer.parseInt(splitPath[2]));
addFileEvent(fileEventList, event, null);
break;
case LogCenterConstants.FD_API_TYPE_UNLOCK:
- openEvent = sysCallMap.get(filePath);
- if(openEvent == null) {
- // make fake open event
- FileEvent fakeOpenEvent = new FileEvent(0, pid,
- tid, fd, filePath,
- LogCenterConstants.FD_API_TYPE_OPEN,
- time, 0, false);
+ if(!filePathMap.containsKey(key)){
addFileEvent(fileEventList, fakeOpenEvent, null);
+ addFilePathInfo(key, filePath, -1, -1);
}
- entryMap.put(seq, event);
break;
case LogCenterConstants.FD_API_TYPE_READ_START:
case LogCenterConstants.FD_API_TYPE_WRITE_START:
- openEvent = sysCallMap.get(filePath);
- if(openEvent == null) {
- // make fake open event
- FileEvent fakeOpenEvent = new FileEvent(0, pid,
- tid, fd, filePath,
- LogCenterConstants.FD_API_TYPE_OPEN,
- time, 0, false);
+ if(!filePathMap.containsKey(key)){
addFileEvent(fileEventList, fakeOpenEvent, null);
+ addFilePathInfo(key, filePath, -1, -1);
}
entryMap.put(seq, event);
addFileEvent(fileEventList, event, null);
}// else, non-target file
break;
case DataChannelConstants.MSG_FUNCTION_EXIT:
- // for creating read/write end event with MSG_FUNCTION_EXIT
+ // for creating read/write/lock end event with MSG_FUNCTION_EXIT
int entrySeq = profileData.getEntrySeq();
+ String ret = profileData.getReturn();
+
if(entryMap.containsKey(entrySeq)) {
- Logger.debug(">> syscall entrySeq:" + + entrySeq + "endseq:" + seq + ", pid:" + pid
- + ", tid:" + tid + ", type:" + eventType);
event = entryMap.get(entrySeq);
if(Long.parseLong(profileData.getReturn()) == -1) {
event.setErrNo(-1);
switch(eventType) {
case LogCenterConstants.FD_API_TYPE_READ_START:
event.setFdApiType(LogCenterConstants.FD_API_TYPE_READ_END);
+ event.setTime(time);
addFileEvent(fileEventList, event, null);
break;
case LogCenterConstants.FD_API_TYPE_WRITE_START:
event.setFdApiType(LogCenterConstants.FD_API_TYPE_WRITE_END);
+ event.setTime(time);
addFileEvent(fileEventList, event, null);
break;
case LogCenterConstants.FD_API_TYPE_LOCK_START:
event.setFdApiType(LogCenterConstants.FD_API_TYPE_LOCK_END);
+ event.setTime(time);
addFileEvent(fileEventList, event, null);
break;
case LogCenterConstants.FD_API_TYPE_UNLOCK:
event.setFdApiType(LogCenterConstants.FD_API_TYPE_UNLOCK);
event.setTime(time);
addFileEvent(fileEventList, event, null);
+ break;
default:
break;
}
for(FileEvent data : fileEventList) {
fileApiList.add(data.getDBData());
}
- fileLogsQueue.add(fileEventList);
FileDataManager.getInstance().getApiDB().insert((List<List<Object>>)fileApiList);
}
+
+ Set<String> kyeSet = fileAccessorMap.keySet();
+ for (Iterator<String> iterator = kyeSet.iterator(); iterator.hasNext();) {
+ String key = (String) iterator.next();
+ List<Object> values= fileAccessorMap.get(key);
+ Object[] list = values.toArray();
+ List<FileAccessor> accessor = (ArrayList<FileAccessor>)list[1];
+ fileAccessorList.addAll(accessor);
+ }
+ fileAccessorQueue.add(fileAccessorList);
}
/**
long size = event.getSize();
long errNo = event.getErrno();
- int fileId = 0;
String key = null;
Logger.debug("pid:" + pid + " tid:" +tid + " apiType:" + apiType);
+
if(isTarget) {
key = createKey(pid, tid, fd);
if(fd == -1) {
- // set the unknown file if the file open or close has been failed
- event.setFilePath(FilePageLabels.FILE_CHART_UNKNOWN_FILE);
- } else if(filePath == null || filePath.equals("")) {
- // set the file path to all normal file event that open and close was succeed
- filePath = getFilePath(key);
+ filePath = FilePageLabels.FILE_CHART_UNKNOWN_FILE;
+ int[] fileInfo = addFileAccessor(filePath, pid, tid, isTarget);
+ event.setFileId(fileInfo[0]);
+ event.setAccessorId(fileInfo[1]);
event.setFilePath(filePath);
- event.setFileId(getFileId(filePath));
- }else{
- fileId = getFileId(filePath);
- event.setFileId(fileId);
+ }else if(filePath == null || filePath.equals("")) {
+ // get file path except open event
+ Object[] fileInfo = getFilePathInfo(key);
+ filePath = (String)fileInfo[0];
+ event.setFilePath(filePath);
+ event.setFileId((Integer)fileInfo[1]);
+ event.setAccessorId((Integer)fileInfo[2]);
}
+ }else{
+ int[] fileInfo = addFileAccessor(filePath, pid, tid, isTarget);
+ event.setFileId(fileInfo[0]);
+ event.setAccessorId(fileInfo[1]);
}
switch (apiType) {
case LogCenterConstants.FD_API_TYPE_OPEN:
- if(isTarget && errNo == 0) {
- addFileAccessor(key, filePath);
+ if (isTarget) {
+ int[] fileInfo = addFileAccessor(filePath, pid, tid, isTarget);
+ event.setFileId(fileInfo[0]);
+ event.setAccessorId(fileInfo[1]);
+ addFilePathInfo(key, filePath, fileInfo[0], fileInfo[1]);
+ }
+ if (errNo == 0) {
+ addStatusData(new FileStatus(event.getFileId(), apiType, eventTime));
}
- addStatusData(new FileStatus(filePath, apiType, eventTime, errNo));
break;
case LogCenterConstants.FD_API_TYPE_CLOSE:
- if(isTarget && errNo == 0) {
- removeFileAccessor(key);
- }
- addStatusData(new FileStatus(filePath, apiType, eventTime, errNo));
- // if it remains lock without lock release
- if(getCurrentLockNum(filePath) > 0) {
- removeLockNum(filePath);
- addEndAccessData(pid, tid, fd, filePath, eventTime, size,
- LogCenterConstants.FD_API_TYPE_LOCK_START, errNo);
+ if(errNo == 0) {
+ if(isTarget) {
+ removeFilePathInfo(key);
+ }
+ addStatusData(new FileStatus(event.getFileId(), apiType, eventTime));
+ List<Integer> accessorIds = getTidsHasLock(event.getFileId(), pid);
+ if(accessorIds != null) {
+ // lock auto release
+ for(Integer accessor : accessorIds){
+ FileAccess access = new FileAccess(accessor,
+ LogCenterConstants.FD_API_TYPE_LOCK_AUTORELEASE,
+ eventTime, eventTime, FilePageLabels.FILE_CHART_TOOLTIP_LOCK_AUTORELEASE);
+ addAccessData(access);
+ }
+ removeTidsHasLock(event.getFileId(), pid);
+ }
}
break;
case LogCenterConstants.FD_API_TYPE_READ_START:
- FileAccess readAccess = new FileAccess(filePath, pid,
- tid, fd, apiType, eventTime);
+ FileAccess readAccess = new FileAccess(event.getAccessorId(), fd, apiType,
+ eventTime, FilePageLabels.FILE_CHART_TOOLTIP_READ);
if(checkConcurrentAccess(filePath)) {
readAccess.setWarning();
+ readAccess.setTooltip(FilePageLabels.FILE_CHART_TOOLTIP_CONCURRENT_READ);
if(logData != null) {
SummaryDataManager.getInstance().getWarningDataMaker().makeData(
logData,
addStartAccessData(readAccess);
break;
case LogCenterConstants.FD_API_TYPE_READ_END:
- addEndAccessData(pid, tid, fd, filePath, eventTime,
- size, LogCenterConstants.FD_API_TYPE_READ_START, errNo);
+ addEndAccessData(event.getAccessorId(), fd, eventTime,
+ size, LogCenterConstants.FD_API_TYPE_READ_START, errNo);
removeConcurrentAccess(filePath);
break;
case LogCenterConstants.FD_API_TYPE_WRITE_START:
- FileAccess writeAccess = new FileAccess(filePath, pid,
- tid, fd, apiType, eventTime);
+ FileAccess writeAccess = new FileAccess(event.getAccessorId(), fd, apiType,
+ eventTime, FilePageLabels.FILE_CHART_TOOLTIP_WRITE);
if(checkConcurrentAccess(filePath)) {
writeAccess.setWarning();
+ writeAccess.setTooltip(FilePageLabels.FILE_CHART_TOOLTIP_CONCURRENT_WRITE);
if(logData != null) {
SummaryDataManager.getInstance().getWarningDataMaker().makeData(
logData,
addStartAccessData(writeAccess);
break;
case LogCenterConstants.FD_API_TYPE_WRITE_END:
- addEndAccessData(pid, tid, fd, filePath, eventTime,
+ addEndAccessData(event.getAccessorId(), fd, eventTime,
size, LogCenterConstants.FD_API_TYPE_WRITE_START, errNo);
removeConcurrentAccess(filePath);
break;
case LogCenterConstants.FD_API_TYPE_LOCK_START:
- addStartAccessData(new FileAccess(filePath, pid, tid, fd,
- apiType, eventTime));
- if(event.getLockType() == AnalyzerConstants.F_SETLKW) {// F_SETLKW
- addStartAccessData(new FileAccess(filePath, pid, tid, fd,
- LogCenterConstants.FD_API_TYPE_LOCK_WAIT_START, eventTime));
- }
- addCurrentLock(filePath);
+ addStartAccessData(new FileAccess(event.getAccessorId(), fd, apiType,
+ eventTime, FilePageLabels.FILE_CHART_TOOLTIP_LOCK));
break;
case LogCenterConstants.FD_API_TYPE_LOCK_END:
- if(event.getLockType() == AnalyzerConstants.F_SETLKW) {// F_SETLKW
- addEndAccessData(pid, tid, fd, filePath, eventTime,
- size, LogCenterConstants.FD_API_TYPE_LOCK_WAIT_START, errNo);
- }
+ addEndAccessData(event.getAccessorId(), fd, eventTime, size,
+ LogCenterConstants.FD_API_TYPE_LOCK_START, errNo);
+ addFileLock(event.getFileId(), pid, event.getAccessorId());
break;
case LogCenterConstants.FD_API_TYPE_UNLOCK:
- removeLockNum(filePath);
- addEndAccessData(pid, tid, fd, filePath, eventTime,
- size, LogCenterConstants.FD_API_TYPE_LOCK_START, errNo);
+ addAccessData(new FileAccess(event.getAccessorId(), apiType,
+ eventTime, eventTime, FilePageLabels.FILE_CHART_TOOLTIP_UNLOCK));
break;
default:
break;
}
- fileEventList.add(event);
+
+ // file access fail
+ if (errNo != 0) {
+ String tooltip = FilePageLabels.FILE_CHART_TOOLTIP_FAIL + " "
+ + Global.getFunctionName(event.getApiId());
+ FileAccess accessFail = new FileAccess(event.getAccessorId(),
+ LogCenterConstants.FD_API_TYPE_FAIL, eventTime, eventTime,
+ tooltip);
+ addAccessData(accessFail);
+ }
+
+ if(event.isTarget()) {
+ fileEventList.add(event);
+ }
}
public void addStatusData(FileStatus data) {
public void addStartAccessData(FileAccess data) {
fileAccessList.add(data);
}
-
+
+ public void addAccessData(FileAccess data) {
+ fileAccessList.add(data);
+ FileDataManager.getInstance().getAccessDB().insert(data);
+ }
+
// in case of file read/write/lock probe/system call
- public void addEndAccessData(int pid, int tid, long fd, String filePath,
- long endTime, long fileSize, int apiType, long errNo) {
+ public void addEndAccessData(int accessorId, long fd, long endTime,
+ long ioSize, int apiType, long errNo) {
for (int i = 0; i < fileAccessList.size(); i++) {
FileAccess data = fileAccessList.get(i);
- if (data.getPid() == pid
- && data.getTid() == tid
+ if (data.getAccessorId() == accessorId
&& data.getFd() == fd
&& data.getApiType() == apiType
&& data.getEndTime() <= 0){
- data.setEndTime(endTime);
- data.setFileSize(fileSize);
- data.setErroNo(errNo);
- FileDataManager.getInstance().getAccessDB().insert(data);
+ if(errNo!=0) {
+ fileAccessList.remove(i);
+ }else{
+ data.setEndTime(endTime);
+ if(apiType == LogCenterConstants.FD_API_TYPE_WRITE_START
+ || apiType == LogCenterConstants.FD_API_TYPE_READ_START){
+ String tooltip = data.getTooltip() + " , " + String.valueOf(ioSize);
+ data.setTooltip(tooltip);
+ }
+ FileDataManager.getInstance().getAccessDB().insert(data);
+ }
break;
}
}
// when failed search start time, dump endEvent.
}
- public List<FileEvent> getFileEventList() {
- return fileLogsQueue.poll();
- }
-
- public List<FileAccess> getFileAccessList() {
- return fileAccessList;
- }
-
- public List<FileStatus> getFileStatusList() {
- return fileStatusList;
- }
-
- public List<FileEvent> getFileApiList() {
- return fileApiList;
- }
-
private String createKey(int pid, int tid, long fd) {
StringBuffer key = new StringBuffer();
key.append(pid);
return key.toString();
}
- // for the open log: probe only
- private void addFileAccessor(String key, String filePath) {
- if(!fileAccessorMap.containsKey(key)) {
- fileAccessorMap.put(key, filePath);
- } else {
- Logger.error(" addFileAccessor:" + key + "is aleady exist" );
- }
- }
-
- // for the close log: probe only
- private void removeFileAccessor(String key) {
- if(fileAccessorMap.containsKey(key)) {
- fileAccessorMap.remove(key);
- }else {
- Logger.error(" removeFileAccessor:" + key + "is not exist" );
- }
- }
-
- private String getFilePath(String key) {
- String filePath = null;
- if(fileAccessorMap.containsKey(key)) {
- filePath = fileAccessorMap.get(key);
- }else{
- Logger.error("The key is not exist : " + key);
- }
- return filePath;
- }
-
/**
* Check if it is concurrent access
* @param concurrentKey
}
}
- private int addCurrentLock(String lockKey) {
- int num = 0;
- if(lockNumMap.containsKey(lockKey)) {
- num = lockNumMap.get(lockKey);
- lockNumMap.put(lockKey, num+1);
+ /**
+ * Add a new file accessor
+ * @param filePath
+ * @param pid
+ * @param tid
+ * @return fileId
+ */
+ private int[] addFileAccessor(String filePath, int pid, int tid, boolean isTarget) {
+ int fileId = -1;
+ int accessorId = -1;
+ if(fileAccessorMap.containsKey(filePath)) {
+ List<Object> set = fileAccessorMap.get(filePath);
+ Object[] list = set.toArray();
+ fileId = (Integer) list[0];
+ List<FileAccessor> accessorList = (ArrayList<FileAccessor>) list[1];
+ boolean isExistAccessor = false;
+ for(FileAccessor accessor : accessorList) {
+ if(pid == accessor.getPid() && tid == accessor.getTid()) {
+ accessorId = accessor.getAccessorId();
+ isExistAccessor = true;
+ break;
+ }
+ }
+ if(!isExistAccessor){
+ // add a new file accessor
+ accessorId = idGenerator.incrementAndGet();
+ FileAccessor newAccessor = new FileAccessor(
+ accessorId, fileId, filePath, pid, tid, isTarget);
+ accessorList.add(newAccessor);
+ set.add(fileId);
+ set.add(accessorList);
+ fileAccessorMap.put(filePath, set);
+ FileDataManager.getInstance().getAccessorDB().insert(newAccessor);
+ }
+ }else{
+ fileId = fileAccessorMap.size()+1;
+ accessorId = idGenerator.incrementAndGet();
+ List<FileAccessor> accessorList = new ArrayList<FileAccessor>();
+ FileAccessor newAccessor = new FileAccessor(accessorId,
+ fileId, filePath, pid, tid, isTarget);
+ accessorList.add(newAccessor);
+ List<Object> set = new ArrayList<Object>();
+ set.add(fileId);
+ set.add(accessorList);
+ fileAccessorMap.put(filePath, set);
+ FileDataManager.getInstance().getAccessorDB().insert(newAccessor);
}
- lockNumMap.put(lockKey, num+1);
- return num;
+ return new int[]{fileId, accessorId};
}
- private int getCurrentLockNum(String lockKey) {
- int num = 0;
- if(lockNumMap.containsKey(lockKey)) {
- num = lockNumMap.get(lockKey);
+
+ /**
+ * Get file path
+ * @param key
+ * @return Object[0]:filePath,Object[1]:fileId, Object[2]:accessorId
+ */
+ private Object[] getFilePathInfo(String key) {
+ Object[] list = null;
+ if(filePathMap.containsKey(key)) {
+ List<Object> set = filePathMap.get(key);
+ list = set.toArray();
+ }else{
+ Logger.error("The key is not exist : " + key);
}
- return num;
+ return list;
}
-
- private void removeLockNum(String lockKey) {
- int num = 0;
- if(lockNumMap.containsKey(lockKey)) {
- num = lockNumMap.get(lockKey);
- lockNumMap.put(lockKey, num-1);
- } else {
- Logger.error("Couldn't get current lock num!, key :" + lockKey);
+
+ /**
+ * Add file path information
+ * @param key
+ * @param filePath
+ * @param fileId
+ * @param accessorId
+ */
+ private void addFilePathInfo(String key, String filePath, int fileId, int accessorId){
+ if(!filePathMap.containsKey(key)) {
+ List<Object> set = new ArrayList<Object>();
+ set.add((String)filePath);
+ set.add((Integer)fileId);
+ set.add((Integer)accessorId);
+ filePathMap.put(key, set);
}
}
- private int getFileId(String filePath) {
- if(fileMap.containsKey(filePath)) {
- return fileMap.get(filePath);
+ private void removeFilePathInfo(String key) {
+ if(filePathMap.containsKey(key)) {
+ filePathMap.remove(key);
+ }
+ }
+
+ /**
+ * Add file lock information
+ * @param fileId
+ * @param pid
+ * @param accessorId
+ */
+ private void addFileLock(int fileId, int pid, int accessorId) {
+ List<Integer> key = Arrays.asList(fileId, pid);
+ List<Integer> tids = new ArrayList<Integer>();
+ if(accessorHasLockMap.containsKey(key)){
+ tids = accessorHasLockMap.get(key);
+ if(!tids.contains(accessorId)) {
+ tids.add(accessorId);
+ accessorHasLockMap.put(key, tids);
+ }
}else{
- int size = fileMap.size()+1;
- fileMap.put(filePath, size);
- return size;
+ tids.add(accessorId);
+ accessorHasLockMap.put(key, tids);
+ }
+ }
+
+ /**
+ * Get TIDs which has file locks
+ * @param fileId
+ * @param pid
+ * @return
+ */
+ private List<Integer> getTidsHasLock(int fileId, int pid) {
+ List<Integer> tids = null;
+ List<Integer> key = Arrays.asList(fileId, pid);
+ if(accessorHasLockMap.containsKey(key)) {
+ tids = accessorHasLockMap.get(key);
+ }
+ return tids;
+ }
+
+ private void removeTidsHasLock(int fileId, int pid) {
+ List<Integer> key = Arrays.asList(fileId, pid);
+ if(accessorHasLockMap.containsKey(key)) {
+ accessorHasLockMap.remove(key);
}
}
}
}
-
/**
* filtering out STDIN/STDOUT ops
* @param input
return false;
}
+ public List<FileAccessor> getFileAccessor() {
+ return fileAccessorQueue.poll();
+ }
+
+ public List<FileAccess> getFileAccessList() {
+ return fileAccessList;
+ }
+
+ public List<FileStatus> getFileStatusList() {
+ return fileStatusList;
+ }
+
+ public List<FileEvent> getFileApiList() {
+ return fileApiList;
+ }
+
+ public List<FileAccessor> getFileAccessorList() {
+ return fileAccessorList;
+ }
+
public void setFileAccessList(List<FileAccess> fileAccessList) {
this.fileAccessList = fileAccessList;
}
public void setFileApiList(List<FileEvent> fileApiList) {
this.fileApiList = fileApiList;
}
+
+ public void setFileAccessorList(List<FileAccessor> fileAccessorList) {
+ this.fileAccessorList = fileAccessorList;
+ }
}
import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager;
import org.tizen.dynamicanalyzer.ui.file.data.FileAccessDB;
+import org.tizen.dynamicanalyzer.ui.file.data.FileAccessorDB;
import org.tizen.dynamicanalyzer.ui.file.data.FileApiDB;
import org.tizen.dynamicanalyzer.ui.file.data.FileStatusDB;
import org.tizen.dynamicanalyzer.ui.file.model.FileAccess;
private FileAccessDB accessDB = null;
private FileApiDB apiDB = null;
private FileStatusDB statusDB = null;
+ private FileAccessorDB accessorDB = null;
private FileSelectedData selectedData = null;
accessDB = new FileAccessDB();
apiDB = new FileApiDB();
statusDB = new FileStatusDB();
+ accessorDB = new FileAccessorDB();
}
public void clear() {
accessDB = null;
apiDB = null;
statusDB = null;
+ accessorDB = null;
selectedData = null;
}
return statusDB;
}
+ public FileAccessorDB getAccessorDB() {
+ return accessorDB;
+ }
+
public void saveData(Map<String, String> dataMap) {
List<FileAccess> accessList = dataMaker.getFileAccessList();
if (accessList != null ) {
if (dataMaker.getFileApiList().size() == 0) {
dataMaker.setFileApiList(apiDB.select());
}
+
+ if (dataMaker.getFileAccessorList().size() == 0) {
+ dataMaker.setFileAccessorList(accessorDB.select());
+ }
}
public FileDataMaker getFileChartDataMaker() {
public class FileAccess {
- private String filePath = null;
- private int pid = -1;
- private int tid = -1;
+ private int accessorId = -1;
private long fd = -1;
- private int apiType = -1; // only read, write, lock event
+ private int apiType = -1; // r/w, concurrent r/w, lock, lock wait, unlock, auto release, fail
private long startTime = -1;
private long endTime = -1;
- private long erroNo = 0;
- private long fileSize = -1;
+ private String tooltip = null;
private boolean isAlreadyReading = false;
private boolean isAlreadyWriting = false;
private boolean isAlreadyLocking = false;
private boolean isWarning = false;
-
- public FileAccess(String filePath, int pid, int tid, long fd, int apiType, long startTime) {
- this.filePath = filePath;
- this.pid = pid;
- this.tid = tid;
+ public FileAccess(int accessorId, long fd, int apiType, long startTime, String tooltip) {
this.fd = fd;
+ this.accessorId = accessorId;
this.apiType = apiType;
this.startTime = startTime;
+ this.tooltip = tooltip;
}
- public FileAccess(int pid, int tid, String filePath, long fd, int apiType, long startTime,
- long endTime, long erroNo, long fileSize) {
- this.pid = pid;
- this.tid = tid;
- this.filePath = filePath;
- this.fd = fd;
+ public FileAccess(int accessorId, int apiType, long startTime, long endTime, String tooltip) {
+ this.accessorId = accessorId;
this.apiType = apiType;
this.startTime = startTime;
this.endTime = endTime;
- this.erroNo = erroNo;
- this.fileSize = fileSize;
+ this.tooltip = tooltip;
}
public List<Object> getDBData() {
List<Object> data = new ArrayList<Object>();
- data.add(new Integer(this.pid));
- data.add(new Integer(this.tid));
- data.add(this.filePath);
- data.add(new Long(this.fd));
- data.add(new Integer(this.apiType));
- data.add(new Long(this.startTime));
- data.add(new Long(this.endTime));
- data.add(new Long(this.erroNo));
- data.add(new Long(this.fileSize));
+ data.add(this.accessorId);
+ data.add(this.apiType);
+ data.add(this.startTime);
+ data.add(this.endTime);
+ data.add(this.tooltip);
return data;
}
-
- public String getFilePath() {
- return filePath;
- }
-
- public void setFilePath(String filePath) {
- this.filePath = filePath;
- }
-
- public int getPid() {
- return pid;
- }
-
- public void setPid(int pid) {
- this.pid = pid;
- }
-
- public int getTid() {
- return tid;
- }
-
- public void setTid(int tid) {
- this.tid = tid;
- }
-
- public long getFd() {
- return fd;
- }
-
- public void setFd(long fd) {
- this.fd = fd;
- }
public int getApiType() {
return apiType;
this.isAlreadyLocking = isAlreadyLocking;
}
- public long getErroNo() {
- return erroNo;
- }
- public void setErroNo(long erroNo) {
- this.erroNo = erroNo;
+ public String getTooltip() {
+ return tooltip;
}
- public long getFileSize() {
- return fileSize;
- }
-
- public void setFileSize(long fileSize) {
- this.fileSize = fileSize;
+ public void setTooltip(String tooltip) {
+ this.tooltip = tooltip;
}
public void setWarning() {
public boolean isWarning() {
return isWarning;
}
+
+ public void setFd(long fd) {
+ this.fd = fd;
+ }
+
+ public long getFd() {
+ return fd;
+ }
+
+ public int getAccessorId() {
+ return accessorId;
+ }
+
+ public void setAccessorId(int accessorId) {
+ this.accessorId = accessorId;
+ }
}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hyeran Kim <Hyeran74.kim@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.dynamicanalyzer.ui.file.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class FileAccessor {
+ private int accessorId = -1;
+ private int fileId = -1;
+ private String filePath = null;
+ private int pid = -1;
+ private int tid = -1;
+ private boolean isTarget = true;
+
+ public FileAccessor(int accessorId, int fileId, String filePath, int pid, int tid, boolean isTarget) {
+ this.accessorId = accessorId;
+ this.fileId = fileId;
+ this.filePath = filePath;
+ this.pid = pid;
+ this.tid = tid;
+ this.isTarget = isTarget;
+ }
+
+ public List<Object> getDBData() {
+ List<Object> data = new ArrayList<Object>();
+ data.add(this.accessorId);
+ data.add(this.fileId);
+ data.add(this.filePath);
+ data.add(this.pid);
+ data.add(this.tid);
+ data.add(this.isTarget);
+ return data;
+ }
+
+ public int getAccessorId() {
+ return accessorId;
+ }
+ public void setAccessorId(int accessorId) {
+ this.accessorId = accessorId;
+ }
+ public int getFileId() {
+ return fileId;
+ }
+ public void setFileId(int fileId) {
+ this.fileId = fileId;
+ }
+ public String getFilePath() {
+ return filePath;
+ }
+ public void setFilePath(String filePath) {
+ this.filePath = filePath;
+ }
+ public int getPid() {
+ return pid;
+ }
+ public void setPid(int pid) {
+ this.pid = pid;
+ }
+ public int getTid() {
+ return tid;
+ }
+ public void setTid(int tid) {
+ this.tid = tid;
+ }
+ public boolean isTarget() {
+ return isTarget;
+ }
+ public void setIsTarget(boolean isTarget) {
+ this.isTarget = isTarget;
+ }
+
+ @Override
+ public boolean equals(Object o){
+ FileAccessor s = (FileAccessor) o;
+ if(this.fileId == s.getFileId()
+ && this.pid == s.getPid()
+ && this.tid == s.getTid()){
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
import java.util.List;
import org.tizen.dynamicanalyzer.swap.model.data.FileData;
-import org.tizen.dynamicanalyzer.ui.file.data.FileApiDB;
public class FileEvent extends FileData{
- // TODO considering apiId
private int apiId = -1;
- private long ioSize =-1;
private boolean target = false;
private int lockType = -1;
- protected int fileId = -1;
-
+
+ protected int fileId = -1;
+ protected int accessorId = -1;
+
public FileEvent() { }
// for non-target process
public FileEvent(int seq, String filePath, int pid, int tid,
long fd, int apiType, int apiId, long eventTime, long fileSize, long size,
- String args, String returnVal, long errNo, boolean target, int fileId){
+ String args, String returnVal, long errNo){
this.seq = seq;
- this.filePath = filePath;
this.pid = pid;
this.tid = tid;
+ this.filePath = filePath;
this.fdValue = fd;
this.fdApiType = apiType;
this.apiId = apiId;
this.args = args;
this.ret = returnVal;
this.errno = errNo;
- this.target = target;
- this.fileId = fileId;
}
- public FileEvent(int seq, String filePath, int pid, int tid) {
+ public FileEvent(int seq, int accessorId, int fileId,
+ long fd, int apiType, int apiId, long eventTime, long fileSize, long size,
+ String args, String returnVal, long errNo){
this.seq = seq;
- this.filePath = filePath;
- this.pid = pid;
- this.tid = tid;
+ this.fileId = fileId;
+ this.accessorId = accessorId;
+ this.fdValue = fd;
+ this.fdApiType = apiType;
+ this.apiId = apiId;
+ this.time = eventTime;
+ this.fileSize = fileSize;
+ this.size = size;
+ this.args = args;
+ this.ret = returnVal;
+ this.errno = errNo;
}
public List<Object> getDBData() {
List<Object> data = new ArrayList<Object>();
data.add(this.seq);
- data.add(this.filePath);
- data.add(this.pid);
- data.add(this.tid);
+ data.add(this.fileId);
+ data.add(this.accessorId);
data.add(this.fdValue);
data.add(this.fdApiType);
data.add(this.time);
data.add(this.apiId);
data.add(this.errno);
- data.add(this.ioSize);
data.add(this.fileSize);
data.add(this.size);
data.add(this.ret);
data.add(this.args);
- data.add(this.target);
- data.add(this.fileId);
+
return data;
}
this.seq = seqNo;
}
- public long getIoSize() {
- return ioSize;
- }
-
- public void setIoSize(long ioSize) {
- this.ioSize = ioSize;
- }
-
public long getFileSize() {
return fileSize;
}
public int getFileId() {
return fileId;
}
+
+ public int getAccessorId() {
+ return accessorId;
+ }
+
+ public void setAccessorId(int accessorId) {
+ this.accessorId = accessorId;
+ }
}
public class FileSelectedData extends FileEvent{
private boolean isParentChart = false;
+ private FileAccessor accessor = null;
- public FileSelectedData(String filePath, int pid, int tid,long fd, boolean isParentChart, int fileId) {
- this.filePath = filePath;
- this.pid = pid;
- this.tid = tid;
- this.fdValue = fd;
+ public FileSelectedData(FileAccessor accessor, boolean isParentChart) {
+ this.accessor = accessor;
+ this.accessorId = accessor.getAccessorId();
+ this.fileId = accessor.getFileId();
+ }
+
+ /*public FileSelectedData(int accessorId, int fileId, boolean isParentChart) {
+ this.fileId = fileId;
+ this.accessorId = accessorId;
this.isParentChart = isParentChart;
+ }*/
+
+ public FileSelectedData(int fileId, boolean isParentChart) {
this.fileId = fileId;
+ this.isParentChart = isParentChart;
}
-
+
+
public boolean isParentChart() {
return isParentChart;
}
this.isParentChart = isParentChart;
}
+ public FileAccessor getFileAccessor() {
+ return accessor;
+ }
+
public String getFileName() {
String[] splitPath = this.filePath.split("\\/"); //$NON-NLS-1$
String fileName = new String(splitPath[splitPath.length - 1]);
import java.util.List;
public class FileStatus {
- private String filePath = null;
+ private int fileId = -1;
private int apiType = -1; // only open, close event
private long eventTime = -1;
- private long errNo = 0;
-
- public FileStatus(String filePath,int apiType, long eventTime, long errNo) {
- this.filePath = filePath;
+
+ public FileStatus(int fileId, int apiType, long eventTime) {
+ this.fileId = fileId;
this.apiType = apiType;
this.eventTime = eventTime;
- this.errNo = errNo;
}
public List<Object> getDBData() {
List<Object> data = new ArrayList<Object>();
- data.add(this.filePath);
+ data.add(this.fileId);
data.add(this.apiType);
data.add(this.eventTime);
- data.add(this.errNo);
return data;
}
- public String getFilePath() {
- return filePath;
- }
-
- public void setFilePath(String filePath) {
- this.filePath = filePath;
- }
-
public int getApiType() {
return apiType;
}
public void setApiType(int apiType) {
this.apiType = apiType;
}
-
- public void setErrNo(long errNo) {
- this.errNo = errNo;
- }
-
- public long getErrNo() {
- return errNo;
+ public void setFileId(int fileId) {
+ this.fileId = fileId;
}
+ public int getFileId() {
+ return fileId;
+ }
}