Search in sources :

Example 6 with HAHostStatusInfo

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

the class HostNode method setConnected.

/**
	 * Only fire the property changed events,does not change the server's real
	 * connection status, call this method after the server is connected or
	 * disconnected.
	 * 
	 * @param connected connections status.
	 */
public void setConnected(boolean connected) {
    isConnected = connected && getServerInfo() != null;
    if (!isConnected) {
        HAHostStatusInfo statusInfo = new HAHostStatusInfo();
        statusInfo.setIp(getIp());
        setHostStatusInfo(statusInfo);
        for (DatabaseNode dn : dbNodeList) {
            dn.setConnected(isConnected);
        }
        for (BrokerNode brokerNode : brokerNodeList) {
            brokerNode.setBrokerInfo(null);
            brokerNode.setBrokerDiagData(null);
            brokerNode.setBrokerStatusInfos(null);
        }
    }
    this.firePropertyChange(PROP_HOST_CONNECTION_STATUS, null, isConnected);
}
Also used : HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)

Example 7 with HAHostStatusInfo

use of com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo 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 8 with HAHostStatusInfo

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

Example 9 with HAHostStatusInfo

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

the class GetHeartbeatNodeInfoTask method getHAHostStatusList.

/**
	 * 
	 * Get host status list
	 * 
	 * @return The List<HAHostStatus>
	 */
public List<HAHostStatusInfo> getHAHostStatusList() {
    TreeNode response = getResponse();
    if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
        return null;
    }
    String currentHostName = response.getValue("currentnode");
    String currentHostStatus = response.getValue("currentnodestate");
    HAHostStatusInfo currentHaHostStatus = null;
    hostStatusList = new ArrayList<HAHostStatusInfo>();
    for (int i = 0; i < response.childrenSize(); i++) {
        TreeNode node = response.getChildren().get(i);
        if (node.getValue("open") == null) {
            continue;
        }
        if (node.getValue("open").trim().equals("hanodelist")) {
            currentHaHostStatus = buildHaNodeList(node, hostStatusList, currentHostName);
        } else if (node.getValue("open").trim().equals("hadbinfolist")) {
            buildHaDbInfoList(node, currentHaHostStatus);
        }
    }
    if (currentHaHostStatus != null) {
        currentHaHostStatus.setStatusType(HostStatusType.getType(currentHostStatus));
    }
    return hostStatusList;
}
Also used : HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode)

Example 10 with HAHostStatusInfo

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

the class SelectDbPage method createTable.

/**
	 * 
	 * Create table area
	 * 
	 * @param parent the parent composite
	 */
private void createTable(Composite parent) {
    Label tipLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
    tipLabel.setText(Messages.lblDbListInfo);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    tipLabel.setLayoutData(gridData);
    final String[] columnNameArr = new String[] { Messages.colNickName, Messages.colDbName, Messages.colDbStatus, Messages.colIP, Messages.colPort, Messages.colServerStatus };
    dbTableViewer = CommonUITool.createCommonTableViewer(parent, null, columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 500));
    dbTable = dbTableViewer.getTable();
    for (int i = 0; i < dbTable.getColumnCount(); i++) {
        dbTable.getColumn(i).pack();
    }
    dbTable.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("unchecked")
        public void widgetSelected(SelectionEvent event) {
            deleteDbButton.setEnabled(dbTable.getSelectionCount() > 0);
            addHANodeButton.setEnabled(false);
            StructuredSelection selection = (StructuredSelection) dbTableViewer.getSelection();
            if (selection == null || selection.isEmpty() || selection.size() > 1) {
                return;
            }
            Map<String, Object> map = (Map<String, Object>) selection.getFirstElement();
            DatabaseNode dbNode = (DatabaseNode) map.get("7");
            DBStatusType type = dbNode.getHaDatabaseStatus().getStatusType();
            if (type == DBStatusType.ACTIVE || type == DBStatusType.TO_BE_ACTIVE || type == DBStatusType.MAINTENANCE || type == DBStatusType.STANDBY || type == DBStatusType.TO_BE_STANDBY) {
                addHANodeButton.setEnabled(true);
            }
        }
    });
    dbTableViewer.setInput(dbNodeList);
    Composite composite = new Composite(parent, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 5;
    composite.setLayout(rowLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalAlignment = GridData.END;
    composite.setLayoutData(gridData);
    addHANodeButton = new Button(composite, SWT.NONE);
    addHANodeButton.setText(Messages.btnAddHADb);
    addHANodeButton.setToolTipText(Messages.tipBtnAddHaDb);
    addHANodeButton.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("unchecked")
        public void widgetSelected(SelectionEvent event) {
            StructuredSelection selection = (StructuredSelection) dbTableViewer.getSelection();
            if (selection == null || selection.isEmpty() || selection.size() > 1) {
                return;
            }
            Map<String, Object> map = (Map<String, Object>) selection.getFirstElement();
            DatabaseNode dbNode = (DatabaseNode) map.get("7");
            List<HAHostStatusInfo> haHostStatusInfoList = (List<HAHostStatusInfo>) map.get("8");
            List<DatabaseNode> haDbNodeList = getHADatabaseList(dbNode.getHaDatabaseStatus(), haHostStatusInfoList, false);
            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);
            addHANodeButton.setEnabled(dbTable.getSelectionCount() > 0);
        }
    });
    addHANodeButton.setEnabled(false);
    deleteDbButton = new Button(composite, SWT.NONE);
    deleteDbButton.setText(Messages.btnDelete);
    deleteDbButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            StructuredSelection selection = (StructuredSelection) dbTableViewer.getSelection();
            if (selection != null && !selection.isEmpty()) {
                dbNodeList.removeAll(selection.toList());
            }
            dbTableViewer.refresh();
            deleteDbButton.setEnabled(dbTable.getSelectionCount() > 0);
        }
    });
    deleteDbButton.setEnabled(false);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) DBStatusType(com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType) HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) 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) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)19 HADatabaseStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)7 ArrayList (java.util.ArrayList)6 DBStatusType (com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType)4 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)4 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)3 HashMap (java.util.HashMap)3 List (java.util.List)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 GridData (org.eclipse.swt.layout.GridData)3 RowLayout (org.eclipse.swt.layout.RowLayout)3 Button (org.eclipse.swt.widgets.Button)3 Composite (org.eclipse.swt.widgets.Composite)3 Label (org.eclipse.swt.widgets.Label)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 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 TreeNode (com.cubrid.cubridmanager.core.common.socket.TreeNode)2