use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.
the class DatabaseDashboardViewPart method performUpdate.
/**
* Perform the update data
*
* @param dataChangedEvent the given event including newest data
*/
public void performUpdate(DataChangedEvent dataChangedEvent) {
if (composite == null || composite.isDisposed()) {
return;
}
if (dbNode.getParent().isConnected()) {
HADatabaseStatusInfo haDbStatusInfo = HAUtil.getDatabaseStatusInfo(dataChangedEvent.getHaHostStatusInfoList(), dbNode.getParent().getIp(), dbNode.getDbName());
if (haDbStatusInfo == null) {
haDbStatusInfo = HAUtil.getDatabaseStatusInfo(dataChangedEvent.getDbStatusInfoList(), dbNode.getDbName());
if (null == haDbStatusInfo) {
haDbStatusInfo = new HADatabaseStatusInfo();
haDbStatusInfo.setDbName(dbNode.getDbName());
}
}
dbNode.setHaDatabaseStatus(haDbStatusInfo);
} else {
HADatabaseStatusInfo haDatabaseStatus = new HADatabaseStatusInfo();
haDatabaseStatus.setDbName(dbNode.getDbName());
dbNode.setHaDatabaseStatus(haDatabaseStatus);
}
Set<MondashDataResult> set = dataChangedEvent.getResultSet();
Map<IDiagPara, String> updateMap = null;
String hostCpuTotal = "0";
String hostMemTotal = "0";
for (MondashDataResult result : set) {
if (dbNode.getDbName().equals(result.getName())) {
updateMap = result.getUpdateMap();
} else if (generator.getName().equals(result.getName())) {
Map<IDiagPara, String> hostMap = result.getUpdateMap();
if (hostMap != null) {
hostCpuTotal = hostMap.get(HostStatEnum.CPU_TOTAL);
hostCpuTotal = hostCpuTotal == null ? "0" : hostCpuTotal;
hostMemTotal = hostMap.get(HostStatEnum.MEMPHY_TOTAL);
hostMemTotal = hostMemTotal == null ? "0" : hostMemTotal;
}
}
}
performUpdate(updateMap, hostCpuTotal, hostMemTotal);
}
use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.
the class SelectDbPage method createControl.
/**
* Create the control for this page
*
* @param parent Composite
*/
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 10;
layout.marginWidth = 10;
composite.setLayout(layout);
GridData gridData = new GridData(GridData.FILL_BOTH);
composite.setLayoutData(gridData);
Group dbInfoGroup = new Group(composite, SWT.NONE);
dbInfoGroup.setText(Messages.grpSelectDb);
gridData = new GridData(GridData.FILL_HORIZONTAL);
dbInfoGroup.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 2;
dbInfoGroup.setLayout(layout);
Label dbNameLabel = new Label(dbInfoGroup, SWT.LEFT);
dbNameLabel.setText(Messages.lblDbName);
dbNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dbNameCombo = new Combo(dbInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
dbNameCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
dbNameCombo.addModifyListener(this);
Label nickNameLable = new Label(dbInfoGroup, SWT.LEFT);
nickNameLable.setText(Messages.lblNickName);
nickNameLable.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
nickNameText = new Text(dbInfoGroup, SWT.LEFT | SWT.BORDER);
nickNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Label dbaPasswordLabel = new Label(dbInfoGroup, SWT.LEFT);
dbaPasswordLabel.setText(Messages.lblDbaPassword);
dbaPasswordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dbaPasswordText = new Text(dbInfoGroup, SWT.LEFT | SWT.BORDER | SWT.PASSWORD);
dbaPasswordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
Composite btnComposite = new Composite(composite, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.spacing = 5;
btnComposite.setLayout(rowLayout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalAlignment = GridData.END;
btnComposite.setLayoutData(gridData);
addButton = new Button(btnComposite, SWT.NONE);
addButton.setText(Messages.btnAddDb);
addButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String dbName = dbNameCombo.getText();
String dbaPassword = dbaPasswordText.getText();
String nickName = nickNameText.getText();
if (nickName.trim().length() == 0) {
nickName = dbName;
}
//check whether this database already be added
if (isExist(dbName, hostNode)) {
CommonUITool.openErrorBox(Messages.bind(Messages.errDbExist, dbName));
return;
}
DatabaseInfo dbInfo = serverInfo.getLoginedUserInfo().getDatabaseInfo(dbName);
TaskExecutor executor = new CommonTaskExec(null);
VerifyDbUserPasswordTask verifyDbUserPasswordTask = null;
if (dbInfo.isLogined() && dbInfo.getAuthLoginedDbUserInfo().getName().equalsIgnoreCase("dba")) {
String password = dbInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
if (!dbaPassword.equals(password)) {
CommonUITool.openErrorBox(Messages.errDbaPassowrd);
return;
}
} else {
verifyDbUserPasswordTask = new VerifyDbUserPasswordTask(serverInfo);
verifyDbUserPasswordTask.setDbName(dbName);
verifyDbUserPasswordTask.setDbUser("dba");
verifyDbUserPasswordTask.setDbPassword(dbaPassword);
executor.addTask(verifyDbUserPasswordTask);
}
GetHeartbeatNodeInfoTask getHeartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
getHeartbeatNodeInfoTask.setAllDb(false);
List<String> dbList = new ArrayList<String>();
dbList.add(dbName);
getHeartbeatNodeInfoTask.setDbList(dbList);
executor.addTask(getHeartbeatNodeInfoTask);
new ExecTaskWithProgress(executor).exec(true, true);
if (!executor.isSuccess()) {
if (verifyDbUserPasswordTask != null && !verifyDbUserPasswordTask.isSuccess()) {
dbaPasswordText.selectAll();
dbaPasswordText.setFocus();
}
return;
}
List<HAHostStatusInfo> haHostStatusInfoList = getHeartbeatNodeInfoTask.getHAHostStatusList();
HADatabaseStatusInfo haDbStatusInfo = getHeartbeatNodeInfoTask.getDatabaseStatusInfo(dbName);
HAHostStatusInfo haHostStatusInfo = getHeartbeatNodeInfoTask.getHostStatusInfo(serverInfo.getHostAddress());
//if this database is HA Mode,will get it's active database or standby database
List<DatabaseNode> haDbNodeList = getHADatabaseList(haDbStatusInfo, haHostStatusInfoList, true);
if (haHostStatusInfo == null) {
haHostStatusInfo = HAUtil.getHAHostStatusInfo(serverInfo);
if (haDbStatusInfo != null) {
haHostStatusInfo.addHADatabaseStatus(haDbStatusInfo);
}
}
if (haDbStatusInfo == null) {
haDbStatusInfo = HAUtil.getHADatabaseStatusInfo(dbName, haHostStatusInfo, serverInfo);
}
DatabaseNode dbNode = new DatabaseNode();
hostNode.setHostStatusInfo(haHostStatusInfo);
dbNode.setParent(hostNode);
dbNode.setDbName(dbName);
dbNode.setDbUser("dba");
dbNode.setDbPassword(dbaPassword);
dbNode.setName(nickName);
dbNode.setHaDatabaseStatus(haDbStatusInfo);
dbNode.setConnected(true);
if (haDbNodeList == null) {
haDbNodeList = new ArrayList<DatabaseNode>();
}
if (dbNode.getDbStatusType() == DBStatusType.ACTIVE || dbNode.getDbStatusType() == DBStatusType.TO_BE_ACTIVE) {
haDbNodeList.add(0, dbNode);
} else {
haDbNodeList.add(dbNode);
}
addDbNodeToTable(haDbNodeList, haHostStatusInfoList);
}
});
haModeBtn = new Button(dbInfoGroup, SWT.LEFT | SWT.CHECK);
haModeBtn.setText(Messages.btnHAMode);
haModeBtn.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
haModeBtn.setEnabled(false);
createTable(composite);
dbNameCombo.setFocus();
setTitle(Messages.titleSelectDbPage);
setMessage(Messages.msgSelectDbPage);
setControl(composite);
}
use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo 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.core.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.
the class DashboardConnectionManager method refreshDB2DBConnections.
/**
* Refresh DB to DB connections.
*
*/
public void refreshDB2DBConnections() {
List<DatabaseNode> allDatabaseNode = dashboard.getAllDatabaseNode();
List<DatabaseNode> standByList = new ArrayList<DatabaseNode>();
for (DatabaseNode dbNode : allDatabaseNode) {
if (standByList.contains(dbNode)) {
continue;
}
HADatabaseStatusInfo haDatabaseStatus = dbNode.getHaDatabaseStatus();
if (haDatabaseStatus == null) {
dbNode.removeAllHAConnections();
continue;
}
HAHostStatusInfo haHostStatusInfo = haDatabaseStatus.getHaHostStatusInfo();
if (haHostStatusInfo == null) {
dbNode.removeAllHAConnections();
continue;
}
//Is standby db
if (haHostStatusInfo.getMasterHostStatusInfo() != null && (haHostStatusInfo.getSlaveHostStatusInfoList() == null || haHostStatusInfo.getSlaveHostStatusInfoList().size() == 0)) {
HostNode master = dashboard.getHostNodeByName(haHostStatusInfo.getMasterHostStatusInfo().getHostName());
if (null == master) {
dbNode.removeAllHAConnections();
continue;
}
DatabaseNode activeNode = master.getDBNodeByName(dbNode.getDbName());
if (null == activeNode) {
dbNode.removeAllHAConnections();
continue;
}
if (null == HAUtil.getSyncModeType(dbNode, activeNode)) {
dbNode.removeAllHAConnections();
continue;
}
if (!dbNode.sourceExists(activeNode)) {
new MonitorConnection(activeNode, dbNode);
}
//handled.add(activeNode);
continue;
}
//Is active db
if (haHostStatusInfo.getMasterHostStatusInfo() == null && haHostStatusInfo.getSlaveHostStatusInfoList() != null && haHostStatusInfo.getSlaveHostStatusInfoList().size() > 0) {
//get the standby nodes of the active node
standByList.clear();
for (HAHostStatusInfo hostStatus : haHostStatusInfo.getSlaveHostStatusInfoList()) {
HostNode slave = dashboard.getHostNodeByName(hostStatus.getHostName());
if (slave == null) {
continue;
}
DatabaseNode standbyNode = slave.getDBNodeByName(dbNode.getDbName());
if (standbyNode == null) {
continue;
}
if (null == HAUtil.getSyncModeType(standbyNode, dbNode)) {
continue;
}
standByList.add(standbyNode);
}
dbNode.removeConnectionsTargetNotInList(standByList, DatabaseNode.class);
for (DatabaseNode standbyNode : standByList) {
if (!dbNode.targetExists(standbyNode)) {
new MonitorConnection(dbNode, standbyNode);
}
}
continue;
}
//other db
dbNode.removeAllHAConnections();
}
}
use of com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo in project cubrid-manager by CUBRID.
the class DatabaseMonitorPart 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() {
DatabaseMonitorFigure dmfg = (DatabaseMonitorFigure) this.getFigure();
DatabaseNode dn = (DatabaseNode) this.getModel();
dmfg.setTitle(dn.getName());
HADatabaseStatusInfo haDatabaseStatus = dn.getHaDatabaseStatus();
String dbStatus = "";
if (haDatabaseStatus != null) {
dmfg.setCpuUsage(haDatabaseStatus.getCpuUsage());
dmfg.setMemUsage(haDatabaseStatus.getMemUsage());
dmfg.setDelay(haDatabaseStatus.getDelay());
dbStatus = DBStatusType.getShowText(haDatabaseStatus.getStatusType());
}
dmfg.setStatus(true, dn.getParent().isConnected(), dn.isConnected(), dbStatus, dn.getErrorMsg(), dn.hasNewErrorMsg());
super.refreshVisuals();
}
Aggregations