Search in sources :

Example 6 with BrokerInfo

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.

the class UserAuthDbInfoPage method initialBrokerPorts.

/**
	 * 
	 * Initial the broker ports
	 * 
	 * @param brokerIp String
	 * 
	 */
private void initialBrokerPorts(String brokerIp) {
    String ip = server.getHostAddress();
    if (!ip.equals(brokerIp)) {
        allBrokerPorts = null;
        return;
    }
    BrokerInfos brokerInfos = server.getServerInfo().getBrokerInfos();
    if (brokerInfos != null) {
        String brokerStauts = brokerInfos.getBrokerstatus();
        BrokerInfoList brokerInfo = brokerInfos.getBorkerInfoList();
        if (brokerInfo != null) {
            List<BrokerInfo> brokerInfoList = brokerInfo.getBrokerInfoList();
            if (brokerInfoList != null) {
                List<String> brokerPortList = new ArrayList<String>();
                for (int i = 0; i < brokerInfoList.size(); i++) {
                    BrokerInfo info = brokerInfoList.get(i);
                    if (info.getPort() == null || info.getPort().trim().length() == 0) {
                        continue;
                    }
                    String port = info.getPort();
                    String status = "";
                    if (brokerStauts == null || !brokerStauts.equalsIgnoreCase("ON")) {
                        status = "OFF";
                    } else {
                        status = info.getState() == null || info.getState().trim().equalsIgnoreCase("OFF") ? "OFF" : "ON";
                    }
                    brokerPortList.add(info.getName() + "[" + port + "/" + status + "]");
                }
                if (!brokerPortList.isEmpty()) {
                    allBrokerPorts = new String[brokerPortList.size()];
                    brokerPortList.toArray(allBrokerPorts);
                }
            }
        }
    }
}
Also used : BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) ArrayList(java.util.ArrayList) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 7 with BrokerInfo

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.

the class DatabaseDashboardEditor method loadBrokerInfo.

/**
	 * load broker information
	 */
public void loadBrokerInfo() {
    // if database is stop, do not get data
    if (database.getRunningType() != DbRunningType.CS) {
        return;
    }
    // broker info tasks
    BrokerInfos brokerInfos = new BrokerInfos();
    final CommonQueryTask<BrokerInfos> brokerInfosTask = new CommonQueryTask<BrokerInfos>(database.getServer().getServerInfo(), CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
    new Thread(new Runnable() {

        public void run() {
            brokerInfosTask.execute();
            if (!brokerInfosTask.isSuccess()) {
                brokerInfosTask.finish();
                return;
            }
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    process();
                }
            });
        }

        private void process() {
            asinfoLst.clear();
            brokerInfoListData.clear();
            BrokerInfos brokerInfos = brokerInfosTask.getResultModel();
            if (null != brokerInfos) {
                BrokerInfoList list = brokerInfos.getBorkerInfoList();
                if (list != null && list.getBrokerInfoList() != null) {
                    // all broker
                    List<BrokerInfo> newBrokerInfoList = list.getBrokerInfoList();
                    for (BrokerInfo brokerInfo : newBrokerInfoList) {
                        BrokerStatusInfos brokerStatusInfos = new BrokerStatusInfos();
                        final GetBrokerStatusInfosTask<BrokerStatusInfos> statisTask = new GetBrokerStatusInfosTask<BrokerStatusInfos>(database.getServer().getServerInfo(), CommonSendMsg.getGetBrokerStatusItems(), brokerStatusInfos);
                        statisTask.setBrokerName(brokerInfo.getName());
                        statisTask.execute();
                        brokerStatusInfos = statisTask.getResultModel();
                        if (brokerStatusInfos != null) {
                            //one broker status
                            List<ApplyServerInfo> applyServerInfoList = brokerStatusInfos.getAsinfo();
                            for (ApplyServerInfo applyServerInfo : applyServerInfoList) {
                                if (database.getName().equalsIgnoreCase(applyServerInfo.getAs_dbname())) {
                                    HashMap<String, ApplyServerInfo> valueMap = new HashMap<String, ApplyServerInfo>();
                                    valueMap.put(brokerInfo.getName(), applyServerInfo);
                                    asinfoLst.add(valueMap);
                                }
                            }
                        }
                        statisTask.finish();
                    }
                }
            }
            //set task obejct to table view
            for (HashMap<String, ApplyServerInfo> brokerValueMap : asinfoLst) {
                for (Entry<String, ApplyServerInfo> entry : brokerValueMap.entrySet()) {
                    String brokerName = entry.getKey();
                    ApplyServerInfo applyServerInfo = entry.getValue();
                    Map<String, String> brokerInfoMap = new HashMap<String, String>();
                    brokerInfoMap.put("0", brokerName);
                    brokerInfoMap.put("1", applyServerInfo.getAs_id());
                    brokerInfoMap.put("2", applyServerInfo.getAs_pid());
                    brokerInfoMap.put("3", applyServerInfo.getAs_num_query());
                    brokerInfoMap.put("4", applyServerInfo.getAs_long_query());
                    brokerInfoMap.put("5", applyServerInfo.getAs_status());
                    brokerInfoMap.put("6", applyServerInfo.getAs_lct());
                    brokerInfoListData.add(brokerInfoMap);
                }
            }
            setBrokerInfoData();
            brokerInfosTask.finish();
        }
    }).start();
}
Also used : HashMap(java.util.HashMap) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos) GetBrokerStatusInfosTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 8 with BrokerInfo

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.

