Search in sources :

Example 6 with MonitorDashboardPreference

use of com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference in project cubrid-manager by CUBRID.

the class SetDatabaseInfoPage method modifyText.

/**
	 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
	 * @param event ModifyEvent
	 */
public void modifyText(ModifyEvent event) {
    final String port = portText.getText();
    String password = passwordText.getText();
    String mdbPassword = masteDbaPasswordText.getText();
    String distdbPassword = distDbaPasswordText.getText();
    boolean isValidPort = ValidateUtil.isNumber(port);
    if (isValidPort) {
        int portVal = Integer.parseInt(port);
        if (portVal < 1024 || portVal > 65535) {
            isValidPort = false;
        }
    }
    if (!isValidPort) {
        setErrorMessage(Messages.errInvalidPort);
        setPageComplete(false);
        return;
    }
    boolean isValidPassword = password.length() >= 4 && password.indexOf(" ") < 0;
    if (!isValidPassword) {
        setErrorMessage(Messages.errInvalidPassword);
        setPageComplete(false);
        return;
    }
    boolean isValidMdbPassword = mdbPassword.length() >= 4 && mdbPassword.indexOf(" ") < 0;
    if (!isValidMdbPassword) {
        setErrorMessage(Messages.errInvalidMdbPassword);
        setPageComplete(false);
        return;
    }
    boolean isValidDistdbPassword = distdbPassword.length() >= 4 && distdbPassword.indexOf(" ") < 0;
    if (!isValidDistdbPassword) {
        setErrorMessage(Messages.errInvalidDistdbPassword);
        setPageComplete(false);
        return;
    }
    boolean isValid = isValidPort && isValidPassword && isValidMdbPassword && isValidDistdbPassword;
    setPageComplete(false);
    if (isValid) {
        final String ip = ipText.getText();
        final String userName = userNameText.getText();
        final MonitorDashboardPreference monPref = new MonitorDashboardPreference();
        TaskExecutor taskExcutor = new TaskExecutor() {

            public boolean exec(final IProgressMonitor monitor) {
                Display display = getShell().getDisplay();
                if (monitor.isCanceled()) {
                    return false;
                }
                boolean isConnected = false;
                for (ITask task : taskList) {
                    if (task instanceof MonitoringTask) {
                        MonitoringTask monitoringTask = (MonitoringTask) task;
                        monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
                        isConnected = true;
                    } else if (task instanceof LoginDatabaseTask) {
                        task.execute();
                    }
                    final String msg = task.getErrorMsg();
                    if (monitor.isCanceled()) {
                        if (isConnected) {
                            ServerManager.getInstance().setConnected(ip, Integer.parseInt(port), userName, false);
                        }
                        return false;
                    }
                    if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
                        monitor.done();
                        display.syncExec(new Runnable() {

                            public void run() {
                                setErrorMessage(msg);
                            }
                        });
                        if (isConnected) {
                            ServerManager.getInstance().setConnected(ip, Integer.parseInt(port), userName, false);
                        }
                        return false;
                    }
                }
                if (!monitor.isCanceled()) {
                    if (isConnected) {
                        ServerManager.getInstance().setConnected(ip, Integer.parseInt(port), userName, false);
                    }
                    display.syncExec(new Runnable() {

                        public void run() {
                            setErrorMessage(null);
                            setPageComplete(true);
                        }
                    });
                }
                return true;
            }
        };
        ServerInfo serverInfo = new ServerInfo();
        if (ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName)) {
            serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(ip, Integer.parseInt(port), userName);
        } else {
            serverInfo.setHostAddress(ip);
            serverInfo.setHostMonPort(Integer.parseInt(port));
            serverInfo.setHostJSPort(Integer.parseInt(port + 1));
            serverInfo.setUserName(userNameText.getText());
            serverInfo.setUserPassword(password);
            CMHostNodePersistManager.getInstance().addServer(ip, Integer.parseInt(port), userName, serverInfo);
            MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
            taskExcutor.addTask(monitoringTask);
        }
        LoginDatabaseTask loginMDbTask = new LoginDatabaseTask(serverInfo);
        loginMDbTask.setCMUser("admin");
        loginMDbTask.setDbName(masterDbNameText.getText());
        loginMDbTask.setDbUser("dba");
        loginMDbTask.setDbPassword(masteDbaPasswordText.getText());
        taskExcutor.addTask(loginMDbTask);
        LoginDatabaseTask loginDistdbTask = new LoginDatabaseTask(replNode.getServer().getServerInfo());
        loginDistdbTask.setCMUser("admin");
        loginDistdbTask.setDbName(distDbNameText.getText());
        loginDistdbTask.setDbUser("dba");
        loginDistdbTask.setDbPassword(distDbaPasswordText.getText());
        taskExcutor.addTask(loginDistdbTask);
        new ExecTaskWithProgress(taskExcutor).exec(true, true);
    }
}
Also used : MonitorDashboardPreference(com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference) ITask(com.cubrid.common.core.task.ITask) LoginDatabaseTask(com.cubrid.cubridmanager.core.cubrid.database.task.LoginDatabaseTask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) Display(org.eclipse.swt.widgets.Display)

