Search in sources :

Example 11 with ReplicationInfo

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

Example 12 with ReplicationInfo

use of com.cubrid.cubridmanager.core.replication.model.ReplicationInfo in project cubrid-manager by CUBRID.

the class StopReplicationAgentAction method isSupportedNode.

/**
	 * @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
	 *      .lang.Object)
	 * @param obj Object
	 * @return boolean(whether to support)
	 */
public static boolean isSupportedNode(Object obj) {
    if (obj instanceof CubridDatabase) {
        CubridDatabase database = (CubridDatabase) obj;
        if (!database.isLogined()) {
            return false;
        }
        ServerUserInfo serverUserInfo = database.getServer().getServerInfo().getLoginedUserInfo();
        if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
            return false;
        }
        if (!database.isDistributorDb()) {
            return false;
        }
        ReplicationInfo replInfo = (ReplicationInfo) database.getAdapter(ReplicationInfo.class);
        if (replInfo != null && replInfo.getDistInfo() != null) {
            return replInfo.getDistInfo().isAgentActive();
        }
        return false;
    }
    return false;
}
Also used : ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 13 with ReplicationInfo

use of com.cubrid.cubridmanager.core.replication.model.ReplicationInfo in project cubrid-manager by CUBRID.

the class StopReplicationAgentAction method run.

/**
	 * Start database and refresh navigator
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode schemaNode = (ISchemaNode) obj[0];
    CubridDatabase database = schemaNode.getDatabase();
    String dbNames = database.getName();
    boolean isStop = CommonUITool.openConfirmBox(getShell(), Messages.bind(Messages.msgConfirmStopAgent, dbNames));
    if (!isStop) {
        return;
    }
    ReplicationInfo replInfo = (ReplicationInfo) database.getAdapter(ReplicationInfo.class);
    StopReplicationAgentTask task = new StopReplicationAgentTask(database.getServer().getServerInfo());
    task.setDbName(dbNames);
    TaskExecutor taskExecutor = new CommonTaskExec(null);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        CommonUITool.openInformationBox(Messages.msgSuccess, Messages.bind(Messages.msgStopAgent, dbNames));
        replInfo.getDistInfo().setAgentActive(false);
        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) StopReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 14 with ReplicationInfo

use of com.cubrid.cubridmanager.core.replication.model.ReplicationInfo in project cubrid-manager by CUBRID.

the class GetReplicationInfoTaskTest method testReceive.

public void testReceive() throws Exception {
    if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
        return;
    //case 1
    String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/replication/task/test.message/GetReplicationInfo_receive");
    String msg = Tool.getFileContent(filepath);
    TreeNode node = MessageUtil.parseResponse(msg);
    GetReplicationInfoTask task = new GetReplicationInfoTask(serverInfo);
    task.setResponse(node);
    ReplicationInfo replInfo = task.getReplicationInfo();
    assertEquals(replInfo.getDistInfo().getAgentPort(), "6443");
    assertEquals(replInfo.getDistInfo().getCopyLogPath(), "/home/biaozhang/cubrid/databases/dist_biaodb");
    assertEquals(replInfo.getDistInfo().getTrailLogPath(), "/home/biaozhang/cubrid/databases/dist_biaodb");
    assertEquals(replInfo.getDistInfo().getErrorLogPath(), "/home/biaozhang/cubrid/databases/dist_biaodb");
    assertEquals(replInfo.getDistInfo().getDelayTimeLogSize(), "1090");
    assertTrue(replInfo.getDistInfo().isRestartReplWhenError());
    assertEquals(replInfo.getMasterList().get(0).getMasterDbName(), "src_biaodb");
    assertEquals(replInfo.getMasterList().get(0).getMasterIp(), "192.168.1.132");
    assertEquals(replInfo.getMasterList().get(0).getReplServerPort(), "5555");
    assertEquals(replInfo.getSlaveList().get(0).getSlaveDbName(), "dest_biaodb");
    assertEquals(replInfo.getSlaveList().get(0).getSlaveIP(), "192.168.1.212");
    assertEquals(replInfo.getSlaveList().get(0).getDbUser(), "dba");
    assertEquals(replInfo.getSlaveList().get(0).getPassword(), "123456");
    //exception case1
    task.setResponse(null);
    assertTrue(task.getReplicationInfo() == null);
    //exception case2
    task.setResponse(node);
    task.setErrorMsg("has error");
    assertTrue(task.getReplicationInfo() == null);
}
Also used : TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo)

Example 15 with ReplicationInfo

use of com.cubrid.cubridmanager.core.replication.model.ReplicationInfo in project cubrid-manager by CUBRID.

the class ReplServerDialog method initialize.

/**
	 * initialize some values
	 */
private void initialize() {
    if (node != null) {
        ReplicationInfo replInfo = (ReplicationInfo) node.getAdapter(ReplicationInfo.class);
        if (replInfo != null && replInfo.getMasterList() != null && replInfo.getMasterList().size() > 0) {
            MasterInfo masterInfo = replInfo.getMasterList().get(0);
            ipText.setText(masterInfo.getMasterIp());
            portText.setText("8001");
            portText.selectAll();
            userNameText.setText("admin");
            passwordText.setText("");
            mdbNameText.setText(masterInfo.getMasterDbName());
            replServerPortText.setText(masterInfo.getReplServerPort());
        }
        portText.addModifyListener(this);
        passwordText.addModifyListener(this);
    }
}
Also used : MasterInfo(com.cubrid.cubridmanager.core.replication.model.MasterInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo)

Aggregations

ReplicationInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationInfo)17 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)9 MasterInfo (com.cubrid.cubridmanager.core.replication.model.MasterInfo)6 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)5 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)5 SlaveInfo (com.cubrid.cubridmanager.core.replication.model.SlaveInfo)5 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)4 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)4 ITask (com.cubrid.common.core.task.ITask)3 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)3 DistributorInfo (com.cubrid.cubridmanager.core.replication.model.DistributorInfo)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)2 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)2 TreeNode (com.cubrid.cubridmanager.core.common.socket.TreeNode)2 CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)2 ReplicationParamInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo)2 HashSet (java.util.HashSet)2 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2