Search in sources :

Example 1 with CreateDistributorTask

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

the class CreateReplicationUtil method createDistributorTaskGroup.

/**
	 * 
	 * Fill in the tasks of creating distributor to executor
	 * 
	 * @param master MasterNode
	 * @param slave SlaveNode
	 * @param dist DistributorNode
	 * @param executor CreateReplicationJobExecutor
	 * @return null or error message
	 */
public static String createDistributorTaskGroup(MasterNode master, SlaveNode slave, DistributorNode dist, CreateReplicationJobExecutor executor) {
    TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_CREATE_DIST);
    taskGroup.setTarget(dist.getDbName());
    HostNode distdbHost = (HostNode) dist.getParent();
    HostNode slaveHost = (HostNode) slave.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(slave.getDbName());
    createDistributorTask.setMasterDbIp(slaveHost.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 2 with CreateDistributorTask

use of com.cubrid.cubridmanager.core.replication.task.CreateDistributorTask 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)

Aggregations

TaskGroup (com.cubrid.common.ui.spi.progress.TaskGroup)2 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)2 CreateDistributorTask (com.cubrid.cubridmanager.core.replication.task.CreateDistributorTask)2 HostNode (com.cubrid.cubridmanager.ui.replication.editor.model.HostNode)2