Search in sources :

Example 1 with MasterInfo

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

the class GetReplicationInfoTask method getReplicationInfo.

/**
	 * 
	 * Get replication information
	 * 
	 * @return the ReplicationInfo obj
	 */
public ReplicationInfo getReplicationInfo() {
    TreeNode response = getResponse();
    if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
        return null;
    }
    ReplicationInfo replInfo = new ReplicationInfo();
    DistributorInfo distInfo = new DistributorInfo();
    String agentPort = response.getValue("agent_port");
    String copyLogPath = response.getValue("copy_log_path");
    String trailLogPath = response.getValue("trail_log_path");
    String errorLogPath = response.getValue("error_log_path");
    String delayTimeLogSize = response.getValue("delay_time_log_size");
    String retryConnect = response.getValue("retry_connect");
    distInfo.setDistDbName(distDbName);
    distInfo.setAgentPort(agentPort);
    distInfo.setCopyLogPath(copyLogPath);
    distInfo.setTrailLogPath(trailLogPath);
    distInfo.setErrorLogPath(errorLogPath);
    distInfo.setDelayTimeLogSize(delayTimeLogSize);
    distInfo.setRestartReplWhenError(retryConnect.equalsIgnoreCase("Y"));
    replInfo.setDistInfo(distInfo);
    MasterInfo masterInfo = new MasterInfo();
    String masterDbName = response.getValue("master_db_name");
    String masterIP = response.getValue("master_ip");
    String replServerPort = response.getValue("repl_server_port");
    masterInfo.setMasterDbName(masterDbName);
    masterInfo.setMasterIp(masterIP);
    masterInfo.setReplServerPort(replServerPort);
    replInfo.addMasterInfo(masterInfo);
    SlaveInfo slaveInfo = new SlaveInfo();
    String slaveName = response.getValue("slave_db_name");
    String slaveIP = response.getValue("slave_ip");
    String userId = response.getValue("slave_userid");
    String password = response.getValue("slave_pass");
    slaveInfo.setSlaveDbName(slaveName);
    slaveInfo.setSlaveIP(slaveIP);
    slaveInfo.setDbUser(userId);
    slaveInfo.setPassword(password);
    replInfo.addSlaveInfo(slaveInfo);
    return replInfo;
}
Also used : MasterInfo(com.cubrid.cubridmanager.core.replication.model.MasterInfo) TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) DistributorInfo(com.cubrid.cubridmanager.core.replication.model.DistributorInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) SlaveInfo(com.cubrid.cubridmanager.core.replication.model.SlaveInfo)

Example 2 with MasterInfo

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

the class ReplicationEditor method createDiagram.

/**
	 * create the diagram
	 * 
	 * @param input IEditorInput
	 */
