Search in sources :

Example 1 with GetBrokerStatusInfosTask

use of com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask 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 2 with GetBrokerStatusInfosTask

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

use of com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask 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 4 with GetBrokerStatusInfosTask

use of com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask in project cubrid-manager by CUBRID.

the class HaShardDemo method getBrokerNodeInfo.

protected NodeInfo getBrokerNodeInfo(ServerInfo serverInfo) {
    BrokerNode nodeInfo = new BrokerNode();
    BrokerInfos brokerInfos = new BrokerInfos();
    GetBrokerStatusInfosTask<BrokerInfos> getBrokerStatusInfosTask = new GetBrokerStatusInfosTask<BrokerInfos>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), brokerInfos);
    getBrokerStatusInfosTask.execute();
    if (!getBrokerStatusInfosTask.isSuccess()) {
        return null;
    }
    brokerInfos = getBrokerStatusInfosTask.getResultModel();
    BrokerInfoList brokerInfoList = brokerInfos.getBorkerInfoList();
    if (!(brokerInfoList != null && brokerInfoList.getBrokerInfoList() != null && brokerInfoList.getBrokerInfoList().size() > 0)) {
        return null;
    }
    nodeInfo.setBrokerInfoList(brokerInfoList);
    //Set<String> dbHosts = new HashSet<String>();
    for (BrokerInfo brokerInfo : brokerInfoList.getBrokerInfoList()) {
        if (brokerInfo == null) {
            continue;
        }
        String brokerName = brokerInfo.getName();
        String brokerPort = brokerInfo.getPort();
        BrokerStatusInfos brokerStatusInfos = new BrokerStatusInfos();
        GetBrokerStatusInfosTask<BrokerStatusInfos> statisTask = new GetBrokerStatusInfosTask<BrokerStatusInfos>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), brokerStatusInfos);
        statisTask.setBrokerName(brokerName);
        statisTask.execute();
        if (!statisTask.isSuccess()) {
            continue;
        }
        brokerStatusInfos = statisTask.getResultModel();
        nodeInfo.addBrokerStatus(brokerPort, brokerStatusInfos);
    }
    return nodeInfo;
}
Also used : BrokerNode(com.cubrid.cubridmanager.core.cubrid.service.model.BrokerNode) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) GetBrokerStatusInfosTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Example 5 with GetBrokerStatusInfosTask

use of com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask in project cubrid-manager by CUBRID.

the class HaShardDemo method getHaNodeInfo.

protected NodeInfo getHaNodeInfo(ServerInfo serverInfo, String haMode) {
    //"heartbeatlist"
    GetHeartbeatNodeInfoTask getHeartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
    getHeartbeatNodeInfoTask.setAllDb(true);
    getHeartbeatNodeInfoTask.execute();
    if (!getHeartbeatNodeInfoTask.isSuccess()) {
        return null;
    }
    String status = getHeartbeatNodeInfoTask.getCurrentHostStatus();
    NodeType type = CMServiceAnalysisUtil.convertHaStatToNodeType(status);
    HaNode nodeInfo = null;
    if (type != NodeType.NORMAL) {
        nodeInfo = new HaNode(type);
        nodeInfo.buildStatus("ON");
        nodeInfo.setHostStatusInfoList(getHeartbeatNodeInfoTask.getHAHostStatusList());
    } else if ("on".equals(haMode)) {
        nodeInfo = new HaNode(NodeType.SLAVE);
        nodeInfo.buildStatus("OFF");
    } else if ("replica".equals(haMode)) {
        nodeInfo = new HaNode(NodeType.REPLICA);
        nodeInfo.buildStatus("OFF");
    }
    //"getallsysparam"/"cubrid_ha.conf"
    GetHAConfParameterTask getHAConfParameterTask = new GetHAConfParameterTask(serverInfo);
    getHAConfParameterTask.execute();
    BrokerInfos brokerInfos = new BrokerInfos();
    GetBrokerStatusInfosTask<BrokerInfos> getBrokerStatusInfosTask = new GetBrokerStatusInfosTask<BrokerInfos>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), brokerInfos);
    getBrokerStatusInfosTask.execute();
    if (!getHAConfParameterTask.isSuccess() || !getBrokerStatusInfosTask.isSuccess()) {
        return null;
    }
    brokerInfos = getBrokerStatusInfosTask.getResultModel();
    if (brokerInfos != null) {
        nodeInfo.setBrokerInfoList(brokerInfos.getBorkerInfoList());
    }
    Map<String, Map<String, String>> haConfParas = getHAConfParameterTask.getConfParameters();
    Map<String, String> haCommonConf = haConfParas.get("[common]");
    //		String haNodeStr = haCommonConf.get("ha_node_list").substring("cubrid@".length());
    //		List<String> haNodeList = Arrays.asList(haNodeStr.split(":"));
    //		String replicaStr = haCommonConf.get("ha_replica_list");
    //		List<String> replicaNodeList = Arrays.asList(replicaStr.substring("cubrid@".length()).split(":"));
    String dbList = haCommonConf.get("ha_db_list");
    if (dbList.indexOf(",") > -1) {
        String[] dbAr = dbList.split(",");
        for (String s : dbAr) {
            if (s.trim().length() > 0) {
                nodeInfo.addDatabase(s);
            }
        }
    } else {
        nodeInfo.addDatabase(dbList);
    }
    return nodeInfo;
}
Also used : HaNode(com.cubrid.cubridmanager.core.cubrid.service.model.HaNode) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) NodeType(com.cubrid.cubridmanager.core.cubrid.service.model.NodeType) GetBrokerStatusInfosTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask) GetHAConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetHAConfParameterTask) Map(java.util.Map) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask)

Aggregations

GetBrokerStatusInfosTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask)7 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)5 BrokerStatusInfos (com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)5 ApplyServerInfo (com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo)4 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)4 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)3 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)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 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)1 GetHAConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetHAConfParameterTask)1 BrokerNode (com.cubrid.cubridmanager.core.cubrid.service.model.BrokerNode)1 HaNode (com.cubrid.cubridmanager.core.cubrid.service.model.HaNode)1 NodeType (com.cubrid.cubridmanager.core.cubrid.service.model.NodeType)1 GetHeartbeatNodeInfoTask (com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1