Search in sources :

Example 21 with DbSpaceInfoList

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList in project cubrid-manager by CUBRID.

the class EditStatisticHostDialog method refreshDbVolData.

private void refreshDbVolData(String dbName, boolean isInitial) {
    boolean isEmptyData = false;
    boolean isNeedInitVolNameValue = isNewHost || !isInitial || dbVolNameValue == null;
    if (StringUtil.isEmpty(dbName)) {
        isEmptyData = true;
    } else {
        DbSpaceInfoList dbSpaceInfo = new DbSpaceInfoList();
        CommonQueryTask<DbSpaceInfoList> dbSpaceInfoTask = new CommonQueryTask<DbSpaceInfoList>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfo);
        dbSpaceInfoTask.setDbName(dbName);
        dbSpaceInfoTask.execute();
        if (dbSpaceInfoTask.isSuccess()) {
            dbSpaceInfo = dbSpaceInfoTask.getResultModel();
            if (dbSpaceInfo.getSpaceinfo() != null && dbSpaceInfo.getSpaceinfo().size() > 0) {
                List<DbSpaceInfo> spaceInfoList = dbSpaceInfo.getSpaceinfo();
                itemsVolName = new String[spaceInfoList.size()];
                for (int i = 0; i < spaceInfoList.size(); i++) {
                    itemsVolName[i] = spaceInfoList.get(i).getSpacename();
                }
                if (isNeedInitVolNameValue) {
                    dbVolNameValue = itemsVolName[0];
                }
            } else {
                isEmptyData = true;
            }
        } else {
            isEmptyData = true;
        }
    }
    if (isEmptyData) {
        itemsVolName = ITEMS_EMPTY;
        if (isNeedInitVolNameValue) {
            dbVolNameValue = VALUE_DEFAULT;
        }
    }
}
Also used : 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 22 with DbSpaceInfoList

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList 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 23 with DbSpaceInfoList

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList 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

DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)23 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)18 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)7 DbSpaceInfo (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo)7 ITask (com.cubrid.common.core.task.ITask)6 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)6 IStatus (org.eclipse.core.runtime.IStatus)6 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)5 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)5 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)5 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)4 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)4 DbSpaceInfoListNew (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListNew)4 DbSpaceInfoListOld (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 TreeViewer (org.eclipse.jface.viewers.TreeViewer)4 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)3 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)3 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)3