Search in sources :

Example 6 with BrokerNode

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

the class SelectBrokerPage method addBrokerNodeToTable.

/**
	 * 
	 * Add broker node to table
	 * 
	 */
private void addBrokerNodeToTable() {
    String brokerName = brokerNameCombo.getText();
    String nickName = nickNameText.getText();
    BrokerInfo brokerInfo = getBrokerInfo(brokerName);
    if (nickName.trim().length() == 0) {
        nickName = brokerName;
        nickName = brokerInfo == null || brokerInfo.getPort() == null ? nickName : nickName + "[" + brokerInfo.getPort() + "]";
    }
    BrokerNode brokerNode = new BrokerNode();
    brokerNode.setName(nickName);
    brokerNode.setBrokerName(brokerName);
    brokerNode.setBrokerInfo(brokerInfo);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("0", nickName);
    map.put("1", brokerNode.getBrokerName());
    map.put("2", brokerInfo == null ? "" : brokerInfo.getPort());
    map.put("3", brokerInfo == null ? "" : brokerInfo.getState());
    map.put("4", brokerInfo == null ? "" : brokerInfo.getAccess_mode());
    map.put("5", hostNode.getIp());
    map.put("6", hostNode.getPort());
    map.put("7", HostStatusType.getShowText(hostNode.getHostStatusInfo().getStatusType()));
    map.put("8", hostNode);
    map.put("9", brokerNode);
    brokerNodeList.add(map);
    brokerTableViewer.refresh();
    for (int i = 0; i < brokerTable.getColumnCount(); i++) {
        brokerTable.getColumn(i).pack();
    }
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) HashMap(java.util.HashMap) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 7 with BrokerNode

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

the class BrokerDataProvider method setDefaultValue.

/**
	 * 
	 * Set default value
	 * 
	 */
private void setDefaultValue() {
    isExecGetBrokerTask = false;
    errorMsg = "";
    if (brokerNodeList == null || brokerNodeList.isEmpty()) {
        return;
    }
    BrokerNode brokerNode = null;
    for (BrokerNode node : brokerNodeList) {
        if (node.getParent().isConnected()) {
            brokerNode = node;
            break;
        }
    }
    if (brokerNode == null) {
        return;
    }
    HostNode hostNode = brokerNode.getParent();
    if (hostNode != null && hostNode.isConnected()) {
        List<DataUpdateListener> listenerList = generator.getListeners();
        for (DataUpdateListener listener : listenerList) {
            if (listener instanceof BrokerMonitorPartHelper || listener instanceof BrokerDashboardViewPart) {
                isExecGetBrokerTask = true;
                break;
            }
        }
        serverInfo = hostNode.getServerInfo();
    }
    StringBuffer strBuff = new StringBuffer();
    for (BrokerNode node : brokerNodeList) {
        strBuff.append(node.getBrokerName());
        strBuff.append(",");
    }
    strBuff = strBuff.deleteCharAt(strBuff.length() - 1);
    allBrokersStr = strBuff.toString();
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) BrokerDashboardViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.BrokerDashboardViewPart) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) BrokerMonitorPartHelper(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.helper.BrokerMonitorPartHelper)

Example 8 with BrokerNode

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

the class DataGeneratorPool method isHasConnection.

/**
	 * 
	 * Return whether has connection
	 * 
	 * @param ip String
	 * @param port String
	 * @param userName String
	 * @return boolean
	 */
public boolean isHasConnection(String ip, String port, String userName) {
    Iterator<DataGenerator> it = map.values().iterator();
    while (it.hasNext()) {
        DataGenerator generator = it.next();
        List<DataUpdateListener> listenerList = generator.getListeners();
        for (DataUpdateListener listener : listenerList) {
            HostNode hostNode = null;
            if (listener.getModel() instanceof HostNode) {
                hostNode = (HostNode) listener.getModel();
            } else if (listener.getModel() instanceof DatabaseNode) {
                hostNode = ((DatabaseNode) listener.getModel()).getParent();
            } else if (listener.getModel() instanceof BrokerNode) {
                hostNode = ((BrokerNode) listener.getModel()).getParent();
            }
            if (hostNode != null && hostNode.isConnected() && ip.equals(hostNode.getIp()) && port.equals(hostNode.getPort()) && userName.equals(hostNode.getUserName())) {
                return true;
            }
        }
    }
    return false;
}
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)

Example 9 with BrokerNode

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

the class DataProvider method getUpdateValue.

/**
	 * Get the newest update data
	 * 
	 * @return DataChangedEvent
	 */
