use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode in project cubrid-manager by CUBRID.
the class SelectBrokerPage method addBrokerNodeToTable.
/**
*
* Add broker node to table
*
*/
private void addBrokerNodeToTable() {
String brokerName = brokerNameCombo.getText();
String nickName = nickNameText.getText();
BrokerInfo brokerInfo = getBrokerInfo(brokerName);
if (nickName.trim().length() == 0) {
nickName = brokerName;
nickName = brokerInfo == null || brokerInfo.getPort() == null ? nickName : nickName + "[" + brokerInfo.getPort() + "]";
}
BrokerNode brokerNode = new BrokerNode();
brokerNode.setName(nickName);
brokerNode.setBrokerName(brokerName);
brokerNode.setBrokerInfo(brokerInfo);
Map<String, Object> map = new HashMap<String, Object>();
map.put("0", nickName);
map.put("1", brokerNode.getBrokerName());
map.put("2", brokerInfo == null ? "" : brokerInfo.getPort());
map.put("3", brokerInfo == null ? "" : brokerInfo.getState());
map.put("4", brokerInfo == null ? "" : brokerInfo.getAccess_mode());
map.put("5", hostNode.getIp());
map.put("6", hostNode.getPort());
map.put("7", HostStatusType.getShowText(hostNode.getHostStatusInfo().getStatusType()));
map.put("8", hostNode);
map.put("9", brokerNode);
brokerNodeList.add(map);
brokerTableViewer.refresh();
for (int i = 0; i < brokerTable.getColumnCount(); i++) {
brokerTable.getColumn(i).pack();
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode in project cubrid-manager by CUBRID.
the class BrokerDataProvider method setDefaultValue.
/**
*
* Set default value
*
*/
private void setDefaultValue() {
isExecGetBrokerTask = false;
errorMsg = "";
if (brokerNodeList == null || brokerNodeList.isEmpty()) {
return;
}
BrokerNode brokerNode = null;
for (BrokerNode node : brokerNodeList) {
if (node.getParent().isConnected()) {
brokerNode = node;
break;
}
}
if (brokerNode == null) {
return;
}
HostNode hostNode = brokerNode.getParent();
if (hostNode != null && hostNode.isConnected()) {
List<DataUpdateListener> listenerList = generator.getListeners();
for (DataUpdateListener listener : listenerList) {
if (listener instanceof BrokerMonitorPartHelper || listener instanceof BrokerDashboardViewPart) {
isExecGetBrokerTask = true;
break;
}
}
serverInfo = hostNode.getServerInfo();
}
StringBuffer strBuff = new StringBuffer();
for (BrokerNode node : brokerNodeList) {
strBuff.append(node.getBrokerName());
strBuff.append(",");
}
strBuff = strBuff.deleteCharAt(strBuff.length() - 1);
allBrokersStr = strBuff.toString();
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode in project cubrid-manager by CUBRID.
the class DataGeneratorPool method isHasConnection.
/**
*
* Return whether has connection
*
* @param ip String
* @param port String
* @param userName String
* @return boolean
*/
public boolean isHasConnection(String ip, String port, String userName) {
Iterator<DataGenerator> it = map.values().iterator();
while (it.hasNext()) {
DataGenerator generator = it.next();
List<DataUpdateListener> listenerList = generator.getListeners();
for (DataUpdateListener listener : listenerList) {
HostNode hostNode = null;
if (listener.getModel() instanceof HostNode) {
hostNode = (HostNode) listener.getModel();
} else if (listener.getModel() instanceof DatabaseNode) {
hostNode = ((DatabaseNode) listener.getModel()).getParent();
} else if (listener.getModel() instanceof BrokerNode) {
hostNode = ((BrokerNode) listener.getModel()).getParent();
}
if (hostNode != null && hostNode.isConnected() && ip.equals(hostNode.getIp()) && port.equals(hostNode.getPort()) && userName.equals(hostNode.getUserName())) {
return true;
}
}
}
return false;
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode in project cubrid-manager by CUBRID.
the class DataProvider method getUpdateValue.
/**
* Get the newest update data
*
* @return DataChangedEvent
*/
public DataChangedEvent getUpdateValue() {
setDefaultValue();
DataChangedEvent dataChangedEvent = new DataChangedEvent(this);
Set<MondashDataResult> resultSet = new HashSet<MondashDataResult>();
try {
executeInThread();
} catch (InterruptedException e) {
LOGGER.error("", e);
}
// handle with the data
//get host status
Map<IDiagPara, String> hostMap = new HashMap<IDiagPara, String>();
if (isExecuteHostStatTask) {
performHostStatTask(hostMap);
}
//get broker status
if (isExecuteBrokerStatTask) {
performBrokerDiagTask(hostMap);
}
if (isExecuteHostStatTask || isExecuteBrokerStatTask) {
MondashDataResult hostResult = new MondashDataResult();
hostResult.setName(generator.getName());
hostResult.putUpdateMap(hostMap);
resultSet.add(hostResult);
}
//get HA node status
List<HAHostStatusInfo> haHostStatusInfoList = null;
if (isExecuteHeartbeatTask) {
performHeartbeatNodeInfoTask();
haHostStatusInfoList = getHeartbeatNodeInfoTask == null ? null : getHeartbeatNodeInfoTask.getHAHostStatusList();
}
//get database status
List<HADatabaseStatusInfo> dbStatusInfoList = null;
String dbStatusErrorInfo = null;
if (isExecuteDbModeTask) {
dbStatusErrorInfo = getDbModeTask.getErrorMsg();
if (dbStatusErrorInfo != null && dbStatusErrorInfo.trim().length() > 0) {
dbStatusErrorInfo += ", can not get database status.";
}
dbStatusInfoList = getDbModeTask.getDbModes();
}
//get some broker status
DataChangedEvent event = brokerDataProvider == null ? null : brokerDataProvider.getUpdateValue();
for (int i = 0; i < uniqueBrokerNodeList.size(); i++) {
BrokerNode brokerNode = uniqueBrokerNodeList.get(i);
if (event != null) {
String brokerName = brokerNode.getBrokerName();
dataChangedEvent.getBrokerInfosMap().put(brokerName, event.getBrokerInfosMap().get(brokerName));
dataChangedEvent.getBrokerStatusInfosMap().put(brokerName, event.getBrokerStatusInfosMap().get(brokerName));
dataChangedEvent.getBrokerDiagDataMap().put(brokerName, event.getBrokerDiagDataMap().get(brokerName));
}
}
//get some databases status
for (int i = 0; i < dbDataProviderList.size(); i++) {
Set<MondashDataResult> dbResultSet = dbDataProviderList.get(i).getUpdateValue().getResultSet();
if (dbResultSet != null) {
resultSet.addAll(dbResultSet);
}
//set error
DatabaseNode dbNode = dbDataProviderList.get(i).getDatabaseNode();
if (StringUtil.isNotEmpty(dbStatusErrorInfo) && dbNode.getParent().isConnected()) {
dbNode.setErrorMsg(dbStatusErrorInfo);
}
HADatabaseStatusInfo dbStatusInfo = HAUtil.getDatabaseStatusInfo(dbStatusInfoList, dbNode.getDbName());
String errorInfo = dbStatusInfo == null ? null : dbStatusInfo.getErrorInfo();
if (StringUtil.isNotEmpty(errorInfo) && dbNode.getParent().isConnected()) {
dbNode.setErrorMsg(errorInfo);
}
}
if (requestCount < 2) {
requestCount++;
}
dataChangedEvent.setResultSet(resultSet);
dataChangedEvent.setHaHostStatusInfoList(haHostStatusInfoList);
dataChangedEvent.setDbStatusInfoList(dbStatusInfoList);
setErrorMsg(errorMsg);
if (errorMsg != null && errorMsg.trim().length() > 0) {
LOGGER.error(errorMsg);
}
return dataChangedEvent;
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode in project cubrid-manager by CUBRID.
the class BrokerMonitorPart method refreshVisuals.
/**
* Refreshes this EditPart's <i>visuals</i>. This method is called by
* {@link #refresh()}, and may also be called in response to notifications
* from the model.
*/
protected void refreshVisuals() {
BrokerMonitorFigure figure = (BrokerMonitorFigure) this.getFigure();
BrokerNode broker = (BrokerNode) this.getModel();
setMode2View(figure, broker);
BrokerDiagData dsr = broker.getBrokerDiagData();
if (dsr == null) {
figure.setSessionCount(0);
figure.setActiveSessionCount(0);
figure.setActiveSessionCount(0);
figure.setTps(0);
} else {
figure.setSessionCount(Integer.parseInt(dsr.getCas_mon_session()));
//Avoid looks like ActiveSessionCount larger then SessionCount
figure.setActiveSessionCount(Integer.parseInt(dsr.getCas_mon_session()));
figure.setActiveSessionCount(Integer.parseInt(dsr.getCas_mon_active()));
figure.setTps(Integer.parseInt(dsr.getCas_mon_tran()));
}
super.refreshVisuals();
}
Aggregations