Search in sources :

Example 16 with DbSpaceInfoList

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

the class CubridDbSpaceFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        HashMap<String, FolderInformationContainer> foldersInformation;
        HashMap<String, ICubridNode> foldersHashMap = new HashMap<String, ICubridNode>();
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        CommonQueryTask<? extends DbSpaceInfoList> task;
        DbSpaceInfoList dbSpaceInfoList;
        if (DbSpaceInfoList.useOld(database.getDatabaseInfo().getServerInfo().getEnvInfo())) {
            foldersInformation = foldersInformationOldFormat;
            task = new CommonQueryTask<DbSpaceInfoListOld>(parent.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld());
        } else {
            foldersInformation = foldersInformationNewFormat;
            task = new CommonQueryTask<DbSpaceInfoListNew>(parent.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
        }
        for (Map.Entry<String, FolderInformationContainer> entry : foldersInformation.entrySet()) {
            String key = entry.getKey();
            FolderInformationContainer value = entry.getValue();
            ICubridNode folder = addFolder(parent, key, value.volumeFolderName, value.volumeFolder, value.type);
            foldersHashMap.put(value.volumeType, folder);
        }
        ICubridNode logFolder = addFolder(parent, LOG_VOLUME_FOLDER_ID, LOG_VOLUME_FOLDER_NAME, CubridNodeType.LOG_VOLUEM_FOLDER, null);
        foldersHashMap.put(VolumeType.ACTIVE_LOG.getText(), addFolder(logFolder, ACTIVE_LOG_FOLDER_ID, ACTIVE_LOG_FOLDER_NAME, CubridNodeType.ACTIVE_LOG_FOLDER, CubridNodeType.ACTIVE_LOG));
        foldersHashMap.put(VolumeType.ARCHIVE_LOG.getText(), addFolder(logFolder, ARCHIVE_LOG_FOLDER_ID, ARCHIVE_LOG_FOLDER_NAME, CubridNodeType.ARCHIVE_LOG_FOLDER, CubridNodeType.ARCHIVE_LOG));
        task.setDbName(database.getLabel());
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            for (ICubridNode folder : foldersHashMap.values()) {
                folder.removeAllChild();
            }
            Display display = Display.getDefault();
            display.syncExec(new Runnable() {

                public void run() {
                    CommonUITool.openErrorBox(null, errorMsg);
                }
            });
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        for (ICubridNode folder : foldersHashMap.values()) {
            folder.removeAllChild();
        }
        dbSpaceInfoList = task.getResultModel();
        List<DbSpaceInfo> spaceInfoList = dbSpaceInfoList == null ? null : dbSpaceInfoList.getSpaceinfo();
        for (int i = 0; spaceInfoList != null && i < spaceInfoList.size(); i++) {
            DbSpaceInfo spaceInfo = spaceInfoList.get(i);
            ICubridNode volumeNode = new DefaultSchemaNode("", spaceInfo.getShortVolumeName(), "");
            volumeNode.setContainer(false);
            volumeNode.setModelObj(spaceInfo);
            volumeNode.setEditorId(VolumeInformationEditor.ID);
            String key = null;
            String type = spaceInfo.getType();
            if (spaceInfo.getPurpose() != null) {
                key = type + "_" + spaceInfo.getPurpose();
            } else {
                key = type;
            }
            if (type == null) {
                continue;
            }
            ICubridNode folder = foldersHashMap.get(key);
            if (folder != null) {
                String id = folder.getId() + NODE_SEPARATOR + spaceInfo.getShortVolumeName();
                volumeNode.setId(id);
                volumeNode.setType(folder.getType());
                volumeNode.setIconPath("icons/navigator/volume_item.png");
                folder.addChild(volumeNode);
            }
        }
        if (spaceInfoList != null && !spaceInfoList.isEmpty()) {
            for (ICubridNode folder : foldersHashMap.values()) {
                Collections.sort(folder.getChildren());
            }
        }
        databaseInfo.setDbSpaceInfoList(dbSpaceInfoList);
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) HashMap(java.util.HashMap) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DbSpaceInfoListOld(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListOld) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) DbSpaceInfoListNew(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoListNew) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) HashMap(java.util.HashMap) Map(java.util.Map) Display(org.eclipse.swt.widgets.Display)

Example 17 with DbSpaceInfoList

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

the class DatabaseInfoTest method testGetDbSpaceInfoList.

/**
	 * Test method for
	 * {@link com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo#getDbSpaceInfoList()}
	 * .
	 */
public void testGetDbSpaceInfoList() {
    bean.setDbSpaceInfoList(new DbSpaceInfoList());
    assertEquals(bean.getDbSpaceInfoList() != null, true);
}
Also used : DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)

Example 18 with DbSpaceInfoList

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

the class CopyDatabaseAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode schemaNode = (ISchemaNode) obj[0];
    final CubridDatabase database = schemaNode.getDatabase();
    if (database == null) {
        CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
        return;
    }
    GetDbSizeTask dbSizeTask = new GetDbSizeTask(database.getServer().getServerInfo());
    dbSizeTask.setDbName(database.getName());
    final CommonQueryTask<DbSpaceInfoList> dbSpaceInfotask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
    dbSpaceInfotask.setDbName(database.getName());
    ISelectionProvider provider = getSelectionProvider();
    final TreeViewer viewer = (TreeViewer) provider;
    final CopyDatabaseDialog dlg = new CopyDatabaseDialog(getShell(), viewer);
    dlg.execTask(-1, new SocketTask[] { dbSizeTask, dbSpaceInfotask }, true, getShell());
    if (dbSpaceInfotask.getErrorMsg() != null || dbSizeTask.isCancel() || dbSizeTask.getErrorMsg() != null || dbSpaceInfotask.isCancel()) {
        return;
    }
    dlg.setDbSize(dbSizeTask.getDbSize());
    dlg.setDbSpaceInfo(dbSpaceInfotask.getResultModel());
    dlg.setDatabase(database);
    dlg.open();
}
Also used : CopyDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.CopyDatabaseDialog) GetDbSizeTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDbSizeTask) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 19 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 20 with DbSpaceInfoList

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

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