Search in sources :

Example 1 with GetHeartbeatNodeInfoTask

use of com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask in project cubrid-manager by CUBRID.

the class SetHostInfoPage 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 cmServerInfoGroup = new Group(composite, SWT.NONE);
    cmServerInfoGroup.setText(Messages.grpHostInfo);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    cmServerInfoGroup.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    cmServerInfoGroup.setLayout(layout);
    Label nickNameLable = new Label(cmServerInfoGroup, SWT.LEFT);
    nickNameLable.setText(Messages.lblNickName);
    nickNameLable.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    nickNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    nickNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Label ipLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    ipLabel.setText(Messages.lblIPAddress);
    ipLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    ipText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    ipText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    ipText.addModifyListener(this);
    Label portNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    portNameLabel.setText(Messages.lblPort);
    portNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    portText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    portText.setTextLimit(5);
    portText.setText("8001");
    portText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    portText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            portText.selectAll();
            portText.setFocus();
        }
    });
    portText.addModifyListener(this);
    Label userNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    userNameLabel.setText(Messages.lblUserName);
    userNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    userNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    userNameText.setText("admin");
    userNameText.setEnabled(false);
    userNameText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
    userNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Label passwordLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    passwordLabel.setText(Messages.lblPassword);
    passwordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    passwordText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
    passwordText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
    passwordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    passwordText.addModifyListener(this);
    passwordText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            passwordText.selectAll();
            passwordText.setFocus();
        }
    });
    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);
    connectHostButton = new Button(btnComposite, SWT.NONE);
    connectHostButton.setText(Messages.btnConnect);
    connectHostButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String address = ipText.getText();
            String port = portText.getText();
            String userName = userNameText.getText();
            String password = passwordText.getText();
            String nickName = nickNameText.getText();
            if (nickName.trim().length() == 0) {
                nickNameText.setText(address + ":" + port);
            }
            ServerInfo serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(address, Integer.parseInt(port), userName);
            if (serverInfo == null) {
                serverInfo = new ServerInfo();
                serverInfo.setServerName(address);
                serverInfo.setHostAddress(address);
                serverInfo.setHostMonPort(Integer.parseInt(port));
                serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
                serverInfo.setUserName(userName);
                serverInfo.setUserPassword(password);
                serverInfo.setJdbcDriverVersion(ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION);
            }
            heartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
            heartbeatNodeInfoTask.setAllDb(false);
            heartbeatNodeInfoTask.setDbList(new ArrayList<String>());
            TaskExecutor executor = null;
            if (serverInfo.isConnected()) {
                if (CompatibleUtil.isSupportHA(serverInfo)) {
                    executor = new CommonTaskExec(null);
                    executor.addTask(heartbeatNodeInfoTask);
                }
            } else {
                executor = new ConnectHostExecutor(getShell(), serverInfo, true);
                executor.addTask(heartbeatNodeInfoTask);
            }
            if (executor != null) {
                new ExecTaskWithProgress(executor).exec(true, true);
            }
            changeBtnStatus();
        }
    });
    connectHostButton.setEnabled(false);
    init();
    nickNameText.setFocus();
    setTitle(Messages.titileHostInfoPage);
    setMessage(Messages.msgHostInfoPage);
    setControl(composite);
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) Composite(org.eclipse.swt.widgets.Composite) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask) GridLayout(org.eclipse.swt.layout.GridLayout) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) 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) ConnectHostExecutor(com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor)

Example 2 with GetHeartbeatNodeInfoTask

use of com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask in project cubrid-manager by CUBRID.

the class ConnectHostJobExecutor method exec.

/**
	 * Execute to connect host
	 * 
	 * @param monitor the IProgressMonitor
	 * @return <code>true</code> if successful;<code>false</code>otherwise;
	 */
