use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask 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);
}
use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask 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.GetCMConfParameterTask in project cubrid-manager by CUBRID.
the class AddStatusMonitorTemplateAction method run.
/**
* Override the run method in order to open an instance of status monitor
* dialog
*
*/
public void run() {
Object[] obj = this.getSelectedObj();
ICubridNode selection = (ICubridNode) obj[0];
ServerInfo site = selection.getServer().getServerInfo();
boolean execDiagChecked = false;
final GetCMConfParameterTask task = new GetCMConfParameterTask(site);
TaskExecutor taskExec = new CommonTaskExec(null);
taskExec.addTask(task);
new ExecTaskWithProgress(taskExec).exec();
if (!taskExec.isSuccess()) {
return;
}
Map<String, String> confParas = task.getConfParameters();
if (confParas == null) {
execDiagChecked = false;
} else {
if (confParas.get(ConfConstants.EXECUTE_DIAG) == null) {
execDiagChecked = false;
} else {
execDiagChecked = confParas.get(ConfConstants.EXECUTE_DIAG).equals(OnOffType.ON.getText()) ? true : false;
}
}
DiagStatusMonitorTemplateDialog dialog = new DiagStatusMonitorTemplateDialog(getShell());
dialog.setOperation(AddEditType.ADD);
dialog.setSelection(selection);
dialog.setExecDiagChecked(execDiagChecked);
if (dialog.open() == Dialog.OK) {
StatusTemplateInfo statusTemplateInfo = dialog.getStatusTemplateInfo();
AddStatusTemplateTask addTask = new AddStatusTemplateTask(site);
addTask.setStatusTemplateInfo(statusTemplateInfo);
addTask.buildMsg();
String taskName = Messages.bind(Messages.addTemplateTaskName, statusTemplateInfo.getName());
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(addTask);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
CommonUITool.refreshNavigatorTree(treeViewer, selection);
}
}
}
use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask in project cubrid-manager by CUBRID.
the class EditStatusMonitorTemplateAction method run.
/**
* Override the run method in order to open an instance of status monitor
* dialog
*
*/
public void run() {
Object[] obj = this.getSelectedObj();
ICubridNode selection = (ICubridNode) obj[0];
ServerInfo serverInfo = selection.getServer().getServerInfo();
boolean execDiagChecked = false;
final GetCMConfParameterTask task = new GetCMConfParameterTask(serverInfo);
TaskExecutor taskExec = new CommonTaskExec(null);
taskExec.addTask(task);
new ExecTaskWithProgress(taskExec).exec();
if (!taskExec.isSuccess()) {
return;
}
Map<String, String> confParas = task.getConfParameters();
if (confParas == null) {
execDiagChecked = false;
} else {
if (confParas.get(ConfConstants.EXECUTE_DIAG) == null) {
execDiagChecked = false;
} else {
execDiagChecked = confParas.get(ConfConstants.EXECUTE_DIAG).equals(OnOffType.ON.getText()) ? true : false;
}
}
DiagStatusMonitorTemplateDialog dialog = new DiagStatusMonitorTemplateDialog(getShell());
dialog.setOperation(AddEditType.EDIT);
dialog.setSelection(selection);
dialog.setExecDiagChecked(execDiagChecked);
if (dialog.open() == Dialog.OK) {
StatusTemplateInfo statusTemplateInfo = dialog.getStatusTemplateInfo();
UpdateStatusTemplateTask updateTask = new UpdateStatusTemplateTask(serverInfo);
updateTask.setStatusTemplateInfo(statusTemplateInfo);
updateTask.buildMsg();
String taskName = Messages.bind(Messages.editTemplateTaskName, statusTemplateInfo.getName());
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(updateTask);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
CommonUITool.refreshNavigatorTree(treeViewer, selection.getParent());
}
}
}
use of com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask in project cubrid-manager by CUBRID.
the class SetHostInfoDialog method connect.
/**
* connect the host
*
* @param buttonId int
*/
private void connect(final int buttonId) {
final String ip = ipText.getText();
final String port = portText.getText();
final String userName = userNameText.getText();
final String password = passwordText.getText();
boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
if (isConnected && hostInfo != null) {
ServerInfo serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(ip, Integer.parseInt(port), userName);
if (!serverInfo.getLoginedUserInfo().isAdmin()) {
CommonUITool.openErrorBox(Messages.bind(Messages.errInvalidUser, ip));
return;
}
hostInfo.setIp(ip);
hostInfo.setPort(port);
hostInfo.setUserName(userName);
hostInfo.setPassword(password);
hostInfo.setName(ip + ":" + port);
List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
hostInfo.setDatabaseInfoList(databaseInfoList);
hostInfo.setDbPath(serverInfo.getEnvInfo().getDatabaseDir());
hostInfo.setOsInfoType(serverInfo.getServerOsInfo());
setReturnCode(buttonId);
close();
return;
}
if (!isConnected) {
final ServerInfo serverInfo = new ServerInfo();
serverInfo.setHostAddress(ip);
serverInfo.setHostMonPort(Integer.parseInt(port));
serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
serverInfo.setUserName(userName);
serverInfo.setUserPassword(password);
TaskExecutor taskExcutor = new ConnectHostTaskExecutor(serverInfo, buttonId);
MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
taskExcutor.addTask(monitoringTask);
GetEnvInfoTask getEnvInfoTask = new GetEnvInfoTask(serverInfo);
taskExcutor.addTask(getEnvInfoTask);
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo);
taskExcutor.addTask(getCMConfParameterTask);
GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
taskExcutor.addTask(getDatabaseListTask);
new ExecTaskWithProgress(taskExcutor).exec(true, true);
}
}
Aggregations