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