Search in sources :

Example 1 with DBStatusType

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

the class AddHADatabaseDialog method initial.

/**
	 * 
	 * Initial the value of dialog field
	 * 
	 */
private void initial() {
    DBStatusType type = haDbStatusInfo.getStatusType();
    String ip = haDbStatusInfo.getHaHostStatusInfo().getIp();
    String dbName = haDbStatusInfo.getDbName();
    if (type == DBStatusType.ACTIVE || type == DBStatusType.TO_BE_ACTIVE) {
        setMessage(Messages.bind(Messages.msgAddStadnbyDbDialog, dbName));
    } else if (type == DBStatusType.STANDBY || type == DBStatusType.TO_BE_STANDBY || type == DBStatusType.MAINTENANCE) {
        setMessage(Messages.bind(Messages.msgAddActiveDbDialog, dbName));
    }
    for (int i = 0; haHostStatusInfoList != null && i < haHostStatusInfoList.size(); i++) {
        String address = haHostStatusInfoList.get(i).getIp();
        if (!address.equals(ip)) {
            ipCombo.add(address);
        }
    }
    if (ipCombo.getItemCount() > 0) {
        ipCombo.select(0);
    }
    dbNameText.setText(dbName);
    ipCombo.addModifyListener(this);
    portText.addModifyListener(this);
    passwordText.addModifyListener(this);
    portText.selectAll();
    portText.setFocus();
}
Also used : DBStatusType(com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType)

Example 2 with DBStatusType

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

the class DashboardPreferencePage method performApply.

/**
	 * Perform Apply,save colors to local.
	 */
protected void performApply() {
    for (DBStatusType dbt : DBStatusType.values()) {
        PREFER.setColor(getDBStatusText(dbt), colorSettings.get(getDBStatusText(dbt)).getBackground());
    }
    PREFER.setHAHeartBeatTimeout(haHeartBeatTimeout);
    PREFER.save();
}
Also used : DBStatusType(com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType)

Example 3 with DBStatusType

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

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

the class SelectDbPage method getHADatabaseList.

/**
	 * 
	 * Get databases in HA mode
	 * 
	 * @param haDbStatusInfo The HADatabaseStatusInfo
	 * @param haHostStatusInfoList The List<HAHostStatusInfo>
	 * @param isShowMsg boolean
	 * @return List<DatabaseNode>
	 */
private List<DatabaseNode> getHADatabaseList(HADatabaseStatusInfo haDbStatusInfo, List<HAHostStatusInfo> haHostStatusInfoList, boolean isShowMsg) {
    boolean isConfirm = false;
    if (haDbStatusInfo != null) {
        DBStatusType type = haDbStatusInfo.getStatusType();
        String msg = null;
        if (type == DBStatusType.ACTIVE || type == DBStatusType.TO_BE_ACTIVE) {
            msg = Messages.bind(Messages.confirmMsgAddStandby, type.getText());
            isConfirm = true;
        } else if (type == DBStatusType.STANDBY || type == DBStatusType.TO_BE_STANDBY || type == DBStatusType.MAINTENANCE) {
            msg = Messages.bind(Messages.confirmMsgAddActive, type.getText());
            isConfirm = true;
        }
        if (isShowMsg) {
            isConfirm = CommonUITool.openConfirmBox(msg);
        }
    }
    if (isConfirm) {
        AddHADatabaseDialog dialog = new AddHADatabaseDialog(getShell(), haDbStatusInfo, haHostStatusInfoList);
        int ret = dialog.open();
        if (ret == IDialogConstants.OK_ID) {
            return dialog.getDbNodeList();
        }
    }
    return null;
}
Also used : DBStatusType(com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType) AddHADatabaseDialog(com.cubrid.cubridmanager.ui.mondashboard.dialog.AddHADatabaseDialog)

Example 5 with DBStatusType

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

DBStatusType (com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType)9 HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)4 HADatabaseStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)3 DbProcessStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.DbProcessStatusInfo)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 DecoratedImage (com.cubrid.common.ui.decorator.DecoratedImage)1 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)1 AddHADatabaseDialog (com.cubrid.cubridmanager.ui.mondashboard.dialog.AddHADatabaseDialog)1 DatabaseDashboardViewPart (com.cubrid.cubridmanager.ui.mondashboard.editor.DatabaseDashboardViewPart)1 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)1 HANode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode)1 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)1 DatabaseMonitorPartHelper (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.helper.DatabaseMonitorPartHelper)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1