Search in sources :

Example 21 with HostNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.

the class HAUtil method calcLocation.

/**
	 * 
	 * Calculate the location
	 * 
	 * @param hostNodeList List<HostNode>
	 */
public static void calcLocation(List<HostNode> hostNodeList) {
    Point zeroLocation = new Point(0, 0);
    List<HostNode> zeroPointHostList = new ArrayList<HostNode>();
    List<HostNode> noZeroPointHostList = new ArrayList<HostNode>();
    for (HostNode hostNode : hostNodeList) {
        Point location = hostNode.getLocation();
        if (zeroLocation.equals(location)) {
            zeroPointHostList.add(hostNode);
        } else {
            noZeroPointHostList.add(hostNode);
        }
    }
    int hostMaxY = 0;
    for (HostNode hostNode : noZeroPointHostList) {
        Point hostLocation = hostNode.getLocation();
        int tY = hostLocation.y + hostNode.getSize().height;
        if (tY > hostMaxY) {
            hostMaxY = tY;
        }
        int nodeMaxY = hostLocation.y + hostNode.getSize().height + HEIGHT_DISTANCE;
        int nodeMaxX = hostLocation.x + hostNode.getSize().width;
        List<HANode> haNodeList = new ArrayList<HANode>();
        haNodeList.addAll(hostNode.getDbNodeList());
        haNodeList.addAll(hostNode.getBrokerNodeList());
        List<HANode> zeroPointChildList = new ArrayList<HANode>();
        for (HANode haNode : haNodeList) {
            if (haNode.getLocation().equals(zeroLocation)) {
                zeroPointChildList.add(haNode);
            } else {
                int tX = haNode.getLocation().x + haNode.getSize().width;
                if (tX > nodeMaxX) {
                    nodeMaxX = tX;
                }
                tY = haNode.getLocation().y;
                if (tY > nodeMaxY) {
                    nodeMaxY = tY;
                }
                tY = haNode.getLocation().y + haNode.getSize().height;
                if (tY > hostMaxY) {
                    hostMaxY = tY;
                }
            }
        }
        nodeMaxX = nodeMaxX + WIDTH_DISTANCE;
        for (HANode haNode : zeroPointChildList) {
            haNode.setLocation(new Point(nodeMaxX, nodeMaxY));
            nodeMaxX = nodeMaxX + haNode.getSize().width + WIDTH_DISTANCE;
        }
    }
    if (!zeroPointHostList.isEmpty()) {
        calcLocation(zeroPointHostList, hostMaxY);
    }
}
Also used : HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) ArrayList(java.util.ArrayList) Point(org.eclipse.draw2d.geometry.Point) HANode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode) Point(org.eclipse.draw2d.geometry.Point)

Example 22 with HostNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.

the class HAUtil method mergeHostNode.

/**
	 * 
	 * Merge the host node list
	 * 
	 * @param hostNodeList The List<HostNode>
	 * @param addedHostNodeList The addedHostNodeList
	 */
public static void mergeHostNode(List<HostNode> hostNodeList, List<HostNode> addedHostNodeList) {
    for (int i = 0; i < addedHostNodeList.size(); i++) {
        HostNode addedHostNode = addedHostNodeList.get(i);
        boolean isExist = false;
        for (int j = 0; j < hostNodeList.size(); j++) {
            HostNode hostNode = hostNodeList.get(j);
            if (addedHostNode.equals(hostNode)) {
                isExist = true;
                hostNode.setPassword(addedHostNode.getPassword());
                hostNode.setHostStatusInfo(addedHostNode.getHostStatusInfo());
                mergeCopyedHostChildNode(hostNode, addedHostNode);
            }
        }
        if (!isExist) {
            hostNodeList.add(addedHostNode);
        }
    }
}
Also used : HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) Point(org.eclipse.draw2d.geometry.Point)

Example 23 with HostNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.

the class AddHostAndDbWizard method performFinish.

/**
	 * Called when user clicks Finish
	 * 
	 * @return boolean
	 */
