Search in sources :

Example 1 with BrokerStatusInfos

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

the class BrokerNodeTest method buildFakeData.

public void buildFakeData(BrokerNode brokerNode) {
    DbLocationInfo dbLocalInfo = new DbLocationInfo();
    dbLocalInfo.setDbName("demodb");
    dbLocalInfo.setVolPath("/home1/demo/CUBRID/databases/demodb");
    dbLocalInfo.setLobBasePath("file:/home1/demo/CUBRID/databases/demodb/lob");
    dbLocalInfo.setLogPath("/home1/demo/CUBRID/databases/demodb");
    dbLocalInfo.addDbHost("localhost");
    List<DbLocationInfo> dbLocationInfoList = new ArrayList<DbLocationInfo>();
    dbLocationInfoList.add(dbLocalInfo);
    brokerNode.setDbLocationInfoList(dbLocationInfoList);
    BrokerStatusInfos bStatInfos = new BrokerStatusInfos();
    bStatInfos.setBname("query_editor");
    Map<String, BrokerStatusInfos> brokerStatusMap = new HashMap<String, BrokerStatusInfos>();
    brokerStatusMap.put("query_editor", bStatInfos);
    brokerNode.setBrokerStatusMap(brokerStatusMap);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Example 2 with BrokerStatusInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos 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 3 with BrokerStatusInfos

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

the class BrokerStatusView method refresh.

/**
	 * 
	 * Refresh the page content
	 * 
	 * @param isUpdateTable whether update table
	 * @param isRefreshChanged whether refresh changed
	 */
public void refresh(boolean isUpdateTable, boolean isRefreshChanged) {
    ServerInfo site = brokerNode.getServer().getServerInfo();
    if (isSupportNewBrokerParamPropery) {
        refreshBasicTable(site);
    }
    BrokerStatusInfos brokerStatusInfos = new BrokerStatusInfos();
    final GetBrokerStatusInfosTask<BrokerStatusInfos> task = new GetBrokerStatusInfosTask<BrokerStatusInfos>(site, CommonSendMsg.getGetBrokerStatusItems(), brokerStatusInfos);
    task.setBrokerName(nodeName);
    task.execute();
    if (!task.isSuccess()) {
        return;
    }
    brokerStatusInfos = task.getResultModel();
    //job queue
    if (brokerStatusInfos != null) {
        jobinfoLst = brokerStatusInfos.getJobinfo();
        jqTableViewer.setInput(jobinfoLst);
        jqTableViewer.refresh();
    }
    //apply server
    List<ApplyServerInfo> newAsInfoLst = null;
    if (null != brokerStatusInfos) {
        newAsInfoLst = brokerStatusInfos.getAsinfo();
    }
    List<ApplyServerInfo> changedAsInfoLst = new ArrayList<ApplyServerInfo>();
    for (int i = 0; newAsInfoLst != null && i < newAsInfoLst.size(); i++) {
        ApplyServerInfo newAsInfo = newAsInfoLst.get(i);
        ApplyServerInfo changedAsInfo = newAsInfo.clone();
        for (int j = 0; oldAsInfoLst != null && j < oldAsInfoLst.size(); j++) {
            ApplyServerInfo oldAsInfo = oldAsInfoLst.get(j);
            if (newAsInfo.getAs_id().equalsIgnoreCase(oldAsInfo.getAs_id())) {
                long newQuery = StringUtil.intValue(newAsInfo.getAs_num_query());
                long newTran = StringUtil.intValue(newAsInfo.getAs_num_tran());
                long newLongQuery = StringUtil.longValue(newAsInfo.getAs_long_query());
                long newLongTran = StringUtil.longValue(newAsInfo.getAs_long_tran());
                long newErrQuery = StringUtil.intValue(newAsInfo.getAs_error_query());
                long oldQuery = StringUtil.intValue(oldAsInfo.getAs_num_query());
                long oldTran = StringUtil.intValue(oldAsInfo.getAs_num_tran());
                long oldLongQuery = StringUtil.longValue(oldAsInfo.getAs_long_query());
                long oldLongTran = StringUtil.longValue(oldAsInfo.getAs_long_tran());
                long oldErrQuery = StringUtil.intValue(oldAsInfo.getAs_error_query());
                long changedQuery = newQuery - oldQuery;
                long changedTran = newTran - oldTran;
                long changedLongTran = newLongTran - oldLongTran;
                long changedLongQuery = newLongQuery - oldLongQuery;
                long changedErrQuery = newErrQuery - oldErrQuery;
                changedAsInfo.setAs_num_query(String.valueOf(changedQuery > 0 ? changedQuery : 0));
                changedAsInfo.setAs_num_tran(String.valueOf(changedTran > 0 ? changedTran : 0));
                changedAsInfo.setAs_long_tran(String.valueOf(changedLongTran > 0 ? changedLongTran : 0));
                changedAsInfo.setAs_long_query(String.valueOf(changedLongQuery > 0 ? changedLongQuery : 0));
                changedAsInfo.setAs_error_query(String.valueOf(changedErrQuery > 0 ? changedErrQuery : 0));
                break;
            }
        }
        changedAsInfoLst.add(changedAsInfo);
    }
    oldAsInfoLst = newAsInfoLst;
    if (isUpdateTable) {
        if (isRefreshChanged) {
            asTableViewer.setInput(changedAsInfoLst);
        } else {
            asTableViewer.setInput(oldAsInfoLst);
        }
    }
    asTableViewer.refresh();
    //job queue
    jobinfoLst = brokerStatusInfos.getJobinfo();
    jqTableViewer.setInput(jobinfoLst);
    jqTableViewer.refresh();
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) GetBrokerStatusInfosTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask) ArrayList(java.util.ArrayList) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Example 4 with BrokerStatusInfos

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