Example 7 with MonitorDashboardPreference

use of com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference in project cubrid-manager by CUBRID.

the class ReplServerDialog method execute.

/**
	 * excute the task.
	 * 
	 * @param buttonId int
	 */
private void execute(final int buttonId) {
    final String ip = ipText.getText();
    final String port = portText.getText();
    final String userName = userNameText.getText();
    final String password = passwordText.getText();
    final String mdbName = mdbNameText.getText();
    final String replServerPort = replServerPortText.getText();
    TaskExecutor taskExcutor = new TaskExecutor() {

        public void disConnect() {
            ServerManager.getInstance().setConnected(ip, Integer.parseInt(port), userName, false);
        }

        public boolean exec(final IProgressMonitor monitor) {
            Display display = Display.getDefault();
            if (monitor.isCanceled()) {
                return false;
            }
            boolean isConnected = false;
            MonitorDashboardPreference monPref = new MonitorDashboardPreference();
            for (ITask task : taskList) {
                if (task instanceof MonitoringTask) {
                    MonitoringTask monitoringTask = (MonitoringTask) task;
                    monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
                    isConnected = true;
                } else if (task instanceof GetReplServerStatusTask) {
                    GetReplServerStatusTask getReplServerStatusTask = (GetReplServerStatusTask) task;
                    getReplServerStatusTask.execute();
                    isActive = getReplServerStatusTask.isActive();
                } else if (task instanceof StartReplServerTask) {
                    if (isActive) {
                        openErrorBox(getShell(), Messages.msgReplServerStarted, monitor);
                    } else {
                        StartReplServerTask startReplServerTask = (StartReplServerTask) task;
                        startReplServerTask.execute();
                        if (task.isSuccess()) {
                            openInformationgBox(getShell(), com.cubrid.cubridmanager.ui.common.Messages.titleSuccess, Messages.msgReplServerStartedSuccess, monitor);
                        }
                    }
                } else if (task instanceof StopReplServerTask) {
                    if (isActive) {
                        StopReplServerTask stopReplServerTask = (StopReplServerTask) task;
                        stopReplServerTask.execute();
                        if (task.isSuccess()) {
                            openInformationgBox(getShell(), com.cubrid.cubridmanager.ui.common.Messages.titleSuccess, Messages.msgReplServerStopedSuccess, monitor);
                        }
                    } else {
                        openErrorBox(getShell(), Messages.msgReplServerStoped, monitor);
                    }
                }
                if (monitor.isCanceled()) {
                    if (isConnected) {
                        disConnect();
                    }
                    return false;
                }
                final String msg = task.getErrorMsg();
                if (openErrorBox(getShell(), msg, monitor)) {
                    if (isConnected) {
                        ServerManager.getInstance().setConnected(ip, Integer.parseInt(port), userName, false);
                    }
                    return false;
                }
            }
            if (isConnected) {
                disConnect();
            }
            if (!monitor.isCanceled()) {
                display.syncExec(new Runnable() {

                    public void run() {
                        setReturnCode(buttonId);
                        close();
                    }
                });
            }
            return true;
        }
    };
    boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
    ServerInfo serverInfo = new ServerInfo();
    if (isConnected) {
        serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(ip, Integer.parseInt(port), userName);
    } else {
        serverInfo.setHostAddress(ip);
        serverInfo.setHostMonPort(Integer.parseInt(port));
        serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
        serverInfo.setUserName(userName);
        serverInfo.setUserPassword(password);
        CMHostNodePersistManager.getInstance().addServer(ip, Integer.parseInt(port), userName, serverInfo);
        MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
        taskExcutor.addTask(monitoringTask);
    }
    GetReplServerStatusTask getReplServerStatusTask = new GetReplServerStatusTask(serverInfo);
    getReplServerStatusTask.setDbName(mdbName);
    taskExcutor.addTask(getReplServerStatusTask);
    if (isStartReplServer) {
        StartReplServerTask task = new StartReplServerTask(serverInfo);
        task.setDbName(mdbName);
        task.setServerPort(replServerPort);
        taskExcutor.addTask(task);
    } else {
        StopReplServerTask task = new StopReplServerTask(serverInfo);
        task.setDbName(mdbName);
        taskExcutor.addTask(task);
    }
    new ExecTaskWithProgress(taskExcutor).exec();
}
Also used : MonitorDashboardPreference(com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference) ITask(com.cubrid.common.core.task.ITask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) GetReplServerStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplServerStatusTask) StopReplServerTask(com.cubrid.cubridmanager.core.replication.task.StopReplServerTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) StartReplServerTask(com.cubrid.cubridmanager.core.replication.task.StartReplServerTask) Display(org.eclipse.swt.widgets.Display)

