Search in sources :

Example 1 with HADatabaseStatusInfo

use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.

the class DatabaseDashboardViewPart method performUpdate.

/**
	 * Perform the update data
	 *
	 * @param dataChangedEvent the given event including newest data
	 */
public void performUpdate(DataChangedEvent dataChangedEvent) {
    if (composite == null || composite.isDisposed()) {
        return;
    }
    if (dbNode.getParent().isConnected()) {
        HADatabaseStatusInfo haDbStatusInfo = HAUtil.getDatabaseStatusInfo(dataChangedEvent.getHaHostStatusInfoList(), dbNode.getParent().getIp(), dbNode.getDbName());
        if (haDbStatusInfo == null) {
            haDbStatusInfo = HAUtil.getDatabaseStatusInfo(dataChangedEvent.getDbStatusInfoList(), dbNode.getDbName());
            if (null == haDbStatusInfo) {
                haDbStatusInfo = new HADatabaseStatusInfo();
                haDbStatusInfo.setDbName(dbNode.getDbName());
            }
        }
        dbNode.setHaDatabaseStatus(haDbStatusInfo);
    } else {
        HADatabaseStatusInfo haDatabaseStatus = new HADatabaseStatusInfo();
        haDatabaseStatus.setDbName(dbNode.getDbName());
        dbNode.setHaDatabaseStatus(haDatabaseStatus);
    }
    Set<MondashDataResult> set = dataChangedEvent.getResultSet();
    Map<IDiagPara, String> updateMap = null;
    String hostCpuTotal = "0";
    String hostMemTotal = "0";
    for (MondashDataResult result : set) {
        if (dbNode.getDbName().equals(result.getName())) {
            updateMap = result.getUpdateMap();
        } else if (generator.getName().equals(result.getName())) {
            Map<IDiagPara, String> hostMap = result.getUpdateMap();
            if (hostMap != null) {
                hostCpuTotal = hostMap.get(HostStatEnum.CPU_TOTAL);
                hostCpuTotal = hostCpuTotal == null ? "0" : hostCpuTotal;
                hostMemTotal = hostMap.get(HostStatEnum.MEMPHY_TOTAL);
                hostMemTotal = hostMemTotal == null ? "0" : hostMemTotal;
            }
        }
    }
    performUpdate(updateMap, hostCpuTotal, hostMemTotal);
}
Also used : MondashDataResult(com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.MondashDataResult) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo) IDiagPara(com.cubrid.cubridmanager.core.monitoring.model.IDiagPara) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 2 with HADatabaseStatusInfo

use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.

the class SelectDbPage method createControl.

