use of com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask in project cubrid-manager by CUBRID.
the class CoreUtilsTest method testDeleteDatabaseFromServiceServer.
public void testDeleteDatabaseFromServiceServer() {
List<String> lst = null;
try {
lst = CoreUtils.deleteDatabaseFromServiceServer(null, null, "demodb");
assertTrue(lst == null);
} catch (Exception e) {
assertTrue(true);
}
{
GetCubridConfParameterTask task = new GetCubridConfParameterTask(null);
List<String> clist = new ArrayList<String>();
clist.add(ConfConstants.SERVICE_SECTION);
clist.add("[service]\n");
clist.add("# The list of processes to be started automatically by 'cubrid service start' command\n");
clist.add("# Any combinations are available with server, broker, manager and heartbeat.\n");
clist.add("service=server,broker,manager\n");
clist.add("# The list of database servers in all by 'cubrid service start' command.\n");
clist.add("# This property is effective only when the above 'service' property contains 'server' keyword.\n");
clist.add("server=demodb,testdb,quick\n");
lst = CoreUtils.deleteDatabaseFromServiceServer(task, clist, "demodb");
assertNotNull(lst);
}
try {
GetCubridConfParameterTask task = new GetCubridConfParameterTask(null);
List<String> clist = new ArrayList<String>();
clist.add(ConfConstants.SERVICE_SECTION);
clist.add("[service]\n");
clist.add("# The list of processes to be started automatically by 'cubrid service start' command\n");
clist.add("# Any combinations are available with server, broker, manager and heartbeat.\n");
clist.add("service=server,broker,manager\n");
clist.add("# The list of database servers in all by 'cubrid service start' command.\n");
clist.add("# This property is effective only when the above 'service' property contains 'server' keyword.\n");
clist.add("#server=demodb,testdb,\n");
lst = CoreUtils.deleteDatabaseFromServiceServer(task, clist, "demodb");
assertTrue(lst == null);
} catch (Exception e) {
assertTrue(true);
}
{
GetCubridConfParameterTask task = new GetCubridConfParameterTask(null);
List<String> clist = new ArrayList<String>();
clist.add(ConfConstants.SERVICE_SECTION);
clist.add("[service]\n");
clist.add("# The list of processes to be started automatically by 'cubrid service start' command\n");
clist.add("# Any combinations are available with server, broker, manager and heartbeat.\n");
clist.add("service=server,broker,manager\n");
clist.add("# The list of database servers in all by 'cubrid service start' command.\n");
clist.add("# This property is effective only when the above 'service' property contains 'server' keyword.\n");
clist.add("server=demodb,,quick\n");
lst = CoreUtils.deleteDatabaseFromServiceServer(task, clist, "demodb");
assertNotNull(lst);
}
{
GetCubridConfParameterTask task = new GetCubridConfParameterTask(null);
List<String> clist = new ArrayList<String>();
clist.add(ConfConstants.SERVICE_SECTION);
clist.add("[service]\n");
clist.add("# The list of processes to be started automatically by 'cubrid service start' command\n");
clist.add("# Any combinations are available with server, broker, manager and heartbeat.\n");
clist.add("service=server,broker,manager\n");
clist.add("# The list of database servers in all by 'cubrid service start' command.\n");
clist.add("# This property is effective only when the above 'service' property contains 'server' keyword.\n");
clist.add("# server=,testdb,quick\n");
lst = CoreUtils.deleteDatabaseFromServiceServer(task, clist, "demodb");
assertNull(lst);
}
{
GetCubridConfParameterTask task = new GetCubridConfParameterTask(null);
List<String> clist = new ArrayList<String>();
clist.add(ConfConstants.SERVICE_SECTION);
clist.add("[service]\n");
clist.add("# The list of processes to be started automatically by 'cubrid service start' command\n");
clist.add("# Any combinations are available with server, broker, manager and heartbeat.\n");
clist.add("service=server,,manager\n");
clist.add("# The list of database servers in all by 'cubrid service start' command.\n");
clist.add("# This property is effective only when the above 'service' property contains 'server' keyword.\n");
clist.add("server=demodb,testdb,quick\n");
lst = CoreUtils.deleteDatabaseFromServiceServer(task, clist, "demodb");
assertNotNull(lst);
}
{
GetCubridConfParameterTask task = new GetCubridConfParameterTask(null);
List<String> clist = new ArrayList<String>();
clist.add(ConfConstants.SERVICE_SECTION);
clist.add("[service]\n");
clist.add("# The list of processes to be started automatically by 'cubrid service start' command\n");
clist.add("# Any combinations are available with server, broker, manager and heartbeat.\n");
clist.add("service=server,broker,\n");
clist.add("# The list of database servers in all by 'cubrid service start' command.\n");
clist.add("# This property is effective only when the above 'service' property contains 'server' keyword.\n");
clist.add("server=,,\n");
lst = CoreUtils.deleteDatabaseFromServiceServer(task, clist, "demodb");
assertNull(lst);
}
{
GetCubridConfParameterTask task = new GetCubridConfParameterTask(null);
List<String> clist = new ArrayList<String>();
clist.add(ConfConstants.SERVICE_SECTION);
clist.add("[service]\n");
clist.add("# The list of processes to be started automatically by 'cubrid service start' command\n");
clist.add("# Any combinations are available with server, broker, manager and heartbeat.\n");
clist.add("service=,broker,manager\n");
clist.add("# The list of database servers in all by 'cubrid service start' command.\n");
clist.add("# This property is effective only when the above 'service' property contains 'server' keyword.\n");
clist.add("server=\n");
try {
lst = CoreUtils.deleteDatabaseFromServiceServer(task, clist, "demodb");
assertTrue(false);
} catch (Exception e) {
assertTrue(true);
}
}
{
GetCubridConfParameterTask task = new GetCubridConfParameterTask(null);
List<String> clist = new ArrayList<String>();
clist.add(ConfConstants.SERVICE_SECTION);
clist.add("[service]\n");
clist.add("# The list of processes to be started automatically by 'cubrid service start' command\n");
clist.add("# Any combinations are available with server, broker, manager and heartbeat.\n");
clist.add("service=,broker,manager\n");
clist.add("# The list of database servers in all by 'cubrid service start' command.\n");
clist.add("# This property is effective only when the above 'service' property contains 'server' keyword.\n");
clist.add("server=\n");
try {
lst = CoreUtils.deleteDatabaseFromServiceServer(task, clist, "demodb");
assertTrue(false);
} catch (Exception e) {
assertTrue(true);
}
}
{
GetCubridConfParameterTask task = new GetCubridConfParameterTask(null);
List<String> clist = new ArrayList<String>();
clist.add(ConfConstants.SERVICE_SECTION);
clist.add("[service]\n");
clist.add("# The list of processes to be started automatically by 'cubrid service start' command\n");
clist.add("# Any combinations are available with server, broker, manager and heartbeat.\n");
clist.add("service=server,,manager\n");
clist.add("# The list of database servers in all by 'cubrid service start' command.\n");
clist.add("# This property is effective only when the above 'service' property contains 'server' keyword.\n");
clist.add("server=\n");
try {
lst = CoreUtils.deleteDatabaseFromServiceServer(task, clist, "demodb");
assertTrue(false);
} catch (Exception e) {
assertTrue(true);
}
}
{
GetCubridConfParameterTask task = new GetCubridConfParameterTask(null);
List<String> clist = new ArrayList<String>();
clist.add(ConfConstants.SERVICE_SECTION);
clist.add("[service]\n");
clist.add("# The list of processes to be started automatically by 'cubrid service start' command\n");
clist.add("# Any combinations are available with server, broker, manager and heartbeat.\n");
clist.add("service=server,broker,manager\n");
clist.add("# The list of database servers in all by 'cubrid service start' command.\n");
clist.add("# This property is effective only when the above 'service' property contains 'server' keyword.\n");
clist.add("server=\n");
try {
lst = CoreUtils.deleteDatabaseFromServiceServer(task, clist, "demodb");
assertTrue(false);
} catch (Exception e) {
assertTrue(true);
}
}
}
use of com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask in project cubrid-manager by CUBRID.
the class BackupDatabaseAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
final CubridDatabase database = node.getDatabase();
final BackupDatabaseDialog dialog = new BackupDatabaseDialog(getShell());
dialog.setDatabase(database);
final Shell shell = getShell();
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return false;
}
monitor.beginTask(Messages.loadDbBackupInfoTaskName, 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 GetDbBackupInfoTask) {
GetDbBackupInfoTask getDbBackupInfoTask = (GetDbBackupInfoTask) task;
dialog.setDbBackupInfo(getDbBackupInfoTask.getDbBackupInfo());
} else if (task instanceof GetCubridConfParameterTask) {
GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
Map<String, String> commonParas = confParas.get(ConfConstants.COMMON_SECTION_NAME);
Map<String, String> dbParas = confParas.get("[@" + database.getLabel() + "]");
String str = dbParas == null ? null : dbParas.get(ConfConstants.REPLICATION);
boolean isReplication = "yes".equals(str);
if (!isReplication) {
str = commonParas == null ? null : commonParas.get(ConfConstants.REPLICATION);
isReplication = "yes".equals(str);
}
dialog.setReplication(isReplication);
}
}
return true;
}
};
ServerInfo serverInfo = database.getServer().getServerInfo();
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
taskExcutor.addTask(getCubridConfParameterTask);
GetDbBackupInfoTask getDbBackupInfoTask = new GetDbBackupInfoTask(serverInfo);
getDbBackupInfoTask.setDbName(database.getLabel());
taskExcutor.addTask(getDbBackupInfoTask);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (taskExcutor.isSuccess()) {
dialog.open();
}
}
use of com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method loadData.
/**
* load edit data
*/
public void loadData() {
if (editorInput.getTaskCountValue() == 0) {
return;
}
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(getSite().getShell());
progress.setCancelable(false);
progress.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
monitor.beginTask(Messages.unifyHostConfigEditorLoadingDataMsg, editorInput.getTaskCountValue());
unifyHostConfigUtil = new UnifyHostConfigUtil();
for (CubridServer cubridServer : editorInput.getCubridServers()) {
if (editorInput.isEditCubridConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "cubrid.conf", cubridServer.getName()));
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(cubridServer.getServerInfo());
getCubridConfParameterTask.execute();
if (getCubridConfParameterTask.isSuccess()) {
List<String> contentsList = getCubridConfParameterTask.getConfContents();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
CubridConfConfig cubridConfConfig = unifyHostConfigUtil.parseStringLineToCubridConfConfig(contentBuilder.toString());
cubridConfConfigDataMap.put(cubridServer.getName(), cubridConfConfig);
monitor.worked(1);
}
}
if (editorInput.isEditBrokerConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "broker", cubridServer.getName()));
GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(cubridServer.getServerInfo());
getBrokerConfParameterTask.execute();
if (getBrokerConfParameterTask.isSuccess()) {
List<String> contentsList = getBrokerConfParameterTask.getConfContents();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
BrokerConfig cubridBrokerConfig = cubridBrokerConfUtil.parseStringLineToBrokerConfig(contentBuilder.toString());
cubridBrokerConfigDataMap.put(cubridServer.getName(), cubridBrokerConfig);
monitor.worked(1);
}
}
if (editorInput.isEditCMConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "cm.conf", cubridServer.getName()));
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(cubridServer.getServerInfo());
getCMConfParameterTask.execute();
if (getCMConfParameterTask.isSuccess()) {
List<String> contentsList = getCMConfParameterTask.getConfContents();
StringBuilder contentBuilder = new StringBuilder();
for (String content : contentsList) {
contentBuilder.append(content).append(StringUtil.NEWLINE);
}
CubridCMConfConfig cubridCMConfConfig = unifyHostConfigUtil.parseStringLineToCubridCMConfConfig(contentBuilder.toString());
cubridConfCMConfigDataMap.put(cubridServer.getName(), cubridCMConfConfig);
// System.out.println(contentBuilder.toString());
}
monitor.worked(1);
}
if (editorInput.isEditHAConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "cubrid_ha.conf", cubridServer.getName()));
monitor.worked(1);
}
if (editorInput.isEditACLConf()) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorLoadingDataMsg2, "acl", cubridServer.getName()));
monitor.worked(1);
}
}
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
}
use of com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask in project cubrid-manager by CUBRID.
the class FinishTask method initTask.
public void initTask(ServerInfo serverInfo) {
MonitoringTask monitoringTask = serverInfo.getMonitoringTask();
GetEnvInfoTask getEnvInfoTask = new GetEnvInfoTask(serverInfo);
GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo);
CommonQueryTask<BrokerInfos> getBrokerTask = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new BrokerInfos());
GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo);
UpdateCMUserTask updateTask = new UpdateCMUserTask(serverInfo);
updateTask.setCmUserName(serverInfo.getUserName());
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(serverInfo);
addTask(monitoringTask);
addTask(getEnvInfoTask);
addTask(getDatabaseListTask);
addTask(getCMConfParameterTask);
addTask(getBrokerTask);
addTask(getUserInfoTask);
addTask(updateTask);
addTask(getCubridConfParameterTask);
addTask(getBrokerConfParameterTask);
addTask(new FinishTask());
}
use of com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask in project cubrid-manager by CUBRID.
the class ConnectHostExecutor method initTasks.
private void initTasks() {
MonitoringTask monitoringTask = serverInfo.getMonitoringTask();
addTask(monitoringTask);
GetEnvInfoTask getEnvInfoTask = new GetEnvInfoTask(serverInfo);
addTask(getEnvInfoTask);
GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
addTask(getDatabaseListTask);
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo);
addTask(getCMConfParameterTask);
CommonQueryTask<BrokerInfos> getBrokerTask = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new BrokerInfos());
addTask(getBrokerTask);
GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo);
addTask(getUserInfoTask);
UpdateCMUserTask updateTask = new UpdateCMUserTask(serverInfo);
updateTask.setCmUserName(serverInfo.getUserName());
addTask(updateTask);
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
addTask(getCubridConfParameterTask);
GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(serverInfo);
addTask(getBrokerConfParameterTask);
}
Aggregations