Search in sources :

Example 56 with CommonQueryTask

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

the class DatabaseDashboardEditor method loadVolumnsInfo.

/**
	 * load volumns information
	 */
public void loadVolumnsInfo() {
    // if database is stop, do not get data
    if (database.getRunningType() != DbRunningType.CS) {
        return;
    }
    final DbSpaceInfoList dbSpaceInfoList = new DbSpaceInfoList();
    final CommonQueryTask<DbSpaceInfoList> loadVolumnTask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfoList);
    loadVolumnTask.setDbName(database.getName());
    new Thread(new Runnable() {

        public void run() {
            loadVolumnTask.execute();
            if (!loadVolumnTask.isSuccess()) {
                loadVolumnTask.finish();
                return;
            }
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    process();
                }
            });
        }

        private void process() {
            volumnInfoListData.clear();
            DbSpaceInfoList dbSpaceInfoList = loadVolumnTask.getResultModel();
            if (dbSpaceInfoList != null) {
                long archiveSize = 0;
                for (DbSpaceInfo dbSpaceInfo : dbSpaceInfoList.getSpaceinfo()) {
                    if (StringUtil.isEmpty(dbSpaceInfo.getType())) {
                        continue;
                    }
                    if (dbSpaceInfo.getType().equals(VolumeType.ARCHIVE_LOG.getText())) {
                        archiveSize += dbSpaceInfo.getTotalpage() * dbSpaceInfoList.getPagesize();
                        continue;
                    }
                    boolean isLogVolumn = VolumeType.ACTIVE_LOG.getText().equals(dbSpaceInfo.getType()) || VolumeType.ARCHIVE_LOG.getText().equals(dbSpaceInfo.getType());
                    Map<String, String> volumnMap = new HashMap<String, String>();
                    volumnMap.put("0", dbSpaceInfo.getSpacename());
                    volumnMap.put("1", dbSpaceInfo.getType());
                    String freeSize = getSpaceDesc(Long.valueOf(dbSpaceInfo.getFreepage()) * Long.valueOf(dbSpaceInfoList.getPagesize()));
                    String totalSize = getSpaceDesc(Long.valueOf(dbSpaceInfo.getTotalpage()) * Long.valueOf(dbSpaceInfoList.getPagesize()));
                    if (isLogVolumn) {
                        volumnMap.put("2", "-");
                    } else {
                        volumnMap.put("2", freeSize);
                    }
                    volumnMap.put("3", totalSize);
                    volumnMap.put("4", dbSpaceInfo.getDate());
                    volumnMap.put("5", dbSpaceInfo.getLocation());
                    volumnInfoListData.add(volumnMap);
                }
                if (archiveSize > 0) {
                    Map<String, String> volumnMap = new HashMap<String, String>();
                    volumnMap.put("0", "Total Archives");
                    volumnMap.put("1", "Archive log");
                    volumnMap.put("2", "-");
                    volumnMap.put("3", getSpaceDesc(archiveSize));
                    volumnMap.put("4", "-");
                    volumnMap.put("5", "-");
                    volumnInfoListData.add(volumnMap);
                }
            }
            setVolumnInfoData();
            loadVolumnTask.finish();
        }
    }).start();
}
Also used : HashMap(java.util.HashMap) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 57 with CommonQueryTask

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

the class AddAndDelStatusTemplateTaskTest method testExec.

public void testExec() {
    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 58 with CommonQueryTask

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

the class DatabaseLogListDialog method initial.

/**
	 * 
	 * Initial the value of dialog field
	 * 
	 */
private void initial() {
    DbLogInfos dbLogInfos = new DbLogInfos();
    final CommonQueryTask<DbLogInfos> task = new CommonQueryTask<DbLogInfos>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), dbLogInfos);
    task.setDbName(dbName);
    CommonTaskJobExec jobExecutor = new CommonTaskJobExec(this) {

        /**
			 * Close the dialog
			 */
        protected void closeDialog() {
        //empty
        }

        /**
			 * Set the dialog visible or invisible.
			 * 
			 * @param flag whether it is visible
			 */
        protected void setDialogVisible(boolean flag) {
        //empty
        }
    };
    jobExecutor.addTask(task);
    JobFamily jobFamily = new JobFamily();
    String serverName = serverInfo.getServerName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    jobExecutor.schedule(Messages.jobGetLogList, jobFamily, false, Job.SHORT);
}
Also used : DbLogInfos(com.cubrid.cubridmanager.core.logs.model.DbLogInfos) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily)

Example 59 with CommonQueryTask

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

the class AutoAddVolumeLogDialog method loadData.

/**
	 * load the data
	 * 
	 * @return boolean
	 */
public boolean loadData() {
    CommonQueryTask<AutoAddVolumeLogList> task = new CommonQueryTask<AutoAddVolumeLogList>(server.getServerInfo(), CommonSendMsg.getCommonSimpleSendMsg(), new AutoAddVolumeLogList());
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.getAuotAddedVolLogTaskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (!taskExecutor.isSuccess()) {
        return false;
    }
    volumeLogList = task.getResultModel();
    return true;
}
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) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) AutoAddVolumeLogList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.AutoAddVolumeLogList)

Example 60 with CommonQueryTask

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

the class DatabaseStatusEditor method loadData.

/**
	 *
	 * Load data
	 *
	 * @return <code>true</code> whether it is successful;<code>false</code>
	 *         otherwise
	 */
public boolean loadData() {
    TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {

        @SuppressWarnings("unchecked")
        @Override
        public IStatus exec(IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return Status.CANCEL_STATUS;
            }
            for (ITask t : taskList) {
                t.execute();
                final String msg = t.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);
                } else {
                    final DbSpaceInfoList dbSpaceInfoList = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            database.getDatabaseInfo().setDbSpaceInfoList(dbSpaceInfoList);
                            if (scrolledComp == null || scrolledComp.isDisposed()) {
                                return;
                            }
                            initial();
                            paintComp();
                            scrolledComp.setContent(parentComp);
                            scrolledComp.setExpandHorizontal(true);
                            scrolledComp.setExpandVertical(true);
                        }
                    });
                }
                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }
            }
            return Status.OK_STATUS;
        }
    };
    CommonQueryTask<? extends DbSpaceInfoList> task = DbSpaceInfoList.useOld(database.getServer().getServerInfo().getEnvInfo()) ? new CommonQueryTask<DbSpaceInfoListOld>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld()) : new CommonQueryTask<DbSpaceInfoListNew>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
    task.setDbName(database.getName());
    taskJobExecutor.addTask(task);
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    String jobName = Messages.viewDbStatusJobName + " - " + dbName + "@" + serverName;
    taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITask(com.cubrid.common.core.task.ITask) DbSpaceInfoListOld(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DbSpaceInfoListNew(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListNew) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Aggregations

CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)60 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)19 ITask (com.cubrid.common.core.task.ITask)14 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)12 IStatus (org.eclipse.core.runtime.IStatus)12 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)11 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)11 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)11 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)8 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)7 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)7 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)7 ArrayList (java.util.ArrayList)7 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)6 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)6 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)6 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)6 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)6 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)5 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)5