Search in sources :

Example 11 with ITaskExecutorInterceptor

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

the class DBSpaceLabelProvider method loadVolumeData.

public void loadVolumeData() {
    //if no database on this server ,don't get volumn data
    if (serverInfo.getAllDatabaseList().size() == 0 || databaseInfoList == null) {
        return;
    }
    final List<CommonQueryTask<DbSpaceInfoList>> getVolumnTaskList = new ArrayList<CommonQueryTask<DbSpaceInfoList>>();
    if (serverInfo.getAllDatabaseList() != null) {
        for (String dbName : serverInfo.getAllDatabaseList()) {
            for (DatabaseInfo databaseInfo : databaseInfoList) {
                // only load start database volumn data
                if (dbName.equals(databaseInfo.getDbName()) && databaseInfo.getRunningType() == DbRunningType.CS) {
                    CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
                    task.setDbName(dbName);
                    getVolumnTaskList.add(task);
                    break;
                }
            }
        }
    }
    //if no start database don't get volumn data
    if (getVolumnTaskList.size() == 0) {
        return;
    }
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            List<DBVolumeSpaceInfo> dbVolumeSpaceInfoList = new ArrayList<DBVolumeSpaceInfo>();
            for (CommonQueryTask<DbSpaceInfoList> task : getVolumnTaskList) {
                DbSpaceInfoList dbSpaceInfoList = task.getResultModel();
                freespaceOnStorage = ((long) dbSpaceInfoList.getFreespace()) * 1024l * 1024l;
                DBVolumeSpaceInfo dbSpaceInfo = new DBVolumeSpaceInfo(dbSpaceInfoList.getDbname());
                dbSpaceInfo.setPageSize(dbSpaceInfoList.getPagesize());
                dbVolumeSpaceInfoList.add(dbSpaceInfo);
                if (dbSpaceInfoList != null) {
                    for (DbSpaceInfo spaceInfo : dbSpaceInfoList.getSpaceinfo()) {
                        dbSpaceInfo.addVolumeSpaceInfo(spaceInfo);
                    }
                }
            }
            setVolumeData(dbVolumeSpaceInfoList);
            finishedCount++;
            updateToolBar();
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    for (CommonQueryTask<DbSpaceInfoList> task : getVolumnTaskList) {
        taskJobExec.addTask(task);
    }
    String serverName = serverInfo.getServerName();
    String jobName = Messages.taskGetVolumeInfo + serverName;
    JobFamily jobFamily = new JobFamily();
    jobFamily.setServerName(serverName);
    taskJobExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ArrayList(java.util.ArrayList) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) 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) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) List(java.util.List) ArrayList(java.util.ArrayList) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)

Example 12 with ITaskExecutorInterceptor

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

the class DBSpaceLabelProvider method loadDbData.

public void loadDbData() {
    final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
    final GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
            List<String> orignAutoStartDBList = getCubridConfParameterTask.getAutoStartDb(false);
            setDatabaseData(databaseInfoList, orignAutoStartDBList);
            finishedCount++;
            updateToolBar();
            //after get database data ,load volumn data
            loadVolumeData();
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    taskJobExec.addTask(getDatabaseListTask);
    taskJobExec.addTask(getCubridConfParameterTask);
    String serverName = serverInfo.getServerName();
    String jobName = Messages.taskGetDBInfo + serverName;
    JobFamily jobFamily = new JobFamily();
    jobFamily.setServerName(serverName);
    taskJobExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
Also used : GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) List(java.util.List) ArrayList(java.util.ArrayList) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily)

Example 13 with ITaskExecutorInterceptor

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

the class ServiceDashboardEditor method loadServerBrokerInfo.

/**
	 * Load Server Broker Info
	 */
private void loadServerBrokerInfo(final ServerInfo serverInfo, final String key) {
    final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new BrokerInfos());
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            Object input = serviceTreeViewer.getInput();
            ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
            BrokerInfos brokerInfos = task.getResultModel();
            setBrokerData(sDashInfo, brokerInfos);
            serviceTreeViewer.refresh(input);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    taskJobExec.addTask(task);
    executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerBrokerInfo);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Aggregations

ITask (com.cubrid.common.core.task.ITask)13 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)13 IStatus (org.eclipse.core.runtime.IStatus)13 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)12 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)12 ArrayList (java.util.ArrayList)8 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)7 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)6 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)6 List (java.util.List)6 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)4 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)3 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)2 EnvInfo (com.cubrid.cubridmanager.core.common.model.EnvInfo)2 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)2 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)2 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1