public boolean performFinish() {
    List<Map<String, Object>> dbNodeList = selectDbPage == null ? null : selectDbPage.getDbNodeList();
    List<Map<String, Object>> brokerNodeNodeList = selectBrokerPage == null ? null : selectBrokerPage.getBrokerNodeList();
    HostNode hostNode = mergeHostNode(setHostInfoPage == null ? null : setHostInfoPage.getHostNode());
    for (int i = 0; dbNodeList != null && i < dbNodeList.size(); i++) {
        Map<String, Object> map = dbNodeList.get(i);
        hostNode = mergeHostNode((HostNode) map.get("6"));
        DatabaseNode dbNode = (DatabaseNode) map.get("7");
        if (hostNode != null) {
            dbNode.setParent(hostNode);
            hostNode.getCopyedHaNodeList().remove(dbNode);
            hostNode.getCopyedHaNodeList().add(dbNode);
        }
    }
    for (int i = 0; brokerNodeNodeList != null && i < brokerNodeNodeList.size(); i++) {
        Map<String, Object> map = brokerNodeNodeList.get(i);
        hostNode = mergeHostNode((HostNode) map.get("8"));
        BrokerNode brokerNode = (BrokerNode) map.get("9");
        if (hostNode != null) {
            brokerNode.setParent(hostNode);
            hostNode.getCopyedHaNodeList().remove(brokerNode);
            hostNode.getCopyedHaNodeList().add(brokerNode);
        }
    }
    return true;
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) Map(java.util.Map)

Example 24 with HostNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.

the class SelectBrokerPage method isBrokerNodeExist.

/**
	 * 
	 * Whether broker node exist
	 * 
	 * @param brokerName String
	 * @return boolean
	 */
private boolean isBrokerNodeExist(String brokerName) {
    for (int i = 0; i < brokerNodeList.size(); i++) {
        Map<String, Object> map = brokerNodeList.get(i);
        HostNode hostNode1 = (HostNode) map.get("8");
        BrokerNode brokerNode1 = (BrokerNode) map.get("9");
        if (hostNode.getIp().equals(hostNode1.getIp()) && hostNode.getPort().equals(hostNode1.getPort()) && hostNode.getUserName().equals(hostNode1.getUserName()) && brokerName.equalsIgnoreCase(brokerNode1.getBrokerName())) {
            return true;
        }
    }
    return false;
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)

Example 25 with HostNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode in project cubrid-manager by CUBRID.

the class BrokerDashboardViewPart method init.

/**
	 * Initializes the parameters of this view
	 * 
	 * @param brokerNode the instance of BrokerNode
	 */
public void init(BrokerNode brokerNode) {
    this.brokerNode = brokerNode;
    String nodeName = brokerNode.getBrokerName();
    String partName = getPartName();
    HostNode hn = brokerNode.getParent();
    String postfix = " - " + nodeName + "@" + hn.getIp() + ":" + hn.getPort();
    if (!partName.endsWith(postfix)) {
        setPartName(partName + postfix);
    }
    serverInfo = hn.getServerInfo();
    String generatorName = hn.getUserName() + "@" + hn.getIp() + ":" + hn.getPort();
    generator = DataGeneratorPool.getInstance().getDataGenerator(generatorName, new DataProvider());
    generator.addDataUpdateListener(this);
}
Also used : DataProvider(com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.DataProvider) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)

Aggregations

HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)57 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)20 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)12 HostMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)10 DatabaseMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)9 Dashboard (com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard)8 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 ArrayList (java.util.ArrayList)6 Point (org.eclipse.draw2d.geometry.Point)6 CMWizardDialog (com.cubrid.common.ui.spi.dialog.CMWizardDialog)4 AddHostAndDbWizard (com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard)4 DataProvider (com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.DataProvider)4 IViewPart (org.eclipse.ui.IViewPart)4 IViewReference (org.eclipse.ui.IViewReference)4 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 PartInitException (org.eclipse.ui.PartInitException)4 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)3 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)3 HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)3