/**
	 * Create the control for this page
	 * 
	 * @param parent Composite
	 */
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 10;
    layout.marginWidth = 10;
    composite.setLayout(layout);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    composite.setLayoutData(gridData);
    Group dbInfoGroup = new Group(composite, SWT.NONE);
    dbInfoGroup.setText(Messages.grpSelectDb);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    dbInfoGroup.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    dbInfoGroup.setLayout(layout);
    Label dbNameLabel = new Label(dbInfoGroup, SWT.LEFT);
    dbNameLabel.setText(Messages.lblDbName);
    dbNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    dbNameCombo = new Combo(dbInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
    dbNameCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
    dbNameCombo.addModifyListener(this);
    Label nickNameLable = new Label(dbInfoGroup, SWT.LEFT);
    nickNameLable.setText(Messages.lblNickName);
    nickNameLable.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    nickNameText = new Text(dbInfoGroup, SWT.LEFT | SWT.BORDER);
    nickNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Label dbaPasswordLabel = new Label(dbInfoGroup, SWT.LEFT);
    dbaPasswordLabel.setText(Messages.lblDbaPassword);
    dbaPasswordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    dbaPasswordText = new Text(dbInfoGroup, SWT.LEFT | SWT.BORDER | SWT.PASSWORD);
    dbaPasswordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
    Composite btnComposite = new Composite(composite, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 5;
    btnComposite.setLayout(rowLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalAlignment = GridData.END;
    btnComposite.setLayoutData(gridData);
    addButton = new Button(btnComposite, SWT.NONE);
    addButton.setText(Messages.btnAddDb);
    addButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String dbName = dbNameCombo.getText();
            String dbaPassword = dbaPasswordText.getText();
            String nickName = nickNameText.getText();
            if (nickName.trim().length() == 0) {
                nickName = dbName;
            }
            //check whether this database already be added
            if (isExist(dbName, hostNode)) {
                CommonUITool.openErrorBox(Messages.bind(Messages.errDbExist, dbName));
                return;
            }
            DatabaseInfo dbInfo = serverInfo.getLoginedUserInfo().getDatabaseInfo(dbName);
            TaskExecutor executor = new CommonTaskExec(null);
            VerifyDbUserPasswordTask verifyDbUserPasswordTask = null;
            if (dbInfo.isLogined() && dbInfo.getAuthLoginedDbUserInfo().getName().equalsIgnoreCase("dba")) {
                String password = dbInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
                if (!dbaPassword.equals(password)) {
                    CommonUITool.openErrorBox(Messages.errDbaPassowrd);
                    return;
                }
            } else {
                verifyDbUserPasswordTask = new VerifyDbUserPasswordTask(serverInfo);
                verifyDbUserPasswordTask.setDbName(dbName);
                verifyDbUserPasswordTask.setDbUser("dba");
                verifyDbUserPasswordTask.setDbPassword(dbaPassword);
                executor.addTask(verifyDbUserPasswordTask);
            }
            GetHeartbeatNodeInfoTask getHeartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
            getHeartbeatNodeInfoTask.setAllDb(false);
            List<String> dbList = new ArrayList<String>();
            dbList.add(dbName);
            getHeartbeatNodeInfoTask.setDbList(dbList);
            executor.addTask(getHeartbeatNodeInfoTask);
            new ExecTaskWithProgress(executor).exec(true, true);
            if (!executor.isSuccess()) {
                if (verifyDbUserPasswordTask != null && !verifyDbUserPasswordTask.isSuccess()) {
                    dbaPasswordText.selectAll();
                    dbaPasswordText.setFocus();
                }
                return;
            }
            List<HAHostStatusInfo> haHostStatusInfoList = getHeartbeatNodeInfoTask.getHAHostStatusList();
            HADatabaseStatusInfo haDbStatusInfo = getHeartbeatNodeInfoTask.getDatabaseStatusInfo(dbName);
            HAHostStatusInfo haHostStatusInfo = getHeartbeatNodeInfoTask.getHostStatusInfo(serverInfo.getHostAddress());
            //if this database is HA Mode,will get it's active database or standby database
            List<DatabaseNode> haDbNodeList = getHADatabaseList(haDbStatusInfo, haHostStatusInfoList, true);
            if (haHostStatusInfo == null) {
                haHostStatusInfo = HAUtil.getHAHostStatusInfo(serverInfo);
                if (haDbStatusInfo != null) {
                    haHostStatusInfo.addHADatabaseStatus(haDbStatusInfo);
                }
            }
            if (haDbStatusInfo == null) {
                haDbStatusInfo = HAUtil.getHADatabaseStatusInfo(dbName, haHostStatusInfo, serverInfo);
            }
            DatabaseNode dbNode = new DatabaseNode();
            hostNode.setHostStatusInfo(haHostStatusInfo);
            dbNode.setParent(hostNode);
            dbNode.setDbName(dbName);
            dbNode.setDbUser("dba");
            dbNode.setDbPassword(dbaPassword);
            dbNode.setName(nickName);
            dbNode.setHaDatabaseStatus(haDbStatusInfo);
            dbNode.setConnected(true);
            if (haDbNodeList == null) {
                haDbNodeList = new ArrayList<DatabaseNode>();
            }
            if (dbNode.getDbStatusType() == DBStatusType.ACTIVE || dbNode.getDbStatusType() == DBStatusType.TO_BE_ACTIVE) {
                haDbNodeList.add(0, dbNode);
            } else {
                haDbNodeList.add(dbNode);
            }
            addDbNodeToTable(haDbNodeList, haHostStatusInfoList);
        }
    });
    haModeBtn = new Button(dbInfoGroup, SWT.LEFT | SWT.CHECK);
    haModeBtn.setText(Messages.btnHAMode);
    haModeBtn.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
    haModeBtn.setEnabled(false);
    createTable(composite);
    dbNameCombo.setFocus();
    setTitle(Messages.titleSelectDbPage);
    setMessage(Messages.msgSelectDbPage);
    setControl(composite);
}
Also used : Group(org.eclipse.swt.widgets.Group) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) Composite(org.eclipse.swt.widgets.Composite) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask) HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) GridLayout(org.eclipse.swt.layout.GridLayout) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ArrayList(java.util.ArrayList) List(java.util.List) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo) VerifyDbUserPasswordTask(com.cubrid.cubridmanager.core.mondashboard.task.VerifyDbUserPasswordTask)

