Search in sources :

Example 11 with DbSpaceInfoList

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

the class DeleteDatabaseAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISelectionProvider provider = this.getSelectionProvider();
    if (!(provider instanceof TreeViewer)) {
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    CubridDatabase database = node.getDatabase();
    if (database == null) {
        CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
        return;
    }
    CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
    task.setDbName(database.getName());
    TaskExecutor taskExcutor = new CommonTaskExec(Messages.getDbSpaceInfoTaskName);
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (!taskExcutor.isSuccess()) {
        return;
    }
    DeleteDatabaseDialog dlg = new DeleteDatabaseDialog(getShell());
    dlg.setDbSpaceInfo(task.getResultModel());
    dlg.setDatabase(database);
    ICubridNode parent = database.getParent();
    if (dlg.open() == DeleteDatabaseDialog.DELETE_ID) {
        boolean isContinue = DatabaseUtils.processDatabaseDeleted(database);
        if (isContinue) {
            TreeViewer viewer = (TreeViewer) provider;
            parent.removeChild(database);
            viewer.remove(parent, obj);
            viewer.setSelection(new StructuredSelection(parent));
        }
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DeleteDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.DeleteDatabaseDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 12 with DbSpaceInfoList

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

the class RenameDatabaseAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    final CubridDatabase database = (CubridDatabase) obj[0];
    ISelectionProvider provider = this.getSelectionProvider();
    final TreeViewer viewer = (TreeViewer) provider;
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    final String jobName = serverName + "-" + dbName + "-" + Messages.msgRenameDBRearJobName;
    final RenameDatabaseDialog dialog = new RenameDatabaseDialog(getShell(), new ITaskExecutorInterceptor() {

        public void completeAll() {
            QueryOptions.removePref(database.getDatabaseInfo());
            CommonUITool.openInformationBox(Messages.titleSuccess, Messages.bind(Messages.msgRenameDBComplete, jobName));
            CommonUITool.refreshNavigatorTree(viewer, database.getParent());
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    dialog.setDatabase(database);
    final Shell shell = getShell();
    TaskExecutor taskExcutor = new TaskExecutor() {

        @SuppressWarnings("unchecked")
        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            monitor.beginTask(Messages.getDbSpaceInfoTaskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
                if (task instanceof CommonQueryTask) {
                    dbSpaceInfo = ((CommonQueryTask<DbSpaceInfoList>) task).getResultModel();
                }
            }
            return true;
        }
    };
    dbSpaceInfo = new DbSpaceInfoList();
    CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfo);
    task.setDbName(database.getLabel());
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (taskExcutor.isSuccess()) {
        dialog.setDbSpaceInfoList(dbSpaceInfo);
        dialog.open();
    }
}
Also used : ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) RenameDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.RenameDatabaseDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 13 with DbSpaceInfoList

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

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

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

the class ServiceDashboardEditor method loadServerVolumeData.

/**
	 * Load Server Volume Info
	 */
private void loadServerVolumeData(final ServerInfo serverInfo, final String key) {
    List<String> dbList = serverInfo.getAllDatabaseList();
    if (dbList == null || dbList.size() == 0) {
        return;
    }
    final List<CommonQueryTask<DbSpaceInfoList>> getVolumnTaskList = new ArrayList<CommonQueryTask<DbSpaceInfoList>>();
    for (String dbname : dbList) {
        CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
        task.setDbName(dbname);
        getVolumnTaskList.add(task);
    }
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            Object input = serviceTreeViewer.getInput();
            ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
            setVolumeData(sDashInfo, getVolumnTaskList);
            serviceTreeViewer.refresh(input);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    for (CommonQueryTask<DbSpaceInfoList> task : getVolumnTaskList) {
        taskJobExec.addTask(task);
    }
    executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerVolumeInfo);
}
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) ArrayList(java.util.ArrayList) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) 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