Search in sources :

Example 11 with HostNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.HostNode in project cubrid-manager by CUBRID.

the class CreateReplicationUtil method createReplServerTaskGroup.

/**
	 * 
	 * Fill in the related tasks of replication server to executor
	 * 
	 * @param master MasterNode
	 * @param executor CreateReplicationJobExecutor
	 * @return null or error message
	 */
public static String createReplServerTaskGroup(MasterNode master, CreateReplicationJobExecutor executor) {
    TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_START_REPL_SERVER);
    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);
    }
    StartReplServerTask startReplServerTask = new StartReplServerTask(serverInfo);
    startReplServerTask.setDbName(master.getDbName());
    startReplServerTask.setServerPort(master.getReplServerPort());
    taskGroup.addTask(startReplServerTask);
    executor.addGroupTask(taskGroup);
    return null;
}
Also used : 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) StartReplServerTask(com.cubrid.cubridmanager.core.replication.task.StartReplServerTask) TaskGroup(com.cubrid.common.ui.spi.progress.TaskGroup)

Example 12 with HostNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.HostNode in project cubrid-manager by CUBRID.

the class CreateReplicationUtil method createDistributorTaskGroup.

/**
	 * 
	 * Fill in the related task of creating distributor to executor
	 * 
	 * @param master MasterNode
	 * @param dist DistributorNode
	 * @param executor CreateReplicationJobExecutor
	 * @return null or error message
	 */
public static String createDistributorTaskGroup(MasterNode master, DistributorNode dist, CreateReplicationJobExecutor executor) {
    TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_CREATE_DIST);
    taskGroup.setTarget(dist.getDbName());
    HostNode distdbHost = (HostNode) dist.getParent();
    HostNode masterHost = (HostNode) master.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);
    }
    addCheckDbTaskGroup(serverInfo, dist.getDbName(), taskGroup);
    CreateDistributorTask createDistributorTask = new CreateDistributorTask(serverInfo);
    createDistributorTask.setDistDbName(dist.getDbName());
    createDistributorTask.setDistDbPath(dist.getDbPath());
    createDistributorTask.setDbaPassword(dist.getDbaPassword());
    createDistributorTask.setReplAgentPort(dist.getReplAgentPort());
    createDistributorTask.setMasterDbName(master.getDbName());
    createDistributorTask.setMasterDbIp(masterHost.getIp());
    createDistributorTask.setReplServerPort(master.getReplServerPort());
    createDistributorTask.setCopyLogPath(dist.getCopyLogPath());
    createDistributorTask.setErrorLogPath(dist.getErrorLogPath());
    createDistributorTask.setTrailLogPath(dist.getTrailLogPath());
    createDistributorTask.setDelayTimeLogSize(dist.getDelayTimeLogSize());
    createDistributorTask.setRestartRepl(dist.isRestartWhenError());
    taskGroup.addTask(createDistributorTask);
    executor.addGroupTask(taskGroup);
    return null;
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CreateDistributorTask(com.cubrid.cubridmanager.core.replication.task.CreateDistributorTask) 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)

Example 13 with HostNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.HostNode 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)

Example 14 with HostNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.HostNode in project cubrid-manager by CUBRID.

the class SetMasterDbInfoWizard method performFinish.

/**
	 * Called when user clicks Finish
	 * 
	 * @return boolean
	 */
public boolean performFinish() {
    String mdbName = selectDatabasePage.getDbName();
    String dbaPassword = selectDatabasePage.getDbaPassword();
    String replServerPort = selectDatabasePage.getReplServerPort();
    List<String> replTableList = selectClassesPage.getReplTableList();
    boolean isReplAllTables = selectClassesPage.isReplAllTables();
    String dbPath = "";
    HostNode host = (HostNode) master.getParent();
    List<DatabaseInfo> dbInfoList = host.getDatabaseInfoList();
    for (int i = 0; dbInfoList != null && i < dbInfoList.size(); i++) {
        DatabaseInfo dbInfo = dbInfoList.get(i);
        if (mdbName.equalsIgnoreCase(dbInfo.getDbName())) {
            dbPath = dbInfo.getDbDir();
        }
    }
    master.setDbName(mdbName);
    master.setDbaPassword(dbaPassword);
    master.setReplServerPort(replServerPort);
    master.setReplicatedClassList(replTableList);
    master.setReplicateAll(isReplAllTables);
    master.setName(mdbName);
    master.setDbPath(dbPath);
    return true;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode)

Example 15 with HostNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.HostNode in project cubrid-manager by CUBRID.

the class ContainerNodePart method performRequest.

/**
	 * @see org.eclipse.gef.editparts.AbstractEditPart#performRequest(org.eclipse.gef.Request)
	 * @param req Request
	 */
public void performRequest(Request req) {
    if (req.getType() == RequestConstants.REQ_OPEN && getContainerNode() instanceof HostNode) {
        Shell shell = replEditor.getSite().getShell();
        SetHostInfoDialog dialog = new SetHostInfoDialog(shell);
        dialog.setHostInfo((HostNode) getContainerNode());
        dialog.setEditable(replEditor.isEditable());
        dialog.open();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) SetHostInfoDialog(com.cubrid.cubridmanager.ui.replication.editor.dialog.SetHostInfoDialog)

Aggregations

HostNode (com.cubrid.cubridmanager.ui.replication.editor.model.HostNode)15 TaskGroup (com.cubrid.common.ui.spi.progress.TaskGroup)7 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)7 SlaveNode (com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode)5 DistributorNode (com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)4 MasterNode (com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode)4 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 ContainerNode (com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode)3 ArrayList (java.util.ArrayList)3 Point (org.eclipse.draw2d.geometry.Point)3 CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)2 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)2 SetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.SetCubridConfParameterTask)2 BackupDbTask (com.cubrid.cubridmanager.core.cubrid.database.task.BackupDbTask)2 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)2 CreateDistributorTask (com.cubrid.cubridmanager.core.replication.task.CreateDistributorTask)2 GetReplServerStatusTask (com.cubrid.cubridmanager.core.replication.task.GetReplServerStatusTask)2 StopReplServerTask (com.cubrid.cubridmanager.core.replication.task.StopReplServerTask)2 SetHostInfoDialog (com.cubrid.cubridmanager.ui.replication.editor.dialog.SetHostInfoDialog)2