@SuppressWarnings("unchecked")
public IStatus exec(final IProgressMonitor monitor) {
    monitor.subTask(Messages.bind(com.cubrid.cubridmanager.ui.mondashboard.Messages.jobConnectHost, serverInfo.getHostAddress()));
    isContinue = true;
    boolean isRunUpdateCmUserTask = false;
    BrokerInfos brokerInfos = null;
    errorMsg = null;
    for (ITask task : taskList) {
        if (task instanceof MonitoringTask) {
            IStatus status = connectHost((MonitoringTask) task);
            if (Status.OK_STATUS != status) {
                return status;
            }
        } else if ((task instanceof UpdateCMUserTask)) {
            updateCMUserAuthInfo(task, isRunUpdateCmUserTask);
        } else if ((task instanceof GetHeartbeatNodeInfoTask) && !CompatibleUtil.isSupportHA(serverInfo)) {
            continue;
        } else {
            task.execute();
        }
        final String msg = task.getErrorMsg();
        if (monitor.isCanceled()) {
            disConnect();
            return Status.CANCEL_STATUS;
        }
        if (!hostNode.isConnecting()) {
            return Status.CANCEL_STATUS;
        }
        if (msg != null && msg.length() > 0) {
            disConnect();
            if (isPing) {
                errorMsg = msg;
                return Status.CANCEL_STATUS;
            }
            return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
        }
        if (task instanceof GetEnvInfoTask) {
            GetEnvInfoTask getEnvInfoTask = (GetEnvInfoTask) task;
            EnvInfo envInfo = getEnvInfoTask.loadEnvInfo();
            serverInfo.setEnvInfo(envInfo);
            String clientVersion = Version.buildVersionId.substring(0, Version.buildVersionId.lastIndexOf("."));
            if (!CompatibleUtil.isSupportCMServer(serverInfo, clientVersion)) {
                disConnect();
                errorMsg = Messages.bind(Messages.errNoSupportServerVersion, clientVersion);
                if (isPing) {
                    return Status.CANCEL_STATUS;
                }
                return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, errorMsg);
            }
            if (!serverInfo.validateJdbcVersion(serverInfo.getJdbcDriverVersion())) {
                disConnect();
                if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(serverInfo.getJdbcDriverVersion())) {
                    errorMsg = Messages.errNoSupportDriver;
                } else {
                    errorMsg = Messages.errSelectSupportDriver;
                }
                if (isPing) {
                    return Status.CANCEL_STATUS;
                }
                return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, errorMsg);
            }
        } else if (task instanceof GetDatabaseListTask) {
            GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
            List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
            if (databaseInfoList != null) {
                allDatabaseInfoList.addAll(databaseInfoList);
            }
        } else if (task instanceof GetCMConfParameterTask) {
            GetCMConfParameterTask getCMConfParameterTask = (GetCMConfParameterTask) task;
            Map<String, String> confParameters = getCMConfParameterTask.getConfParameters();
            ServerType serverType = ServerType.BOTH;
            if (confParameters != null) {
                String target = confParameters.get(ConfConstants.CM_TARGET);
                if (target != null) {
                    if (target.indexOf("broker") >= 0 && target.indexOf("server") >= 0) {
                        serverType = ServerType.BOTH;
                    } else if (target.indexOf("broker") >= 0) {
                        serverType = ServerType.BROKER;
                    } else if (target.indexOf("server") >= 0) {
                        serverType = ServerType.DATABASE;
                    }
                }
            }
            if (serverInfo != null) {
                serverInfo.setServerType(serverType);
            }
        } else if (task instanceof CommonQueryTask) {
            CommonQueryTask<BrokerInfos> getBrokerTask = (CommonQueryTask<BrokerInfos>) task;
            brokerInfos = getBrokerTask.getResultModel();
            if (serverInfo != null) {
                serverInfo.setBrokerInfos(brokerInfos);
            }
        } else if (task instanceof GetCMUserListTask) {
            if (serverInfo != null && serverInfo.isConnected()) {
                GetCMUserListTask getUserInfoTask = (GetCMUserListTask) task;
                List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
                for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
                    ServerUserInfo userInfo = serverUserInfoList.get(i);
                    if (userInfo != null && userInfo.getUserName().equals(serverInfo.getUserName())) {
                        serverInfo.setLoginedUserInfo(userInfo);
                        break;
                    }
                }
                List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
                if (databaseInfoList != null) {
                    authDatabaseList.addAll(databaseInfoList);
                }
                isRunUpdateCmUserTask = CubridDatabasesFolderLoader.filterDatabaseList(serverInfo, allDatabaseInfoList, authDatabaseList);
                if (isRunUpdateCmUserTask) {
                    serverInfo.getLoginedUserInfo().setDatabaseInfoList(authDatabaseList);
                }
            }
        } else if (task instanceof GetCubridConfParameterTask) {
            GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
            Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
            if (serverInfo != null) {
                serverInfo.setCubridConfParaMap(confParas);
            }
        } else if (task instanceof GetBrokerConfParameterTask) {
            GetBrokerConfParameterTask getBrokerConfParameterTask = (GetBrokerConfParameterTask) task;
            Map<String, Map<String, String>> confParas = getBrokerConfParameterTask.getConfParameters();
            if (serverInfo != null) {
                serverInfo.setBrokerConfParaMap(confParas);
            }
        } else if (task instanceof GetHeartbeatNodeInfoTask) {
            GetHeartbeatNodeInfoTask getHeartbeatNodeInfoTask = (GetHeartbeatNodeInfoTask) task;
            haHostStatusInfo = getHeartbeatNodeInfoTask.getHostStatusInfo(serverInfo.getHostAddress());
        }
        if (monitor.isCanceled() || !isContinue) {
            disConnect();
            return Status.CANCEL_STATUS;
        }
    }
    return Status.OK_STATUS;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) ArrayList(java.util.ArrayList) List(java.util.List) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) GetCMUserListTask(com.cubrid.cubridmanager.core.common.task.GetCMUserListTask) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) GetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask) Map(java.util.Map) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Example 3 with GetHeartbeatNodeInfoTask

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

use of com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask in project cubrid-manager by CUBRID.

the class CubridServerLoader method getHostStatus.

/**
	 * Get host status
	 *
	 * @param server - CubridServer
	 */
