use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.
the class HAUtil method getSyncModeType.
/**
*
* Get sync mode from standby database node
*
* @param standbyNode DatabaseNode
* @param activeNode DatabaseNode
* @return SyncModeType
*/
public static SyncModeType getSyncModeType(DatabaseNode standbyNode, DatabaseNode activeNode) {
HADatabaseStatusInfo dbStatusInfo = standbyNode.getHaDatabaseStatus();
if (dbStatusInfo == null) {
return null;
}
DBStatusType dbStatusType = dbStatusInfo.getStatusType();
if (dbStatusType != DBStatusType.STANDBY && dbStatusType != DBStatusType.MAINTENANCE) {
return null;
}
List<DbProcessStatusInfo> dbProcessList = dbStatusInfo.getCopyLogDbProcessStatusList();
if (dbProcessList == null || dbProcessList.isEmpty()) {
return null;
}
HAHostStatusInfo hostStatusInfo = dbStatusInfo.getHaHostStatusInfo();
if (hostStatusInfo.getStatusType() != HostStatusType.SLAVE && hostStatusInfo.getStatusType() != HostStatusType.REPLICA) {
return null;
}
HAHostStatusInfo masterHostStatusInfo = hostStatusInfo.getMasterHostStatusInfo();
if (masterHostStatusInfo == null) {
return null;
}
String masterHostName = masterHostStatusInfo.getHostName();
String masterIp = masterHostStatusInfo.getIp();
if (!StringUtil.isIpEqual(activeNode.getParent().getIp(), masterIp)) {
return null;
}
for (DbProcessStatusInfo dbProcessStatusInfo : dbProcessList) {
String hostName = dbProcessStatusInfo.getHostName();
String dbName = dbProcessStatusInfo.getDbName();
if (masterHostName.equals(hostName) && dbName.equals(activeNode.getDbName())) {
return dbProcessStatusInfo.getMode();
}
}
return null;
}
use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo 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.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.
the class GetHeartbeatNodeInfoTask method buildHaServerList.
/**
*
* Parse the node and build HADatabaseStatus object
*
* @param parent The TreeNode
* @param currentHaHostStatus The HAHostStatus
*/
private void buildHaServerList(TreeNode parent, HAHostStatusInfo currentHaHostStatus) {
HADatabaseStatusInfo dbStatus = new HADatabaseStatusInfo();
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("dbmode")) {
String dbName = node.getValue("dbname");
String serverMode = node.getValue("server_mode");
String error = node.getValue("server_msg");
dbStatus.setDbName(dbName);
if (error != null && !error.equals("none")) {
dbStatus.setErrorInfo(error);
}
dbStatus.setStatusType(DBStatusType.getType(serverMode, serverInfo.isHAMode(dbName)));
dbStatus.setHaHostStatusInfo(currentHaHostStatus);
currentHaHostStatus.addHADatabaseStatus(dbStatus);
} else if (node.getValue("open").trim().equals("dbprocinfo")) {
String dbName = node.getValue("dbname");
String pid = node.getValue("pid");
String state = node.getValue("state");
DbProcessStatusInfo dbProcessStatusInfo = new DbProcessStatusInfo();
dbProcessStatusInfo.setDbName(dbName);
dbProcessStatusInfo.setPid(pid);
dbProcessStatusInfo.setProcessStatus(ProcessStatusType.getType(state));
dbStatus.setDbServerProcessStatus(dbProcessStatusInfo);
} else if (node.getValue("open").trim().equals("applylogdb")) {
buildProcessList(node, dbStatus, "applylogdb");
} else if (node.getValue("open").trim().equals("copylogdb")) {
buildProcessList(node, dbStatus, "copylogdb");
}
}
}
use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.
the class DataProvider method executeInThread.
/**
*
* Execute task by multi-thread
*
* @throws InterruptedException the exception
*/
public void executeInThread() throws InterruptedException {
//multi thread execution
List<Runnable> runnableList = new ArrayList<Runnable>();
if (isExecuteHostStatTask) {
hostStatTask = new CommonQueryTask<HostStatData>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new HostStatData());
hostStatTask.setTimeout(TIME_OUT_MILL);
runnableList.add(hostStatTask);
}
if (isExecuteBrokerStatTask) {
brokerDiagTask = new CommonQueryTask<BrokerDiagData>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), new BrokerDiagData());
brokerDiagTask.setTimeout(TIME_OUT_MILL);
runnableList.add(brokerDiagTask);
}
List<String> dbList = new ArrayList<String>();
for (DatabaseNode dbNode : uniqueDbNodeList) {
dbList.add(dbNode.getDbName());
}
if (isExecuteHeartbeatTask) {
getHeartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
getHeartbeatNodeInfoTask.setAllDb(false);
getHeartbeatNodeInfoTask.setDbList(dbList);
getHeartbeatNodeInfoTask.setTimeout(TIME_OUT_MILL);
runnableList.add(getHeartbeatNodeInfoTask);
}
if (isExecuteDbModeTask) {
getDbModeTask = new GetDbModeTask(serverInfo);
getDbModeTask.setDbList(dbList);
getDbModeTask.setTimeout(TIME_OUT_MILL);
runnableList.add(getDbModeTask);
}
//execute broker related task
if (!uniqueBrokerNodeList.isEmpty()) {
runnableList.addAll(brokerDataProvider.getExecRunnableList());
}
if (IS_MULTI_THREAD && !runnableList.isEmpty()) {
try {
generator.getThreadPoolManager().execute(runnableList, true);
} catch (ThreadCountOutOfBoundsException e) {
LOGGER.error("", e);
}
join(runnableList, 350);
runnableList.clear();
}
//get database status information
List<HADatabaseStatusInfo> dbStatusInfoList = null;
if (isExecuteDbModeTask) {
dbStatusInfoList = getDbModeTask.getDbModes();
}
//execute database related task
for (int i = 0; i < dbDataProviderList.size(); i++) {
DatabaseNode dbNode = dbDataProviderList.get(i).getDatabaseNode();
HADatabaseStatusInfo dbStatusInfo = HAUtil.getDatabaseStatusInfo(dbStatusInfoList, dbNode.getDbName());
dbDataProviderList.get(i).setDbStatusInfo(dbStatusInfo);
runnableList.addAll(dbDataProviderList.get(i).getExecRunnableList());
}
if (IS_MULTI_THREAD && !runnableList.isEmpty()) {
try {
generator.getThreadPoolManager().execute(runnableList, true);
} catch (ThreadCountOutOfBoundsException e) {
LOGGER.error("", e);
}
join(runnableList, 20);
} else {
execute(runnableList);
}
}
use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.
the class NavigatorTreeLabelProvider method decorateDatabaseImgae.
/**
* Decorate the database image
*
* @param label
* @param server
* @return
*/
private Image decorateDatabaseImgae(Image baseImage, CubridDatabase database) {
CubridServer server = database.getServer();
HAHostStatusInfo haHostStatusInfo = server.getServerInfo().getHaHostStatusInfo();
HADatabaseStatusInfo haDatabaseStatusInfo = HAUtil.getHADatabaseStatusInfo(database.getName(), haHostStatusInfo, server.getServerInfo());
List<String> haNodeList = HAUtil.getAllHaDBList(server.getServerInfo());
server.getLoader().setLoaded(true);
if (haNodeList.contains(database.getName())) {
DBStatusType statusType = haDatabaseStatusInfo.getStatusType();
if (DBStatusType.ACTIVE.equals(statusType)) {
DecoratedImage decoratedImage = decoratorManager.decorate(baseImage, "HADatabase", null, null, null, null, null, null, imgDecMaster, "Active");
return decoratedImage.getDecoratedImage();
}
if (DBStatusType.STANDBY.equals(statusType)) {
DecoratedImage decoratedImage = decoratorManager.decorate(baseImage, "HADatabase", null, null, null, null, null, null, imgDecSlave, "Standby");
return decoratedImage.getDecoratedImage();
}
}
return baseImage;
}
Aggregations