Search in sources :

Example 96 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.

the class SqlLogAnalyzeResultDialog method connect.

/**
	 * each page of log connect
	 *
	 * @param qindex String
	 * @param queryString StringBuffer
	 * @return queryString
	 */
public StringBuilder connect(String qindex, StringBuilder queryString) {
    final GetCasLogTopResultTask task = new GetCasLogTopResultTask(node.getServer().getServerInfo());
    task.setFileName(resultFile);
    task.setQindex(qindex);
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.loadLogTaskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess() && task.getAnalyzeCasLogTopResultList() != null) {
        AnalyzeCasLogTopResultInfo resultInfo = (AnalyzeCasLogTopResultInfo) task.getAnalyzeCasLogTopResultList();
        if (resultInfo != null && resultInfo.getLogString() != null) {
            for (String logString : resultInfo.getLogString()) {
                queryString.append(logString + "\n");
            }
        }
    }
    return queryString;
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) AnalyzeCasLogTopResultInfo(com.cubrid.cubridmanager.core.logs.model.AnalyzeCasLogTopResultInfo) GetCasLogTopResultTask(com.cubrid.cubridmanager.core.logs.task.GetCasLogTopResultTask)

Example 97 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.

the class SqlLogAnalyzeResultDialog method createGroupQuery.

/**
	 * This method initializes groupQuery
	 */
private void createGroupQuery() {
    GridData gridData22 = new GridData(GridData.FILL_HORIZONTAL);
    gridData22.heightHint = 26;
    gridData22.widthHint = 122;
    GridData gridData21 = new GridData(GridData.FILL_BOTH);
    gridData21.horizontalSpan = 3;
    gridData21.widthHint = 432;
    gridData21.heightHint = 150;
    GridData gridData11 = new GridData(GridData.FILL_BOTH);
    gridData11.horizontalSpan = 3;
    gridData11.widthHint = 432;
    gridData11.heightHint = 250;
    GridLayout gridLayout2 = new GridLayout();
    gridLayout2.numColumns = 3;
    gridLayout2.horizontalSpacing = 45;
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.verticalSpan = 2;
    Group groupQuery = new Group(composite, SWT.NONE);
    groupQuery.setText("");
    groupQuery.setLayout(gridLayout2);
    groupQuery.setLayoutData(gridData);
    Label label1 = new Label(groupQuery, SWT.NONE);
    label1.setText(Messages.labelLogContents);
    textQuery = new Text(groupQuery, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
    textQuery.setEditable(true);
    textQuery.setLayoutData(gridData11);
    Label label2 = new Label(groupQuery, SWT.NONE);
    label2.setText(Messages.labelExecuteResult);
    textQueryResult = new Text(groupQuery, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
    textQueryResult.setLayoutData(gridData21);
    buttonRunOriginalQuery = new Button(groupQuery, SWT.NONE);
    buttonRunOriginalQuery.setEnabled(false);
    buttonRunOriginalQuery.setText(Messages.buttonExecuteOriginalQuery);
    Label dummy5 = new Label(groupQuery, SWT.NONE);
    dummy5.setLayoutData(gridData22);
    buttonRunOriginalQuery.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String queryString = textQuery.getText();
            LogInfo logInfo = null;
            String targetBroker = null;
            if (node.getId().indexOf("Sql log/") < 0) {
                targetBroker = node.getParent().getLabel();
            } else {
                targetBroker = node.getParent().getParent().getLabel();
            }
            logInfo = (LogInfo) node.getAdapter(LogInfo.class);
            List<String> allDatabaseList = node.getServer().getServerInfo().getAllDatabaseList();
            BrokerInfos brokerInfos = node.getServer().getServerInfo().getBrokerInfos();
            CasRunnerConfigDialog casRunnerConfigDialog = new CasRunnerConfigDialog(getShell());
            casRunnerConfigDialog.setLogstring(queryString);
            casRunnerConfigDialog.setBrokerInfos(brokerInfos);
            casRunnerConfigDialog.setAllDatabaseList(allDatabaseList);
            casRunnerConfigDialog.setLogInfo(logInfo);
            casRunnerConfigDialog.setTargetBroker(targetBroker);
            casRunnerConfigDialog.create();
            if (casRunnerConfigDialog.open() == Dialog.OK) {
                final GetExecuteCasRunnerContentResultTask task = new GetExecuteCasRunnerContentResultTask(node.getServer().getServerInfo());
                task.setBrokerName(CasRunnerConfigDialog.getBrokerName());
                task.setUserName(CasRunnerConfigDialog.getUserName());
                task.setPasswd(CasRunnerConfigDialog.getPassword());
                task.setNumThread(CasRunnerConfigDialog.getNumThread());
                task.setRepeatCount(casRunnerConfigDialog.getNumRepeatCount());
                String isShowqueryresult = "";
                String isShowqueryplan = "";
                if (casRunnerConfigDialog.isShowqueryresult()) {
                    isShowqueryresult = "yes";
                    isShowqueryplan = casRunnerConfigDialog.isShowqueryresult() ? "yes" : "no";
                } else {
                    isShowqueryresult = "no";
                    isShowqueryplan = "no";
                }
                task.setShowQueryResult(isShowqueryresult);
                task.setShowQueryResult(isShowqueryplan);
                task.setDbName(CasRunnerConfigDialog.getDbname());
                task.setExecuteLogFile("no");
                String[] queryStringArr = queryString.split("\\r\\n");
                task.setLogstring(queryStringArr);
                TaskExecutor taskExecutor = new CommonTaskExec(Messages.loadSqlLogExecResultTaskName);
                taskExecutor.addTask(task);
                new ExecTaskWithProgress(taskExecutor).exec();
                if (taskExecutor.isSuccess()) {
                    GetExecuteCasRunnerResultInfo getExecuteCasRunnerResultInfo = (GetExecuteCasRunnerResultInfo) task.getContent();
                    StringBuffer result = new StringBuffer("");
                    for (int i = 0, n = getExecuteCasRunnerResultInfo.getResult().size(); i < n; i++) {
                        result.append(getExecuteCasRunnerResultInfo.getResult().get(i) + "\n");
                    }
                    String logPath = null;
                    String totalResultNum = null;
                    logPath = getExecuteCasRunnerResultInfo.getQueryResultFile();
                    totalResultNum = getExecuteCasRunnerResultInfo.getQueryResultFileNum();
                    if (queryString.length() > 0) {
                        textQueryResult.setText(result.toString());
                        if (casRunnerConfigDialog.isShowqueryresult()) {
                            CasRunnerResultViewDialog casRunnerResultViewDialog = new CasRunnerResultViewDialog(getShell());
                            casRunnerResultViewDialog.create();
                            casRunnerResultViewDialog.connectInit(logPath, CasRunnerConfigDialog.getDbname(), node);
                            casRunnerResultViewDialog.setTotalResultNum(Integer.parseInt(totalResultNum));
                            casRunnerResultViewDialog.getShell().setSize(665, 555);
                            casRunnerResultViewDialog.open();
                        }
                    }
                }
            }
        }
    });
    buttonSaveToFile = new Button(groupQuery, SWT.NONE);
    buttonSaveToFile.setEnabled(false);
    buttonSaveToFile.setText(Messages.buttonSaveLogString);
    buttonSaveToFile.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String savedFilename = saveAsFile();
            if (isBlank(savedFilename)) {
                return;
            }
            if (analyzeCasLogResultList == null || analyzeCasLogResultList.getLogFileInfoList() == null) {
                return;
            }
            AnalyzeCasLogResultInfo analyzeCasLogResultInfo = (AnalyzeCasLogResultInfo) (analyzeCasLogResultList.getLogFileInfoList().get(currentResultIndex));
            if (savedFilename.length() > 0) {
                analyzeCasLogResultInfo.setSavedFileName(savedFilename);
            }
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) GetExecuteCasRunnerResultInfo(com.cubrid.cubridmanager.core.logs.model.GetExecuteCasRunnerResultInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GetExecuteCasRunnerContentResultTask(com.cubrid.cubridmanager.core.logs.task.GetExecuteCasRunnerContentResultTask) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) AnalyzeCasLogResultInfo(com.cubrid.cubridmanager.core.logs.model.AnalyzeCasLogResultInfo) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) AnalyzeCasLogResultList(com.cubrid.cubridmanager.core.logs.model.AnalyzeCasLogResultList) List(java.util.List)

