Search in sources :

Example 6 with LeafNode

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

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

the class ReplicationEditor method doSave.

/**
	 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
	 * @param monitor IProgressMonitor
	 */
public void doSave(IProgressMonitor monitor) {
    List<ContainerNode> hostNodeList = diagram.getChildNodeList();
    int hostSize = 0;
    if (hostNodeList != null) {
        hostSize = hostNodeList.size();
    }
    //check the host number,2 at less
    if (hostSize <= 1) {
        CommonUITool.openErrorBox(this.getSite().getShell(), Messages.errInvalidReplDesign);
        monitor.setCanceled(true);
        return;
    }
    //check the host and replication component information integrity
    for (int i = 0; i < hostSize; i++) {
        HostNode host = (HostNode) hostNodeList.get(i);
        if (!host.isValid()) {
            CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidHost, host.getName()));
            monitor.setCanceled(true);
            return;
        }
        List<LeafNode> leafNodeList = host.getChildNodeList();
        for (int j = 0; j < leafNodeList.size(); j++) {
            LeafNode node = leafNodeList.get(j);
            if (!node.isValid()) {
                CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidReplComponent, node.getName()));
                monitor.setCanceled(true);
                return;
            }
        }
    }
    //check the replication component connection validity
    List<List<Node>> replicationsList = new ArrayList<List<Node>>();
    for (int i = 0; i < hostSize; i++) {
        HostNode host = (HostNode) hostNodeList.get(i);
        List<LeafNode> leafNodeList = host.getChildNodeList();
        for (int j = 0; j < leafNodeList.size(); j++) {
            LeafNode node = leafNodeList.get(j);
            if (node instanceof MasterNode) {
                List<ArrowConnection> connList = node.getOutgoingConnections();
                if (connList == null || connList.isEmpty()) {
                    CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidMasterConn1, node.getName()));
                    monitor.setCanceled(true);
                    return;
                } else {
                    for (int k = 0; k < connList.size(); k++) {
                        LOGGER.debug("Replication chain" + k);
                        LOGGER.debug(node.getName());
                        List<Node> replicationList = new ArrayList<Node>();
                        replicationList.add(node);
                        HostNode masterHost = (HostNode) node.getParent();
                        ArrowConnection conn = connList.get(k);
                        HostNode distHost = (HostNode) conn.getTarget().getParent();
                        if (masterHost.getName().equals(distHost.getName())) {
                            CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidMasterConn2, new String[] { node.getName(), conn.getTarget().getName() }));
                            monitor.setCanceled(true);
                            return;
                        }
                        createReplChain(replicationList, conn);
                        replicationsList.add(replicationList);
                    }
                }
            } else if (node instanceof DistributorNode) {
                if (node.getIncomingConnections() == null || node.getIncomingConnections().size() == 0) {
                    CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidDistConn1, node.getName()));
                    monitor.setCanceled(true);
                    return;
                }
                if (node.getOutgoingConnections() == null || node.getOutgoingConnections().size() == 0) {
                    CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidDistConn2, node.getName()));
                    monitor.setCanceled(true);
                    return;
                }
            } else if (node instanceof SlaveNode && (node.getIncomingConnections() == null || node.getIncomingConnections().isEmpty())) {
                CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidSlaveConn, node.getName()));
                monitor.setCanceled(true);
                return;
            }
        }
    }
    int count = replicationsList.size();
    if (count <= 0) {
        CommonUITool.openErrorBox(this.getSite().getShell(), Messages.errInvalidReplDesign);
        monitor.setCanceled(true);
        return;
    }
    for (int i = 0; i < count; i++) {
        List<Node> replcationlist = replicationsList.get(i);
        int size = replcationlist.size();
        if (size < 3) {
            CommonUITool.openErrorBox(this.getSite().getShell(), Messages.errInvalidReplDesign);
            monitor.setCanceled(true);
            return;
        }
        if (!(replcationlist.get(size - 1) instanceof SlaveNode)) {
            CommonUITool.openErrorBox(this.getSite().getShell(), Messages.errInvalidReplDesign);
            monitor.setCanceled(true);
            return;
        }
        //check the connection validity,
        for (int j = 1; j + 1 < size; j++) {
            Node node1 = (Node) replcationlist.get(j).getParent();
            Node node2 = (Node) replcationlist.get(j + 1).getParent();
            //from the slave to the distributor can not in the same host
            if (j % 2 == 0) {
                if (node1.getName().equals(node2.getName())) {
                    CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidConn1, new String[] { node1.getName(), node2.getName() }));
                    monitor.setCanceled(true);
                    return;
                }
            } else {
                //from the distributor to the slave must be in the same host
                if (!node1.getName().equals(node2.getName())) {
                    CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidConn2, new String[] { node1.getName(), node2.getName() }));
                    monitor.setCanceled(true);
                    return;
                }
            }
        }
    }
    if (!CommonUITool.openConfirmBox(Messages.msgConfirmCreateRepl)) {
        return;
    }
    isEditable = false;
    getCommandStack().flush();
    setDirty(false);
    createReplication(replicationsList);
}
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) ContainerNode(com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) Node(com.cubrid.cubridmanager.ui.replication.editor.model.Node) LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) ArrayList(java.util.ArrayList) Point(org.eclipse.draw2d.geometry.Point) 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) List(java.util.List) ArrayList(java.util.ArrayList) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 8 with LeafNode

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

