use of com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask in project cubrid-manager by CUBRID.
the class DBSpaceLabelProvider method saveAutoParam.
private void saveAutoParam(Set<String> settingAutoStartDB) {
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
getCubridConfParameterTask.execute();
if (!getCubridConfParameterTask.isSuccess()) {
CommonUITool.openInformationBox(com.cubrid.cubridmanager.ui.common.Messages.titleError, getCubridConfParameterTask.getErrorMsg());
return;
}
List<String> cubridConfContentList = getCubridConfParameterTask.getConfContents();
List<String> currentAutoStartDBList = getCubridConfParameterTask.getAutoStartDb(false);
/*Merge the data*/
for (String db : currentAutoStartDBList) {
if (!settingAutoStartDB.contains(db)) {
cubridConfContentList = CoreUtils.deleteDatabaseFromServiceServer(getCubridConfParameterTask, cubridConfContentList, db);
}
}
for (String db : settingAutoStartDB) {
if (!currentAutoStartDBList.contains(db)) {
cubridConfContentList = CoreUtils.addDatabaseToServiceServer(getCubridConfParameterTask, cubridConfContentList, db);
}
}
/*Update the config*/
SetCubridConfParameterTask setParaTask = new SetCubridConfParameterTask(serverInfo);
setParaTask.setConfContents(cubridConfContentList);
CommonTaskExec taskExcutor = new CommonTaskExec(com.cubrid.cubridmanager.ui.common.Messages.setCubridParameterTaskName);
taskExcutor.addTask(setParaTask);
new ExecTaskWithProgress(taskExcutor).exec(true, true);
if (taskExcutor.isSuccess()) {
isDirty = false;
updateToolBar();
CommonUITool.openInformationBox(com.cubrid.cubridmanager.ui.common.Messages.titleSuccess, com.cubrid.cubridmanager.ui.common.Messages.msgChangeServiceParaSuccess);
}
}
use of com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask in project cubrid-manager by CUBRID.
the class ConnectHostJobExecutor method exec.
/**
* Execute to connect host
*
* @param monitor the IProgressMonitor
* @return <code>true</code> if successful;<code>false</code>otherwise;
*/
@SuppressWarnings("unchecked")
public IStatus exec(final IProgressMonitor monitor) {
monitor.subTask(Messages.bind(com.cubrid.cubridmanager.ui.mondashboard.Messages.jobConnectHost, serverInfo.getHostAddress()));
isContinue = true;
boolean isRunUpdateCmUserTask = false;
BrokerInfos brokerInfos = null;
errorMsg = null;
for (ITask task : taskList) {
if (task instanceof MonitoringTask) {
IStatus status = connectHost((MonitoringTask) task);
if (Status.OK_STATUS != status) {
return status;
}
} else if ((task instanceof UpdateCMUserTask)) {
updateCMUserAuthInfo(task, isRunUpdateCmUserTask);
} else if ((task instanceof GetHeartbeatNodeInfoTask) && !CompatibleUtil.isSupportHA(serverInfo)) {
continue;
} else {
task.execute();
}
final String msg = task.getErrorMsg();
if (monitor.isCanceled()) {
disConnect();
return Status.CANCEL_STATUS;
}
if (!hostNode.isConnecting()) {
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0) {
disConnect();
if (isPing) {
errorMsg = msg;
return Status.CANCEL_STATUS;
}
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
}
if (task instanceof GetEnvInfoTask) {
GetEnvInfoTask getEnvInfoTask = (GetEnvInfoTask) task;
EnvInfo envInfo = getEnvInfoTask.loadEnvInfo();
serverInfo.setEnvInfo(envInfo);
String clientVersion = Version.buildVersionId.substring(0, Version.buildVersionId.lastIndexOf("."));
if (!CompatibleUtil.isSupportCMServer(serverInfo, clientVersion)) {
disConnect();
errorMsg = Messages.bind(Messages.errNoSupportServerVersion, clientVersion);
if (isPing) {
return Status.CANCEL_STATUS;
}
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, errorMsg);
}
if (!serverInfo.validateJdbcVersion(serverInfo.getJdbcDriverVersion())) {
disConnect();
if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(serverInfo.getJdbcDriverVersion())) {
errorMsg = Messages.errNoSupportDriver;
} else {
errorMsg = Messages.errSelectSupportDriver;
}
if (isPing) {
return Status.CANCEL_STATUS;
}
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, errorMsg);
}
} else if (task instanceof GetDatabaseListTask) {
GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
if (databaseInfoList != null) {
allDatabaseInfoList.addAll(databaseInfoList);
}
} else if (task instanceof GetCMConfParameterTask) {
GetCMConfParameterTask getCMConfParameterTask = (GetCMConfParameterTask) task;
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);
}
} else if (task instanceof CommonQueryTask) {
CommonQueryTask<BrokerInfos> getBrokerTask = (CommonQueryTask<BrokerInfos>) task;
brokerInfos = getBrokerTask.getResultModel();
if (serverInfo != null) {
serverInfo.setBrokerInfos(brokerInfos);
}
} else if (task instanceof GetCMUserListTask) {
if (serverInfo != null && serverInfo.isConnected()) {
GetCMUserListTask getUserInfoTask = (GetCMUserListTask) task;
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();
if (databaseInfoList != null) {
authDatabaseList.addAll(databaseInfoList);
}
isRunUpdateCmUserTask = CubridDatabasesFolderLoader.filterDatabaseList(serverInfo, allDatabaseInfoList, authDatabaseList);
if (isRunUpdateCmUserTask) {
serverInfo.getLoginedUserInfo().setDatabaseInfoList(authDatabaseList);
}
}
} else if (task instanceof GetCubridConfParameterTask) {
GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
if (serverInfo != null) {
serverInfo.setCubridConfParaMap(confParas);
}
} else if (task instanceof GetBrokerConfParameterTask) {
GetBrokerConfParameterTask getBrokerConfParameterTask = (GetBrokerConfParameterTask) task;
Map<String, Map<String, String>> confParas = getBrokerConfParameterTask.getConfParameters();
if (serverInfo != null) {
serverInfo.setBrokerConfParaMap(confParas);
}
} else if (task instanceof GetHeartbeatNodeInfoTask) {
GetHeartbeatNodeInfoTask getHeartbeatNodeInfoTask = (GetHeartbeatNodeInfoTask) task;
haHostStatusInfo = getHeartbeatNodeInfoTask.getHostStatusInfo(serverInfo.getHostAddress());
}
if (monitor.isCanceled() || !isContinue) {
disConnect();
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
use of com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask in project cubrid-manager by CUBRID.
the class CreateReplicationUtil method createSlaveMasterTaskGroup.
/**
*
* Fill in the related tasks of creating master to executor according to
* slave and master information,this slave node is also master node.
*
* @param master MasterNode
* @param slave SlaveNode
* @param executor CreateReplicationJobExecutor
* @return null or error message
*/
public static String createSlaveMasterTaskGroup(MasterNode master, SlaveNode slave, CreateReplicationJobExecutor executor) {
TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_CREATE_MASTER);
taskGroup.setTarget(master.getDbName());
HostNode slaveHost = (HostNode) slave.getParent();
final String ip = slaveHost.getIp();
final String port = slaveHost.getPort();
final String userName = slaveHost.getUserName();
final String password = slaveHost.getPassword();
boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
ServerInfo serverInfo = new ServerInfo();
if (isConnected) {
serverInfo = ServerManager.getInstance().getServer(ip, Integer.parseInt(port), userName);
if (!serverInfo.getLoginedUserInfo().isAdmin()) {
return Messages.bind(Messages.errInvalidUser, ip);
}
} else {
serverInfo.setHostAddress(ip);
serverInfo.setHostMonPort(Integer.parseInt(port));
serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
serverInfo.setUserName(userName);
serverInfo.setUserPassword(password);
MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
taskGroup.addTask(monitoringTask);
}
GetReplServerStatusTask getReplServerStatusTask = new GetReplServerStatusTask(serverInfo);
getReplServerStatusTask.setDbName(slave.getDbName());
taskGroup.addTask(getReplServerStatusTask);
StopReplServerTask stopReplServerTask = new StopReplServerTask(serverInfo);
stopReplServerTask.setDbName(slave.getDbName());
taskGroup.addTask(stopReplServerTask);
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
getCubridConfParameterTask.putData("dbName", slave.getDbName());
taskGroup.addTask(getCubridConfParameterTask);
SetCubridConfParameterTask setCubridConfParameterTask = new SetCubridConfParameterTask(serverInfo);
taskGroup.addTask(setCubridConfParameterTask);
GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
getDatabaseListTask.putData("dbName", slave.getDbName());
taskGroup.addTask(getDatabaseListTask);
CommonUpdateTask stopDbTask = new CommonUpdateTask(CommonTaskName.STOP_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
stopDbTask.setDbName(slave.getDbName());
taskGroup.addTask(stopDbTask);
CommonUpdateTask startDbTask = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
startDbTask.setDbName(slave.getDbName());
taskGroup.addTask(startDbTask);
BackupDbTask backupDbTask = new BackupDbTask(serverInfo);
backupDbTask.setDbName(slave.getDbName());
backupDbTask.setLevel("0");
backupDbTask.setVolumeName(slave.getDbName() + "_bk0v000");
backupDbTask.setBackupDir(slave.getDbPath());
backupDbTask.setRemoveLog(false);
backupDbTask.setCheckDatabaseConsist(true);
backupDbTask.setThreadCount(String.valueOf(0));
backupDbTask.setZiped(false);
backupDbTask.setSafeReplication(false);
taskGroup.addTask(backupDbTask);
executor.addGroupTask(taskGroup);
return null;
}
use of com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask in project cubrid-manager by CUBRID.
the class ConfigParaHelp method performGetCubridConf.
/**
* Perform the task of get cubrid.conf
*
* @param serverInfo the CubridServer
* @return the List<String>
*/
public static List<String> performGetCubridConf(ServerInfo serverInfo) {
List<String> confContent = new ArrayList<String>();
CommonTaskExec taskExcutor = new CommonTaskExec(com.cubrid.cubridmanager.ui.host.Messages.getCubridConfTaskRunning);
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
taskExcutor.addTask(getCubridConfParameterTask);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (taskExcutor.isSuccess()) {
confContent = getCubridConfParameterTask.getConfContents();
}
return confContent;
}
use of com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask 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