Search in sources :

Example 6 with DbSpaceInfo

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

the class EditSingleHostStatisticItemDialog method refreshDbVolData.

//refresh data of itemsVolName and dbVolName
private void refreshDbVolData(String dbName) {
    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();
            }
            dbVolNameValue = itemsVolName[0];
        } else {
            itemsVolName = ITEMS_EMPTY;
            dbVolNameValue = VALUE_DEFAULT;
        }
    } else {
        itemsVolName = ITEMS_EMPTY;
        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 7 with DbSpaceInfo

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

the class ServiceDashboardEditor method setVolumeData.

/**
	 * Set Server Volume Data
	 */
private void setVolumeData(ServiceDashboardInfo sDashInfo, List<CommonQueryTask<DbSpaceInfoList>> getVolumnTaskList) {
    long totalPageData = 0, freePageData = 0, totalPageIndex = 0, freePageIndex = 0, totalPageTemp = 0, freePageTemp = 0, totalPageGeneric = 0, freePageGeneric = 0, freespaceOnStorage = 0;
    for (CommonQueryTask<DbSpaceInfoList> task : getVolumnTaskList) {
        DbSpaceInfoList dbSpaceInfoList = task.getResultModel();
        if (dbSpaceInfoList != null && task.getErrorMsg() == null) {
            freespaceOnStorage = ((long) dbSpaceInfoList.getFreespace()) * 1024l * 1024l;
            for (DbSpaceInfo spaceInfo : dbSpaceInfoList.getSpaceinfo()) {
                String type = spaceInfo.getType();
                if (type.equals(VolumeType.DATA.getText())) {
                    totalPageData += spaceInfo.getTotalpage();
                    freePageData += spaceInfo.getFreepage();
                } else if (type.equals(VolumeType.INDEX.getText())) {
                    totalPageIndex += spaceInfo.getTotalpage();
                    freePageIndex += spaceInfo.getFreepage();
                } else if (type.equals(VolumeType.TEMP.getText())) {
                    totalPageTemp += spaceInfo.getTotalpage();
                    freePageTemp += spaceInfo.getFreepage();
                } else if (type.equals(VolumeType.GENERIC.getText())) {
                    totalPageGeneric += spaceInfo.getTotalpage();
                    freePageGeneric += spaceInfo.getFreepage();
                }
            }
        }
    }
    if (totalPageData > 0)
        sDashInfo.setFreeDataPerc(new Double(freePageData * 100.0d / totalPageData).intValue());
    else
        sDashInfo.setFreeDataPerc(-1);
    if (totalPageIndex > 0)
        sDashInfo.setFreeIndexPerc(new Double(freePageIndex * 100.0d / totalPageIndex).intValue());
    else
        sDashInfo.setFreeIndexPerc(-1);
    if (totalPageTemp > 0)
        sDashInfo.setFreeTempPerc(new Double(freePageTemp * 100.0d / totalPageTemp).intValue());
    else
        sDashInfo.setFreeTempPerc(-1);
    if (totalPageGeneric > 0)
        sDashInfo.setFreeGenericPerc(new Double(freePageGeneric * 100.0d / totalPageGeneric).intValue());
    else
        sDashInfo.setFreeGenericPerc(-1);
    sDashInfo.setFreespaceOnStorage(freespaceOnStorage);
}
Also used : DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo)

Example 8 with DbSpaceInfo

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

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

the class DatabaseInfoTest method testAddSpaceInfo.

/**
	 * Test method for
	 * {@link com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo#addSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo)}
	 * .
	 */
public void testAddSpaceInfo() {
    bean.addSpaceInfo(new DbSpaceInfo());
    bean.addSpaceInfo(new DbSpaceInfo());
    bean.removeSpaceInfo(new DbSpaceInfo());
}
Also used : DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo)

Example 10 with DbSpaceInfo

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

the class DBSpaceLabelProvider method getVolumeString.

private String getVolumeString(DBVolumeSpaceInfo volumeSpaceInfo, String type) {
    // FIXME extract
    long totalPage = 0;
    long freePage = 0;
    Date lastCreateDate = null;
    StringBuilder sb = new StringBuilder();
    List<DbSpaceInfo> dbSpaceInfoList = volumeSpaceInfo.getVolumeSpaceInfo(type);
    if (dbSpaceInfoList != null) {
        for (DbSpaceInfo dbSpaceInfo : dbSpaceInfoList) {
            totalPage += dbSpaceInfo.getTotalpage();
            freePage += dbSpaceInfo.getFreepage();
            Date createDate = null;
            try {
                createDate = DateUtil.getDateFormat("yyyyMMdd").parse(dbSpaceInfo.getDate());
            } catch (ParseException e) {
                e.printStackTrace();
            }
            if (createDate != null && (lastCreateDate == null || lastCreateDate.getTime() < createDate.getTime())) {
                lastCreateDate = createDate;
            }
        }
    }
    if (totalPage > 0) {
        sb.append(getSpaceDesc((totalPage - freePage) * volumeSpaceInfo.getPageSize())).append(" / ");
        sb.append(getSpaceDesc(totalPage * volumeSpaceInfo.getPageSize())).append(" / ");
        sb.append(new Double(freePage * 100.0d / totalPage).intValue()).append("%");
    } else {
        sb.append("-");
    }
    return sb.toString();
}
Also used : DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) ParseException(java.text.ParseException) Date(java.util.Date)

Aggregations

DbSpaceInfo (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo)17 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)7 HashMap (java.util.HashMap)7 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 Map (java.util.Map)4 ArrayList (java.util.ArrayList)3 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 Point (org.eclipse.swt.graphics.Point)2 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)1 ITask (com.cubrid.common.core.task.ITask)1 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)1 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)1 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)1 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)1 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)1