use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetHAConfParameterTask method getConfContents.
/**
*
* Get cm.conf parameters
*
* @return List<String> The map that stored configure parameters
*/
public List<String> getConfContents() {
String[] confData = null;
List<String> confContents = new ArrayList<String>();
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode node = response.getChildren().get(i);
if (node != null && node.getValue("open").equals("conflist")) {
confData = node.getValues("confdata");
}
}
if (confData != null) {
for (String line : confData) {
confContents.add(line);
}
}
return confContents;
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetHAConfParameterTask method getConfParameters.
/**
*
* Get cubrid.conf parameters map
*
* @return Map<String, Map<String, String>> The map that stored the
* configure parameters
*/
public Map<String, Map<String, String>> getConfParameters() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
Map<String, Map<String, String>> confMap = new HashMap<String, Map<String, String>>();
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode node = response.getChildren().get(i);
if (node != null && node.getValue("open").equals("conflist")) {
String[] confData = node.getValues("confdata");
if (confData != null && confData.length > 0) {
buildConf(confMap, confData);
}
}
}
return confMap;
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetBackupListTask method getDbBackupList.
/**
*
* Get database backup list
*
* @return List<String> a list that includes the backup
*/
public List<String> getDbBackupList() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
List<String> backupList = new ArrayList<String>();
for (int i = 0; i < 3; i++) {
String levelStr = response.getValue("level" + i);
if (!StringUtil.isTrimEqual(levelStr, "none")) {
backupList.add(levelStr);
}
}
return backupList;
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetBackupVolInfoTask method getDbBackupVolInfo.
/**
*
* Get database backup vol information
*
* @return String A string that include backup volume info
*/
public String getDbBackupVolInfo() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
StringBuffer buffer = new StringBuffer();
String[] lines = response.getValues("line");
for (int i = 0; lines != null && i < lines.length; i++) {
buffer.append(lines[i] + "\n");
}
return buffer.toString();
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetDatabaseListTask method loadDatabaseInfo.
/**
*
* Load CUBRID Server database information
*
* @return List<DatabaseInfo> a list includes the databse info
*/
public List<DatabaseInfo> loadDatabaseInfo() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
List<DatabaseInfo> databaseInfoList = new ArrayList<DatabaseInfo>();
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode node = response.getChildren().get(i);
if (node.getValue("open") != null && node.getValue("open").equals("dblist")) {
String[] dbNameArr = node.getValues("dbname");
String[] dbDirArr = node.getValues("dbdir");
/*
* As the old interface data format is not strict, as follows:
* ****************************************************************
* old format:
* open:dblist
* dbname:db1
* dbdir:d:\CUBRID\DATABA~1\db1
* dbname:demodb
* dbdir:d:\CUBRID\DATABA~1\demodb
* close:dblist
* ****************************************************************
* new format:
* "dblist" : [
* {
* "dbs" : [
* {
* "dbdir" : "d:\\CUBRID\\DATABA~1\\db1",
* "dbname" : "db1"
* },
* {
* "dbdir" : "d:\\CUBRID\\DATABA~1\\demodb",
* "dbname" : "demodb"
* }
* ]
* }
* ]
* ****************************************************************
* Thus here to add additional judgment operation
*/
if (null == dbNameArr) {
int length = node.childrenSize();
dbNameArr = new String[length];
dbDirArr = new String[length];
for (int j = 0; j < length; j++) {
TreeNode subNode = node.getChildren().get(j);
if (subNode == null || !StringUtil.isEqual(subNode.getValue("open"), "dbs", true)) {
continue;
}
dbNameArr[j] = subNode.getValue("dbname");
dbDirArr[j] = subNode.getValue("dbdir");
}
}
// end
for (int j = 0; dbNameArr != null && j < dbNameArr.length; j++) {
String dbName = dbNameArr[j];
DatabaseInfo databaseInfo = new DatabaseInfo(dbName, serverInfo);
if (dbDirArr != null && dbDirArr.length > j) {
databaseInfo.setDbDir(dbDirArr[j]);
}
databaseInfoList.add(databaseInfo);
}
}
if (node != null && StringUtil.isEqual(node.getValue("open"), "activelist", true)) {
String[] dbNameArr = node.getValues("dbname");
// start
if (null == dbNameArr) {
int length = node.childrenSize();
dbNameArr = new String[length];
for (int j = 0; j < length; j++) {
TreeNode subNode = node.getChildren().get(j);
if (subNode == null || !StringUtil.isEqual(subNode.getValue("open"), "active", true)) {
continue;
}
dbNameArr[j] = subNode.getValue("dbname");
}
}
// end
for (int j = 0; dbNameArr != null && j < dbNameArr.length; j++) {
String dbName = dbNameArr[j];
for (int k = 0; k < databaseInfoList.size(); k++) {
DatabaseInfo databaseInfo = databaseInfoList.get(k);
if (databaseInfo.getDbName().equals(dbName)) {
databaseInfo.setRunningType(DbRunningType.CS);
break;
}
}
}
}
}
return databaseInfoList;
}
Aggregations