public DataChangedEvent getUpdateValue() {
    setDefaultValue();
    DataChangedEvent dataChangedEvent = new DataChangedEvent(this);
    Set<MondashDataResult> resultSet = new HashSet<MondashDataResult>();
    try {
        executeInThread();
    } catch (InterruptedException e) {
        LOGGER.error("", e);
    }
    // handle with the data
    //get host status
    Map<IDiagPara, String> hostMap = new HashMap<IDiagPara, String>();
    if (isExecuteHostStatTask) {
        performHostStatTask(hostMap);
    }
    //get broker status
    if (isExecuteBrokerStatTask) {
        performBrokerDiagTask(hostMap);
    }
    if (isExecuteHostStatTask || isExecuteBrokerStatTask) {
        MondashDataResult hostResult = new MondashDataResult();
        hostResult.setName(generator.getName());
        hostResult.putUpdateMap(hostMap);
        resultSet.add(hostResult);
    }
    //get HA node status
    List<HAHostStatusInfo> haHostStatusInfoList = null;
    if (isExecuteHeartbeatTask) {
        performHeartbeatNodeInfoTask();
        haHostStatusInfoList = getHeartbeatNodeInfoTask == null ? null : getHeartbeatNodeInfoTask.getHAHostStatusList();
    }
    //get database status
    List<HADatabaseStatusInfo> dbStatusInfoList = null;
    String dbStatusErrorInfo = null;
    if (isExecuteDbModeTask) {
        dbStatusErrorInfo = getDbModeTask.getErrorMsg();
        if (dbStatusErrorInfo != null && dbStatusErrorInfo.trim().length() > 0) {
            dbStatusErrorInfo += ", can not get database status.";
        }
        dbStatusInfoList = getDbModeTask.getDbModes();
    }
    //get some broker status
    DataChangedEvent event = brokerDataProvider == null ? null : brokerDataProvider.getUpdateValue();
    for (int i = 0; i < uniqueBrokerNodeList.size(); i++) {
        BrokerNode brokerNode = uniqueBrokerNodeList.get(i);
        if (event != null) {
            String brokerName = brokerNode.getBrokerName();
            dataChangedEvent.getBrokerInfosMap().put(brokerName, event.getBrokerInfosMap().get(brokerName));
            dataChangedEvent.getBrokerStatusInfosMap().put(brokerName, event.getBrokerStatusInfosMap().get(brokerName));
            dataChangedEvent.getBrokerDiagDataMap().put(brokerName, event.getBrokerDiagDataMap().get(brokerName));
        }
    }
    //get some databases status
    for (int i = 0; i < dbDataProviderList.size(); i++) {
        Set<MondashDataResult> dbResultSet = dbDataProviderList.get(i).getUpdateValue().getResultSet();
        if (dbResultSet != null) {
            resultSet.addAll(dbResultSet);
        }
        //set error
        DatabaseNode dbNode = dbDataProviderList.get(i).getDatabaseNode();
        if (StringUtil.isNotEmpty(dbStatusErrorInfo) && dbNode.getParent().isConnected()) {
            dbNode.setErrorMsg(dbStatusErrorInfo);
        }
        HADatabaseStatusInfo dbStatusInfo = HAUtil.getDatabaseStatusInfo(dbStatusInfoList, dbNode.getDbName());
        String errorInfo = dbStatusInfo == null ? null : dbStatusInfo.getErrorInfo();
        if (StringUtil.isNotEmpty(errorInfo) && dbNode.getParent().isConnected()) {
            dbNode.setErrorMsg(errorInfo);
        }
    }
    if (requestCount < 2) {
        requestCount++;
    }
    dataChangedEvent.setResultSet(resultSet);
    dataChangedEvent.setHaHostStatusInfoList(haHostStatusInfoList);
    dataChangedEvent.setDbStatusInfoList(dbStatusInfoList);
    setErrorMsg(errorMsg);
    if (errorMsg != null && errorMsg.trim().length() > 0) {
        LOGGER.error(errorMsg);
    }
    return dataChangedEvent;
}
Also used : HashMap(java.util.HashMap) IDiagPara(com.cubrid.cubridmanager.core.monitoring.model.IDiagPara) HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo) HashSet(java.util.HashSet)

Example 10 with BrokerNode

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

the class BrokerMonitorPart method refreshVisuals.

/**
	 * Refreshes this EditPart's <i>visuals</i>. This method is called by
	 * {@link #refresh()}, and may also be called in response to notifications
	 * from the model.
	 */
protected void refreshVisuals() {
    BrokerMonitorFigure figure = (BrokerMonitorFigure) this.getFigure();
    BrokerNode broker = (BrokerNode) this.getModel();
    setMode2View(figure, broker);
    BrokerDiagData dsr = broker.getBrokerDiagData();
    if (dsr == null) {
        figure.setSessionCount(0);
        figure.setActiveSessionCount(0);
        figure.setActiveSessionCount(0);
        figure.setTps(0);
    } else {
        figure.setSessionCount(Integer.parseInt(dsr.getCas_mon_session()));
        //Avoid looks like ActiveSessionCount larger then SessionCount
        figure.setActiveSessionCount(Integer.parseInt(dsr.getCas_mon_session()));
        figure.setActiveSessionCount(Integer.parseInt(dsr.getCas_mon_active()));
        figure.setTps(Integer.parseInt(dsr.getCas_mon_tran()));
    }
    super.refreshVisuals();
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) BrokerMonitorFigure(com.cubrid.cubridmanager.ui.mondashboard.editor.figure.BrokerMonitorFigure) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData)

Aggregations

BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)28 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)14 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)12 BrokerMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart)8 Dashboard (com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard)7 BrokerDBListNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerDBListNode)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 ClientNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.ClientNode)5 DashboardPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart)4 Point (org.eclipse.draw2d.geometry.Point)4 DatabaseMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)3 ArrayList (java.util.ArrayList)3 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)2 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)2 BrokerDashboardViewPart (com.cubrid.cubridmanager.ui.mondashboard.editor.BrokerDashboardViewPart)2 BrokerMonitorFigure (com.cubrid.cubridmanager.ui.mondashboard.editor.figure.BrokerMonitorFigure)2 HashMap (java.util.HashMap)2 CMWizardDialog (com.cubrid.common.ui.spi.dialog.CMWizardDialog)1 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1