Search in sources :

Example 11 with DbSpaceInfo

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

the class CopyDatabaseDialog method getCopyDbTask.

/**
	 * Check the directory of server
	 * 
	 * 
	 * @return the SocketTask
	 */
private SocketTask getCopyDbTask() {
    CopyDbTask task = new CopyDbTask(database.getServer().getServerInfo());
    task.setSrcdbname(sourceDBNameText.getText());
    task.setDestdbname(destinationDBNameText.getText());
    task.setDestdbpath(destinationDBDirPathText.getText());
    task.setExvolpath(volumePathText.getText());
    task.setLogpath(destinationDBLogPathText.getText());
    if (overwriteButton.getSelection()) {
        task.setOverwrite(YesNoType.Y);
    } else {
        task.setOverwrite(YesNoType.N);
    }
    if (moveButton.getSelection()) {
        task.setMove(YesNoType.Y);
    } else {
        task.setMove(YesNoType.N);
    }
    String oldVolName = null, newVolName = null, oldVolDir = null, newVolDir = null;
    if (copyVolButton.getSelection()) {
        task.setAdvanced(OnOffType.ON);
        StringBuffer openStr = new StringBuffer("volume");
        for (int i = 0; i < copyDBVolList.getItemCount(); i++) {
            TableItem ti = copyDBVolList.getItem(i);
            for (DbSpaceInfo bean : volumeList) {
                if (bean.getSpacename().equals(ti.getText(0))) {
                    oldVolDir = bean.getLocation();
                    break;
                }
            }
            oldVolName = ti.getText(0);
            newVolName = ti.getText(1);
            newVolDir = ti.getText(2);
            if (oldVolDir != null) {
                oldVolDir = oldVolDir.replaceAll(":", "|");
            }
            if (newVolDir != null) {
                newVolDir = newVolDir.replaceAll(":", "|");
            }
            openStr.append("\n").append(oldVolDir).append("/").append(oldVolName).append(":").append(newVolDir).append("/").append(newVolName);
        }
        task.setOpen(openStr.toString());
        task.setClose("volume");
    } else {
        task.setAdvanced(OnOffType.OFF);
    }
    return task;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) CopyDbTask(com.cubrid.cubridmanager.core.cubrid.database.task.CopyDbTask) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) Point(org.eclipse.swt.graphics.Point)

Example 12 with DbSpaceInfo

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

Example 14 with DbSpaceInfo

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

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

the class DBSpaceLabelProvider method getForeground.

public Color getForeground(Object element, int columnIndex) {
    long totalPage = 0;
    long freePage = 0;
    String type = null;
    switch(columnIndex) {
        case 1:
            type = VolumeType.DATA.getText();
            break;
        case 2:
            type = VolumeType.INDEX.getText();
            break;
        case 3:
            type = VolumeType.TEMP.getText();
            break;
        case 4:
            type = VolumeType.GENERIC.getText();
            break;
    }
    if (type != null && element instanceof DBVolumeSpaceInfo) {
        DBVolumeSpaceInfo volumeSpaceInfo = (DBVolumeSpaceInfo) element;
        List<DbSpaceInfo> dbSpaceInfoList = volumeSpaceInfo.getVolumeSpaceInfo(type);
        if (dbSpaceInfoList != null) {
            for (DbSpaceInfo dbSpaceInfo : dbSpaceInfoList) {
                totalPage += dbSpaceInfo.getTotalpage();
                freePage += dbSpaceInfo.getFreepage();
            }
        }
        if (totalPage > 0 && freePage * 1.0d / totalPage < warningThreshold) {
            return ResourceManager.getColor(SWT.COLOR_RED);
        } else if (totalPage > 0 && freePage * 1.0d / totalPage < noticeThreshold) {
            return ResourceManager.getColor(SWT.COLOR_DARK_YELLOW);
        }
    }
    return null;
}
Also used : DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo)

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