private final static int MAX_IMAGEPATH_LEN = 1024;
public static enum COLUMN {
- TIME,
+ CAPTURE_TIME,
IMAGE_FILE_PATH,
IMAGE_ORIENTATION
}
- public static final String TIME = "TIME";
+ public static final String CAPTURE_TIME = "CAPTURE_TIME";
public static final String IMAGE_FILE_PATH = "IMAGE_FILE_PATH";
public static final String IMAGE_ORIENTATION = "IMAGE_ORIENTATION";
}
public ScreenShotDBTable() {
- addColumn(new DBColumn(TIME, DBConstants.NOT_NULL, DBConstants.LONG));
+ addColumn(new DBColumn(CAPTURE_TIME, DBConstants.NOT_NULL, DBConstants.LONG));
addColumn(new DBColumn(IMAGE_FILE_PATH, DBConstants.NOT_NULL, DBConstants.VARCHAR, MAX_IMAGEPATH_LEN));
addColumn(new DBColumn(IMAGE_ORIENTATION, DBConstants.NOT_NULL, DBConstants.INTEGER));
- setIndexColumn(COLUMN.TIME.ordinal());
+ setIndexColumn(COLUMN.CAPTURE_TIME.ordinal());
}
@Override
isPrepared = false;
} else {
try {
- prep.setLong(1, (Long) (rowData.get(COLUMN.TIME.ordinal())));
+ prep.setLong(1, (Long) (rowData.get(COLUMN.CAPTURE_TIME.ordinal())));
prep.setString(2, (String) (rowData.get(COLUMN.IMAGE_FILE_PATH.ordinal())));
prep.setInt(3, (Integer) (rowData.get(COLUMN.IMAGE_ORIENTATION.ordinal())));
} catch (SQLException e) {
}
String querystr = String.format(SCREENSHOT_QUERY, columnstr.toString(),
- screenShotDBTable.getTableName(), ScreenShotDBTable.COLUMN.TIME);
+ screenShotDBTable.getTableName(), ScreenShotDBTable.COLUMN.CAPTURE_TIME);
ResultSet rs = SqlConnectionManager.executeQueryRS(querystr);
if (rs != null) {
}
private void computeData() {
- List<Object> row = TimelineChartManager.getInstance().getSystemDataFromDB(startTime);
- if (row.isEmpty()) {
+ Object[] cpuLoadList = TimelineChartManager.getInstance().getCPULoadFromDB(startTime);
+ if (cpuLoadList == null) {
return;
}
- @SuppressWarnings("unchecked")
- List<Object> cpuLoadList = (List<Object>) row.get(SystemDataDBTable.COLUMN.CPU_LOAD
- .ordinal());
cpuUsage.clear();
- for (int ii = 0; ii < cpuLoadList.size(); ii++) {
- double cpu = (Double)cpuLoadList.get(ii);
+ for (int i = 0; i < cpuLoadList.length; i++) {
+ double cpu = (Double)cpuLoadList[i];
long value = (long)cpu;
cpuUsage.add(value);
}
private static final String TABLENAME = "TIMELINE_SYSTEM_DATA";
public static enum COLUMN {
- TIME,
+ SAMPLING_TIME,
CPU_LOAD_TOTAL,
PROCESS_COUNT_OTHER,
PROCESS_COUNT_TARGET,
DEVICE_STATUS
}
- public static final String TIME = "TIME";
+ public static final String SAMPLING_TIME = "SAMPLING_TIME";
public static final String CPU_LOAD_TOTAL = "CPU_LOAD_TOTAL";
public static final String PROCESS_COUNT_OTHER = "PROCESS_COUNT_OTHER";
public static final String PROCESS_COUNT_TARGET = "PROCESS_COUNT_TARGET";
}
public SystemDataDBTable() {
- addColumn(new DBColumn(TIME, DBConstants.NOT_NULL, DBConstants.LONG));
+ addColumn(new DBColumn(SAMPLING_TIME, DBConstants.NOT_NULL, DBConstants.LONG));
addColumn(new DBColumn(CPU_LOAD_TOTAL, DBConstants.EMPTY, DBConstants.FLOAT));
addColumn(new DBColumn(PROCESS_COUNT_OTHER, DBConstants.EMPTY, DBConstants.INTEGER));
addColumn(new DBColumn(PROCESS_COUNT_TARGET, DBConstants.EMPTY, DBConstants.INTEGER));
addColumn(new DBColumn(PROCESS_PID_OTHER, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
addColumn(new DBColumn(PROCESS_LOAD_OTHER, DBConstants.EMPTY, DBConstants.FLOAT_ARRAY));
addColumn(new DBColumn(DEVICE_STATUS, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
- setIndexColumn(COLUMN.TIME.ordinal());
+ setIndexColumn(COLUMN.SAMPLING_TIME.ordinal());
}
@Override
} else {
try {
int index = 1;
- prep.setLong(index++, (Long) (rowData.get(COLUMN.TIME.ordinal())));
+ prep.setLong(index++, (Long) (rowData.get(COLUMN.SAMPLING_TIME.ordinal())));
prep.setFloat(index++, (Float) (rowData.get(COLUMN.CPU_LOAD_TOTAL.ordinal())));
prep.setInt(index++, (Integer) (rowData.get(COLUMN.PROCESS_COUNT_OTHER.ordinal())));
prep.setInt(index++, (Integer) (rowData.get(COLUMN.PROCESS_COUNT_TARGET.ordinal())));
private static final String TABLENAME = "TIMELINE_TARGET_PROCESS";
public static enum COLUMN {
- TIME,
+ SAMPLING_TIME,
PID,
CPU_LOAD,
MEMORY_VIRTUAL,
THREAD_LOAD
}
- public static final String TIME = "TIME";
+ public static final String SAMPLING_TIME = "SAMPLING_TIME";
public static final String PID = "PID";
public static final String CPU_LOAD = "CPU_LOAD";
public static final String MEMORY_VIRTUAL = "MEMORY_VIRTUAL";
}
public TargetProcessDBTable() {
- addColumn(new DBColumn(TIME, DBConstants.NOT_NULL, DBConstants.LONG));
+ addColumn(new DBColumn(SAMPLING_TIME, DBConstants.NOT_NULL, DBConstants.LONG));
addColumn(new DBColumn(PID, DBConstants.EMPTY, DBConstants.INTEGER));
addColumn(new DBColumn(CPU_LOAD, DBConstants.EMPTY, DBConstants.FLOAT));
addColumn(new DBColumn(MEMORY_VIRTUAL, DBConstants.EMPTY, DBConstants.LONG));
addColumn(new DBColumn(HEAP_ALLOCATION_BYTE, DBConstants.EMPTY, DBConstants.BIGINT_ARRAY));
addColumn(new DBColumn(THREAD_ID, DBConstants.EMPTY, DBConstants.INTEGER_ARRAY));
addColumn(new DBColumn(THREAD_LOAD, DBConstants.EMPTY, DBConstants.FLOAT_ARRAY));
- setIndexColumn(COLUMN.TIME.ordinal());
+ setIndexColumn(COLUMN.SAMPLING_TIME.ordinal());
}
@Override
} else {
try {
int index = 0;
- prep.setLong(++index, (Long) (rowData.get(COLUMN.TIME.ordinal())));
+ prep.setLong(++index, (Long) (rowData.get(COLUMN.SAMPLING_TIME.ordinal())));
prep.setInt(++index, (Integer) (rowData.get(COLUMN.PID.ordinal())));
prep.setFloat(++index, (Float) (rowData.get(COLUMN.CPU_LOAD.ordinal())));
prep.setLong(++index, (Long) (rowData.get(COLUMN.MEMORY_VIRTUAL.ordinal())));
private final static int MAX_INFO_LEN = 256;
public static enum COLUMN {
- TIME,
+ EVENT_TIME,
EVENT_TYPE,
DETAIL_TYPE,
POINT_X,
INFO_INTEGER
}
- public static final String TIME = "TIME";
+ public static final String EVENT_TIME = "EVENT_TIME";
public static final String EVENT_TYPE = "EVENT_TYPE";
public static final String DETAIL_TYPE = "DETAIL_TYPE";
public static final String POINT_X = "POINT_X";
}
public UIEventDBTable() {
- addColumn(new DBColumn(TIME, DBConstants.NOT_NULL, DBConstants.LONG));
+ addColumn(new DBColumn(EVENT_TIME, DBConstants.NOT_NULL, DBConstants.LONG));
addColumn(new DBColumn(EVENT_TYPE, DBConstants.NOT_NULL, DBConstants.INTEGER));
addColumn(new DBColumn(DETAIL_TYPE, DBConstants.NOT_NULL, DBConstants.INTEGER));
addColumn(new DBColumn(POINT_X, DBConstants.NOT_NULL, DBConstants.INTEGER));
addColumn(new DBColumn(POINT_Y, DBConstants.NOT_NULL, DBConstants.INTEGER));
addColumn(new DBColumn(INFO_STRING, DBConstants.NOT_NULL, DBConstants.VARCHAR, MAX_INFO_LEN));
addColumn(new DBColumn(INFO_INTEGER, DBConstants.NOT_NULL, DBConstants.INTEGER));
- setIndexColumn(COLUMN.TIME.ordinal());
+ setIndexColumn(COLUMN.EVENT_TIME.ordinal());
}
@Override
isPrepared = false;
} else {
try {
- prep.setLong(1, (Long) (rowData.get(COLUMN.TIME.ordinal())));
+ prep.setLong(1, (Long) (rowData.get(COLUMN.EVENT_TIME.ordinal())));
prep.setInt(2, (Integer) (rowData.get(COLUMN.EVENT_TYPE.ordinal())));
prep.setInt(3, (Integer) (rowData.get(COLUMN.DETAIL_TYPE.ordinal())));
prep.setInt(4, (Integer) (rowData.get(COLUMN.POINT_X.ordinal())));
*/
for (int i = 0; i < systemData.size(); i++) {
List<Object> row = systemData.get(i);
- double time = (Long) row.get(SystemDataDBTable.COLUMN.TIME.ordinal())
+ double time = (Long) row.get(SystemDataDBTable.COLUMN.SAMPLING_TIME.ordinal())
/ TimelineConstants.MEGA_DOUBLE;
try {
List<List<Object>> data = targetProcessDataMap.get(pid);
for (int i = 0; i < data.size(); i++) {
List<Object> oneTime = data.get(i);
- Long time = (Long) oneTime.get(TargetProcessDBTable.COLUMN.TIME.ordinal());
+ Long time = (Long) oneTime.get(TargetProcessDBTable.COLUMN.SAMPLING_TIME.ordinal());
Float cpuLoad = (Float) oneTime.get(TargetProcessDBTable.COLUMN.CPU_LOAD.ordinal());
Float processLoadSum = processLoadSumMap.get(time);
if (processLoadSum == null) {
.get(TimelineConstants.SYSTEM_DB_DATA);
for (int i = 0; i < data.size(); i++) {
List<Object> row = data.get(i);
- double time = (Long) row.get(SystemDataDBTable.COLUMN.TIME.ordinal())
+ double time = (Long) row.get(SystemDataDBTable.COLUMN.SAMPLING_TIME.ordinal())
/ TimelineConstants.MEGA_DOUBLE;
@SuppressWarnings("unchecked")
List<Object> cpuLoadList = (List<Object>) row.get(SystemDataDBTable.COLUMN.CPU_LOAD
.get(TimelineConstants.SYSTEM_DB_DATA);
for (int i = 0; i < data.size(); i++) {
List<Object> row = data.get(i);
- double time = (Long) row.get(SystemDataDBTable.COLUMN.TIME.ordinal())
+ double time = (Long) row.get(SystemDataDBTable.COLUMN.SAMPLING_TIME.ordinal())
/ TimelineConstants.MEGA_DOUBLE;
@SuppressWarnings("unchecked")
List<Object> cpuLoadList = (List<Object>) row.get(SystemDataDBTable.COLUMN.CPU_FREQUENCY
for (int i = 0; i < data.size(); i++) {
List<Object> row = data.get(i);
- double time = (Long) row.get(SystemDataDBTable.COLUMN.TIME.ordinal())
+ double time = (Long) row.get(SystemDataDBTable.COLUMN.SAMPLING_TIME.ordinal())
/ TimelineConstants.MEGA_DOUBLE;
@SuppressWarnings("unchecked")
for (int i = 0; i < data.size(); i++) {
List<Object> row = data.get(i);
- double time = (Long)row.get(SystemDataDBTable.COLUMN.TIME.ordinal())
+ double time = (Long)row.get(SystemDataDBTable.COLUMN.SAMPLING_TIME.ordinal())
/ TimelineConstants.MEGA_DOUBLE;
long readCount = (Long)row.get(SystemDataDBTable.COLUMN.DISK_IO_READ_OP_COUNT.ordinal());
long writeCount = (Long)row.get(SystemDataDBTable.COLUMN.DISK_IO_WRITE_OP_COUNT.ordinal());
for (int i = 0; i < systemData.size(); i++) {
List<Object> row = systemData.get(i);
- double time = (Long) row.get(SystemDataDBTable.COLUMN.TIME.ordinal())
+ double time = (Long) row.get(SystemDataDBTable.COLUMN.SAMPLING_TIME.ordinal())
/ TimelineConstants.MEGA_DOUBLE;
try {
long energyUsage = (Long) row.get(SystemDataDBTable.COLUMN.ENERGY_USAGE
Map<String, DAChartSeries> seriesMap = seriesPerProcessMap.get(pid);
for (int i = 0; i < data.size(); i++) {
List<Object> row = data.get(i);
- double time = (Long) row.get(TargetProcessDBTable.COLUMN.TIME.ordinal())
+ double time = (Long) row.get(TargetProcessDBTable.COLUMN.SAMPLING_TIME.ordinal())
/ TimelineConstants.MEGA_DOUBLE;
long totalAlloc = (Long) row
.get(TargetProcessDBTable.COLUMN.HEAP_ALLOCATION_TOTAL_BYTE.ordinal());
for (int i = 0; i < data.size(); i++) {
List<Object> row = data.get(i);
- double time = (Long)row.get(SystemDataDBTable.COLUMN.TIME.ordinal())
+ double time = (Long)row.get(SystemDataDBTable.COLUMN.SAMPLING_TIME.ordinal())
/ TimelineConstants.MEGA_DOUBLE;
long sendSize = (Long)row.get(SystemDataDBTable.COLUMN.NETWORK_SIZE_SEND.ordinal());
long receiveSize = (Long)row.get(SystemDataDBTable.COLUMN.NETWORK_SIZE_RECEIVE.ordinal());
List<List<Object>> data = processDataMap.get(pid);
for (int i = 0; i < data.size(); i++) {
List<Object> row = data.get(i);
- double time = (Long) row.get(TargetProcessDBTable.COLUMN.TIME.ordinal())
+ double time = (Long) row.get(TargetProcessDBTable.COLUMN.SAMPLING_TIME.ordinal())
/ TimelineConstants.MEGA_DOUBLE;
long vssMemory = (Long) row
.get(TargetProcessDBTable.COLUMN.MEMORY_VIRTUAL.ordinal());
try {
for (int i = 0; i < data.size(); i++) {
List<Object> row = data.get(i);
- double time = (Long)row.get(ScreenShotDBTable.COLUMN.TIME.ordinal())
+ double time = (Long)row.get(ScreenShotDBTable.COLUMN.CAPTURE_TIME.ordinal())
/ TimelineConstants.MEGA_DOUBLE;
String fileName = (String)row.get(ScreenShotDBTable.COLUMN.IMAGE_FILE_PATH.ordinal());
int orientation = (Integer)row.get(ScreenShotDBTable.COLUMN.IMAGE_ORIENTATION.ordinal());
double maxTime = 0.0;
for (int i = 0; i < systemData.size(); i++) {
List<Object> row = systemData.get(i);
- double time = (Long) row.get(SystemDataDBTable.COLUMN.TIME
+ double time = (Long) row.get(SystemDataDBTable.COLUMN.SAMPLING_TIME
.ordinal()) / TimelineConstants.MEGA_DOUBLE;
try {
List<List<Object>> data = targetProcessDataMap.get(pid);
for (int i = 0; i < data.size(); i++) {
List<Object> oneTime = data.get(i);
- Long time = (Long) oneTime.get(TargetProcessDBTable.COLUMN.TIME
+ Long time = (Long) oneTime.get(TargetProcessDBTable.COLUMN.SAMPLING_TIME
.ordinal());
Long processMemorySize = (Long) oneTime
.get(TargetProcessDBTable.COLUMN.MEMORY_RESIDENT
for (int i = 0; i < data.size(); i++) {
List<Object> row = data.get(i);
- double time = (Long)row.get(UIEventDBTable.COLUMN.TIME.ordinal())
+ double time = (Long)row.get(UIEventDBTable.COLUMN.EVENT_TIME.ordinal())
/ TimelineConstants.MEGA_DOUBLE;
int eventType = (Integer)row.get(UIEventDBTable.COLUMN.EVENT_TYPE.ordinal());
int detailType = (Integer)row.get(UIEventDBTable.COLUMN.DETAIL_TYPE.ordinal());
}
public List<List<Object>> getSystemDataFromDB(long start, long end) {
- String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
- + SystemDataDBTable.TIME;
+ String where = "WHERE " + SystemDataDBTable.SAMPLING_TIME + " BETWEEN " + start + " AND " + end +
+ " ORDER BY " + SystemDataDBTable.SAMPLING_TIME;
List<List<Object>> result = systemDataTable.selectAllColumnData(where);
if (result != null) {
}
}
- public List<Object> getSystemDataFromDB(long time) {
- String where = "where TIME = (SELECT MAX(TIME) FROM TIMELINE_SYSTEM_DATA WHERE TIME <= "
- + time + ")";
- List<List<Object>> result = systemDataTable.selectAllColumnData(where);
-
- if (result == null || result.isEmpty()) {
- where = "where TIME = (SELECT MIN(time) FROM TIMELINE_SYSTEM_DATA)";
- result = systemDataTable.selectAllColumnData(where);
- if (result == null || result.isEmpty()) {
- return new ArrayList<Object>();
- } else {
- return result.get(0);
+ public Object[] getCPULoadFromDB(long time) {
+ Object[] cpuLoadList = null;
+ String query = "SELECT " + SystemDataDBTable.CPU_LOAD + " FROM "
+ + systemDataTable.getTableName() + " WHERE " + SystemDataDBTable.SAMPLING_TIME +
+ " = (SELECT MAX(TIME) FROM " + systemDataTable.getTableName() + " WHERE " +
+ SystemDataDBTable.SAMPLING_TIME + " <= " + time + ")";
+ ResultSet rs = SqlConnectionManager.executeQueryRS(query);
+ if (rs != null) {
+ try {
+ while (rs.next()) {
+ cpuLoadList = (Object[])rs.getArray(SystemDataDBTable.CPU_LOAD).getArray();
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ SqlConnectionManager.releaseResultSet(rs);
}
- } else {
- return result.get(0);
}
+
+ return cpuLoadList;
}
public List<List<Object>> getUIEventDataFromDB(long start, long end) {
- String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
- + UIEventDBTable.TIME;
+ String where = "WHERE " + UIEventDBTable.EVENT_TIME + " BETWEEN " + start + " AND " +
+ end + " ORDER BY " + UIEventDBTable.EVENT_TIME;
List<List<Object>> result = uiEventDBTable.selectAllColumnData(where);
if (result != null) {
}
public List<List<Object>> getScreenShotDataFromDB(long start, long end) {
- String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
- + ScreenShotDBTable.TIME;
+ String where = "WHERE " + ScreenShotDBTable.CAPTURE_TIME + " BETWEEN " + start + " AND " +
+ end + " ORDER BY " + ScreenShotDBTable.CAPTURE_TIME;
List<List<Object>> result = ScreenshotDataManager.getInstance().getScreenShotTable()
.selectAllColumnData(where);
public Map<Integer, List<List<Object>>> getTargetProcessDataFromDB(long start, long end) {
Map<Integer, List<List<Object>>> processedResult = new HashMap<Integer, List<List<Object>>>();
- String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY "
- + TargetProcessDBTable.TIME;
+ String where = "WHERE " + TargetProcessDBTable.SAMPLING_TIME + " BETWEEN " + start + " AND " + end +
+ " ORDER BY " + TargetProcessDBTable.SAMPLING_TIME;
List<List<Object>> queryResult = targetProcessDBTable.selectAllColumnData(where);
if (queryResult == null) {
return processedResult;
public long getProcessMemoriesFromDB(long time) {
long processMemories = 0;
String query = "SELECT " + TargetProcessDBTable.MEMORY_RESIDENT + " FROM "
- + targetProcessDBTable.getTableName() + " WHERE TIME = (SELECT MAX(TIME) FROM "
- + targetProcessDBTable.getTableName() + " WHERE TIME <= " + time + ")";
+ + targetProcessDBTable.getTableName() + " WHERE " + TargetProcessDBTable.SAMPLING_TIME +
+ " = (SELECT MAX(TIME) FROM " + targetProcessDBTable.getTableName() + " WHERE " +
+ TargetProcessDBTable.SAMPLING_TIME + " <= " + time + ")";
ResultSet rs = SqlConnectionManager.executeQueryRS(query);
if (rs != null) {
try {