private void createDiagram(IEditorInput input) {
    diagram = new Diagram();
    if (input instanceof ICubridNode) {
        ICubridNode node = (ICubridNode) input;
        if (NodeType.DATABASE.equals(node.getType())) {
            isEditable = false;
            CubridServer server = node.getServer();
            int x = 100;
            int y = 20;
            int hostVertSpan = 100;
            if (server != null) {
                ReplicationInfo replicationInfo = (ReplicationInfo) node.getAdapter(ReplicationInfo.class);
                if (replicationInfo != null) {
                    //distributor component
                    DistributorInfo distInfo = replicationInfo.getDistInfo();
                    DistributorNode dist = null;
                    if (distInfo != null) {
                        dist = new DistributorNode();
                        dist.setDbName(distInfo.getDistDbName());
                        dist.setDbPath(distInfo.getDistDbPath());
                        dist.setCopyLogPath(distInfo.getCopyLogPath());
                        dist.setErrorLogPath(distInfo.getErrorLogPath());
                        dist.setTrailLogPath(distInfo.getTrailLogPath());
                        dist.setReplAgentPort(distInfo.getAgentPort());
                        dist.setDelayTimeLogSize(distInfo.getDelayTimeLogSize());
                        dist.setRestartWhenError(distInfo.isRestartReplWhenError());
                        dist.setName(distInfo.getDistDbName());
                        dist.setLocation(new Point(30, 30));
                        dist.setSize(new Dimension(120, 40));
                    }
                    //master component
                    List<MasterInfo> masterList = replicationInfo.getMasterList();
                    MasterNode master = null;
                    for (int i = 0; masterList != null && i < masterList.size(); i++) {
                        MasterInfo masterInfo = masterList.get(i);
                        if (masterInfo != null) {
                            master = new MasterNode();
                            String ip = masterInfo.getMasterIp();
                            String masterDbName = masterInfo.getMasterDbName();
                            String replServerPort = masterInfo.getReplServerPort();
                            boolean isReplAll = masterInfo.isReplAllTable();
                            List<String> tableList = masterInfo.getReplTableList();
                            HostNode mdbHost = new HostNode();
                            mdbHost.setIp(ip);
                            mdbHost.setUserName("admin");
                            mdbHost.setName(ip);
                            mdbHost.setLocation(new Point(x, y));
                            y += mdbHost.getSize().height + hostVertSpan;
                            mdbHost.setParent(diagram);
                            diagram.addNode(mdbHost);
                            master.setDbName(masterDbName);
                            master.setReplServerPort(replServerPort);
                            master.setReplicateAll(isReplAll);
                            master.setReplicatedClassList(tableList);
                            master.setName(masterDbName);
                            master.setLocation(new Point(30, 80));
                            master.setSize(new Dimension(120, 40));
                            master.setParent(mdbHost);
                            mdbHost.addChildNode(master);
                        }
                    }
                    //distributor host component
                    HostNode distdbhost = new HostNode();
                    distdbhost.setIp(server.getHostAddress());
                    distdbhost.setPort(server.getMonPort());
                    distdbhost.setUserName(server.getUserName());
                    distdbhost.setPassword(server.getPassword());
                    distdbhost.setName(server.getHostAddress() + ":" + server.getMonPort());
                    distdbhost.setLocation(new Point(x, y));
                    distdbhost.setParent(diagram);
                    diagram.addNode(distdbhost);
                    //distributor component
                    if (dist != null) {
                        dist.setParent(distdbhost);
                        distdbhost.addChildNode(dist);
                    }
                    //slave component
                    List<SlaveInfo> slaveInfoList = replicationInfo.getSlaveList();
                    SlaveNode slave = null;
                    for (int i = 0; slaveInfoList != null && i < slaveInfoList.size(); i++) {
                        SlaveInfo slaveInfo = slaveInfoList.get(i);
                        if (slaveInfo != null) {
                            slave = new SlaveNode();
                            slave.setDbName(slaveInfo.getSlaveDbName());
                            slave.setDbPath(slaveInfo.getSlaveDbPath());
                            slave.setDbUser(slaveInfo.getDbUser());
                            slave.setDbPassword(slaveInfo.getPassword());
                            ReplicationParamInfo replParaInfo = slaveInfo.getParamInfo();
                            if (replParaInfo != null) {
                                slave.setParamMap(replParaInfo.getParamMap());
                            }
                            slave.setName(slaveInfo.getSlaveDbName());
                            slave.setLocation(new Point(30, 150));
                            slave.setSize(new Dimension(120, 40));
                            slave.setParent(distdbhost);
                            distdbhost.addChildNode(slave);
                        }
                    }
                }
            }
        }
    }
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) DistributorInfo(com.cubrid.cubridmanager.core.replication.model.DistributorInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) Point(org.eclipse.draw2d.geometry.Point) Diagram(com.cubrid.cubridmanager.ui.replication.editor.model.Diagram) MasterInfo(com.cubrid.cubridmanager.core.replication.model.MasterInfo) ReplicationParamInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) SlaveInfo(com.cubrid.cubridmanager.core.replication.model.SlaveInfo) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 3 with MasterInfo

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

the class SetDatabaseInfoPage method initialize.

/**
	 * initialize some values
	 */
private void initialize() {
    if (replNode != null && NodeType.DATABASE.equals(replNode.getType())) {
        ReplicationInfo replInfo = (ReplicationInfo) replNode.getAdapter(ReplicationInfo.class);
        if (replInfo != null && replInfo.getMasterList() != null && replInfo.getMasterList().size() > 0) {
            MasterInfo masterInfo = replInfo.getMasterList().get(0);
            ipText.setText(masterInfo.getMasterIp());
            masterDbNameText.setText(masterInfo.getMasterDbName());
        }
        if (replInfo != null && replInfo.getDistInfo() != null) {
            DistributorInfo distInfo = replInfo.getDistInfo();
            distDbNameText.setText(distInfo.getDistDbName());
        }
        if (replInfo != null && replInfo.getSlaveList() != null && replInfo.getSlaveList().size() > 0) {
            SlaveInfo slaveInfo = replInfo.getSlaveList().get(0);
            slaveDbNameText.setText(slaveInfo.getSlaveDbName());
        }
    }
    ipText.setEnabled(false);
    userNameText.setEnabled(false);
    masterDbNameText.setEnabled(false);
    distDbNameText.setEnabled(false);
    slaveDbNameText.setEnabled(false);
    portText.addModifyListener(this);
    passwordText.addModifyListener(this);
    distDbaPasswordText.addModifyListener(this);
}
Also used : MasterInfo(com.cubrid.cubridmanager.core.replication.model.MasterInfo) DistributorInfo(com.cubrid.cubridmanager.core.replication.model.DistributorInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) SlaveInfo(com.cubrid.cubridmanager.core.replication.model.SlaveInfo)