Example 8 with MonitorDashboardPreference

use of com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference in project cubrid-manager by CUBRID.

the class CreateReplicationJobExecutor method startAgent.

/**
	 * start agent service
	 * 
	 * @param agentName String
	 * @param monitor IProgressMonitor
	 * @param taskList List<ITask>
	 * @return status
	 */
private IStatus startAgent(String agentName, final IProgressMonitor monitor, List<ITask> taskList) {
    monitor.subTask(Messages.bind(Messages.startAgentJobName, agentName));
    MonitoringTask monitoringTask = null;
    boolean isExecuteStopAgentTask = true;
    MonitorDashboardPreference monPref = new MonitorDashboardPreference();
    for (ITask task : taskList) {
        if (task instanceof MonitoringTask) {
            monitoringTask = (MonitoringTask) task;
            ServerInfo serverInfo = monitoringTask.getServerInfo();
            CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
            monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
        } else if (task instanceof StopReplicationAgentTask) {
            if (isExecuteStopAgentTask) {
                task.execute();
            } else {
                continue;
            }
        } else {
            task.execute();
        }
        if (monitor.isCanceled()) {
            disConnect(monitoringTask);
            return Status.CANCEL_STATUS;
        }
        final String msg = task.getErrorMsg();
        if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
            disConnect(monitoringTask);
            return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
        }
        if (task instanceof GetReplAgentStatusTask) {
            GetReplAgentStatusTask getReplAgentStatusTask = (GetReplAgentStatusTask) task;
            isExecuteStopAgentTask = getReplAgentStatusTask.isActive();
        }
    }
    disConnect(monitoringTask);
    return Status.OK_STATUS;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) MonitorDashboardPreference(com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference) ITask(com.cubrid.common.core.task.ITask) GetReplAgentStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) StopReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask)

Example 9 with MonitorDashboardPreference

use of com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference in project cubrid-manager by CUBRID.

the class CreateReplicationJobExecutor method createMaster.

/**
	 * create master database
	 * 
	 * @param dbName String
	 * @param monitor IProgressMonitor
	 * @param taskList List<ITask>
	 * @return status
	 */
