Search in sources :

Example 1 with ChangeReplTablesTask

use of com.cubrid.cubridmanager.core.replication.task.ChangeReplTablesTask in project cubrid-manager by CUBRID.

the class ChangeReplTablesWizard method performFinish.

/**
	 * Called when user clicks Finish
	 *
	 * @return boolean
	 */
public boolean performFinish() {
    String mdbName = setDatabaseInfoPage.getMasterDbName();
    String distdbName = setDatabaseInfoPage.getDistributorDbName();
    String distdbPassword = setDatabaseInfoPage.getDistdbPassword();
    boolean isReplAllTables = changeTablesPage.isReplAllTables();
    List<String> replTableList = changeTablesPage.getReplTableList();
    TaskJobExecutor taskExcutor = new TaskJobExecutor() {

        public void closeUI() {
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    dialog.close();
                }
            });
        }

        public void setVisible(final boolean isVisible) {
            Display display = Display.getDefault();
            display.syncExec(new Runnable() {

                public void run() {
                    dialog.getShell().setVisible(isVisible);
                }
            });
        }

        public IStatus exec(final IProgressMonitor monitor) {
            setVisible(false);
            for (ITask task : taskList) {
                task.execute();
                if (monitor.isCanceled()) {
                    closeUI();
                    return Status.CANCEL_STATUS;
                }
                final String msg = task.getErrorMsg();
                if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
                    return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
                }
            }
            closeUI();
            return Status.OK_STATUS;
        }
    };
    ServerInfo serverInfo = replicationNode.getServer().getServerInfo();
    ChangeReplTablesTask task = new ChangeReplTablesTask(serverInfo);
    task.setMdbName(mdbName);
    task.setDistdbName(distdbName);
    task.setDistdbPassword(distdbPassword);
    task.setReplAllClasses(isReplAllTables);
    task.setReplicatedClasses(replTableList);
    taskExcutor.addTask(task);
    JobFamily jobFamily = new JobFamily();
    String serverName = replicationNode.getServer().getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(distdbName);
    String jobName = Messages.bind(Messages.changeReplicationSchemaJobName, new String[] { distdbName, serverName });
    taskExcutor.schedule(jobName, jobFamily, true, Job.SHORT);
    return false;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ChangeReplTablesTask(com.cubrid.cubridmanager.core.replication.task.ChangeReplTablesTask) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITask(com.cubrid.common.core.task.ITask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) Display(org.eclipse.swt.widgets.Display)

Example 2 with ChangeReplTablesTask

use of com.cubrid.cubridmanager.core.replication.task.ChangeReplTablesTask in project cubrid-manager by CUBRID.

the class ChangeSlaveDbWizard method createSlaveTaskGroup.

/**
	 * create slave database task group
	 * 
	 * @param executor CreateReplicationSlaveDbJobExecutor
	 * @return boolean
	 */