Example 4 with MasterInfo

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

the class CubridDatabaseLoader method loadReplication.

/**
	 * 
	 * Load replication function
	 * 
	 * @param parent the parent node
	 * @param monitor the monitor object
	 * @return <code>true</code> it can be loaded;<code>false</code> otherwise
	 */
private boolean loadReplication(final ICubridNode parent, final IProgressMonitor monitor) {
    CubridDatabase database = (CubridDatabase) parent;
    ServerInfo serverInfo = parent.getServer().getServerInfo();
    ServerUserInfo serverUserInfo = serverInfo.getLoginedUserInfo();
    if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
        return true;
    }
    DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
    if (dbUserInfo == null || dbUserInfo.getName() == null || !dbUserInfo.getName().trim().equalsIgnoreCase("DBA")) {
        return true;
    }
    String dbPassword = dbUserInfo.getNoEncryptPassword();
    //add for replication support,only can be supported after version 8.2.2 and in linux OS
    if (serverInfo.isSupportReplication() == 0) {
        final CheckDistributorDbTask checkDistributorDbTask = new CheckDistributorDbTask(serverInfo);
        checkDistributorDbTask.setDistDbName(database.getLabel());
        checkDistributorDbTask.setDbaPassword(dbPassword);
        checkDistributorDbTask.setRunningMode(database.getRunningType() == DbRunningType.CS);
        final GetReplicationInfoTask getReplicationInfoTask = new GetReplicationInfoTask(serverInfo);
        getReplicationInfoTask.setDistDbName(database.getLabel());
        getReplicationInfoTask.setDbaPassword(dbPassword);
        getReplicationInfoTask.setRunningMode(database.getRunningType() == DbRunningType.CS);
        final GetReplicatedTablesTask getReplicatedTablesTask = new GetReplicatedTablesTask(serverInfo);
        getReplicatedTablesTask.setDistdbName(database.getLabel());
        getReplicatedTablesTask.setDistdbPassword(dbPassword);
        getReplicatedTablesTask.setRunningMode(database.getRunningType() == DbRunningType.CS);
        final GetReplicationParamTask getReplicationParamTask = new GetReplicationParamTask(serverInfo);
        getReplicationParamTask.setDistDbName(database.getLabel());
        getReplicationParamTask.setDistDbDbaPasswd(dbPassword);
        getReplicationParamTask.setRunningMode(database.getRunningType() == DbRunningType.CS);
        final GetReplAgentStatusTask getReplAgentStatusTask = new GetReplAgentStatusTask(serverInfo);
        getReplAgentStatusTask.setDbName(database.getLabel());
        monitorCancel(monitor, new ITask[] { checkDistributorDbTask, getReplicationInfoTask, getReplicatedTablesTask, getReplicationParamTask, getReplAgentStatusTask });
        checkDistributorDbTask.execute();
        if (!checkResult(checkDistributorDbTask, monitor)) {
            return false;
        }
        boolean isDistdb = checkDistributorDbTask.isDistributorDb();
        database.getDatabaseInfo().setDistributorDb(isDistdb);
        if (isDistdb) {
            getReplicationInfoTask.execute();
            if (!checkResult(getReplicationInfoTask, monitor)) {
                return false;
            }
            ReplicationInfo replInfo = getReplicationInfoTask.getReplicationInfo();
            database.getDatabaseInfo().setReplInfo(replInfo);
            if (replInfo != null && replInfo.getDistInfo() != null) {
                replInfo.getDistInfo().setDistDbPath(database.getDatabaseInfo().getDbDir());
            }
            if (replInfo != null && replInfo.getMasterList() != null && replInfo.getMasterList().size() > 0 && replInfo.getSlaveList() != null && replInfo.getSlaveList().size() > 0) {
                MasterInfo masterInfo = replInfo.getMasterList().get(0);
                SlaveInfo slaveInfo = replInfo.getSlaveList().get(0);
                getReplicatedTablesTask.setMasterdbName(masterInfo.getMasterDbName());
                getReplicatedTablesTask.setSlavedbName(slaveInfo.getSlaveDbName());
                getReplicatedTablesTask.execute();
                if (!checkResult(getReplicatedTablesTask, monitor)) {
                    return false;
                }
                String[] classNames = getReplicatedTablesTask.getReplicatedTables();
                boolean isReplAll = getReplicatedTablesTask.isReplicateAll();
                if (classNames != null && classNames.length > 0) {
                    masterInfo.setReplTableList(Arrays.asList(classNames));
                }
                masterInfo.setReplAllTable(isReplAll);
                getReplicationParamTask.setMasterDbName(masterInfo.getMasterDbName());
                getReplicationParamTask.setSlaveDbName(replInfo.getSlaveList().get(0).getSlaveDbName());
                getReplicationParamTask.execute();
                if (!checkResult(getReplicationParamTask, monitor)) {
                    return false;
                }
                ReplicationParamInfo paramInfo = getReplicationParamTask.getReplicationParams();
                slaveInfo.setParamInfo(paramInfo);
            }
            getReplAgentStatusTask.execute();
            if (!checkResult(getReplAgentStatusTask, monitor)) {
                return false;
            }
            boolean isActive = getReplAgentStatusTask.isActive();
            replInfo.getDistInfo().setAgentActive(isActive);
        }
    }
    return true;
}
Also used : GetReplicationInfoTask(com.cubrid.cubridmanager.core.replication.task.GetReplicationInfoTask) GetReplAgentStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) GetReplicatedTablesTask(com.cubrid.cubridmanager.core.replication.task.GetReplicatedTablesTask) GetReplicationParamTask(com.cubrid.cubridmanager.core.replication.task.GetReplicationParamTask) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) MasterInfo(com.cubrid.cubridmanager.core.replication.model.MasterInfo) CheckDistributorDbTask(com.cubrid.cubridmanager.core.replication.task.CheckDistributorDbTask) ReplicationParamInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) SlaveInfo(com.cubrid.cubridmanager.core.replication.model.SlaveInfo)

