Search in sources :

Example 6 with HADatabaseStatusInfo

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;
}
Also used : HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) DBStatusType(com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType) DbProcessStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.DbProcessStatusInfo) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)

Example 7 with HADatabaseStatusInfo

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

Example 8 with HADatabaseStatusInfo

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

Example 9 with HADatabaseStatusInfo

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);
    }
}
Also used : ArrayList(java.util.ArrayList) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask) GetDbModeTask(com.cubrid.cubridmanager.core.mondashboard.task.GetDbModeTask) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) ThreadCountOutOfBoundsException(com.cubrid.common.ui.spi.thread.ThreadCountOutOfBoundsException) HostStatData(com.cubrid.cubridmanager.core.monitoring.model.HostStatData) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)

Example 10 with HADatabaseStatusInfo

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;
}
Also used : DecoratedImage(com.cubrid.common.ui.decorator.DecoratedImage) HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) DBStatusType(com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType) StyledString(org.eclipse.jface.viewers.StyledString) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)

Aggregations

HADatabaseStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)16 HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)7 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)5 ArrayList (java.util.ArrayList)5 DbProcessStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.DbProcessStatusInfo)4 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)3 DBStatusType (com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType)3 IDiagPara (com.cubrid.cubridmanager.core.monitoring.model.IDiagPara)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)2 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)2 TreeNode (com.cubrid.cubridmanager.core.common.socket.TreeNode)2 GetDbModeTask (com.cubrid.cubridmanager.core.mondashboard.task.GetDbModeTask)2 GetHeartbeatNodeInfoTask (com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask)2 VerifyDbUserPasswordTask (com.cubrid.cubridmanager.core.mondashboard.task.VerifyDbUserPasswordTask)2 MondashDataResult (com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.MondashDataResult)2 List (java.util.List)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2