Search in sources :

Example 1 with StartReplicationAgentTask

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;
}
Also used : GetReplAgentStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) StopReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) StartReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StartReplicationAgentTask) TaskGroup(com.cubrid.common.ui.spi.progress.TaskGroup)

Example 2 with StartReplicationAgentTask

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());
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) StartReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StartReplicationAgentTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

StartReplicationAgentTask (com.cubrid.cubridmanager.core.replication.task.StartReplicationAgentTask)2 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 TaskGroup (com.cubrid.common.ui.spi.progress.TaskGroup)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)1 ReplicationInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationInfo)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