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));
}
}
}
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();
}
}
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;
}
}
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);
}
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);
}
Aggregations