use of com.cubrid.cubridmanager.core.replication.task.StartReplicationAgentTask 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.cubridmanager.core.replication.task.StartReplicationAgentTask in project cubrid-manager by CUBRID.
the class StartReplicationAgentAction method run.
/**
* Start replication agent and refresh navigator
*/
public void run() {
Object[] obj = this.getSelectedObj();
if (obj == null || obj.length == 0 || !isSupported(obj[0])) {
setEnabled(false);
return;
}
ISchemaNode schemaNode = (ISchemaNode) obj[0];
CubridDatabase database = schemaNode.getDatabase();
String dbNames = database.getName();
String dbaPassword = database.getPassword();
ReplicationInfo replInfo = (ReplicationInfo) database.getAdapter(ReplicationInfo.class);
if (!CommonUITool.openConfirmBox(Messages.bind(Messages.msgConfirmStartMasterDbAndSlaveDb, replInfo.getMasterList().get(0).getMasterDbName(), replInfo.getSlaveList().get(0).getSlaveDbName()))) {
return;
}
StartReplicationAgentTask task = new StartReplicationAgentTask(database.getServer().getServerInfo());
task.setDbName(dbNames);
task.setDbaPasswd(dbaPassword);
TaskExecutor taskExecutor = new CommonTaskExec(null);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
CommonUITool.openInformationBox(Messages.msgSuccess, Messages.bind(Messages.msgStartAgent, dbNames));
if (replInfo != null && replInfo.getDistInfo() != null) {
replInfo.getDistInfo().setAgentActive(true);
}
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
Aggregations