use of com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo 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.mondashboard.model.HAHostStatusInfo in project cubrid-manager by CUBRID.
the class SetHostInfoPage method getHostNode.
/**
*
* Get Host Node
*
* @return The HostNode
*/
public HostNode getHostNode() {
HostNode hostNode = new HostNode();
String nickName = nickNameText.getText();
if (nickName.trim().length() == 0) {
nickName = ipText.getText() + ":" + portText.getText();
}
hostNode.setName(nickName);
hostNode.setIp(ipText.getText());
hostNode.setPort(portText.getText());
hostNode.setUserName(userNameText.getText());
hostNode.setPassword(passwordText.getText());
hostNode.setConnected(true);
HAHostStatusInfo hostStatusInfo = null;
if (heartbeatNodeInfoTask != null) {
hostStatusInfo = heartbeatNodeInfoTask.getHostStatusInfo(ipText.getText());
}
if (hostStatusInfo == null) {
hostStatusInfo = getHostStatusInfo(ipText.getText(), portText.getText());
}
if (hostStatusInfo == null) {
ServerInfo serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(ipText.getText(), Integer.parseInt(portText.getText()), userNameText.getText());
hostStatusInfo = HAUtil.getHAHostStatusInfo(serverInfo);
}
hostNode.setHostStatusInfo(hostStatusInfo);
return hostNode;
}
use of com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo 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.HAHostStatusInfo 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.HAHostStatusInfo 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();
}
}
Aggregations