Example 5 with MasterInfo

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

the class MasterInfoTest method testMasterInfo.

public void testMasterInfo() {
    MasterInfo masterInfo = new MasterInfo();
    String masterIp = "192.168.1.221";
    String masterDbName = "masterdb";
    String replServerPort = "666";
    boolean isReplAllTable = true;
    List<String> replTableList = new ArrayList<String>();
    replTableList.add("table1");
    replTableList.add("table2");
    masterInfo.setMasterIp(masterIp);
    masterInfo.setMasterDbName(masterDbName);
    masterInfo.setReplServerPort(replServerPort);
    masterInfo.setReplAllTable(isReplAllTable);
    masterInfo.setReplTableList(replTableList);
    assertEquals(masterInfo.getMasterIp(), masterIp);
    assertEquals(masterInfo.getMasterDbName(), masterDbName);
    assertEquals(masterInfo.getReplServerPort(), replServerPort);
    assertEquals(masterInfo.isReplAllTable(), isReplAllTable);
    assertEquals(masterInfo.getReplTableList().size(), replTableList.size());
}
Also used : MasterInfo(com.cubrid.cubridmanager.core.replication.model.MasterInfo) ArrayList(java.util.ArrayList)

Aggregations

MasterInfo (com.cubrid.cubridmanager.core.replication.model.MasterInfo)7 ReplicationInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationInfo)6 SlaveInfo (com.cubrid.cubridmanager.core.replication.model.SlaveInfo)4 DistributorInfo (com.cubrid.cubridmanager.core.replication.model.DistributorInfo)3 ReplicationParamInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo)2 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)1 TreeNode (com.cubrid.cubridmanager.core.common.socket.TreeNode)1 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)1 CheckDistributorDbTask (com.cubrid.cubridmanager.core.replication.task.CheckDistributorDbTask)1 GetReplAgentStatusTask (com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask)1 GetReplicatedTablesTask (com.cubrid.cubridmanager.core.replication.task.GetReplicatedTablesTask)1 GetReplicationInfoTask (com.cubrid.cubridmanager.core.replication.task.GetReplicationInfoTask)1 GetReplicationParamTask (com.cubrid.cubridmanager.core.replication.task.GetReplicationParamTask)1 Diagram (com.cubrid.cubridmanager.ui.replication.editor.model.Diagram)1 DistributorNode (com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)1 HostNode (com.cubrid.cubridmanager.ui.replication.editor.model.HostNode)1