use of com.cubrid.cubridmanager.core.broker.model.BrokerInfoList in project cubrid-manager by CUBRID.
the class HaNodeTest method testHaNode.
public void testHaNode() {
HaNode node = new HaNode(NodeType.MASTER);
BrokerInfoList brokerInfoList = new BrokerInfoList();
node.setBrokerInfoList(brokerInfoList);
assertEquals(node.getBrokerInfoList(), brokerInfoList);
assertNotNull(node.getBrokerInfo());
List<HAHostStatusInfo> hostStatusInfoList = new ArrayList<HAHostStatusInfo>();
node.setHostStatusInfoList(hostStatusInfoList);
assertEquals(node.getHostStatusInfoList(), hostStatusInfoList);
node.buildStatus("ON");
assertNotNull(node.getStatus());
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfoList in project cubrid-manager by CUBRID.
the class BrokerEnvStatusView method refresh.
/**
* Refreshes this view
*
* @param isUpdateTable whether update table
* @param isRefreshChanged whether refresh changed
*
*/
public void refresh(boolean isUpdateTable, boolean isRefreshChanged) {
ServerInfo site = cubridNode.getServer().getServerInfo();
BrokerInfos brokerInfos = new BrokerInfos();
final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(site, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
task.execute();
brokerInfos = task.getResultModel();
List<BrokerInfo> newBrokerInfoList = null;
if (null != brokerInfos) {
BrokerInfoList list = brokerInfos.getBorkerInfoList();
if (list != null && list.getBrokerInfoList() != null) {
newBrokerInfoList = list.getBrokerInfoList();
}
}
List<BrokerInfo> changedBrokerInfoList = new ArrayList<BrokerInfo>();
for (int i = 0; newBrokerInfoList != null && i < newBrokerInfoList.size(); i++) {
BrokerInfo newBrokerInfo = newBrokerInfoList.get(i);
BrokerInfo changedBrokerInfo = newBrokerInfo.clone();
for (int j = 0; oldBrokerInfoList != null && j < oldBrokerInfoList.size(); j++) {
BrokerInfo oldBrokerInfo = oldBrokerInfoList.get(j);
if (newBrokerInfo.getName().equalsIgnoreCase(oldBrokerInfo.getName())) {
// FIXME more simple
long newTran = StringUtil.intValue(newBrokerInfo.getTran());
long newQuery = StringUtil.intValue(newBrokerInfo.getQuery());
long newLongTran = StringUtil.longValue(newBrokerInfo.getLong_tran());
long newLongQuery = StringUtil.longValue(newBrokerInfo.getLong_query());
long newErrQuery = StringUtil.intValue(newBrokerInfo.getError_query());
long oldTran = StringUtil.intValue(oldBrokerInfo.getTran());
long oldQuery = StringUtil.intValue(oldBrokerInfo.getQuery());
long oldLongTran = StringUtil.longValue(oldBrokerInfo.getLong_tran());
long oldLongQuery = StringUtil.longValue(oldBrokerInfo.getLong_query());
long oldErrQuery = StringUtil.intValue(oldBrokerInfo.getError_query());
long changedTran = newTran - oldTran;
long changedQuery = newQuery - oldQuery;
long changedLongTran = newLongTran - oldLongTran;
long changedLongQuery = newLongQuery - oldLongQuery;
long changedErrQuery = newErrQuery - oldErrQuery;
changedBrokerInfo.setTran(String.valueOf(changedTran > 0 ? changedTran : 0));
changedBrokerInfo.setQuery(String.valueOf(changedQuery > 0 ? changedQuery : 0));
changedBrokerInfo.setLong_tran(String.valueOf(changedLongTran > 0 ? changedLongTran : 0));
changedBrokerInfo.setLong_query(String.valueOf(changedLongQuery > 0 ? changedLongQuery : 0));
changedBrokerInfo.setError_query(String.valueOf(changedErrQuery > 0 ? changedErrQuery : 0));
break;
}
}
changedBrokerInfoList.add(changedBrokerInfo);
}
oldBrokerInfoList = newBrokerInfoList;
if (isUpdateTable) {
if (isRefreshChanged) {
tableViewer.setInput(changedBrokerInfoList);
} else {
tableViewer.setInput(oldBrokerInfoList);
}
tableViewer.refresh();
}
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfoList 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);
}
}
}
}
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfoList 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.model.BrokerInfoList in project cubrid-manager by CUBRID.
the class DBSpaceLabelProvider method loadBrokerData.
public void loadBrokerData() {
BrokerInfos brokerInfos = new BrokerInfos();
final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
BrokerInfos brokerInfos = task.getResultModel();
List<BrokerInfo> newBrokerInfoList = null;
if (null != brokerInfos) {
BrokerInfoList list = brokerInfos.getBorkerInfoList();
if (list != null && list.getBrokerInfoList() != null) {
newBrokerInfoList = list.getBrokerInfoList();
}
}
setBrokerData(newBrokerInfoList);
finishedCount++;
updateToolBar();
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
taskJobExec.addTask(task);
String serverName = serverInfo.getServerName();
String jobName = Messages.taskGetBrokerInfo + serverName;
JobFamily jobFamily = new JobFamily();
jobFamily.setServerName(serverName);
taskJobExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
Aggregations