Search in sources :

Example 46 with TreeNode

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;
}
Also used : TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) ArrayList(java.util.ArrayList)

Example 47 with TreeNode

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;
}
Also used : HashMap(java.util.HashMap) TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) Map(java.util.Map) HashMap(java.util.HashMap)

Example 48 with TreeNode

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;
}
Also used : TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) ArrayList(java.util.ArrayList)

Example 49 with TreeNode

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();
}
Also used : TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode)

Example 50 with TreeNode

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;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) ArrayList(java.util.ArrayList)

Aggregations

TreeNode (com.cubrid.cubridmanager.core.common.socket.TreeNode)142 ArrayList (java.util.ArrayList)20 HashMap (java.util.HashMap)7 Map (java.util.Map)6 Trigger (com.cubrid.common.core.common.model.Trigger)2 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)2 DbBackupInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DbBackupInfo)2 DbUnloadInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DbUnloadInfo)2 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)2 GetExecuteCasRunnerResultInfo (com.cubrid.cubridmanager.core.logs.model.GetExecuteCasRunnerResultInfo)2 ManagerLogInfoList (com.cubrid.cubridmanager.core.logs.model.ManagerLogInfoList)2 ManagerLogInfos (com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos)2 DbProcessStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.DbProcessStatusInfo)2 HADatabaseStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)2 HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)2 ReplicationInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationInfo)2 ReplicationParamInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo)2 TransFileProgressInfo (com.cubrid.cubridmanager.core.replication.model.TransFileProgressInfo)2 CasAuthType (com.cubrid.cubridmanager.core.common.model.CasAuthType)1