public boolean createSlaveTaskGroup(CreateReplicationSlaveDbJobExecutor executor) {
    TaskGroup taskGroup = new TaskGroup(REPL_GROUP_NAME_CREATE_SLAVE);
    taskGroup.setTarget(slaveDbInfoPage.getSlaveDbName());
    CreateReplicationUtil.addCheckDbTaskGroup(database.getServer().getServerInfo(), slaveDbInfoPage.getSlaveDbName(), taskGroup);
    GetReplAgentStatusTask getReplAgentStatusTask = new GetReplAgentStatusTask(database.getServer().getServerInfo());
    getReplAgentStatusTask.setDbName(database.getLabel());
    taskGroup.addTask(getReplAgentStatusTask);
    StopReplicationAgentTask stopReplicationAgentTask = new StopReplicationAgentTask(database.getServer().getServerInfo());
    stopReplicationAgentTask.setDbName(database.getLabel());
    taskGroup.addTask(stopReplicationAgentTask);
    CreateSlaveDbTask createSlaveDbTask = new CreateSlaveDbTask(database.getServer().getServerInfo());
    createSlaveDbTask.setSlaveDbName(slaveDbInfoPage.getSlaveDbName());
    createSlaveDbTask.setSlaveDbPath(slaveDbInfoPage.getSlaveDbPath());
    createSlaveDbTask.setSlaveDbUser(slaveDbInfoPage.getSlaveDbUser());
    createSlaveDbTask.setSlaveDbPassword(slaveDbInfoPage.getSlaveDbaPassword());
    createSlaveDbTask.setMasterDbName(slaveDbInfoPage.getMasterDbName());
    createSlaveDbTask.setMasterDbPassword(slaveDbInfoPage.getMasterDbDbaPassword());
    createSlaveDbTask.setDistDbName(database.getLabel());
    createSlaveDbTask.setDistDbaPassword(database.getPassword());
    taskGroup.addTask(createSlaveDbTask);
    SetReplicationParamTask setReplicationParamTask = new SetReplicationParamTask(database.getServer().getServerInfo());
    setReplicationParamTask.setMasterDbName(slaveDbInfoPage.getMasterDbName());
    setReplicationParamTask.setSlaveDbName(slaveDbInfoPage.getSlaveDbName());
    setReplicationParamTask.setDistDbName(database.getLabel());
    setReplicationParamTask.setDistDbDbaPasswd(database.getPassword());
    setReplicationParamTask.setParameterMap(setReplicationParamPage.getParamMap());
    setReplicationParamTask.setRunningMode(true);
    taskGroup.addTask(setReplicationParamTask);
    ChangeReplTablesTask changeReplTablesTask = new ChangeReplTablesTask(database.getServer().getServerInfo());
    changeReplTablesTask.setDistdbName(database.getLabel());
    changeReplTablesTask.setDistdbPassword(database.getPassword());
    changeReplTablesTask.setMdbName(slaveDbInfoPage.getMasterDbName());
    changeReplTablesTask.setMdbUserId("dba");
    changeReplTablesTask.setMdbPass(slaveDbInfoPage.getMasterDbDbaPassword());
    if (selectTablesPage.isReplAllTables()) {
        changeReplTablesTask.setReplAllClasses(selectTablesPage.isReplAllTables());
    } else if (selectTablesPage.getReplTableList() != null && selectTablesPage.getReplTableList().size() > 0) {
        changeReplTablesTask.setReplicatedClasses(selectTablesPage.getReplTableList());
    } else {
        changeReplTablesTask.setReplNoneClasses(true);
    }
    taskGroup.addTask(changeReplTablesTask);
    executor.addGroupTask(taskGroup);
    return true;
}
Also used : ChangeReplTablesTask(com.cubrid.cubridmanager.core.replication.task.ChangeReplTablesTask) CreateSlaveDbTask(com.cubrid.cubridmanager.core.replication.task.CreateSlaveDbTask) GetReplAgentStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask) StopReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask) TaskGroup(com.cubrid.common.ui.spi.progress.TaskGroup) SetReplicationParamTask(com.cubrid.cubridmanager.core.replication.task.SetReplicationParamTask)

Example 3 with ChangeReplTablesTask

use of com.cubrid.cubridmanager.core.replication.task.ChangeReplTablesTask in project cubrid-manager by CUBRID.

the class CreateReplicationUtil method createSlaveTaskGroup.

/**
	 * 
	 * Create the related task of creating slave database to executor
	 * 
	 * @param masterDb MasterNode
	 * @param distDb DistributorNode
	 * @param slaveDb SlaveNode
	 * @param executor CreateReplicationJobExecutor
	 * @return null or error message
	 */
