Search in sources :

Example 1 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class DatabaseDashboardEditor method showLogView.

/**
	 * show sql log view at broker table
	 *
	 * @param type sql type
	 */
public void showLogView(String type) {
    try {
        int i = brokerInfoTable.getSelectionIndex();
        if (i < 0) {
            return;
        }
        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window == null) {
            return;
        }
        String brokerName = brokerInfoTable.getItem(i).getText(0);
        String serverId = brokerInfoTable.getItem(i).getText(1);
        //get all log infor
        BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
        final CommonQueryTask<BrokerLogInfos> task = new CommonQueryTask<BrokerLogInfos>(database.getDatabaseInfo().getServerInfo(), CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
        task.setBroker(brokerName);
        task.execute();
        brokerLogInfos = task.getResultModel();
        String logFileName = brokerName + "_" + serverId + "." + type + ".log";
        sqlLogViewPartName = logFileName + "@" + database.getServer().getLabel() + ":" + database.getServer().getMonPort();
        List<LogInfo> logInfoList = brokerLogInfos == null ? null : brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
        task.finish();
        //get the current log
        LogInfo logInfo = null;
        if (logInfoList != null && !logInfoList.isEmpty()) {
            for (LogInfo logInfoInlist : logInfoList) {
                if (logFileName.equals(logInfoInlist.getName())) {
                    logInfo = logInfoInlist;
                    break;
                }
            }
        }
        if (logInfo == null) {
            String msg = Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.errLogFileNoExist, logFileName);
            LOGGER.error(msg);
            //CommonUITool.openErrorBox(msg);
            return;
        }
        final String filePath = logInfo.getPath();
        TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {

            public IStatus exec(IProgressMonitor monitor) {
                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }
                for (ITask task : taskList) {
                    task.execute();
                    final String msg = task.getErrorMsg();
                    if (monitor.isCanceled()) {
                        return Status.CANCEL_STATUS;
                    }
                    if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
                        return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
                    }
                    if (task instanceof CheckFileTask) {
                        CheckFileTask checkFileTask = (CheckFileTask) task;
                        final String[] files = checkFileTask.getExistFiles();
                        if (files == null || files.length == 0) {
                            return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.errLogFileNoExist, filePath));
                        }
                    } else if (task instanceof GetLogListTask) {
                        GetLogListTask getLogListTask = (GetLogListTask) task;
                        final LogContentInfo logContentInfo = (LogContentInfo) getLogListTask.getLogContent();
                        Display.getDefault().syncExec(new Runnable() {

                            public void run() {
                                try {
                                    ICubridNode logInfoNode = new DefaultCubridNode("", "", "");
                                    IEditorPart editor = window.getActivePage().openEditor(logInfoNode, LogEditorPart.ID);
                                    ((LogEditorPart) editor).setTableInfo(logContentInfo, true);
                                    ((LogEditorPart) editor).setShowLogPartName(sqlLogViewPartName);
                                } catch (PartInitException e) {
                                    LOGGER.error(e.getMessage(), e);
                                }
                            }
                        });
                    }
                    if (monitor.isCanceled()) {
                        return Status.CANCEL_STATUS;
                    }
                    task.finish();
                }
                return Status.OK_STATUS;
            }
        };
        CheckFileTask checkFileTask = new CheckFileTask(cubridNode.getServer().getServerInfo());
        checkFileTask.setFile(new String[] { filePath });
        taskJobExecutor.addTask(checkFileTask);
        GetLogListTask getLogListTask = new GetLogListTask(cubridNode.getServer().getServerInfo());
        getLogListTask.setPath(filePath);
        getLogListTask.setStart("1");
        getLogListTask.setEnd("100");
        taskJobExecutor.addTask(getLogListTask);
        String jobName = com.cubrid.cubridmanager.ui.logs.Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
        taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
    } catch (Exception e) {
        LOGGER.error(Messages.exportDashboardOpenSQLLogErrMsg, e);
    //			CommonUITool.openErrorBox(Messages.exportDashboardOpenSQLLogErrMsg);
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITask(com.cubrid.common.core.task.ITask) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) BrokerLogInfos(com.cubrid.cubridmanager.core.logs.model.BrokerLogInfos) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask) PartInitException(org.eclipse.ui.PartInitException) CheckFileTask(com.cubrid.cubridmanager.core.cubrid.database.task.CheckFileTask) LogEditorPart(com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)

Example 2 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class AutoAddVolumeLogAction method run.

/**
	 * 
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    DefaultCubridNode node = null;
    CubridServer server = null;
    if (obj.length > 0 && obj[0] instanceof DefaultCubridNode) {
        node = (DefaultCubridNode) obj[0];
        server = node.getServer();
    }
    AutoAddVolumeLogDialog dlg = new AutoAddVolumeLogDialog(getShell());
    dlg.setServer(server);
    if (dlg.loadData()) {
        dlg.open();
    }
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) AutoAddVolumeLogDialog(com.cubrid.cubridmanager.ui.cubrid.dbspace.dialog.AutoAddVolumeLogDialog) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 3 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class RestartBrokerAction method run.

public void run() {
    final Object[] obj = this.getSelectedObj();
    DefaultCubridNode selection = (DefaultCubridNode) obj[0];
    if (selection == null || selection.getServer() == null) {
        return;
    }
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    if (serverInfo == null) {
        return;
    }
    //stop first
    StopBrokerTask stopTask = new StopBrokerTask(serverInfo);
    stopTask.setBrokerName(selection.getLabel());
    //then start again
    StartBrokerTask startTask = new StartBrokerTask(serverInfo);
    startTask.setBrokerName(selection.getLabel());
    final String taskName = Messages.bind(Messages.restartBrokerTaskName, selection.getLabel());
    TaskExecutor taskExecutor = new CommonTaskExec(taskName);
    taskExecutor.addTask(stopTask);
    taskExecutor.addTask(startTask);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    CommonUITool.refreshNavigatorTree(treeViewer, selection.getParent());
    ActionManager.getInstance().fireSelectionChanged(getSelection());
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) StartBrokerTask(com.cubrid.cubridmanager.core.broker.task.StartBrokerTask) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) StopBrokerTask(com.cubrid.cubridmanager.core.broker.task.StopBrokerTask)

Example 4 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class StartBrokerAction method run.

/**
	 * Override the run method in order to complete starting broker environment
	 * 
	 */
