use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask in project cubrid-manager by CUBRID.
the class SetupEnvTestCase method setupDatabaseInfo.
/**
* Setup database 8.4.0
*
*/
private void setupDatabaseInfo() {
serverInfo = new ServerInfo();
serverInfo.setHostAddress(host);
serverInfo.setHostMonPort(monport);
serverInfo.setHostJSPort(jpport);
serverInfo.setUserName(userName);
serverInfo.setUserPassword(passwd);
serverInfo.setJdbcDriverVersion(serverVersion);
ServerManager.getInstance().addServer(host, monport, userName, serverInfo);
MonitoringTask monTask = new MonitoringTask(serverInfo);
serverInfo = monTask.connectServer(serverVersion, 1000);
// get the latest token
token = serverInfo.getHostToken();
//get evnInfo
if (envInfo == null) {
GetEnvInfoTask envTask = new GetEnvInfoTask(serverInfo);
envTask.loadEnvInfo();
envTask.execute();
envInfo = envTask.loadEnvInfo();
serverInfo.setEnvInfo(envInfo);
}
assertNotNull(envInfo);
serverPath = envInfo.getRootDir();
dbRootDir = envInfo.getDatabaseDir();
//get server type
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo);
getCMConfParameterTask.execute();
assertEquals(null, getCMConfParameterTask.getErrorMsg());
Map<String, String> confParameters = getCMConfParameterTask.getConfParameters();
ServerType serverType = ServerType.BOTH;
if (confParameters != null) {
String target = confParameters.get(ConfConstants.CM_TARGET);
if (target != null) {
if (target.indexOf("broker") >= 0 && target.indexOf("server") >= 0) {
serverType = ServerType.BOTH;
} else if (target.indexOf("broker") >= 0) {
serverType = ServerType.BROKER;
} else if (target.indexOf("server") >= 0) {
serverType = ServerType.DATABASE;
}
}
}
if (serverInfo != null) {
serverInfo.setServerType(serverType);
}
//Get database list task
if (serverType == ServerType.DATABASE || serverType == ServerType.BOTH) {
final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
getDatabaseListTask.execute();
assertEquals(null, getDatabaseListTask.getErrorMsg());
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
for (DatabaseInfo dbInfo : databaseInfoList) {
if (dbInfo.getDbName().equals(testDbName)) {
databaseInfo = dbInfo;
break;
}
}
if (databaseInfo == null) {
return;
}
}
//get CubridManager user list task
GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo);
getUserInfoTask.execute();
assertEquals(null, getUserInfoTask.getErrorMsg());
List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
ServerUserInfo userInfo = serverUserInfoList.get(i);
if (userInfo != null && userInfo.getUserName().equals(serverInfo.getUserName())) {
serverInfo.setLoginedUserInfo(userInfo);
break;
}
}
List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
String dbDir = databaseInfo.getDbDir();
DbRunningType type = databaseInfo.getRunningType();
for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
if (testDbName.equalsIgnoreCase(databaseInfoList.get(i).getDbName())) {
databaseInfo = databaseInfoList.get(i);
databaseInfo.setDbDir(dbDir);
databaseInfo.setBrokerIP(host);
databaseInfo.setBrokerPort(port);
databaseInfo.setCharSet(charset);
databaseInfo.setRunningType(type);
break;
}
}
//get CUBRID conf parameter
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
getCubridConfParameterTask.execute();
assertEquals(null, getCubridConfParameterTask.getErrorMsg());
Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
if (serverInfo != null) {
serverInfo.setCubridConfParaMap(confParas);
}
//get broker Info
GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(serverInfo);
getBrokerConfParameterTask.execute();
assertEquals(null, getBrokerConfParameterTask.getErrorMsg());
confParas = getBrokerConfParameterTask.getConfParameters();
if (serverInfo != null) {
serverInfo.setBrokerConfParaMap(confParas);
}
//Set JDBC driver
String filePath = this.getFilePathInPlugin("/lib/JDBC-8.3.0.1004-cubrid.jar");
if (filePath != null) {
String version = JdbcClassLoaderFactory.validateJdbcFile(filePath);
if (version != null) {
JdbcClassLoaderFactory.registerClassLoader(filePath);
serverInfo.setJdbcDriverVersion(version);
}
}
filePath = this.getFilePathInPlugin("/lib/JDBC-8.3.1.0173-cubrid.jar");
if (filePath != null) {
String version = JdbcClassLoaderFactory.validateJdbcFile(filePath);
if (version != null) {
JdbcClassLoaderFactory.registerClassLoader(filePath);
serverInfo.setJdbcDriverVersion(version);
}
}
filePath = this.getFilePathInPlugin("/lib/JDBC-8.4.0.0196-cubrid.jar");
if (filePath != null) {
String version = JdbcClassLoaderFactory.validateJdbcFile(filePath);
if (version != null) {
JdbcClassLoaderFactory.registerClassLoader(filePath);
serverInfo.setJdbcDriverVersion(version);
}
}
}
use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask in project cubrid-manager by CUBRID.
the class SetupEnvTestCase method setupDatabaseInfo930.
/**
* Setup database 9.3.0
*
*/
private void setupDatabaseInfo930() throws Exception {
serverInfo930 = new ServerInfo();
serverInfo930.setHostAddress(host930);
serverInfo930.setHostMonPort(monport930);
serverInfo930.setHostJSPort(jpport930);
serverInfo930.setUserName(userName930);
serverInfo930.setUserPassword(passwd930);
serverInfo930.setJdbcDriverVersion(serverVersion930);
ServerManager.getInstance().addServer(host930, monport930, userName930, serverInfo930);
MonitoringTask monTask = new MonitoringTask(serverInfo930);
serverInfo930 = monTask.connectServer(serverVersion930, 1000);
// get the latest token
token930 = serverInfo930.getHostToken();
//get evnInfo
if (envInfo930 == null) {
GetEnvInfoTask envTask = new GetEnvInfoTask(serverInfo930);
envTask.loadEnvInfo();
envTask.execute();
envInfo930 = envTask.loadEnvInfo();
serverInfo930.setEnvInfo(envInfo930);
}
assertNotNull(envInfo930);
serverPath930 = envInfo930.getRootDir();
dbRootDir930 = envInfo930.getDatabaseDir();
//get server type
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo930);
getCMConfParameterTask.execute();
assertEquals(null, getCMConfParameterTask.getErrorMsg());
Map<String, String> confParameters = getCMConfParameterTask.getConfParameters();
ServerType serverType = ServerType.BOTH;
if (confParameters != null) {
String target = confParameters.get(ConfConstants.CM_TARGET);
if (target != null) {
if (target.indexOf("broker") >= 0 && target.indexOf("server") >= 0) {
serverType = ServerType.BOTH;
} else if (target.indexOf("broker") >= 0) {
serverType = ServerType.BROKER;
} else if (target.indexOf("server") >= 0) {
serverType = ServerType.DATABASE;
}
}
}
if (serverInfo930 != null) {
serverInfo930.setServerType(serverType);
}
//Get database list task
if (serverType == ServerType.DATABASE || serverType == ServerType.BOTH) {
final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo930);
getDatabaseListTask.execute();
assertEquals(null, getDatabaseListTask.getErrorMsg());
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
for (DatabaseInfo dbInfo : databaseInfoList) {
if (dbInfo.getDbName().equals(testDbName930)) {
databaseInfo930 = dbInfo;
break;
}
}
if (databaseInfo930 == null) {
return;
}
}
//get CubridManager user list task
GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo930);
getUserInfoTask.execute();
assertEquals(null, getUserInfoTask.getErrorMsg());
List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
ServerUserInfo userInfo = serverUserInfoList.get(i);
if (userInfo != null && userInfo.getUserName().equals(serverInfo930.getUserName())) {
serverInfo930.setLoginedUserInfo(userInfo);
break;
}
}
List<DatabaseInfo> databaseInfoList = serverInfo930.getLoginedUserInfo().getDatabaseInfoList();
String dbDir = databaseInfo930.getDbDir();
DbRunningType type = databaseInfo930.getRunningType();
for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
if (testDbName930.equalsIgnoreCase(databaseInfoList.get(i).getDbName())) {
databaseInfo930 = databaseInfoList.get(i);
databaseInfo930.setDbDir(dbDir);
databaseInfo930.setBrokerIP(host930);
databaseInfo930.setBrokerPort(port930);
databaseInfo930.setCharSet(charset930);
databaseInfo930.setRunningType(type);
break;
}
}
//get CUBRID conf parameter
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo930);
getCubridConfParameterTask.execute();
assertEquals(null, getCubridConfParameterTask.getErrorMsg());
Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
if (serverInfo930 != null) {
serverInfo930.setCubridConfParaMap(confParas);
}
//get broker Info
GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(serverInfo930);
getBrokerConfParameterTask.execute();
assertEquals(null, getBrokerConfParameterTask.getErrorMsg());
confParas = getBrokerConfParameterTask.getConfParameters();
if (serverInfo930 != null) {
serverInfo930.setBrokerConfParaMap(confParas);
}
//Set JDBC driver
String filePath = this.getFilePathInPlugin("/lib/JDBC-9.2.0.0155-cubrid.jar");
if (filePath != null) {
String version = JdbcClassLoaderFactory.validateJdbcFile(filePath);
if (version != null) {
JdbcClassLoaderFactory.registerClassLoader(filePath);
serverInfo930.setJdbcDriverVersion(version);
}
}
}
use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask in project cubrid-manager by CUBRID.
the class PropertyAction method run.
/**
* Open property dialog,view and set property
*/
public void run() {
final Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
return;
}
final ICubridNode node = (ICubridNode) obj[0];
String type = node.getType();
if (CubridNodeType.SERVER.equals(type) || CubridNodeType.DATABASE_FOLDER.equals(type) || CubridNodeType.DATABASE.equals(type) || CubridNodeType.BROKER_FOLDER.equals(type) || CubridNodeType.BROKER.equals(type)) {
TaskExecutor taskExcutor = new GetPropertyExecutor(node, getShell());
ServerInfo serverInfo = node.getServer().getServerInfo();
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(serverInfo);
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo);
if (CubridNodeType.SERVER.equals(type)) {
taskExcutor.addTask(getCubridConfParameterTask);
taskExcutor.addTask(getBrokerConfParameterTask);
taskExcutor.addTask(getCMConfParameterTask);
if (CompatibleUtil.isSupportNewHAConfFile(serverInfo)) {
GetHAConfParameterTask getHAConfParameterTask = new GetHAConfParameterTask(serverInfo);
taskExcutor.addTask(getHAConfParameterTask);
}
}
if (CubridNodeType.DATABASE_FOLDER.equals(type) || CubridNodeType.DATABASE.equals(type)) {
taskExcutor.addTask(getCubridConfParameterTask);
}
if (CubridNodeType.BROKER_FOLDER.equals(type) || CubridNodeType.BROKER.equals(type)) {
taskExcutor.addTask(getBrokerConfParameterTask);
}
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
}
if (!isCancel) {
Dialog dialog = PreferenceUtil.createPropertyDialog(getShell(), node);
dialog.open();
}
}
use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask 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.GetCMConfParameterTask 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());
}
Aggregations