Search in sources :

Example 1 with SlaveNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode 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 2 with SlaveNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode in project cubrid-manager by CUBRID.

the class ReplicationEditor method initConnection.

/**
	 * initialize the connection
	 * 
	 */
private void initConnection() {
    if (diagram != null) {
        MasterNode master = null;
        DistributorNode dist = null;
        SlaveNode slave = null;
        List<ContainerNode> containerNodeList = diagram.getChildNodeList();
        for (int i = 0; containerNodeList != null && i < containerNodeList.size(); i++) {
            ContainerNode containerNode = containerNodeList.get(i);
            if (containerNode != null) {
                List<LeafNode> leafNodeList = containerNode.getChildNodeList();
                for (int j = 0; j < leafNodeList.size(); j++) {
                    LeafNode leafNode = leafNodeList.get(j);
                    if (leafNode instanceof MasterNode) {
                        master = (MasterNode) leafNode;
                    } else if (leafNode instanceof DistributorNode) {
                        dist = (DistributorNode) leafNode;
                    }
                }
            }
        }
        //connection from master to dist
        if (master != null && dist != null) {
            new ArrowConnection(master, dist);
        }
        for (int i = 0; containerNodeList != null && i < containerNodeList.size(); i++) {
            ContainerNode containerNode = containerNodeList.get(i);
            if (containerNode != null) {
                List<LeafNode> leafNodeList = containerNode.getChildNodeList();
                for (int j = 0; j < leafNodeList.size(); j++) {
                    LeafNode leafNode = leafNodeList.get(j);
                    if (leafNode instanceof SlaveNode) {
                        slave = (SlaveNode) leafNode;
                        //connection from dist to slave
                        if (dist != null && slave != null) {
                            new ArrowConnection(dist, slave);
                        }
                    }
                }
            }
        }
    }
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode) ArrowConnection(com.cubrid.cubridmanager.ui.replication.editor.model.ArrowConnection) ContainerNode(com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode) Point(org.eclipse.draw2d.geometry.Point) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 3 with SlaveNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode in project cubrid-manager by CUBRID.

the class EditAction method run.

/**
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    IWorkbenchPart workbenchPart = this.getWorkbenchPart();
    if (!(workbenchPart instanceof ReplicationEditor) || !isEnabled()) {
        return;
    }
    ReplicationEditor replEditor = (ReplicationEditor) workbenchPart;
    Shell shell = replEditor.getSite().getShell();
    NodePart nodePart = (NodePart) getSelectedObjects().get(0);
    if (nodePart.getModel() instanceof MasterNode) {
        SetMasterDbInfoWizard wizard = new SetMasterDbInfoWizard((MasterNode) nodePart.getModel());
        wizard.setEditable(replEditor.isEditable());
        CMWizardDialog dialog = new CMWizardDialog(shell, wizard);
        dialog.setPageSize(560, 300);
        dialog.open();
    } else if (nodePart.getModel() instanceof DistributorNode) {
        SetDistributorDbInfoDialog dialog = new SetDistributorDbInfoDialog(shell);
        dialog.setDistributor((DistributorNode) nodePart.getModel());
        dialog.setEditable(replEditor.isEditable());
        dialog.open();
    } else if (nodePart.getModel() instanceof SlaveNode) {
        SetSlaveDbInfoDialog dialog = new SetSlaveDbInfoDialog(shell);
        dialog.setSlave((SlaveNode) nodePart.getModel());
        dialog.setEditable(replEditor.isEditable());
        dialog.open();
    } else if (nodePart.getModel() instanceof HostNode) {
        SetHostInfoDialog dialog = new SetHostInfoDialog(shell);
        dialog.setHostInfo((HostNode) nodePart.getModel());
        dialog.setEditable(replEditor.isEditable());
        dialog.open();
    }
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) SetHostInfoDialog(com.cubrid.cubridmanager.ui.replication.editor.dialog.SetHostInfoDialog) ReplicationEditor(com.cubrid.cubridmanager.ui.replication.editor.ReplicationEditor) Shell(org.eclipse.swt.widgets.Shell) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) SetDistributorDbInfoDialog(com.cubrid.cubridmanager.ui.replication.editor.dialog.SetDistributorDbInfoDialog) NodePart(com.cubrid.cubridmanager.ui.replication.editor.parts.NodePart) SetMasterDbInfoWizard(com.cubrid.cubridmanager.ui.replication.editor.dialog.wizard.SetMasterDbInfoWizard) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog) SetSlaveDbInfoDialog(com.cubrid.cubridmanager.ui.replication.editor.dialog.SetSlaveDbInfoDialog) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 4 with SlaveNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode in project cubrid-manager by CUBRID.

the class LeafNodePart method refreshVisuals.

/**
	 * @see com.cubrid.cubridmanager.ui.replication.editor.parts.NodePart#refreshVisuals()
	 */
