Search in sources :

Example 1 with StatusTemplateInfo

use of com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo in project cubrid-manager by CUBRID.

the class AddAndDelStatusTemplateTaskTest method testExec2.

public void testExec2() {
    StatusTemplateInfo info = new StatusTemplateInfo();
    info.setDb_name(testDbName);
    info.setDesc("testStatus");
    info.setName("newStatus");
    TargetConfigInfo targetConfigInfo = new TargetConfigInfo();
    targetConfigInfo.setCas_st_long_tran(new String[] { "aaa", "dd", "dd" });
    info.addTarget_config(targetConfigInfo);
    info.setSampling_term("1");
    AddStatusTemplateTask task = new AddStatusTemplateTask(serverInfo);
    task.setStatusTemplateInfo(info);
    task.buildMsg();
    task.execute();
    assertNull(task.getErrorMsg());
    StatusTemplateInfos bean = new StatusTemplateInfos();
    final CommonQueryTask<StatusTemplateInfos> showTask = new CommonQueryTask<StatusTemplateInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), bean);
    showTask.execute();
    bean.getStatusTemplateInfoList();
    assertEquals(bean.getTaskName(), "getstatustemplate");
    DelStatusTemplateTask delTsk = new DelStatusTemplateTask(serverInfo);
    delTsk.setTemplateName("newStatus");
    delTsk.execute();
    assertNull(delTsk.getErrorMsg());
}
Also used : StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) StatusTemplateInfos(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfos) TargetConfigInfo(com.cubrid.cubridmanager.core.monitoring.model.TargetConfigInfo)

Example 2 with StatusTemplateInfo

use of com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo 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 3 with StatusTemplateInfo

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

use of com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo in project cubrid-manager by CUBRID.

the class CubridMonitorFolderLoader method loadStatusTempInfoTask.

/**
	 * load sub node by the task of getStatusTemplateInfos
	 *
	 * @param parent the parent node
	 * @param monitor the instance of IProgressMonitor
	 * @param serverInfo the instance of serverInfo
	 * @return boolean false if error occur, true if succeed
	 */
private boolean loadStatusTempInfoTask(ICubridNode parent, final IProgressMonitor monitor, ServerInfo serverInfo) {
    StatusTemplateInfos statusTemplateInfos = new StatusTemplateInfos();
    final CommonQueryTask<StatusTemplateInfos> task = new CommonQueryTask<StatusTemplateInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), statusTemplateInfos);
    monitorCancel(monitor, new ITask[] { task });
    task.execute();
    final String errorMsg = task.getErrorMsg();
    if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
        //parent.removeAllChild();
        removeAllStatusTemp(parent);
        openErrorBox(errorMsg);
        setLoaded(true);
        return false;
    }
    if (monitor.isCanceled()) {
        setLoaded(true);
        return false;
    }
    //parent.removeAllChild();
    removeAllStatusTemp(parent);
    statusTemplateInfos = task.getResultModel();
    if (statusTemplateInfos != null) {
        List<StatusTemplateInfo> list = statusTemplateInfos.getStatusTemplateInfoList().getStatusTemplateInfoList();
        if (list != null) {
            for (StatusTemplateInfo statusTemplateInfo : list) {
                String id = parent.getId() + NODE_SEPARATOR + statusTemplateInfo.getName();
                ICubridNode logInfoNode = new DefaultCubridNode(id, statusTemplateInfo.getName(), "icons/navigator/status_item.png");
                logInfoNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
                logInfoNode.setModelObj(statusTemplateInfo);
                logInfoNode.setViewId(StatusMonitorViewPart.ID);
                logInfoNode.setContainer(false);
                parent.addChild(logInfoNode);
            }
        }
    }
    return true;
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) StatusTemplateInfos(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfos) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 5 with StatusTemplateInfo

use of com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo in project cubrid-manager by CUBRID.

the class CubridStatusMonitorFolderLoader method loadStatusTempInfoTask.

/**
	 * load sub node by the task of getStatusTemplateInfos
	 * 
	 * @param parent the parent node
	 * @param monitor the instance of IProgressMonitor
	 * @param serverInfo the instance of serverInfo
	 * @return boolean false if error occur, true if succeed
	 */
private boolean loadStatusTempInfoTask(ICubridNode parent, final IProgressMonitor monitor, ServerInfo serverInfo) {
    StatusTemplateInfos statusTemplateInfos = new StatusTemplateInfos();
    final CommonQueryTask<StatusTemplateInfos> task = new CommonQueryTask<StatusTemplateInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), statusTemplateInfos);
    monitorCancel(monitor, new ITask[] { task });
    task.execute();
    final String errorMsg = task.getErrorMsg();
    if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
        parent.removeAllChild();
        openErrorBox(errorMsg);
        setLoaded(true);
        return false;
    }
    if (monitor.isCanceled()) {
        setLoaded(true);
        return false;
    }
    parent.removeAllChild();
    statusTemplateInfos = task.getResultModel();
    if (statusTemplateInfos != null) {
        List<StatusTemplateInfo> list = statusTemplateInfos.getStatusTemplateInfoList().getStatusTemplateInfoList();
        if (list != null) {
            for (StatusTemplateInfo statusTemplateInfo : list) {
                String id = parent.getId() + NODE_SEPARATOR + statusTemplateInfo.getName();
                ICubridNode logInfoNode = new DefaultCubridNode(id, statusTemplateInfo.getName(), "icons/navigator/status_item.png");
                logInfoNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
                logInfoNode.setModelObj(statusTemplateInfo);
                logInfoNode.setViewId(StatusMonitorViewPart.ID);
                logInfoNode.setContainer(false);
                parent.addChild(logInfoNode);
            }
        }
    }
    return true;
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) StatusTemplateInfos(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfos) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Aggregations

StatusTemplateInfo (com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo)10 TargetConfigInfo (com.cubrid.cubridmanager.core.monitoring.model.TargetConfigInfo)6 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)5 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 StatusTemplateInfos (com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfos)4 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)2 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 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)2 DiagStatusMonitorTemplateDialog (com.cubrid.cubridmanager.ui.monitoring.dialog.DiagStatusMonitorTemplateDialog)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 AddStatusTemplateTask (com.cubrid.cubridmanager.core.monitoring.task.AddStatusTemplateTask)1 UpdateStatusTemplateTask (com.cubrid.cubridmanager.core.monitoring.task.UpdateStatusTemplateTask)1 EnumTargetConfig (com.cubrid.cubridmanager.ui.monitoring.editor.EnumTargetConfig)1 TargetConfig (com.cubrid.cubridmanager.ui.monitoring.editor.TargetConfig)1 TargetConfigMap (com.cubrid.cubridmanager.ui.monitoring.editor.TargetConfigMap)1 EnumMap (java.util.EnumMap)1 Map (java.util.Map)1