Search in sources :

Example 1 with ReplicationParamInfo

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

the class GetReplParmetersTaskTest method testReceive.

public void testReceive() throws Exception {
    if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
        return;
    String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/replication/task/test.message/GetReplicationParam_receive");
    String msg = Tool.getFileContent(filepath);
    TreeNode node = MessageUtil.parseResponse(msg);
    GetReplicationParamTask task = new GetReplicationParamTask(serverInfo);
    task.setResponse(node);
    ReplicationParamInfo paramInfo = task.getReplicationParams();
    assertEquals(paramInfo.getParamValue(ReplicationParamConstants.PERF_POLL_INTERVAL), "30");
    assertEquals(paramInfo.getParamValue(ReplicationParamConstants.FOR_RECOVERY), "Y");
    //exception case1
    task.setResponse(null);
    assertTrue(task.getReplicationParams() == null);
    //exception case2
    task.setResponse(node);
    task.setErrorMsg("has error");
    assertTrue(task.getReplicationParams() == null);
}
Also used : ReplicationParamInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo) TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode)

Example 2 with ReplicationParamInfo

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

the class GetReplicationParamTask method getReplicationParams.

/**
	 * get result from the response.
	 * 
	 * @return the ReplicationParamInfo obj
	 */
public ReplicationParamInfo getReplicationParams() {
    TreeNode response = getResponse();
    if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
        return null;
    }
    ReplicationParamInfo replicationParamInfo = new ReplicationParamInfo();
    Map<String, String> dataMap = new HashMap<String, String>();
    dataMap.put(ReplicationParamConstants.PERF_POLL_INTERVAL, response.getValue(ReplicationParamConstants.PERF_POLL_INTERVAL));
    dataMap.put(ReplicationParamConstants.SIZE_OF_LOG_BUFFER, response.getValue(ReplicationParamConstants.SIZE_OF_LOG_BUFFER));
    dataMap.put(ReplicationParamConstants.SIZE_OF_CACHE_BUFFER, response.getValue(ReplicationParamConstants.SIZE_OF_CACHE_BUFFER));
    dataMap.put(ReplicationParamConstants.SIZE_OF_COPYLOG, response.getValue(ReplicationParamConstants.SIZE_OF_COPYLOG));
    dataMap.put(ReplicationParamConstants.INDEX_REPLICATION, response.getValue(ReplicationParamConstants.INDEX_REPLICATION));
    dataMap.put(ReplicationParamConstants.FOR_RECOVERY, response.getValue(ReplicationParamConstants.FOR_RECOVERY));
    dataMap.put(ReplicationParamConstants.LOG_APPLY_INTERVAL, response.getValue(ReplicationParamConstants.LOG_APPLY_INTERVAL));
    dataMap.put(ReplicationParamConstants.RESTART_INTERVAL, response.getValue(ReplicationParamConstants.RESTART_INTERVAL));
    replicationParamInfo.setParamMap(dataMap);
    return replicationParamInfo;
}
Also used : ReplicationParamInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo) HashMap(java.util.HashMap) TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode)

Example 3 with ReplicationParamInfo

use of com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo 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 4 with ReplicationParamInfo

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

the class SetReplicationParamDialog method createBasicGroup.

/**
	 * Creates basic group
	 * 
	 * @param parent Composite
	 */
private void createBasicGroup(Composite parent) {
    final Group group = new Group(parent, SWT.NONE);
    group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    group.setText(Messages.repparm0grpReplicationInfo);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 5;
    group.setLayout(gridLayout);
    Label slaveDbNameLabel = new Label(group, SWT.NONE);
    slaveDbNameLabel.setText(Messages.repparm0lblSlaveDbName);
    slaveDbNameLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    slaveDbNameCombo = new Combo(group, SWT.NONE | SWT.READ_ONLY);
    slaveDbNameCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Button connectButton = new Button(group, SWT.RIGHT);
    connectButton.setText(Messages.repparm0btnConnect);
    connectButton.setLayoutData(new GridData());
    connectButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            GetReplicationParamTask task = new GetReplicationParamTask(database.getServer().getServerInfo());
            task.setMasterDbName(replInfo.getMasterList().get(0).getMasterDbName());
            task.setSlaveDbName(slaveDbNameCombo.getText());
            task.setDistDbName(database.getLabel());
            task.setDistDbDbaPasswd(database.getPassword());
            task.setRunningMode(database.getRunningType() == DbRunningType.CS);
            TaskExecutor taskExecutor = new CommonTaskExec(null);
            taskExecutor.addTask(task);
            new ExecTaskWithProgress(taskExecutor).exec();
            if (taskExecutor.isSuccess()) {
                ReplicationParamInfo paramInfo = task.getReplicationParams();
                Map<String, String> paramMap = paramInfo.getParamMap();
                paramEditor.setReplicationParamMap(paramMap);
            }
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GetReplicationParamTask(com.cubrid.cubridmanager.core.replication.task.GetReplicationParamTask) GridLayout(org.eclipse.swt.layout.GridLayout) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ReplicationParamInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) Map(java.util.Map)

Example 5 with ReplicationParamInfo

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

the class SetReplicationParamDialog method initial.

/**
	 * 
	 * initial the page content
	 * 
	 */
private void initial() {
    setReplInfo((ReplicationInfo) database.getAdapter(ReplicationInfo.class));
    for (int j = 0; j < replInfo.getSlaveList().size(); j++) {
        slaveDbNameCombo.add(replInfo.getSlaveList().get(j).getSlaveDbName());
    }
    slaveDbNameCombo.setText(replInfo.getSlaveList().get(0).getSlaveDbName());
    GetReplicationParamTask task = new GetReplicationParamTask(database.getServer().getServerInfo());
    task.setMasterDbName(replInfo.getMasterList().get(0).getMasterDbName());
    task.setSlaveDbName(slaveDbNameCombo.getText());
    task.setDistDbName(database.getLabel());
    task.setDistDbDbaPasswd(database.getPassword());
    task.setRunningMode(database.getRunningType() == DbRunningType.CS);
    TaskExecutor taskExecutor = new CommonTaskExec(null);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        ReplicationParamInfo paramInfo = task.getReplicationParams();
        Map<String, String> paramMap = paramInfo.getParamMap();
        paramEditor.setReplicationParamMap(paramMap);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ReplicationParamInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) GetReplicationParamTask(com.cubrid.cubridmanager.core.replication.task.GetReplicationParamTask)

Aggregations

ReplicationParamInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo)6 GetReplicationParamTask (com.cubrid.cubridmanager.core.replication.task.GetReplicationParamTask)3 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)2 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)2 TreeNode (com.cubrid.cubridmanager.core.common.socket.TreeNode)2 MasterInfo (com.cubrid.cubridmanager.core.replication.model.MasterInfo)2 ReplicationInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationInfo)2 SlaveInfo (com.cubrid.cubridmanager.core.replication.model.SlaveInfo)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 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)1 DistributorInfo (com.cubrid.cubridmanager.core.replication.model.DistributorInfo)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