Example 3 with HADatabaseStatusInfo

use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.

the class DataProvider method getUpdateValue.

/**
	 * Get the newest update data
	 * 
	 * @return DataChangedEvent
	 */
public DataChangedEvent getUpdateValue() {
    setDefaultValue();
    DataChangedEvent dataChangedEvent = new DataChangedEvent(this);
    Set<MondashDataResult> resultSet = new HashSet<MondashDataResult>();
    try {
        executeInThread();
    } catch (InterruptedException e) {
        LOGGER.error("", e);
    }
    // handle with the data
    //get host status
    Map<IDiagPara, String> hostMap = new HashMap<IDiagPara, String>();
    if (isExecuteHostStatTask) {
        performHostStatTask(hostMap);
    }
    //get broker status
    if (isExecuteBrokerStatTask) {
        performBrokerDiagTask(hostMap);
    }
    if (isExecuteHostStatTask || isExecuteBrokerStatTask) {
        MondashDataResult hostResult = new MondashDataResult();
        hostResult.setName(generator.getName());
        hostResult.putUpdateMap(hostMap);
        resultSet.add(hostResult);
    }
    //get HA node status
    List<HAHostStatusInfo> haHostStatusInfoList = null;
    if (isExecuteHeartbeatTask) {
        performHeartbeatNodeInfoTask();
        haHostStatusInfoList = getHeartbeatNodeInfoTask == null ? null : getHeartbeatNodeInfoTask.getHAHostStatusList();
    }
    //get database status
    List<HADatabaseStatusInfo> dbStatusInfoList = null;
    String dbStatusErrorInfo = null;
    if (isExecuteDbModeTask) {
        dbStatusErrorInfo = getDbModeTask.getErrorMsg();
        if (dbStatusErrorInfo != null && dbStatusErrorInfo.trim().length() > 0) {
            dbStatusErrorInfo += ", can not get database status.";
        }
        dbStatusInfoList = getDbModeTask.getDbModes();
    }
    //get some broker status
    DataChangedEvent event = brokerDataProvider == null ? null : brokerDataProvider.getUpdateValue();
    for (int i = 0; i < uniqueBrokerNodeList.size(); i++) {
        BrokerNode brokerNode = uniqueBrokerNodeList.get(i);
        if (event != null) {
            String brokerName = brokerNode.getBrokerName();
            dataChangedEvent.getBrokerInfosMap().put(brokerName, event.getBrokerInfosMap().get(brokerName));
            dataChangedEvent.getBrokerStatusInfosMap().put(brokerName, event.getBrokerStatusInfosMap().get(brokerName));
            dataChangedEvent.getBrokerDiagDataMap().put(brokerName, event.getBrokerDiagDataMap().get(brokerName));
        }
    }
    //get some databases status
    for (int i = 0; i < dbDataProviderList.size(); i++) {
        Set<MondashDataResult> dbResultSet = dbDataProviderList.get(i).getUpdateValue().getResultSet();
        if (dbResultSet != null) {
            resultSet.addAll(dbResultSet);
        }
        //set error
        DatabaseNode dbNode = dbDataProviderList.get(i).getDatabaseNode();
        if (StringUtil.isNotEmpty(dbStatusErrorInfo) && dbNode.getParent().isConnected()) {
            dbNode.setErrorMsg(dbStatusErrorInfo);
        }
        HADatabaseStatusInfo dbStatusInfo = HAUtil.getDatabaseStatusInfo(dbStatusInfoList, dbNode.getDbName());
        String errorInfo = dbStatusInfo == null ? null : dbStatusInfo.getErrorInfo();
        if (StringUtil.isNotEmpty(errorInfo) && dbNode.getParent().isConnected()) {
            dbNode.setErrorMsg(errorInfo);
        }
    }
    if (requestCount < 2) {
        requestCount++;
    }
    dataChangedEvent.setResultSet(resultSet);
    dataChangedEvent.setHaHostStatusInfoList(haHostStatusInfoList);
    dataChangedEvent.setDbStatusInfoList(dbStatusInfoList);
    setErrorMsg(errorMsg);
    if (errorMsg != null && errorMsg.trim().length() > 0) {
        LOGGER.error(errorMsg);
    }
    return dataChangedEvent;
}
Also used : HashMap(java.util.HashMap) IDiagPara(com.cubrid.cubridmanager.core.monitoring.model.IDiagPara) HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo) HashSet(java.util.HashSet)

Example 4 with HADatabaseStatusInfo

use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.