private IStatus createMaster(final String dbName, final IProgressMonitor monitor, List<ITask> taskList) {
    monitor.subTask(Messages.bind(Messages.createMasterJobName, dbName));
    Display display = Display.getDefault();
    MonitoringTask monitoringTask = null;
    boolean isExecuteSetParaTask = true;
    boolean isExecuteStopDbTask = true;
    boolean isExecuteStartDbTask = false;
    Map<String, Map<String, String>> confParaMaps = null;
    MonitorDashboardPreference monPref = new MonitorDashboardPreference();
    for (ITask task : taskList) {
        if (task instanceof MonitoringTask) {
            monitoringTask = (MonitoringTask) task;
            ServerInfo serverInfo = monitoringTask.getServerInfo();
            CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
            monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
        } else if (task instanceof StopReplServerTask) {
            if (isExecuteStopReplServerTask) {
                task.execute();
            } else {
                continue;
            }
        } else if (task instanceof SetCubridConfParameterTask) {
            if (isExecuteSetParaTask) {
                SetCubridConfParameterTask setCubridConfParameterTask = (SetCubridConfParameterTask) task;
                setCubridConfParameterTask.setConfParameters(confParaMaps);
                task.execute();
            } else {
                continue;
            }
        } else if (task instanceof CommonUpdateTask && task.getTaskname().equals(CommonTaskName.STOP_DB_TASK_NAME)) {
            if (isExecuteStopDbTask) {
                task.execute();
            } else {
                continue;
            }
        } else if (task instanceof CommonUpdateTask && task.getTaskname().equals(CommonTaskName.START_DB_TASK_NAME)) {
            if (isExecuteStartDbTask) {
                task.execute();
            } else {
                continue;
            }
        } else if (task instanceof GetTransferProgressTask) {
            GetTransferProgressTask getTransferProgressTask = (GetTransferProgressTask) task;
            monitor.subTask(Messages.transFileJobName);
            if (pid != null) {
                while (!isCanceled()) {
                    getTransferProgressTask.setPid(pid);
                    getTransferProgressTask.execute();
                    TransFileProgressInfo progressInfo = getTransferProgressTask.getProgressInfo();
                    if (getTransferProgressTask.isSuccess() && progressInfo != null) {
                        String transferStatus = progressInfo.getTransferStatus();
                        String transferNote = progressInfo.getTransferNote();
                        if (transferStatus != null && transferStatus.equals("success")) {
                            pid = null;
                            cancelTransFileTask = null;
                            break;
                        } else if (transferStatus != null && transferStatus.equals("failure")) {
                            pid = null;
                            cancelTransFileTask = null;
                            getTransferProgressTask.setErrorMsg(transferNote);
                            break;
                        } else {
                            try {
                                Thread.sleep(1000);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    } else {
                        break;
                    }
                }
            }
        } else if (task instanceof CancelTransFileTask) {
            cancelTransFileTask = (CancelTransFileTask) task;
        } else {
            task.execute();
        }
        if (monitor.isCanceled()) {
            disConnect(monitoringTask);
            return Status.CANCEL_STATUS;
        }
        final String msg = task.getErrorMsg();
        if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
            disConnect(monitoringTask);
            return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
        }
        if (task instanceof GetReplServerStatusTask) {
            GetReplServerStatusTask getReplServerStatusTask = (GetReplServerStatusTask) task;
            boolean isActive = getReplServerStatusTask.isActive();
            if (isActive) {
                display.syncExec(new Runnable() {

                    public void run() {
                        isExecuteStopReplServerTask = CommonUITool.openConfirmBox(Messages.bind(Messages.msgConfirmStopReplServer, dbName));
                    }
                });
                if (!isExecuteStopReplServerTask) {
                    disConnect(monitoringTask);
                    return Status.CANCEL_STATUS;
                }
            }
        } else if (task instanceof GetCubridConfParameterTask) {
            GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
            confParaMaps = getCubridConfParameterTask.getConfParameters();
            String mdbName = (String) getCubridConfParameterTask.getData("dbName");
            Map<String, String> dbMap = confParaMaps.get("[@" + mdbName + "]");
            if (dbMap == null) {
                Map<String, String> commonMap = confParaMaps.get(ConfConstants.COMMON_SECTION_NAME);
                if (commonMap != null && commonMap.get(ConfConstants.REPLICATION) != null && commonMap.get(ConfConstants.REPLICATION).equalsIgnoreCase("yes")) {
                    isExecuteSetParaTask = false;
                } else if (commonMap != null) {
                    isExecuteSetParaTask = true;
                    commonMap.put(ConfConstants.REPLICATION, "yes");
                }
            } else {
                String replStr = dbMap.get(ConfConstants.REPLICATION);
                if (replStr == null || replStr.equalsIgnoreCase("no")) {
                    isExecuteSetParaTask = true;
                    dbMap.put(ConfConstants.REPLICATION, "yes");
                } else {
                    isExecuteSetParaTask = false;
                }
            }
        } else if (task instanceof GetDatabaseListTask) {
            GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
            String mdbName = (String) getDatabaseListTask.getData("dbName");
            List<DatabaseInfo> dbInfoList = getDatabaseListTask.loadDatabaseInfo();
            for (int i = 0; i < dbInfoList.size(); i++) {
                DatabaseInfo dbInfo = dbInfoList.get(i);
                if (mdbName.equalsIgnoreCase(dbInfo.getDbName())) {
                    if (dbInfo.getRunningType() == DbRunningType.CS) {
                        isExecuteStopDbTask = isExecuteSetParaTask;
                    }
                    isExecuteStartDbTask = dbInfo.getRunningType() == DbRunningType.STANDALONE || isExecuteStopDbTask;
                    break;
                }
            }
        } else if (task instanceof TransFileTask) {
            TransFileTask transFileTask = (TransFileTask) task;
            pid = transFileTask.getTransFilePid();
        }
    }
    disConnect(monitoringTask);
    return Status.OK_STATUS;
}
Also used : TransFileProgressInfo(com.cubrid.cubridmanager.core.replication.model.TransFileProgressInfo) MonitorDashboardPreference(com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) StopReplServerTask(com.cubrid.cubridmanager.core.replication.task.StopReplServerTask) CancelTransFileTask(com.cubrid.cubridmanager.core.replication.task.CancelTransFileTask) CancelTransFileTask(com.cubrid.cubridmanager.core.replication.task.CancelTransFileTask) TransFileTask(com.cubrid.cubridmanager.core.replication.task.TransFileTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask) GetTransferProgressTask(com.cubrid.cubridmanager.core.replication.task.GetTransferProgressTask) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) SetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.SetCubridConfParameterTask) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) GetReplServerStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplServerStatusTask) Map(java.util.Map) Display(org.eclipse.swt.widgets.Display)