the class BrokerStatusView method refresh.

/**
	 * Refresh this view
	 * 
	 */
public void refresh() {
    ServerInfo site = brokerNode.getServer().getServerInfo();
    if (isSupportNewBrokerParamPropery) {
        refreshBasicTable(site);
    }
    BrokerStatusInfos brokerStatusInfos = new BrokerStatusInfos();
    final GetBrokerStatusInfosTask<BrokerStatusInfos> task = new GetBrokerStatusInfosTask<BrokerStatusInfos>(site, CommonSendMsg.getGetBrokerStatusItems(), brokerStatusInfos);
    task.setBrokerName(nodeName);
    task.execute();
    if (!task.isSuccess()) {
        return;
    }
    brokerStatusInfos = task.getResultModel();
    asinfoLst = brokerStatusInfos.getAsinfo();
    jobinfoLst = brokerStatusInfos.getJobinfo();
    asTableViewer.setInput(asinfoLst);
    asTableViewer.refresh();
    jqTableViewer.setInput(jobinfoLst);
    jqTableViewer.refresh();
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) GetBrokerStatusInfosTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Example 5 with BrokerStatusInfos

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

the class BrokerNode method setBrokerStatusInfos.

/**
	 * Set broker status.
	 *
	 * @param brokerStatusInfos BrokerStatusInfos
	 */
public void setBrokerStatusInfos(BrokerStatusInfos brokerStatusInfos) {
    BrokerStatusInfos old = this.brokerStatusInfos;
    this.brokerStatusInfos = brokerStatusInfos;
    this.firePropertyChange(PROP_BROKER_STATUS, old, brokerStatusInfos);
}
Also used : BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Aggregations

BrokerStatusInfos (com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)16 ApplyServerInfo (com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo)10 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)6 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)5 GetBrokerStatusInfosTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)3 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)3 HashSet (java.util.HashSet)2 List (java.util.List)2 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 JobInfo (com.cubrid.cubridmanager.core.broker.model.JobInfo)1 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)1 BrokerNode (com.cubrid.cubridmanager.core.cubrid.service.model.BrokerNode)1 BrokerDiagData (com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData)1 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)1 Set (java.util.Set)1