the class DashboardConnectionManager method refreshDB2DBConnections.

/**
	 * Refresh DB to DB connections.
	 * 
	 */
public void refreshDB2DBConnections() {
    List<DatabaseNode> allDatabaseNode = dashboard.getAllDatabaseNode();
    List<DatabaseNode> standByList = new ArrayList<DatabaseNode>();
    for (DatabaseNode dbNode : allDatabaseNode) {
        if (standByList.contains(dbNode)) {
            continue;
        }
        HADatabaseStatusInfo haDatabaseStatus = dbNode.getHaDatabaseStatus();
        if (haDatabaseStatus == null) {
            dbNode.removeAllHAConnections();
            continue;
        }
        HAHostStatusInfo haHostStatusInfo = haDatabaseStatus.getHaHostStatusInfo();
        if (haHostStatusInfo == null) {
            dbNode.removeAllHAConnections();
            continue;
        }
        //Is standby db
        if (haHostStatusInfo.getMasterHostStatusInfo() != null && (haHostStatusInfo.getSlaveHostStatusInfoList() == null || haHostStatusInfo.getSlaveHostStatusInfoList().size() == 0)) {
            HostNode master = dashboard.getHostNodeByName(haHostStatusInfo.getMasterHostStatusInfo().getHostName());
            if (null == master) {
                dbNode.removeAllHAConnections();
                continue;
            }
            DatabaseNode activeNode = master.getDBNodeByName(dbNode.getDbName());
            if (null == activeNode) {
                dbNode.removeAllHAConnections();
                continue;
            }
            if (null == HAUtil.getSyncModeType(dbNode, activeNode)) {
                dbNode.removeAllHAConnections();
                continue;
            }
            if (!dbNode.sourceExists(activeNode)) {
                new MonitorConnection(activeNode, dbNode);
            }
            //handled.add(activeNode);
            continue;
        }
        //Is active db
        if (haHostStatusInfo.getMasterHostStatusInfo() == null && haHostStatusInfo.getSlaveHostStatusInfoList() != null && haHostStatusInfo.getSlaveHostStatusInfoList().size() > 0) {
            //get the standby nodes of the active node
            standByList.clear();
            for (HAHostStatusInfo hostStatus : haHostStatusInfo.getSlaveHostStatusInfoList()) {
                HostNode slave = dashboard.getHostNodeByName(hostStatus.getHostName());
                if (slave == null) {
                    continue;
                }
                DatabaseNode standbyNode = slave.getDBNodeByName(dbNode.getDbName());
                if (standbyNode == null) {
                    continue;
                }
                if (null == HAUtil.getSyncModeType(standbyNode, dbNode)) {
                    continue;
                }
                standByList.add(standbyNode);
            }
            dbNode.removeConnectionsTargetNotInList(standByList, DatabaseNode.class);
            for (DatabaseNode standbyNode : standByList) {
                if (!dbNode.targetExists(standbyNode)) {
                    new MonitorConnection(dbNode, standbyNode);
                }
            }
            continue;
        }
        //other db
        dbNode.removeAllHAConnections();
    }
}
Also used : HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) ArrayList(java.util.ArrayList) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)

Example 5 with HADatabaseStatusInfo

use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.

the class DatabaseMonitorPart method refreshVisuals.

/**
	 * Refreshes this EditPart's <i>visuals</i>. This method is called by
	 * {@link #refresh()}, and may also be called in response to notifications
	 * from the model.
	 */
protected void refreshVisuals() {
    DatabaseMonitorFigure dmfg = (DatabaseMonitorFigure) this.getFigure();
    DatabaseNode dn = (DatabaseNode) this.getModel();
    dmfg.setTitle(dn.getName());
    HADatabaseStatusInfo haDatabaseStatus = dn.getHaDatabaseStatus();
    String dbStatus = "";
    if (haDatabaseStatus != null) {
        dmfg.setCpuUsage(haDatabaseStatus.getCpuUsage());
        dmfg.setMemUsage(haDatabaseStatus.getMemUsage());
        dmfg.setDelay(haDatabaseStatus.getDelay());
        dbStatus = DBStatusType.getShowText(haDatabaseStatus.getStatusType());
    }
    dmfg.setStatus(true, dn.getParent().isConnected(), dn.isConnected(), dbStatus, dn.getErrorMsg(), dn.hasNewErrorMsg());
    super.refreshVisuals();
}
Also used : DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) DatabaseMonitorFigure(com.cubrid.cubridmanager.ui.mondashboard.editor.figure.DatabaseMonitorFigure) 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