use of com.cubrid.cubridmanager.core.common.model.ServerType in project cubrid-manager by CUBRID.
the class SetupEnvTestCase method setupDatabaseInfo831.
/**
* * Setup database 8.3.1
*
*/
private void setupDatabaseInfo831() {
/*Setting Cubrid 8.3.1*/
serverInfo831 = new ServerInfo();
serverInfo831.setHostAddress(host831);
serverInfo831.setHostMonPort(monport831);
serverInfo831.setHostJSPort(jpport831);
serverInfo831.setUserName(userName831);
serverInfo831.setUserPassword(passwd831);
serverInfo831.setJdbcDriverVersion(serverVersion831);
ServerManager.getInstance().addServer(host831, monport831, userName831, serverInfo831);
MonitoringTask monTask = new MonitoringTask(serverInfo831);
serverInfo831 = monTask.connectServer(serverVersion831, 1000);
// get the latest token
token831 = serverInfo831.getHostToken();
//get evnInfo
if (envInfo831 == null) {
GetEnvInfoTask envTask = new GetEnvInfoTask(serverInfo831);
envTask.loadEnvInfo();
envTask.execute();
envInfo831 = envTask.loadEnvInfo();
serverInfo831.setEnvInfo(envInfo831);
}
assertNotNull(envInfo831);
serverPath831 = envInfo831.getRootDir();
dbRootDir831 = envInfo831.getDatabaseDir();
//get server type
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo831);
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 (serverInfo831 != null) {
serverInfo831.setServerType(serverType);
}
//Get database list task
if (serverType == ServerType.DATABASE || serverType == ServerType.BOTH) {
final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo831);
getDatabaseListTask.execute();
assertEquals(null, getDatabaseListTask.getErrorMsg());
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
for (DatabaseInfo dbInfo : databaseInfoList) {
if (dbInfo.getDbName().equals(testDbName831)) {
databaseInfo831 = dbInfo;
break;
}
}
if (databaseInfo831 == null) {
return;
}
}
//get CubridManager user list task
GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo831);
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(serverInfo831.getUserName())) {
serverInfo831.setLoginedUserInfo(userInfo);
break;
}
}
List<DatabaseInfo> databaseInfoList = serverInfo831.getLoginedUserInfo().getDatabaseInfoList();
String dbDir = databaseInfo831.getDbDir();
DbRunningType type = databaseInfo831.getRunningType();
for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
if (testDbName831.equalsIgnoreCase(databaseInfoList.get(i).getDbName())) {
databaseInfo831 = databaseInfoList.get(i);
databaseInfo831.setDbDir(dbDir);
databaseInfo831.setBrokerIP(host831);
databaseInfo831.setBrokerPort(port831);
databaseInfo831.setCharSet(charset831);
databaseInfo831.setRunningType(type);
break;
}
}
//get CUBRID conf parameter
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo831);
getCubridConfParameterTask.execute();
assertEquals(null, getCubridConfParameterTask.getErrorMsg());
Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
if (serverInfo831 != null) {
serverInfo831.setCubridConfParaMap(confParas);
}
//get broker Info
GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(serverInfo831);
getBrokerConfParameterTask.execute();
assertEquals(null, getBrokerConfParameterTask.getErrorMsg());
confParas = getBrokerConfParameterTask.getConfParameters();
if (serverInfo831 != null) {
serverInfo831.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);
serverInfo831.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);
serverInfo831.setJdbcDriverVersion(version);
}
}
}
Aggregations