use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAutoAddVolumeInfo in project cubrid-manager by CUBRID.
the class SetAutoAddVolumeAction method run.
/**
* Creates a Dialog which is the instance of SetAutoAddVolumeDialog to set a
* auto adding volume
*/
public void run() {
Object[] obj = this.getSelectedObj();
DefaultSchemaNode selection = null;
CubridDatabase database = null;
if (obj.length > 0 && obj[0] instanceof DefaultSchemaNode) {
selection = (DefaultSchemaNode) obj[0];
database = selection.getDatabase();
}
if (database == null) {
CommonUITool.openErrorBox(Messages.msgSelectDB);
return;
}
//Get the info of AutoAddVolumeInfo
GetAutoAddVolumeInfo getAutoAddVolumeInfo = new GetAutoAddVolumeInfo();
final CommonQueryTask<GetAutoAddVolumeInfo> autoAddVolumetask = new CommonQueryTask<GetAutoAddVolumeInfo>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), getAutoAddVolumeInfo);
autoAddVolumetask.setDbName(database.getLabel());
TaskExecutor taskExecutor = new CommonTaskExec(com.cubrid.cubridmanager.ui.cubrid.dbspace.Messages.getVolumeInfoTaskName);
taskExecutor.addTask(autoAddVolumetask);
//Gets the page size in the database
int pageSize = 0;
CommonQueryTask<DbSpaceInfoList> spaceInfoTask = null;
DatabaseInfo databaseInfo = database.getDatabaseInfo();
DbSpaceInfoList dbSpaceInfoList = databaseInfo.getDbSpaceInfoList();
if (null == dbSpaceInfoList) {
dbSpaceInfoList = new DbSpaceInfoList();
spaceInfoTask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfoList);
spaceInfoTask.setDbName(database.getLabel());
taskExecutor.addTask(spaceInfoTask);
}
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (!taskExecutor.isSuccess()) {
return;
}
if (spaceInfoTask == null) {
pageSize = dbSpaceInfoList.getPagesize();
} else {
final DbSpaceInfoList model = ((CommonQueryTask<DbSpaceInfoList>) spaceInfoTask).getResultModel();
pageSize = model.getPagesize();
}
getAutoAddVolumeInfo = autoAddVolumetask.getResultModel();
SetAutoAddVolumeDialog dialog = new SetAutoAddVolumeDialog(getShell());
dialog.setGetAutoAddVolumeInfo(getAutoAddVolumeInfo);
dialog.setPageSize(pageSize);
GetAutoAddVolumeInfo returnInfo = dialog.getGetAutoAddVolumeInfo();
if (dialog.open() == Dialog.OK) {
ServerInfo serverInfo = database.getServer().getServerInfo();
SetAutoAddVolumeTask setTask = new SetAutoAddVolumeTask(serverInfo);
setTask.setDbname(database.getName());
setTask.setData(returnInfo.getData());
setTask.setDataWarnOutofspace(returnInfo.getData_warn_outofspace());
setTask.setDataExtPage(returnInfo.getData_ext_page());
setTask.setIndex(returnInfo.getIndex());
setTask.setIndexWarnOutofspace(returnInfo.getIndex_warn_outofspace());
setTask.setIndexExtPage(returnInfo.getIndex_ext_page());
taskExecutor = new CommonTaskExec(com.cubrid.cubridmanager.ui.cubrid.dbspace.Messages.setAutoAddedVolInfoTaskName);
taskExecutor.addTask(setTask);
new ExecTaskWithProgress(taskExecutor).exec();
}
}
use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAutoAddVolumeInfo in project cubrid-manager by CUBRID.
the class DatabaseInfoPage method fillData.
/**
* Fill in the database information
*/
public void fillData() {
databaseInfoText.setText("");
GeneralInfoPage generalInfoPage = (GeneralInfoPage) getWizard().getPage(GeneralInfoPage.PAGENAME);
int pageSize = Integer.parseInt(generalInfoPage.getPageSize());
double genericVolumeSize = Double.parseDouble(generalInfoPage.getGenericPageNum()) * pageSize / (1024 * 1024);
double logVolumeSize = Double.parseDouble(generalInfoPage.getLogPageNum()) * pageSize / (1024 * 1024);
databaseInfoText.append("General Information:\r\n");
databaseInfoText.append("The database name will be " + generalInfoPage.getDatabaseName() + ".\r\n");
databaseInfoText.append("The size of a page will be " + pageSize + " bytes.\r\n");
databaseInfoText.append("\r\n");
if (CompatibleUtil.isSupportCreateDBByCharset(server.getServerInfo())) {
databaseInfoText.append("Collation(Charset) Information:\r\n");
databaseInfoText.append("The database collation(charset) will be " + generalInfoPage.getCharset() + ".\r\n");
databaseInfoText.append("\r\n");
}
databaseInfoText.append("Generic volume information:\r\n");
databaseInfoText.append("The volume size will be " + genericVolumeSize + " MB.\r\n");
databaseInfoText.append("The volume path will be " + generalInfoPage.getGenericVolumePath() + ".\r\n");
databaseInfoText.append("\r\n");
databaseInfoText.append("Log Volume Information:\r\n");
databaseInfoText.append("The volume size will be " + logVolumeSize + " MB.\r\n");
databaseInfoText.append("The volume path will be " + generalInfoPage.getLogVolumePath() + ".\r\n");
databaseInfoText.append("\r\n");
databaseInfoText.append("Automatic Start Option:\r\n");
databaseInfoText.append("The datebase will ");
if (generalInfoPage.isAutoStart()) {
databaseInfoText.append("start automatically when start cubrid service.\r\n");
} else {
databaseInfoText.append("not start automatically when start cubrid service.\r\n");
}
databaseInfoText.append("\r\n");
VolumeInfoPage volumeInfoPage = (VolumeInfoPage) getWizard().getPage(VolumeInfoPage.PAGENAME);
List<Map<String, String>> volumeList = volumeInfoPage.getVolumeList();
if (!volumeList.isEmpty()) {
databaseInfoText.append("Addtional volume information:\r\n");
}
for (int i = 0; i < volumeList.size(); i++) {
Map<String, String> map = volumeList.get(i);
String volumeName = map.get("0");
String volumeType = map.get("1");
String volumeSize = map.get("2");
String volumePath = map.get("4");
String order = "";
switch(i + 1) {
case 1:
order = "1st";
break;
case 2:
order = "2nd";
break;
case 3:
order = "3rd";
break;
default:
order = (i + 1) + "th";
break;
}
databaseInfoText.append("The " + order + " volume information:\r\n");
databaseInfoText.append("Volume name will be " + volumeName + ", Volume path will be " + volumePath + ", Volume type will be " + volumeType + " volume, Volume size will be " + volumeSize + " MB.\r\n");
databaseInfoText.append("\r\n");
}
SetAutoAddVolumeInfoPage autoAddVolumeInfoPage = (SetAutoAddVolumeInfoPage) getWizard().getPage(SetAutoAddVolumeInfoPage.PAGENAME);
GetAutoAddVolumeInfo autoAddVolumeInfo = autoAddVolumeInfoPage.getAutoAddVolumeInfo();
if (autoAddVolumeInfo != null) {
databaseInfoText.append("Auto added volume information:\r\n");
if (autoAddVolumeInfo.getData().equals(OnOffType.ON.getText())) {
double pageNum = Double.parseDouble(autoAddVolumeInfo.getData_ext_page());
double size = pageSize * pageNum / (1024 * 1024);
double rate = Double.parseDouble(autoAddVolumeInfo.getData_warn_outofspace()) * 100;
databaseInfoText.append("The size of auto added data volume will be " + size + " MB; Out of space of warning rate(%) will be " + rate + ".\r\n");
}
if (autoAddVolumeInfo.getIndex().equals(OnOffType.ON.getText())) {
double pageNum = Double.parseDouble(autoAddVolumeInfo.getIndex_ext_page());
double size = pageSize * pageNum / (1024 * 1024);
double rate = Double.parseDouble(autoAddVolumeInfo.getIndex_warn_outofspace()) * 100;
databaseInfoText.append("The size of auto added index volume will be " + size + " MB; Out of space of warning rate(%) will be " + rate + ".\r\n");
}
}
databaseInfoText.setTopIndex(0);
}
use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAutoAddVolumeInfo in project cubrid-manager by CUBRID.
the class SetAutoAddVolumeInfoPage method getAutoAddVolumeInfo.
/**
*
* Get auto adding volume information
*
* @return the GetAutoAddVolumeInfo object
*/
public GetAutoAddVolumeInfo getAutoAddVolumeInfo() {
if (!dataUsingAutoVolButton.getSelection() && !indexUsingAutoVolButton.getSelection()) {
return null;
}
GetAutoAddVolumeInfo autoAddVolumeInfo = new GetAutoAddVolumeInfo();
if (dataUsingAutoVolButton.getSelection()) {
autoAddVolumeInfo.setData(OnOffType.ON.getText());
String pageNum = String.valueOf(calcPageNum(dataVolumeText.getText()));
double rate = Double.parseDouble(dataOutRateCombo.getText()) / 100;
autoAddVolumeInfo.setData_ext_page(pageNum);
autoAddVolumeInfo.setData_warn_outofspace(String.valueOf(rate));
} else {
autoAddVolumeInfo.setData(OnOffType.OFF.getText());
autoAddVolumeInfo.setData_ext_page("0.0");
autoAddVolumeInfo.setData_warn_outofspace("0.0");
}
if (indexUsingAutoVolButton.getSelection()) {
autoAddVolumeInfo.setIndex(OnOffType.ON.getText());
String pageNum = String.valueOf(calcPageNum(indexVolumeText.getText()));
double rate = Double.parseDouble(indexOutRateCombo.getText()) / 100;
autoAddVolumeInfo.setIndex_ext_page(pageNum);
autoAddVolumeInfo.setIndex_warn_outofspace(String.valueOf(rate));
} else {
autoAddVolumeInfo.setIndex(OnOffType.OFF.getText());
autoAddVolumeInfo.setIndex_ext_page("0.0");
autoAddVolumeInfo.setIndex_warn_outofspace("0.0");
}
return autoAddVolumeInfo;
}
use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAutoAddVolumeInfo in project cubrid-manager by CUBRID.
the class SetAutoAddVolumeTaskTest method testExecute.
public void testExecute() {
SetAutoAddVolumeTask setTask = new SetAutoAddVolumeTask(serverInfo);
GetAutoAddVolumeInfo returnInfo = new GetAutoAddVolumeInfo();
returnInfo.setData("ON");
returnInfo.setDbname(testDbName);
returnInfo.setData_ext_page("10000");
returnInfo.setData_warn_outofspace("5");
returnInfo.setIndex("OFF");
returnInfo.setIndex_ext_page("10000");
returnInfo.setIndex_warn_outofspace("5");
setTask.setDbname(returnInfo.getDbname());
setTask.setData(returnInfo.getData());
setTask.setDataWarnOutofspace(returnInfo.getData_warn_outofspace());
setTask.setDataExtPage(returnInfo.getData_ext_page());
setTask.setIndex(returnInfo.getIndex());
setTask.setIndexWarnOutofspace(returnInfo.getIndex_warn_outofspace());
setTask.setIndexExtPage(returnInfo.getIndex_ext_page());
//setTask.execute();
assertNull(setTask.getErrorMsg());
}
use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAutoAddVolumeInfo in project cubrid-manager by CUBRID.
the class CreateDatabaseWizard method performFinish.
/**
* Called when user clicks Finish
*
* @return boolean
*/
public boolean performFinish() {
isCanFinished = true;
isOverride = true;
final String databaseName = generalInfoPage.getDatabaseName();
String pageSize = generalInfoPage.getPageSize();
String logPageSize = generalInfoPage.getLogPageSize();
String generalPageNum = generalInfoPage.getGenericPageNum();
String generalVolumePath = generalInfoPage.getGenericVolumePath();
String charset = generalInfoPage.getCharset();
final boolean isAutoStart = generalInfoPage.isAutoStart();
TaskJobExecutor taskExcutor = new TaskJobExecutor() {
public IStatus exec(final IProgressMonitor monitor) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
getShell().setVisible(false);
}
});
if (monitor.isCanceled()) {
isCanFinished = true;
Display.getDefault().syncExec(new Runnable() {
public void run() {
cancel();
close();
}
});
return Status.CANCEL_STATUS;
}
List<String> cubridConfContentList = null;
for (ITask task : taskList) {
if (task instanceof CreateDbTask) {
CreateDbTask createDbTask = (CreateDbTask) task;
createDbTask.setOverwriteConfigFile(isOverride);
} else if (task instanceof SetCubridConfParameterTask) {
if (cubridConfContentList == null) {
continue;
} else {
SetCubridConfParameterTask setParaTask = (SetCubridConfParameterTask) task;
setParaTask.setConfContents(cubridConfContentList);
}
}
task.execute();
final String msg = task.getErrorMsg();
if (monitor.isCanceled()) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
cancel();
close();
}
});
isCanFinished = true;
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled() && !isCanceled()) {
//start database failed
if (task instanceof CommonUpdateTask && task.getTaskname().equals(CommonTaskName.START_DB_TASK_NAME)) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(getShell(), msg + StringUtil.NEWLINE + Messages.createDBFailedMsg);
}
});
return Status.OK_STATUS;
}
Display.getDefault().syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(getShell(), msg);
isCanFinished = false;
getShell().setVisible(true);
}
});
return Status.CANCEL_STATUS;
}
if (isCanceled()) {
return Status.CANCEL_STATUS;
}
if (task instanceof CheckDirTask) {
CheckDirTask checkDirTask = (CheckDirTask) task;
final String[] dirs = checkDirTask.getNoExistDirectory();
if (dirs != null && dirs.length > 0) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
CreateDirDialog dialog = new CreateDirDialog(getShell());
dialog.setDirs(dirs);
if (dialog.open() != IDialogConstants.OK_ID) {
isCanFinished = false;
getShell().setVisible(true);
}
}
});
}
} else if (task instanceof CheckFileTask) {
CheckFileTask checkFileTask = (CheckFileTask) task;
final String[] files = checkFileTask.getExistFiles();
if (files != null && files.length > 0) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
OverrideFileDialog dialog = new OverrideFileDialog(getShell());
dialog.setFiles(files);
isOverride = dialog.open() == IDialogConstants.OK_ID;
getShell().setVisible(!isOverride);
}
});
}
} else if (task instanceof GetCubridConfParameterTask) {
GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
List<String> cubridConfContentListCandidate1 = null;
if (isAutoStart) {
cubridConfContentListCandidate1 = CoreUtils.addDatabaseToServiceServer(getCubridConfParameterTask, null, databaseName);
}
List<String> cubridConfContentListCandidate2 = null;
if (CompatibleUtil.isNeedCheckHAModeOnNewDb(server.getServerInfo())) {
cubridConfContentListCandidate2 = CoreUtils.changeHAModeFromCubridConf(getCubridConfParameterTask, cubridConfContentListCandidate1, databaseName);
}
if (cubridConfContentListCandidate2 == null) {
cubridConfContentList = cubridConfContentListCandidate1;
} else {
cubridConfContentList = cubridConfContentListCandidate2;
}
}
if (!isCanFinished) {
return Status.CANCEL_STATUS;
}
if (monitor.isCanceled()) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
completeAll();
close();
cancel();
}
});
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
public void cancel() {
super.cancel();
GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(server.getServerInfo());
getDatabaseListTask.execute();
boolean isExist = false;
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
if (databaseInfoList != null) {
for (int i = 0; i < databaseInfoList.size(); i++) {
DatabaseInfo dbInfo = databaseInfoList.get(i);
String dbName = dbInfo.getDbName();
if (dbName.equals(databaseName)) {
isExist = true;
}
}
}
if (isExist) {
CommonUpdateTask deleteTask = new CommonUpdateTask(CommonTaskName.DELETE_DATABASE_TASK_NAME, server.getServerInfo(), CommonSendMsg.getDeletedbSendMsg());
deleteTask.setDbName(databaseName);
deleteTask.setDelbackup(YesNoType.Y);
deleteTask.execute();
}
}
public void done(IJobChangeEvent event) {
if (event.getResult() == Status.OK_STATUS) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
completeAll();
close();
}
});
}
}
};
CheckDirTask checkDirTask = new CheckDirTask(server.getServerInfo());
CheckFileTask checkFileTask = new CheckFileTask(server.getServerInfo());
CreateDbTask createDbTask = new CreateDbTask(server.getServerInfo());
List<String> checkedDirsList = new ArrayList<String>();
List<String> checkedFilesList = new ArrayList<String>();
// add checked directory(general volume path)
addVolumePath(checkedDirsList, generalVolumePath);
String logPageNum = generalInfoPage.getLogPageNum();
String logVolumePath = generalInfoPage.getLogVolumePath();
// add checked directory(log volume path)
addVolumePath(checkedDirsList, logVolumePath);
List<Map<String, String>> volumeList = volumeInfoPage.getVolumeList();
for (int i = 0; i < volumeList.size(); i++) {
Map<String, String> map = volumeList.get(i);
String volumeName = map.get("0");
String volumePath = map.get("4");
// add checked directory(additional volume path)
addVolumePath(checkedDirsList, volumePath);
// add checked file(additional volume)
addVolumePath(checkedFilesList, volumePath + server.getServerInfo().getPathSeparator() + volumeName);
}
String[] dirs = new String[checkedDirsList.size()];
checkDirTask.setDirectory(checkedDirsList.toArray(dirs));
String[] files = new String[checkedFilesList.size()];
checkFileTask.setFile(checkedFilesList.toArray(files));
createDbTask.setDbName(databaseName);
createDbTask.setPageSize(pageSize);
if (logPageSize != null) {
createDbTask.setLogPageSize(logPageSize);
}
if (charset != null) {
createDbTask.setCharset(charset);
}
createDbTask.setNumPage(generalPageNum);
createDbTask.setGeneralVolumePath(generalVolumePath);
createDbTask.setLogSize(logPageNum);
createDbTask.setLogVolumePath(logVolumePath);
createDbTask.setExVolumes(volumeList);
if (!checkedDirsList.isEmpty()) {
taskExcutor.addTask(checkDirTask);
}
if (!checkedFilesList.isEmpty()) {
taskExcutor.addTask(checkFileTask);
}
taskExcutor.addTask(createDbTask);
//add set auto added volume
GetAutoAddVolumeInfo returnInfo = setAutoAddVolumeInfoPage.getAutoAddVolumeInfo();
if (returnInfo != null) {
SetAutoAddVolumeTask setTask = new SetAutoAddVolumeTask(server.getServerInfo());
setTask.setDbname(databaseName);
setTask.setData(returnInfo.getData());
setTask.setDataWarnOutofspace(returnInfo.getData_warn_outofspace());
setTask.setDataExtPage(returnInfo.getData_ext_page());
setTask.setIndex(returnInfo.getIndex());
setTask.setIndexWarnOutofspace(returnInfo.getIndex_warn_outofspace());
setTask.setIndexExtPage(returnInfo.getIndex_ext_page());
taskExcutor.addTask(setTask);
}
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(server.getServerInfo());
taskExcutor.addTask(getCubridConfParameterTask);
SetCubridConfParameterTask setCubridConfParameterTask = new SetCubridConfParameterTask(server.getServerInfo());
taskExcutor.addTask(setCubridConfParameterTask);
//start database
CommonUpdateTask startDbTask = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, server.getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg());
startDbTask.setDbName(databaseName);
taskExcutor.addTask(startDbTask);
//set dba password
UpdateAddUserTask updateUserTask = new UpdateAddUserTask(server.getServerInfo(), false);
UserSendObj userSendObj = new UserSendObj();
userSendObj.setDbname(databaseName);
userSendObj.setUsername("dba");
String password = setDbaPasswordPage.getPassword();
userSendObj.setUserpass(password);
updateUserTask.setUserSendObj(userSendObj);
taskExcutor.addTask(updateUserTask);
JobFamily jobFamily = new JobFamily();
String serverName = server.getName();
jobFamily.setServerName(serverName);
String jobName = Messages.msgCreateDbrearJobName + " - " + serverName;
taskExcutor.schedule(jobName, jobFamily, true, Job.SHORT);
//the close is in the job
return false;
}
Aggregations