use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetDatabasesParameterTask method getConfContents.
/**
* Get databases.txt config parameters content
*
* @return
*/
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 CancelTransFileTaskTest method testReceive.
public void testReceive() throws Exception {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
return;
String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/replication/task/test.message/CancelTransFile_receive");
String msg = Tool.getFileContent(filepath);
TreeNode node = MessageUtil.parseResponse(msg);
//compare
assertEquals("success", node.getValue("status"));
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetManagerLogListTask method getLogContentV1.
private ManagerLogInfos getLogContentV1() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
ManagerLogInfos managerLogInfos = new ManagerLogInfos();
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode node = response.getChildren().get(i);
if (node != null && node.getValue("open") != null && node.getValue("open").equals("accesslog")) {
// for
ManagerLogInfoList managerLogList = new ManagerLogInfoList();
String[] users = node.getValues("user");
String[] tasknames = node.getValues("taskname");
String[] times = node.getValues("time");
if (users != null) {
addLogToManagerLogList(managerLogList, users, tasknames, times);
managerLogInfos.setAccessLog(managerLogList);
}
} else if (node != null && node.getValue("open") != null && node.getValue("open").equals("errorlog")) {
// for
ManagerLogInfoList managerLogList = new ManagerLogInfoList();
String[] users = null;
users = node.getValues("user");
String[] tasknames = node.getValues("taskname");
String[] times = node.getValues("time");
String[] errornotes = node.getValues("errornote");
if (users != null) {
addLogToManagerLogList(managerLogList, users, tasknames, times, errornotes);
managerLogInfos.setErrorLog(managerLogList);
}
}
}
return managerLogInfos;
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetDbModeTask method getDbModes.
/**
*
* Get database modes list
*
* @return The List<HADatabaseStatus>
*/
public List<HADatabaseStatusInfo> getDbModes() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
List<HADatabaseStatusInfo> dbStatusList = new ArrayList<HADatabaseStatusInfo>();
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode node1 = response.getChildren().get(i);
if (node1.getValue("open") == null) {
continue;
}
if (node1.getValue("open").trim().equals("dbserver")) {
String dbName = node1.getValue("dbname");
String serverMode = node1.getValue("server_mode");
String error = node1.getValue("server_msg");
HADatabaseStatusInfo dbStatus = new HADatabaseStatusInfo();
dbStatus.setDbName(dbName);
if (error == null || error.equals("none")) {
dbStatus.setStatusType(DBStatusType.getType(serverMode, serverInfo.isHAMode(dbName)));
} else {
dbStatus.setErrorInfo(error);
dbStatus.setStatusType(DBStatusType.UNKNOWN);
}
dbStatusList.add(dbStatus);
}
}
return dbStatusList;
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetHeartbeatNodeInfoTask method buildHaNodeList.
/**
*
* Parse the node and build HAHostStatus object
*
* @param parent The TreeNode
* @param hostStatusList The List<HAHostStatus>
* @param currentHostName The String
* @return The HAHostStatus
*/
private HAHostStatusInfo buildHaNodeList(TreeNode parent, List<HAHostStatusInfo> hostStatusList, String currentHostName) {
HAHostStatusInfo reHaHostStatus = null;
List<HAHostStatusInfo> slaveHostStatusInfoList = new ArrayList<HAHostStatusInfo>();
HAHostStatusInfo masterHostStatusInfo = null;
for (int i = 0; i < parent.childrenSize(); i++) {
TreeNode node = parent.getChildren().get(i);
if (node.getValue("open") == null) {
continue;
}
if (node.getValue("open").trim().equals("node")) {
String hostName = node.getValue("hostname");
String ip = node.getValue("ip");
String priority = node.getValue("priority");
String state = node.getValue("state");
HAHostStatusInfo haHostStatus = new HAHostStatusInfo();
haHostStatus.setHostName(hostName);
haHostStatus.setIp(ip);
haHostStatus.setPriority(priority);
haHostStatus.setStatusType(HostStatusType.getType(state));
if (hostName.equals(currentHostName)) {
reHaHostStatus = haHostStatus;
}
if (haHostStatus.getStatusType() == HostStatusType.MASTER) {
masterHostStatusInfo = haHostStatus;
} else if (haHostStatus.getStatusType() == HostStatusType.SLAVE || haHostStatus.getStatusType() == HostStatusType.REPLICA) {
slaveHostStatusInfoList.add(haHostStatus);
}
hostStatusList.add(haHostStatus);
}
}
//set master and slave relation
for (int i = 0; i < slaveHostStatusInfoList.size(); i++) {
slaveHostStatusInfoList.get(i).setMasterHostStatusInfo(masterHostStatusInfo);
}
if (masterHostStatusInfo != null) {
masterHostStatusInfo.setSlaveHostStatusInfoList(slaveHostStatusInfoList);
}
return reHaHostStatus;
}
Aggregations