use of com.cubrid.cubridmanager.core.cubrid.database.model.DbBackupInfo in project cubrid-manager by CUBRID.
the class GetDbBackupInfoTask method getDbBackupInfo.
/**
*
* Get database backup information
*
* @return DbBackupInfo the instance of DbBackupInfo
*/
public DbBackupInfo getDbBackupInfo() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
DbBackupInfo dbBackupInfo = new DbBackupInfo();
String dbDir = response.getValue("dbdir");
dbBackupInfo.setDbDir(dbDir);
String freeSpace = response.getValue("freespace");
dbBackupInfo.setFreeSpace(freeSpace);
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode node = response.getChildren().get(i);
if (node == null) {
continue;
}
String levelName = node.getValue("open");
if (levelName == null || levelName.trim().length() <= 0) {
continue;
}
if (levelName.indexOf("level") >= 0) {
String path = node.getValue("path");
String size = node.getValue("size");
String date = node.getValue("data");
DbBackupHistoryInfo dbBackupHistoryInfo = new DbBackupHistoryInfo(levelName, path, size, date);
dbBackupInfo.addDbBackupHistoryInfo(dbBackupHistoryInfo);
}
}
return dbBackupInfo;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DbBackupInfo in project cubrid-manager by CUBRID.
the class GetDbBackupInfoTaskTest method testBackupExist.
public void testBackupExist() {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
return;
System.out.println("<database.backupdbinfo.001.req.txt>");
GetDbBackupInfoTask task = new GetDbBackupInfoTask(serverInfo);
task.setDbName("demodb");
task.execute();
assertTrue(task.isSuccess());
assertNull(task.getErrorMsg());
DbBackupInfo info = task.getDbBackupInfo();
assertNotNull(info);
assertEquals("/opt/frameworks/cubrid2/databases/demodb/backup", info.getDbDir());
assertEquals("15216", info.getFreeSpace());
List<DbBackupHistoryInfo> list = info.getBackupHistoryList();
assertNotNull(list);
assertEquals(1, list.size());
DbBackupHistoryInfo his = list.get(0);
assertEquals("level0", his.getLevel());
assertEquals("/opt/frameworks/cubrid2/databases/demodb/backup/demodb_backup_lv0", his.getPath());
assertEquals("5256192", his.getSize());
assertEquals("2009.06.26.22.37", his.getDate());
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DbBackupInfo in project cubrid-manager by CUBRID.
the class GetDbBackupInfoTaskTest method testNoBackup.
public void testNoBackup() {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
return;
System.out.println("<database.backupdbinfo.002.req.txt>");
GetDbBackupInfoTask task = new GetDbBackupInfoTask(serverInfo);
task.setDbName("nobackupdb");
task.execute();
assertTrue(task.isSuccess());
assertNull(task.getErrorMsg());
DbBackupInfo info = task.getDbBackupInfo();
assertNotNull(info);
assertEquals("/opt/frameworks/cubrid2/databases/nobackupdb/backup", info.getDbDir());
assertEquals("15216", info.getFreeSpace());
List<DbBackupHistoryInfo> list = info.getBackupHistoryList();
assertNotNull(list);
assertEquals(0, list.size());
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DbBackupInfo in project cubrid-manager by CUBRID.
the class GetDbBackupInfoTaskTest method testReceive.
public void testReceive() throws Exception {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
return;
//case 1
String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/cubrid/database/task/test.message/getdbbackupinfo_receive");
String msg = Tool.getFileContent(filepath);
TreeNode node = MessageUtil.parseResponse(msg);
GetDbBackupInfoTask task = new GetDbBackupInfoTask(serverInfo);
task.setResponse(node);
DbBackupInfo dbBackupInfo = task.getDbBackupInfo();
assertEquals(dbBackupInfo.getDbDir(), "/home/biaozhang/cubrid/databases/distdb_pang/backup");
assertEquals(dbBackupInfo.getFreeSpace(), "814952");
assertTrue(dbBackupInfo.getBackupHistoryList().size() == 1);
assertEquals(dbBackupInfo.getBackupHistoryList().get(0).getDate(), "2010.01.08.15.11");
assertEquals(dbBackupInfo.getBackupHistoryList().get(0).getSize(), "3159040");
assertEquals(dbBackupInfo.getBackupHistoryList().get(0).getLevel(), "level0");
assertEquals(dbBackupInfo.getBackupHistoryList().get(0).getPath(), "/home/biaozhang/cubrid/databases/distdb_pang/backup/distdb_pang_backup_lv0");
//exception case1
task.setResponse(null);
assertTrue(task.getDbBackupInfo() == null);
//exception case2
task.setResponse(node);
task.setErrorMsg("has error");
assertTrue(task.getDbBackupInfo() == null);
//case 2
filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/cubrid/database/task/test.message/getdbbackupinfo_receive2");
msg = Tool.getFileContent(filepath);
node = MessageUtil.parseResponse(msg);
GetDbBackupInfoTask task2 = new GetDbBackupInfoTask(serverInfo);
task2.setResponse(node);
task2.getDbBackupInfo();
//case 3
filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/cubrid/database/task/test.message/getdbbackupinfo_receive3");
msg = Tool.getFileContent(filepath);
node = MessageUtil.parseResponse(msg);
GetDbBackupInfoTask task3 = new GetDbBackupInfoTask(serverInfo);
task3.setResponse(node);
task3.getDbBackupInfo();
//case 4
filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/cubrid/database/task/test.message/getdbbackupinfo_receive4");
msg = Tool.getFileContent(filepath);
node = MessageUtil.parseResponse(msg);
GetDbBackupInfoTask task4 = new GetDbBackupInfoTask(serverInfo);
task4.setResponse(node);
task4.getDbBackupInfo();
}
Aggregations