private void getHostStatus(final CubridServer server) {
    final GetHeartbeatNodeInfoTask getHeartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(server.getServerInfo());
    getHeartbeatNodeInfoTask.setAllDb(true);
    getHeartbeatNodeInfoTask.execute();
    if (getHeartbeatNodeInfoTask.isSuccess()) {
        HAHostStatusInfo haHostStatusInfo = getHeartbeatNodeInfoTask.getHostStatusInfo(server.getServerInfo().getHostAddress());
        if (haHostStatusInfo != null) {
            server.getServerInfo().setHaHostStatusInfo(haHostStatusInfo);
        }
    } else {
        LOGGER.debug("Get host status error:" + getHeartbeatNodeInfoTask.getErrorMsg());
    }
    final GetHAConfParameterTask getHAConfParameterTask = new GetHAConfParameterTask(server.getServerInfo());
    getHAConfParameterTask.execute();
    if (getHAConfParameterTask.isSuccess()) {
        server.getServerInfo().setHaConfParaMap(getHAConfParameterTask.getConfParameters());
    } else {
        LOGGER.debug("Get host ha status error:" + getHAConfParameterTask.getErrorMsg());
    }
}
Also used : HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) GetHAConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetHAConfParameterTask) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask)

Example 5 with GetHeartbeatNodeInfoTask

use of com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask in project cubrid-manager by CUBRID.

the class HaShardDemo method getHaNodeInfo.

protected NodeInfo getHaNodeInfo(ServerInfo serverInfo, String haMode) {
    //"heartbeatlist"
    GetHeartbeatNodeInfoTask getHeartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
    getHeartbeatNodeInfoTask.setAllDb(true);
    getHeartbeatNodeInfoTask.execute();
    if (!getHeartbeatNodeInfoTask.isSuccess()) {
        return null;
    }
    String status = getHeartbeatNodeInfoTask.getCurrentHostStatus();
    NodeType type = CMServiceAnalysisUtil.convertHaStatToNodeType(status);
    HaNode nodeInfo = null;
    if (type != NodeType.NORMAL) {
        nodeInfo = new HaNode(type);
        nodeInfo.buildStatus("ON");
        nodeInfo.setHostStatusInfoList(getHeartbeatNodeInfoTask.getHAHostStatusList());
    } else if ("on".equals(haMode)) {
        nodeInfo = new HaNode(NodeType.SLAVE);
        nodeInfo.buildStatus("OFF");
    } else if ("replica".equals(haMode)) {
        nodeInfo = new HaNode(NodeType.REPLICA);
        nodeInfo.buildStatus("OFF");
    }
    //"getallsysparam"/"cubrid_ha.conf"
    GetHAConfParameterTask getHAConfParameterTask = new GetHAConfParameterTask(serverInfo);
    getHAConfParameterTask.execute();
    BrokerInfos brokerInfos = new BrokerInfos();
    GetBrokerStatusInfosTask<BrokerInfos> getBrokerStatusInfosTask = new GetBrokerStatusInfosTask<BrokerInfos>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), brokerInfos);
    getBrokerStatusInfosTask.execute();
    if (!getHAConfParameterTask.isSuccess() || !getBrokerStatusInfosTask.isSuccess()) {
        return null;
    }
    brokerInfos = getBrokerStatusInfosTask.getResultModel();
    if (brokerInfos != null) {
        nodeInfo.setBrokerInfoList(brokerInfos.getBorkerInfoList());
    }
    Map<String, Map<String, String>> haConfParas = getHAConfParameterTask.getConfParameters();
    Map<String, String> haCommonConf = haConfParas.get("[common]");
    //		String haNodeStr = haCommonConf.get("ha_node_list").substring("cubrid@".length());
    //		List<String> haNodeList = Arrays.asList(haNodeStr.split(":"));
    //		String replicaStr = haCommonConf.get("ha_replica_list");
    //		List<String> replicaNodeList = Arrays.asList(replicaStr.substring("cubrid@".length()).split(":"));
    String dbList = haCommonConf.get("ha_db_list");
    if (dbList.indexOf(",") > -1) {
        String[] dbAr = dbList.split(",");
        for (String s : dbAr) {
            if (s.trim().length() > 0) {
                nodeInfo.addDatabase(s);
            }
        }
    } else {
        nodeInfo.addDatabase(dbList);
    }
    return nodeInfo;
}
Also used : HaNode(com.cubrid.cubridmanager.core.cubrid.service.model.HaNode) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) NodeType(com.cubrid.cubridmanager.core.cubrid.service.model.NodeType) GetBrokerStatusInfosTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask) GetHAConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetHAConfParameterTask) Map(java.util.Map) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask)

Aggregations

GetHeartbeatNodeInfoTask (com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask)6 ArrayList (java.util.ArrayList)4 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 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)2 GetHAConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetHAConfParameterTask)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 HADatabaseStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)2 HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)2 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)2 List (java.util.List)2 Map (java.util.Map)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 RowLayout (org.eclipse.swt.layout.RowLayout)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2