public void run() {
    final Object[] obj = this.getSelectedObj();
    DefaultCubridNode selection = (DefaultCubridNode) obj[0];
    ServerInfo site = selection.getServer().getServerInfo();
    StartBrokerTask task = new StartBrokerTask(site);
    task.setBrokerName(selection.getLabel());
    final String taskName = Messages.bind(Messages.startBrokerTaskName, selection.getLabel());
    TaskExecutor taskExecutor = new CommonTaskExec(taskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    CommonUITool.refreshNavigatorTree(treeViewer, selection.getParent());
    ActionManager.getInstance().fireSelectionChanged(getSelection());
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) StartBrokerTask(com.cubrid.cubridmanager.core.broker.task.StartBrokerTask) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)

Example 5 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class AnalyzeSqlLogAction method run.

/**
	 * Open dialog
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    DefaultCubridNode node = null;
    LogInfo logInfo = null;
    node = (DefaultCubridNode) obj[0];
    logInfo = (LogInfo) node.getAdapter(LogInfo.class);
    SqlLogFileListDialog cASLogTopConfigDialog = new SqlLogFileListDialog(getShell());
    List<String> targetStringList = new ArrayList<String>();
    if (logInfo == null) {
        for (int j = 0, m = node.getChildren().size(); j < m; j++) {
            targetStringList.add(((LogInfo) node.getChildren().get(j).getAdapter(LogInfo.class)).getPath());
        }
    } else {
        targetStringList.add(logInfo.getPath());
    }
    cASLogTopConfigDialog.create();
    cASLogTopConfigDialog.setInfo(targetStringList);
    int returnCode = cASLogTopConfigDialog.open();
    if (returnCode == SqlLogFileListDialog.OK) {
        String optionT;
        final GetAnalyzeCasLogTask task = new GetAnalyzeCasLogTask(node.getServer().getServerInfo());
        if (cASLogTopConfigDialog.isOption()) {
            optionT = "yes";
        } else {
            optionT = "no";
        }
        List<String> selectedStringList = cASLogTopConfigDialog.getSelectedStringList();
        String[] path = new String[selectedStringList.size()];
        selectedStringList.toArray(path);
        task.setLogFiles(path);
        task.setOptionT(optionT);
        TaskExecutor taskExcutor = new CommonTaskExec(Messages.loadLogTaskName);
        taskExcutor.addTask(task);
        new ExecTaskWithProgress(taskExcutor).exec();
        if (!taskExcutor.isSuccess()) {
            return;
        }
        AnalyzeCasLogResultList analyzeCasLogResultList = (AnalyzeCasLogResultList) task.getAnalyzeCasLogResultList();
        SqlLogAnalyzeResultDialog activityCASLogPathDialog = new SqlLogAnalyzeResultDialog(getShell());
        activityCASLogPathDialog.setOption(cASLogTopConfigDialog.isOption());
        activityCASLogPathDialog.setNode(node);
        activityCASLogPathDialog.setResultFile(analyzeCasLogResultList.getResultfile());
        activityCASLogPathDialog.setAnalyzeCasLogResultList(analyzeCasLogResultList);
        activityCASLogPathDialog.create();
        activityCASLogPathDialog.setLabel(selectedStringList);
        activityCASLogPathDialog.insertArrayToTable(analyzeCasLogResultList);
        activityCASLogPathDialog.open();
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) AnalyzeCasLogResultList(com.cubrid.cubridmanager.core.logs.model.AnalyzeCasLogResultList) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) GetAnalyzeCasLogTask(com.cubrid.cubridmanager.core.logs.task.GetAnalyzeCasLogTask) ArrayList(java.util.ArrayList) SqlLogAnalyzeResultDialog(com.cubrid.cubridmanager.ui.logs.dialog.SqlLogAnalyzeResultDialog) SqlLogFileListDialog(com.cubrid.cubridmanager.ui.logs.dialog.SqlLogFileListDialog) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)

Aggregations

DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)41 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)25 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)17 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)15 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)12 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)12 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)12 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)11 TreeViewer (org.eclipse.jface.viewers.TreeViewer)10 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)7 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)6 IEditorPart (org.eclipse.ui.IEditorPart)6 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)6 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)5 DelAllLogTask (com.cubrid.cubridmanager.core.logs.task.DelAllLogTask)5 ArrayList (java.util.ArrayList)5 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)5 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)4 BrokerLogInfos (com.cubrid.cubridmanager.core.logs.model.BrokerLogInfos)4 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)2