public static String createSlaveTaskGroup(MasterNode masterDb, DistributorNode distDb, SlaveNode slaveDb, CreateReplicationJobExecutor executor) {
    TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_CREATE_SLAVE);
    taskGroup.setTarget(slaveDb.getDbName());
    HostNode slaveHost = (HostNode) slaveDb.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);
    }
    addCheckDbTaskGroup(serverInfo, slaveDb.getDbName(), taskGroup);
    CreateSlaveDbTask createSlaveDbTask = new CreateSlaveDbTask(serverInfo);
    createSlaveDbTask.setSlaveDbName(slaveDb.getDbName());
    createSlaveDbTask.setSlaveDbPath(slaveDb.getDbPath());
    createSlaveDbTask.setSlaveDbUser(slaveDb.getDbUser());
    createSlaveDbTask.setSlaveDbPassword(slaveDb.getDbPassword());
    createSlaveDbTask.setMasterDbName(masterDb.getDbName());
    createSlaveDbTask.setMasterDbPassword(masterDb.getDbaPassword());
    createSlaveDbTask.setDistDbName(distDb.getDbName());
    createSlaveDbTask.setDistDbaPassword(distDb.getDbaPassword());
    taskGroup.addTask(createSlaveDbTask);
    SetReplicationParamTask setReplicationParamTask = new SetReplicationParamTask(serverInfo);
    setReplicationParamTask.setMasterDbName(masterDb.getDbName());
    setReplicationParamTask.setSlaveDbName(slaveDb.getDbName());
    setReplicationParamTask.setDistDbName(distDb.getDbName());
    setReplicationParamTask.setDistDbDbaPasswd(distDb.getDbaPassword());
    setReplicationParamTask.setParameterMap(slaveDb.getParamMap());
    setReplicationParamTask.setRunningMode(true);
    taskGroup.addTask(setReplicationParamTask);
    ChangeReplTablesTask changeReplTablesTask = new ChangeReplTablesTask(serverInfo);
    changeReplTablesTask.setDistdbName(distDb.getDbName());
    changeReplTablesTask.setDistdbPassword(distDb.getDbaPassword());
    changeReplTablesTask.setMdbName(masterDb.getDbName());
    changeReplTablesTask.setMdbUserId("dba");
    changeReplTablesTask.setMdbPass(masterDb.getDbaPassword());
    if (masterDb.isReplicateAll()) {
        changeReplTablesTask.setReplAllClasses(masterDb.isReplicateAll());
    } else if (masterDb.getReplicatedClassList() != null && masterDb.getReplicatedClassList().size() > 0) {
        changeReplTablesTask.setReplicatedClasses(masterDb.getReplicatedClassList());
    } else {
        changeReplTablesTask.setReplNoneClasses(true);
    }
    taskGroup.addTask(changeReplTablesTask);
    executor.addGroupTask(taskGroup);
    return null;
}
Also used : ChangeReplTablesTask(com.cubrid.cubridmanager.core.replication.task.ChangeReplTablesTask) CreateSlaveDbTask(com.cubrid.cubridmanager.core.replication.task.CreateSlaveDbTask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) TaskGroup(com.cubrid.common.ui.spi.progress.TaskGroup) SetReplicationParamTask(com.cubrid.cubridmanager.core.replication.task.SetReplicationParamTask)

Aggregations

ChangeReplTablesTask (com.cubrid.cubridmanager.core.replication.task.ChangeReplTablesTask)3 TaskGroup (com.cubrid.common.ui.spi.progress.TaskGroup)2 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 CreateSlaveDbTask (com.cubrid.cubridmanager.core.replication.task.CreateSlaveDbTask)2 SetReplicationParamTask (com.cubrid.cubridmanager.core.replication.task.SetReplicationParamTask)2 ITask (com.cubrid.common.core.task.ITask)1 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)1 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)1 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)1 GetReplAgentStatusTask (com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask)1 StopReplicationAgentTask (com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask)1 HostNode (com.cubrid.cubridmanager.ui.replication.editor.model.HostNode)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 Display (org.eclipse.swt.widgets.Display)1