the class SetSlaveDbInfoDialog method valid.

/**
	 * validate the input data
	 * 
	 * @return boolean
	 */
public boolean valid() {
    String dbName = slaveDbNameText.getText();
    String dbPath = dbPathText.getText();
    String dbUser = dbUserText.getText();
    String dbaPassword = dbPasswordText.getText();
    String confirmDbaPassword = confirmDbPasswordText.getText();
    boolean isValidHost = hostNode != null && hostNode.isValid();
    if (!isValidHost) {
        setErrorMessage(Messages.errInvalidHostInfo);
        return false;
    }
    boolean isValidDbName = ValidateUtil.isValidDBName(dbName);
    if (!isValidDbName) {
        setErrorMessage(Messages.errDatabaseName);
        return false;
    }
    boolean isDatabaseExist = false;
    if (isValidDbName && isValidHost) {
        List<DatabaseInfo> databaseInfoList = hostNode.getDatabaseInfoList();
        for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
            DatabaseInfo databaseInfo = databaseInfoList.get(i);
            if (dbName.equalsIgnoreCase(databaseInfo.getDbName())) {
                isDatabaseExist = true;
                break;
            }
        }
        if (!isDatabaseExist) {
            List<LeafNode> childNodeList = hostNode.getChildNodeList();
            for (int i = 0; childNodeList != null && i < childNodeList.size(); i++) {
                LeafNode node = childNodeList.get(i);
                if (dbName.equalsIgnoreCase(node.getName()) && !dbName.equals(slaveNode.getDbName())) {
                    isDatabaseExist = true;
                    break;
                }
            }
        }
    }
    if (isDatabaseExist) {
        setErrorMessage(Messages.errDbExist);
        return false;
    }
    boolean isValidDbPathName = ValidateUtil.isValidPathName(dbPath);
    if (!isValidDbPathName) {
        setErrorMessage(Messages.errDbPath);
        return false;
    }
    boolean isValidDbUser = dbUser.trim().length() > 0 && dbUser.indexOf(" ") < 0 && !dbUser.equalsIgnoreCase("dba") && dbUser.trim().length() < ValidateUtil.MAX_NAME_LENGTH;
    if (!isValidDbUser) {
        setErrorMessage(Messages.errDbUser);
        return false;
    }
    boolean isValidDbPassword = dbaPassword.trim().length() >= 4 && dbaPassword.indexOf(" ") < 0;
    if (!isValidDbPassword) {
        setErrorMessage(Messages.errDbPassword);
        return false;
    }
    boolean isValidConfirmDbPassword = confirmDbaPassword.length() >= 4 && confirmDbaPassword.indexOf(" ") < 0;
    if (!isValidConfirmDbPassword) {
        setErrorMessage(Messages.errConfirmedDbPassword);
        return false;
    }
    boolean isEqualPassword = dbaPassword.equals(confirmDbaPassword);
    if (!isEqualPassword) {
        setErrorMessage(Messages.errPasswordNotEqual);
        return false;
    }
    setErrorMessage(null);
    return true;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode)

Example 9 with LeafNode

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

the class ContainerNodePart method getModelTargetConnections.

/**
	 * @see com.cubrid.cubridmanager.ui.replication.editor.parts.NodePart#getModelTargetConnections()
	 * @return list
	 */
protected List<ArrowConnection> getModelTargetConnections() {
    List<ArrowConnection> list = new ArrayList<ArrowConnection>();
    list.addAll(getContainerNode().getIncomingConnections());
    for (Iterator<LeafNode> iter = getContainerNode().getChildNodeList().iterator(); iter.hasNext(); ) {
        LeafNode node = (LeafNode) iter.next();
        list.addAll(node.getIncomingConnections());
    }
    return list;
}
Also used : LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode) ArrayList(java.util.ArrayList) ArrowConnection(com.cubrid.cubridmanager.ui.replication.editor.model.ArrowConnection)

Example 10 with LeafNode

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

the class CreateLeafNodeCommand method getSize.

/**
	 * get the size
	 * 
	 * @param name String
	 * @return size
	 */
public int getSize(String name) {
    int count = containerNode.getChildNodeList().size();
    int size = 0;
    for (int i = 0; i < count; i++) {
        LeafNode node = (LeafNode) containerNode.getChildNodeList().get(i);
        if (node.getClass().getName().equals(name)) {
            size++;
        }
    }
    return size;
}
Also used : LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

LeafNode (com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode)11 ArrowConnection (com.cubrid.cubridmanager.ui.replication.editor.model.ArrowConnection)4 ContainerNode (com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode)4 DistributorNode (com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)3 MasterNode (com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode)3 SlaveNode (com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode)3 ArrayList (java.util.ArrayList)3 Point (org.eclipse.draw2d.geometry.Point)3 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 Diagram (com.cubrid.cubridmanager.ui.replication.editor.model.Diagram)2 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 CreateLeafNodeCommand (com.cubrid.cubridmanager.ui.replication.editor.commands.CreateLeafNodeCommand)1 LeafNodeFigure (com.cubrid.cubridmanager.ui.replication.editor.figures.LeafNodeFigure)1 HostNode (com.cubrid.cubridmanager.ui.replication.editor.model.HostNode)1 Node (com.cubrid.cubridmanager.ui.replication.editor.model.Node)1 List (java.util.List)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1