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