Example 98 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.

the class HARoleChangeAction method run.

/**
	 * HA role change.
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    TaskExecutor taskExcutor = new CommonTaskExec(Messages.changeRoleTaskName);
    HostMonitorPart hostPart = (HostMonitorPart) obj[0];
    //deactive data gather first.
    hostPart.stopMonitorGather();
    //role change task execution.
    HARoleChangeTask task = new HARoleChangeTask(((HostNode) hostPart.getModel()).getServerInfo());
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).exec();
    hostPart.startMonitorGather();
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) HARoleChangeTask(com.cubrid.cubridmanager.core.mondashboard.task.HARoleChangeTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) HostMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)

Example 99 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.

the class ConfigParaHelp method performImportCmConf.

/**
	 * Perform the import task for cm.conf
	 * 
	 * @param serverInfo the CubridServer
	 * @param confParamList the List<String>
	 */
public static void performImportCmConf(ServerInfo serverInfo, List<String> confParamList) {
    CommonTaskExec taskExcutor = new CommonTaskExec(Messages.setCMParameterTaskName);
    SetCMConfParameterTask task = new SetCMConfParameterTask(serverInfo);
    task.setConfContents(confParamList);
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (taskExcutor.isSuccess()) {
        CommonUITool.openInformationBox(Messages.titleSuccess, Messages.msgChangeCMParaSuccess);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) SetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.SetCMConfParameterTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)

Example 100 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.

the class ConfigParaHelp method performImportHAConf.

/**
	 * Perform the import task for ha.conf
	 * 
	 * @param serverInfo the CubridServer
	 * @param confParamList the List<String>
	 */
public static void performImportHAConf(ServerInfo serverInfo, List<String> confParamList) {
    CommonTaskExec taskExcutor = new CommonTaskExec(Messages.setHAConfTaskName);
    SetHAConfParameterTask task = new SetHAConfParameterTask(serverInfo);
    task.setConfContents(confParamList);
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (taskExcutor.isSuccess()) {
        CommonUITool.openInformationBox(Messages.titleSuccess, Messages.msgSetHAConfSuccess);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) SetHAConfParameterTask(com.cubrid.cubridmanager.core.common.task.SetHAConfParameterTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)

Aggregations

CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)106 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)106 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)81 TreeViewer (org.eclipse.jface.viewers.TreeViewer)31 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)24 ArrayList (java.util.ArrayList)24 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)23 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)18 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)14 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)13 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)13 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)12 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)11 IEditorPart (org.eclipse.ui.IEditorPart)11 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)9 HashMap (java.util.HashMap)9 AbstractUITask (com.cubrid.common.core.task.AbstractUITask)8 Map (java.util.Map)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)8