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();
}
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();
}
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();
}
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;
}
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;
}
Aggregations