Search in sources :

Example 6 with GetCMConfParameterTask

use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask in project cubrid-manager by CUBRID.

the class ConnectHostExecutor method initTasks.

private void initTasks() {
    MonitoringTask monitoringTask = serverInfo.getMonitoringTask();
    addTask(monitoringTask);
    GetEnvInfoTask getEnvInfoTask = new GetEnvInfoTask(serverInfo);
    addTask(getEnvInfoTask);
    GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
    addTask(getDatabaseListTask);
    GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo);
    addTask(getCMConfParameterTask);
    CommonQueryTask<BrokerInfos> getBrokerTask = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new BrokerInfos());
    addTask(getBrokerTask);
    GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo);
    addTask(getUserInfoTask);
    UpdateCMUserTask updateTask = new UpdateCMUserTask(serverInfo);
    updateTask.setCmUserName(serverInfo.getUserName());
    addTask(updateTask);
    GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
    addTask(getCubridConfParameterTask);
    GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(serverInfo);
    addTask(getBrokerConfParameterTask);
}
Also used : GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) GetCMUserListTask(com.cubrid.cubridmanager.core.common.task.GetCMUserListTask) GetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)

Example 7 with GetCMConfParameterTask

use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask 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 8 with GetCMConfParameterTask

use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask in project cubrid-manager by CUBRID.

the class AddStatusMonitorTemplateAction method run.

/**
	 * Override the run method in order to open an instance of status monitor
	 * dialog
	 *
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    ICubridNode selection = (ICubridNode) obj[0];
    ServerInfo site = selection.getServer().getServerInfo();
    boolean execDiagChecked = false;
    final GetCMConfParameterTask task = new GetCMConfParameterTask(site);
    TaskExecutor taskExec = new CommonTaskExec(null);
    taskExec.addTask(task);
    new ExecTaskWithProgress(taskExec).exec();
    if (!taskExec.isSuccess()) {
        return;
    }
    Map<String, String> confParas = task.getConfParameters();
    if (confParas == null) {
        execDiagChecked = false;
    } else {
        if (confParas.get(ConfConstants.EXECUTE_DIAG) == null) {
            execDiagChecked = false;
        } else {
            execDiagChecked = confParas.get(ConfConstants.EXECUTE_DIAG).equals(OnOffType.ON.getText()) ? true : false;
        }
    }
    DiagStatusMonitorTemplateDialog dialog = new DiagStatusMonitorTemplateDialog(getShell());
    dialog.setOperation(AddEditType.ADD);
    dialog.setSelection(selection);
    dialog.setExecDiagChecked(execDiagChecked);
    if (dialog.open() == Dialog.OK) {
        StatusTemplateInfo statusTemplateInfo = dialog.getStatusTemplateInfo();
        AddStatusTemplateTask addTask = new AddStatusTemplateTask(site);
        addTask.setStatusTemplateInfo(statusTemplateInfo);
        addTask.buildMsg();
        String taskName = Messages.bind(Messages.addTemplateTaskName, statusTemplateInfo.getName());
        TaskExecutor taskExecutor = new CommonTaskExec(taskName);
        taskExecutor.addTask(addTask);
        new ExecTaskWithProgress(taskExecutor).exec();
        if (taskExecutor.isSuccess()) {
            TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
            CommonUITool.refreshNavigatorTree(treeViewer, selection);
        }
    }
}
Also used : DiagStatusMonitorTemplateDialog(com.cubrid.cubridmanager.ui.monitoring.dialog.DiagStatusMonitorTemplateDialog) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) AddStatusTemplateTask(com.cubrid.cubridmanager.core.monitoring.task.AddStatusTemplateTask)

Example 9 with GetCMConfParameterTask

use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask in project cubrid-manager by CUBRID.

the class EditStatusMonitorTemplateAction method run.

/**
	 * Override the run method in order to open an instance of status monitor
	 * dialog
	 * 
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    ICubridNode selection = (ICubridNode) obj[0];
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    boolean execDiagChecked = false;
    final GetCMConfParameterTask task = new GetCMConfParameterTask(serverInfo);
    TaskExecutor taskExec = new CommonTaskExec(null);
    taskExec.addTask(task);
    new ExecTaskWithProgress(taskExec).exec();
    if (!taskExec.isSuccess()) {
        return;
    }
    Map<String, String> confParas = task.getConfParameters();
    if (confParas == null) {
        execDiagChecked = false;
    } else {
        if (confParas.get(ConfConstants.EXECUTE_DIAG) == null) {
            execDiagChecked = false;
        } else {
            execDiagChecked = confParas.get(ConfConstants.EXECUTE_DIAG).equals(OnOffType.ON.getText()) ? true : false;
        }
    }
    DiagStatusMonitorTemplateDialog dialog = new DiagStatusMonitorTemplateDialog(getShell());
    dialog.setOperation(AddEditType.EDIT);
    dialog.setSelection(selection);
    dialog.setExecDiagChecked(execDiagChecked);
    if (dialog.open() == Dialog.OK) {
        StatusTemplateInfo statusTemplateInfo = dialog.getStatusTemplateInfo();
        UpdateStatusTemplateTask updateTask = new UpdateStatusTemplateTask(serverInfo);
        updateTask.setStatusTemplateInfo(statusTemplateInfo);
        updateTask.buildMsg();
        String taskName = Messages.bind(Messages.editTemplateTaskName, statusTemplateInfo.getName());
        TaskExecutor taskExecutor = new CommonTaskExec(taskName);
        taskExecutor.addTask(updateTask);
        new ExecTaskWithProgress(taskExecutor).exec();
        if (taskExecutor.isSuccess()) {
            TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
            CommonUITool.refreshNavigatorTree(treeViewer, selection.getParent());
        }
    }
}
Also used : DiagStatusMonitorTemplateDialog(com.cubrid.cubridmanager.ui.monitoring.dialog.DiagStatusMonitorTemplateDialog) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) UpdateStatusTemplateTask(com.cubrid.cubridmanager.core.monitoring.task.UpdateStatusTemplateTask)

Example 10 with GetCMConfParameterTask

use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask in project cubrid-manager by CUBRID.

the class SetHostInfoDialog method connect.

/**
	 * connect the host
	 * 
	 * @param buttonId int
	 */
