use of com.cubrid.cubridmanager.core.common.task.MonitoringTask 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.MonitoringTask 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.MonitoringTask in project cubrid-manager by CUBRID.
the class ChangeSlaveDbWizard method createTransferTaskGroup.
/**
* create task group of transfer master backup file to slave
*
* @param executor CreateReplicationSlaveDbJobExecutor
* @return boolean
*/
public boolean createTransferTaskGroup(CreateReplicationSlaveDbJobExecutor executor) {
final String ip = slaveDbInfoPage.getMasterHostIp();
final String port = slaveDbInfoPage.getMasterHostPort();
final String userName = "admin";
final String password = slaveDbInfoPage.getMasterHostPassword();
boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
ServerInfo masterServerInfo = new ServerInfo();
String mdbName = slaveDbInfoPage.getMasterDbName();
TaskGroup taskGroup = new TaskGroup(REPL_GROUP_NAME_TRANSFER);
taskGroup.setTarget(mdbName);
if (isConnected) {
masterServerInfo = CMHostNodePersistManager.getInstance().getServerInfo(ip, Integer.parseInt(port), userName);
} else {
masterServerInfo.setHostAddress(ip);
masterServerInfo.setHostMonPort(Integer.parseInt(port));
masterServerInfo.setHostJSPort(Integer.parseInt(port) + 1);
masterServerInfo.setUserName(userName);
masterServerInfo.setUserPassword(password);
MonitoringTask monitoringTask = new MonitoringTask(masterServerInfo);
taskGroup.addTask(monitoringTask);
}
GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(masterServerInfo);
getDatabaseListTask.putData("dbName", mdbName);
taskGroup.addTask(getDatabaseListTask);
BackupDbTask backupDbTask = new BackupDbTask(masterServerInfo);
backupDbTask.setDbName(mdbName);
backupDbTask.setLevel("0");
backupDbTask.setVolumeName(mdbName + "_bk0v000");
backupDbTask.setRemoveLog(false);
backupDbTask.setCheckDatabaseConsist(true);
backupDbTask.setThreadCount(String.valueOf(0));
backupDbTask.setZiped(false);
backupDbTask.setSafeReplication(false);
taskGroup.addTask(backupDbTask);
CancelTransFileTask cancelTransFileTask = new CancelTransFileTask(masterServerInfo);
taskGroup.addTask(cancelTransFileTask);
for (int i = 0; i < replInfo.getSlaveList().size(); i++) {
TransFileTask transFileTask = new TransFileTask(masterServerInfo);
List<String> fileList = new ArrayList<String>();
fileList.add(slaveDbInfoPage.getMasterDbName() + "_bk0v000");
fileList.add(slaveDbInfoPage.getMasterDbName() + "_bkvinf");
transFileTask.setBackupFileList(fileList);
transFileTask.setSlaveDbHost(database.getServer().getServerInfo().getHostAddress());
transFileTask.setSlaveCmServerPort(String.valueOf(database.getServer().getServerInfo().getHostMonPort() + 1));
transFileTask.setSlaveDbDir(slaveDbInfoPage.getSlaveDbPath());
taskGroup.addTask(transFileTask);
GetTransferProgressTask getTransferProgressTask = new GetTransferProgressTask(masterServerInfo);
taskGroup.addTask(getTransferProgressTask);
}
executor.addGroupTask(taskGroup);
return true;
}
use of com.cubrid.cubridmanager.core.common.task.MonitoringTask in project cubrid-manager by CUBRID.
the class CreateReplicationUtil method createAgentTaskGroup.
/**
*
* Fill in the related tasks of agent to executor
*
* @param dist DistributorNode
* @param executor CreateReplicationJobExecutor
* @return null or error message
*/
public static String createAgentTaskGroup(DistributorNode dist, CreateReplicationJobExecutor executor) {
TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_START_AGENT);
taskGroup.setTarget(dist.getDbName());
HostNode distdbHost = (HostNode) dist.getParent();
final String ip = distdbHost.getIp();
final String port = distdbHost.getPort();
final String userName = distdbHost.getUserName();
final String password = distdbHost.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);
}
GetReplAgentStatusTask getReplAgentStatusTask = new GetReplAgentStatusTask(serverInfo);
getReplAgentStatusTask.setDbName(dist.getDbName());
taskGroup.addTask(getReplAgentStatusTask);
StopReplicationAgentTask stopReplicationAgentTask = new StopReplicationAgentTask(serverInfo);
stopReplicationAgentTask.setDbName(dist.getDbName());
taskGroup.addTask(stopReplicationAgentTask);
StartReplicationAgentTask startReplicationAgentTask = new StartReplicationAgentTask(serverInfo);
startReplicationAgentTask.setDbName(dist.getDbName());
startReplicationAgentTask.setDbaPasswd(dist.getDbaPassword());
taskGroup.addTask(startReplicationAgentTask);
executor.addGroupTask(taskGroup);
return null;
}
use of com.cubrid.cubridmanager.core.common.task.MonitoringTask 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;
}
Aggregations