Example 10 with MonitorDashboardPreference

use of com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference in project cubrid-manager by CUBRID.

the class CreateReplicationJobExecutor method createSlave.

/**
	 * create slave database
	 * 
	 * @param dbName String
	 * @param monitor IProgressMonitor
	 * @param taskList List<ITask>
	 * @return status
	 */
private IStatus createSlave(String dbName, final IProgressMonitor monitor, List<ITask> taskList) {
    monitor.subTask(Messages.bind(Messages.createSlaveJobName, dbName));
    Display display = Display.getDefault();
    MonitoringTask monitoringTask = null;
    boolean isExecuteStopDbTask = true;
    MonitorDashboardPreference monPref = new MonitorDashboardPreference();
    for (ITask task : taskList) {
        if (task instanceof MonitoringTask) {
            monitoringTask = (MonitoringTask) task;
            ServerInfo serverInfo = monitoringTask.getServerInfo();
            CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
            monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
        } else if (task instanceof CommonUpdateTask && task.getTaskname().equals(CommonTaskName.STOP_DB_TASK_NAME)) {
            if (isDeleteDb && isExecuteStopDbTask) {
                task.execute();
            } else {
                continue;
            }
        } else if (task instanceof CommonUpdateTask && task.getTaskname().equals(CommonTaskName.DELETE_DATABASE_TASK_NAME)) {
            if (isDeleteDb) {
                task.execute();
            } else {
                continue;
            }
        } else {
            task.execute();
        }
        if (monitor.isCanceled()) {
            disConnect(monitoringTask);
            return Status.CANCEL_STATUS;
        }
        final String msg = task.getErrorMsg();
        if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
            disConnect(monitoringTask);
            return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
        }
        if (task instanceof GetDatabaseListTask) {
            GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
            final String sdbName = (String) getDatabaseListTask.getData("dbName");
            List<DatabaseInfo> dbInfoList = getDatabaseListTask.loadDatabaseInfo();
            boolean isDbExist = false;
            for (int i = 0; i < dbInfoList.size(); i++) {
                DatabaseInfo dbInfo = dbInfoList.get(i);
                if (dbName.equalsIgnoreCase(dbInfo.getDbName())) {
                    isDbExist = true;
                    display.syncExec(new Runnable() {

                        public void run() {
                            isDeleteDb = CommonUITool.openConfirmBox(Messages.bind(Messages.msgConfirmDeleteDb, sdbName));
                        }
                    });
                    if (dbInfo.getRunningType() == DbRunningType.CS) {
                        isExecuteStopDbTask = true;
                    }
                    break;
                }
            }
            if (isDbExist && !isDeleteDb) {
                disConnect(monitoringTask);
                return Status.CANCEL_STATUS;
            }
        }
    }
    disConnect(monitoringTask);
    isDeleteDb = false;
    return Status.OK_STATUS;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) MonitorDashboardPreference(com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask) Display(org.eclipse.swt.widgets.Display)

Aggregations

MonitorDashboardPreference (com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference)11 ITask (com.cubrid.common.core.task.ITask)10 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)10 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)8 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)6 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)6 IStatus (org.eclipse.core.runtime.IStatus)5 Status (org.eclipse.core.runtime.Status)5 Display (org.eclipse.swt.widgets.Display)5 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)3 CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)3 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)3 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)3 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 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