private void connect(final int buttonId) {
    final String ip = ipText.getText();
    final String port = portText.getText();
    final String userName = userNameText.getText();
    final String password = passwordText.getText();
    boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
    if (isConnected && hostInfo != null) {
        ServerInfo serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(ip, Integer.parseInt(port), userName);
        if (!serverInfo.getLoginedUserInfo().isAdmin()) {
            CommonUITool.openErrorBox(Messages.bind(Messages.errInvalidUser, ip));
            return;
        }
        hostInfo.setIp(ip);
        hostInfo.setPort(port);
        hostInfo.setUserName(userName);
        hostInfo.setPassword(password);
        hostInfo.setName(ip + ":" + port);
        List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
        hostInfo.setDatabaseInfoList(databaseInfoList);
        hostInfo.setDbPath(serverInfo.getEnvInfo().getDatabaseDir());
        hostInfo.setOsInfoType(serverInfo.getServerOsInfo());
        setReturnCode(buttonId);
        close();
        return;
    }
    if (!isConnected) {
        final ServerInfo serverInfo = new ServerInfo();
        serverInfo.setHostAddress(ip);
        serverInfo.setHostMonPort(Integer.parseInt(port));
        serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
        serverInfo.setUserName(userName);
        serverInfo.setUserPassword(password);
        TaskExecutor taskExcutor = new ConnectHostTaskExecutor(serverInfo, buttonId);
        MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
        taskExcutor.addTask(monitoringTask);
        GetEnvInfoTask getEnvInfoTask = new GetEnvInfoTask(serverInfo);
        taskExcutor.addTask(getEnvInfoTask);
        GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo);
        taskExcutor.addTask(getCMConfParameterTask);
        GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
        taskExcutor.addTask(getDatabaseListTask);
        new ExecTaskWithProgress(taskExcutor).exec(true, true);
    }
}
Also used : GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)

Aggregations

GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)14 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)10 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)10 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)9 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)9 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)9 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)8 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)7 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)6 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)6 Map (java.util.Map)6 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)5 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)5 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)5 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)5 ArrayList (java.util.ArrayList)5 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)4 List (java.util.List)4 ITask (com.cubrid.common.core.task.ITask)3