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;
}
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;
}
Aggregations