protected void refreshVisuals() {
    super.refreshVisuals();
    LeafNode node = (LeafNode) getModel();
    LeafNodeFigure figure = (LeafNodeFigure) getFigure();
    figure.setText(node.getName());
    if (getModel() instanceof MasterNode) {
        figure.setIcon(CubridManagerUIPlugin.getImage("icons/replication/master.png"));
    }
    if (getModel() instanceof DistributorNode) {
        figure.setIcon(CubridManagerUIPlugin.getImage("icons/replication/distributor.gif"));
    }
    if (getModel() instanceof SlaveNode) {
        figure.setIcon(CubridManagerUIPlugin.getImage("icons/replication/slave.png"));
    }
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode) LeafNodeFigure(com.cubrid.cubridmanager.ui.replication.editor.figures.LeafNodeFigure) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 5 with SlaveNode

use of com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode in project cubrid-manager by CUBRID.

the class LeafNodePart method performRequest.

/**
	 * @see org.eclipse.gef.editparts.AbstractEditPart#performRequest(org.eclipse.gef.Request)
	 * @param req the request to be performed
	 */
public void performRequest(Request req) {
    Shell shell = replEditor.getSite().getShell();
    if (req.getType() == RequestConstants.REQ_OPEN) {
        if (getModel() instanceof MasterNode) {
            SetMasterDbInfoWizard wizard = new SetMasterDbInfoWizard((MasterNode) getModel());
            wizard.setEditable(replEditor.isEditable());
            CMWizardDialog dialog = new CMWizardDialog(shell, wizard);
            dialog.setPageSize(560, 300);
            dialog.open();
        } else if (getModel() instanceof DistributorNode) {
            SetDistributorDbInfoDialog dialog = new SetDistributorDbInfoDialog(shell);
            dialog.setDistributor((DistributorNode) getModel());
            dialog.setEditable(replEditor.isEditable());
            dialog.open();
        } else if (getModel() instanceof SlaveNode) {
            SetSlaveDbInfoDialog dialog = new SetSlaveDbInfoDialog(shell);
            dialog.setSlave((SlaveNode) getModel());
            dialog.setEditable(replEditor.isEditable());
            dialog.open();
        }
    }
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) Shell(org.eclipse.swt.widgets.Shell) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) SetDistributorDbInfoDialog(com.cubrid.cubridmanager.ui.replication.editor.dialog.SetDistributorDbInfoDialog) SetMasterDbInfoWizard(com.cubrid.cubridmanager.ui.replication.editor.dialog.wizard.SetMasterDbInfoWizard) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog) SetSlaveDbInfoDialog(com.cubrid.cubridmanager.ui.replication.editor.dialog.SetSlaveDbInfoDialog) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Aggregations

SlaveNode (com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode)8 DistributorNode (com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)7 MasterNode (com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode)7 HostNode (com.cubrid.cubridmanager.ui.replication.editor.model.HostNode)5 LeafNode (com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode)4 Point (org.eclipse.draw2d.geometry.Point)4 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 ContainerNode (com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode)3 ArrayList (java.util.ArrayList)3 CMWizardDialog (com.cubrid.common.ui.spi.dialog.CMWizardDialog)2 SetDistributorDbInfoDialog (com.cubrid.cubridmanager.ui.replication.editor.dialog.SetDistributorDbInfoDialog)2 SetSlaveDbInfoDialog (com.cubrid.cubridmanager.ui.replication.editor.dialog.SetSlaveDbInfoDialog)2 SetMasterDbInfoWizard (com.cubrid.cubridmanager.ui.replication.editor.dialog.wizard.SetMasterDbInfoWizard)2 ArrowConnection (com.cubrid.cubridmanager.ui.replication.editor.model.ArrowConnection)2 Node (com.cubrid.cubridmanager.ui.replication.editor.model.Node)2 Shell (org.eclipse.swt.widgets.Shell)2 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)1 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)1 TaskGroup (com.cubrid.common.ui.spi.progress.TaskGroup)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1