the class ConnectHostJobExecutor method done.

/**
	 * 
	 * Finish the task executor
	 * 
	 * @param status IStatus
	 */
private void done(final IStatus status) {
    if (!hostNode.isConnecting()) {
        hostNode.setConnected(false);
        return;
    }
    if (status == Status.OK_STATUS) {
        hostNode.setPort(String.valueOf(serverInfo.getHostMonPort()));
        hostNode.setPassword(serverInfo.getUserPassword());
        hostNode.setHostStatusInfo(haHostStatusInfo);
        hostNode.setConnected(true);
        if (haHostStatusInfo == null) {
            haHostStatusInfo = HAUtil.getHAHostStatusInfo(serverInfo);
        }
        for (DatabaseNode dn : hostNode.getDbNodeList()) {
            dn.setHaDatabaseStatus(HAUtil.getHADatabaseStatusInfo(dn.getDbName(), haHostStatusInfo, serverInfo));
        }
        for (BrokerNode brokerNode : hostNode.getBrokerNodeList()) {
            BrokerInfo brokerInfo = HAUtil.getBrokerInfo(serverInfo.getBrokerInfos(), brokerNode.getBrokerName());
            brokerNode.setBrokerInfo(brokerInfo);
        }
    } else {
        hostNode.setConnected(wasConnected);
        if (errorMsg != null) {
            hostNode.setErrorMsg(errorMsg);
        }
    }
    hostNode.setConnecting(false);
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 9 with BrokerInfo

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.

the class SelectBrokerPage method modifyText.

/**
	 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
	 * @param event ModifyEvent
	 */
public void modifyText(ModifyEvent event) {
    String brokerName = brokerNameCombo.getText();
    if (brokerName.trim().length() == 0) {
        addButton.setEnabled(false);
        brokerStatusText.setText("");
        brokerPortText.setText("");
        accessModeText.setText("");
    } else {
        BrokerInfo brokerInfo = getBrokerInfo(brokerName);
        nickNameText.setText(brokerName);
        brokerPortText.setText(brokerInfo == null ? "" : brokerInfo.getPort());
        brokerStatusText.setText(brokerInfo == null ? "" : brokerInfo.getState());
        accessModeText.setText(brokerInfo == null || brokerInfo.getAccess_mode() == null ? "" : brokerInfo.getAccess_mode().toUpperCase(Locale.getDefault()));
        addButton.setEnabled(true);
    }
}
Also used : BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 10 with BrokerInfo

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.

the class SelectBrokerPage method getBrokerInfo.

/**
	 * 
	 * Get broker info
	 * 
	 * @param brokerName String
	 * @return BrokerInfo
	 */
private BrokerInfo getBrokerInfo(String brokerName) {
    for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
        BrokerInfo brokerInfo = brokerInfoList.get(i);
        String name = brokerInfoList.get(i).getName();
        if (brokerName.equalsIgnoreCase(name)) {
            return brokerInfo;
        }
    }
    return null;
}
Also used : BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Aggregations

BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)35 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)16 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)11 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)6 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)5 ArrayList (java.util.ArrayList)5 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)4 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 CubridBroker (com.cubrid.cubridmanager.ui.spi.model.CubridBroker)4 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)3 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)3 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 BrokerStatusInfos (com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)3 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)3 Combo (org.eclipse.swt.widgets.Combo)3 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)2 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)2 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)2 ApplyServerInfo (com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo)2 GetBrokerStatusInfosTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask)2