Search in sources :

Example 16 with DatabaseNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.

the class HAUtil method mergeCopyedHostChildNode.

/**
	 * 
	 * Merge the database node
	 * 
	 * @param hostNode The HostNode
	 * @param addedHostNode The HostNode
	 */
private static void mergeCopyedHostChildNode(HostNode hostNode, HostNode addedHostNode) {
    List<HANode> haNodeList = hostNode.getCopyedHaNodeList();
    //merge database node
    List<DatabaseNode> addedDbNodeList = addedHostNode.getCopyedDbNodeList();
    for (int i = 0; i < addedDbNodeList.size(); i++) {
        DatabaseNode addDbNode = addedDbNodeList.get(i);
        addDbNode.setParent(hostNode);
        if (haNodeList.contains(addDbNode)) {
            haNodeList.remove(addDbNode);
            haNodeList.add(addDbNode);
        } else {
            haNodeList.add(addDbNode);
        }
    }
    //merge broker node
    List<BrokerNode> addedBrokerNodeList = addedHostNode.getCopyedBrokerNodeList();
    for (int i = 0; i < addedBrokerNodeList.size(); i++) {
        BrokerNode addBrokerNode = addedBrokerNodeList.get(i);
        addBrokerNode.setParent(hostNode);
        if (haNodeList.contains(addBrokerNode)) {
            haNodeList.remove(addBrokerNode);
            haNodeList.add(addBrokerNode);
        } else {
            haNodeList.add(addBrokerNode);
        }
    }
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HANode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode) Point(org.eclipse.draw2d.geometry.Point)

Example 17 with DatabaseNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.

the class AddHostAndDbWizard method performFinish.

/**
	 * Called when user clicks Finish
	 * 
	 * @return boolean
	 */
public boolean performFinish() {
    List<Map<String, Object>> dbNodeList = selectDbPage == null ? null : selectDbPage.getDbNodeList();
    List<Map<String, Object>> brokerNodeNodeList = selectBrokerPage == null ? null : selectBrokerPage.getBrokerNodeList();
    HostNode hostNode = mergeHostNode(setHostInfoPage == null ? null : setHostInfoPage.getHostNode());
    for (int i = 0; dbNodeList != null && i < dbNodeList.size(); i++) {
        Map<String, Object> map = dbNodeList.get(i);
        hostNode = mergeHostNode((HostNode) map.get("6"));
        DatabaseNode dbNode = (DatabaseNode) map.get("7");
        if (hostNode != null) {
            dbNode.setParent(hostNode);
            hostNode.getCopyedHaNodeList().remove(dbNode);
            hostNode.getCopyedHaNodeList().add(dbNode);
        }
    }
    for (int i = 0; brokerNodeNodeList != null && i < brokerNodeNodeList.size(); i++) {
        Map<String, Object> map = brokerNodeNodeList.get(i);
        hostNode = mergeHostNode((HostNode) map.get("8"));
        BrokerNode brokerNode = (BrokerNode) map.get("9");
        if (hostNode != null) {
            brokerNode.setParent(hostNode);
            hostNode.getCopyedHaNodeList().remove(brokerNode);
            hostNode.getCopyedHaNodeList().add(brokerNode);
        }
    }
    return true;
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) Map(java.util.Map)

Example 18 with DatabaseNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.

the class SelectDbPage method addDbNodeToTable.

/**
	 * 
	 * Add DatabaseNode to table
	 * 
	 * @param haDbNodeList The List<DatabaseNode>
	 * @param haHostStatusInfoList The List<HAHostStatusInfo>
	 */
private void addDbNodeToTable(List<DatabaseNode> haDbNodeList, List<HAHostStatusInfo> haHostStatusInfoList) {
    for (int i = 0; haDbNodeList != null && i < haDbNodeList.size(); i++) {
        DatabaseNode dbNode = haDbNodeList.get(i);
        if (isDbNodeExist(dbNode)) {
            continue;
        }
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("0", dbNode.getName());
        map.put("1", dbNode.getDbName());
        map.put("2", DBStatusType.getShowText(dbNode.getDbStatusType()));
        map.put("3", dbNode.getParent().getIp());
        map.put("4", dbNode.getParent().getPort());
        map.put("5", HostStatusType.getShowText(dbNode.getParent().getHostStatusInfo().getStatusType()));
        map.put("6", dbNode.getParent());
        map.put("7", dbNode);
        map.put("8", haHostStatusInfoList);
        dbNodeList.add(map);
    }
    dbTableViewer.refresh();
    for (int i = 0; i < dbTable.getColumnCount(); i++) {
        dbTable.getColumn(i).pack();
    }
}
Also used : DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HashMap(java.util.HashMap)

Example 19 with DatabaseNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode 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)

Example 20 with DatabaseNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.

the class ConnectionManager method connectHost.

/**
	 * 
	 * Connect Host
	 * 
	 * @param hostNode The HostNode
	 * @param isConnectChild The boolean
	 * @param isPing The boolean
	 */
public static void connectHost(HostNode hostNode, boolean isConnectChild, boolean isPing) {
    if (hostNode.isConnected() || hostNode.isConnecting()) {
        return;
    }
    ServerInfo serverInfo = hostNode.getServerInfo();
    if (serverInfo == null) {
        serverInfo = new ServerInfo();
        serverInfo.setServerName(hostNode.getIp());
        serverInfo.setHostAddress(hostNode.getIp());
        serverInfo.setHostMonPort(Integer.parseInt(hostNode.getPort()));
        serverInfo.setHostJSPort(Integer.parseInt(hostNode.getPort()) + 1);
        serverInfo.setUserName(hostNode.getUserName());
        serverInfo.setUserPassword(hostNode.getPassword());
        serverInfo.setJdbcDriverVersion(ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION);
    }
    hostNode.setConnecting(true);
    ConnectHostJobExecutor executor = new ConnectHostJobExecutor(hostNode, serverInfo, isPing);
    IStatus status = executor.exec(new NullProgressMonitor());
    executor.finish(status);
    if (isConnectChild && hostNode.isConnected()) {
        List<DatabaseNode> dbNodeList = hostNode.getDbNodeList();
        for (DatabaseNode dbNode : dbNodeList) {
            if (dbNode.isConnecting() || dbNode.isConnected()) {
                continue;
            }
            dbNode.setConnecting(true);
            ConnectDatabaseNodeJobExecutor dbJobExecutor = new ConnectDatabaseNodeJobExecutor(dbNode, serverInfo);
            status = dbJobExecutor.exec(new NullProgressMonitor());
            dbJobExecutor.finish(status);
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Aggregations

DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)36 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)20 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)14 DatabaseMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)11 ArrayList (java.util.ArrayList)9 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)6 HADatabaseStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)5 HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Point (org.eclipse.draw2d.geometry.Point)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 GridData (org.eclipse.swt.layout.GridData)4 RowLayout (org.eclipse.swt.layout.RowLayout)4 Button (org.eclipse.swt.widgets.Button)4 Composite (org.eclipse.swt.widgets.Composite)4 Label (org.eclipse.swt.widgets.Label)4 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)3 BrokerDBListNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerDBListNode)3