use of com.cubrid.common.ui.spi.progress.TaskGroup 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.common.ui.spi.progress.TaskGroup 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.common.ui.spi.progress.TaskGroup 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.common.ui.spi.progress.TaskGroup in project cubrid-manager by CUBRID.
the class CreateReplicationJobExecutor method exec.
/**
* @see com.cubrid.common.ui.spi.progress.TaskJobExecutor#exec(org.eclipse.core.runtime.IProgressMonitor)
* @param monitor the monitor object
* @return the status
*/
public IStatus exec(final IProgressMonitor monitor) {
List<TaskGroup> startReplSvrTaskGrpList = new ArrayList<TaskGroup>();
List<TaskGroup> startAgentTaskGrpList = new ArrayList<TaskGroup>();
for (int i = 0; i < groupTaskList.size(); i++) {
TaskGroup taskGroup = groupTaskList.get(i);
String groupName = taskGroup.getGroupName();
String target = (String) taskGroup.getTarget();
List<ITask> taskList = taskGroup.getTaskList();
IStatus status = Status.OK_STATUS;
if (IConstants.REPL_GROUP_NAME_CREATE_MASTER.equals(groupName)) {
status = createMaster(target, monitor, taskList);
} else if (IConstants.REPL_GROUP_NAME_CREATE_DIST.equals(groupName)) {
status = createDistributor(target, monitor, taskList);
} else if (IConstants.REPL_GROUP_NAME_CREATE_SLAVE.equals(groupName)) {
status = createSlave(target, monitor, taskList);
} else if (IConstants.REPL_GROUP_NAME_START_REPL_SERVER.equals(groupName)) {
startReplSvrTaskGrpList.add(taskGroup);
} else if (IConstants.REPL_GROUP_NAME_START_AGENT.equals(groupName)) {
startAgentTaskGrpList.add(taskGroup);
}
if (monitor.isCanceled()) {
setEditorDirty();
return Status.CANCEL_STATUS;
}
if (status != Status.OK_STATUS) {
setEditorDirty();
return status;
}
}
Display display = Display.getDefault();
if (!startReplSvrTaskGrpList.isEmpty()) {
for (TaskGroup startReplServerTaskGrp : startReplSvrTaskGrpList) {
final String target = (String) startReplServerTaskGrp.getTarget();
display.syncExec(new Runnable() {
public void run() {
isStartReplServer = CommonUITool.openConfirmBox(shell, Messages.bind(Messages.msgConfirmStartReplServer, target));
}
});
if (!isStartReplServer) {
continue;
}
List<ITask> taskList = startReplServerTaskGrp.getTaskList();
IStatus status = startReplServer(target, monitor, taskList);
if (monitor.isCanceled()) {
setEditorDirty();
return Status.CANCEL_STATUS;
}
if (status != Status.OK_STATUS) {
setEditorDirty();
return status;
}
}
}
if (!startAgentTaskGrpList.isEmpty()) {
for (TaskGroup startAgentTaskGrp : startAgentTaskGrpList) {
final String target = (String) startAgentTaskGrp.getTarget();
display.syncExec(new Runnable() {
public void run() {
isStartAgent = CommonUITool.openConfirmBox(shell, Messages.bind(Messages.msgConfirmStartAgent, target));
}
});
if (!isStartAgent) {
continue;
}
List<ITask> taskList = startAgentTaskGrp.getTaskList();
IStatus status = startAgent(target, monitor, taskList);
if (monitor.isCanceled()) {
setEditorDirty();
return Status.CANCEL_STATUS;
}
if (status != Status.OK_STATUS) {
setEditorDirty();
return status;
}
}
}
return Status.OK_STATUS;
}
use of com.cubrid.common.ui.spi.progress.TaskGroup in project cubrid-manager by CUBRID.
the class CreateReplicationUtil method createMasterTaskGroup.
/**
*
* Fill in the related tasks of creating master to executor according master
* information
*
* @param master MasterNode
* @param slaveList List<SlaveNode>
* @param executor CreateReplicationJobExecutor
* @return null or error message
*/
public static String createMasterTaskGroup(MasterNode master, List<SlaveNode> slaveList, CreateReplicationJobExecutor executor) {
TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_CREATE_MASTER);
taskGroup.setTarget(master.getDbName());
HostNode masterHost = (HostNode) master.getParent();
final String ip = masterHost.getIp();
final String port = masterHost.getPort();
final String userName = masterHost.getUserName();
final String password = masterHost.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(master.getDbName());
taskGroup.addTask(getReplServerStatusTask);
StopReplServerTask stopReplServerTask = new StopReplServerTask(serverInfo);
stopReplServerTask.setDbName(master.getDbName());
taskGroup.addTask(stopReplServerTask);
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
getCubridConfParameterTask.putData("dbName", master.getDbName());
taskGroup.addTask(getCubridConfParameterTask);
SetCubridConfParameterTask setCubridConfParameterTask = new SetCubridConfParameterTask(serverInfo);
taskGroup.addTask(setCubridConfParameterTask);
GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
getDatabaseListTask.putData("dbName", master.getDbName());
taskGroup.addTask(getDatabaseListTask);
CommonUpdateTask stopDbTask = new CommonUpdateTask(CommonTaskName.STOP_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
stopDbTask.setDbName(master.getDbName());
taskGroup.addTask(stopDbTask);
CommonUpdateTask startDbTask = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
startDbTask.setDbName(master.getDbName());
taskGroup.addTask(startDbTask);
BackupDbTask backupDbTask = new BackupDbTask(serverInfo);
backupDbTask.setDbName(master.getDbName());
backupDbTask.setLevel("0");
backupDbTask.setVolumeName(master.getDbName() + "_bk0v000");
backupDbTask.setBackupDir(master.getDbPath());
backupDbTask.setRemoveLog(false);
backupDbTask.setCheckDatabaseConsist(true);
backupDbTask.setThreadCount(String.valueOf(0));
backupDbTask.setZiped(false);
backupDbTask.setSafeReplication(false);
taskGroup.addTask(backupDbTask);
CancelTransFileTask cancelTransFileTask = new CancelTransFileTask(serverInfo);
taskGroup.addTask(cancelTransFileTask);
for (int i = 0; i < slaveList.size(); i++) {
SlaveNode slave = slaveList.get(i);
HostNode slaveHost = (HostNode) slave.getParent();
TransFileTask transFileTask = new TransFileTask(serverInfo);
transFileTask.setMasterDbDir(master.getDbPath());
List<String> fileList = new ArrayList<String>();
fileList.add(master.getDbName() + "_bk0v000");
fileList.add(master.getDbName() + "_bkvinf");
transFileTask.setBackupFileList(fileList);
transFileTask.setSlaveDbHost(slaveHost.getIp());
transFileTask.setSlaveCmServerPort(String.valueOf(Integer.parseInt(slaveHost.getPort()) + 1));
transFileTask.setSlaveDbDir(slave.getDbPath());
taskGroup.addTask(transFileTask);
GetTransferProgressTask getTransferProgressTask = new GetTransferProgressTask(serverInfo);
taskGroup.addTask(getTransferProgressTask);
}
executor.addGroupTask(taskGroup);
return null;
}
Aggregations